hackeroni

module
v0.0.0-...-bc8cb11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2016 License: MIT

README

hackeroni GoDoc Build Status Coverage Status

A Go interface around api.hackerone.com.

Usage

import "github.com/uber-go/hackeroni/h1"

To list all reports matching a filter:

reports, _, err := client.Report.List(h1.ReportListFilter{
	Program: []string{"uber"},
})
if err != nil {
	panic(err)
}
for _, report := range reports {
	fmt.Println("Report Title:", *report.Title)
}

To retrieve a specific report:

report, _, err := client.Report.Get("123456")
if err != nil {
	panic(err)
}
fmt.Println("Report Title:", *report.Title)

Authentication

The h1 library does not directly handle authentication. Instead, when creating a new client, you can pass a http.Client that handles authentication for you. It does provide a APIAuthTransport structure when using API Token authentication. It is used like this:

tp := h1.APIAuthTransport{
	APIIdentifier: "your-h1-api-token-identifier",
	APIToken: "big-long-api-token-from-h1",
}

client := h1.NewClient(tp.Client())

Pagination

All requests for listing resources such as Report support pagination. Pagination options are described in the h1.ListOptions struct and passed to the list methods as an optional parameter. Pages information is available via the h1.ResponseLinks struct embedded in the h1.Response struct.

filter := h1.ReportListFilter{
	Program: []string{"uber"},
}
var listOpts h1.ListOptions

var allReports []h1.Report
for {
	reports, resp, err := client.Report.List(filter, &listOpts)
	if err != nil {
		panic(err)
	}
	allReports = append(allReports, reports...)
	if resp.Links.Next == "" {
		break
	}
	listOpts.Page = resp.Links.NextPageNumber()
}

Directories

Path Synopsis
_examples
Package h1 provides a client for the HackerOne API.
Package h1 provides a client for the HackerOne API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL