Documentation
¶
Overview ¶
Package lighthouse provides access to the Lighthouse API. http://help.lighthouseapp.com/kb/api
Index ¶
- Constants
- func BasePath(account string) string
- func CheckResponse(resp *http.Response, expected int) error
- func ID(idStr string) (int, error)
- func NewClient(token string) *http.Client
- func NewClientBasicAuth(email, password string) *http.Client
- func NewClientBasicAuthWithRateLimit(email, password string) *http.Client
- func NewClientWithRateLimit(token string) *http.Client
- type ErrUnexpectedResponse
- type ErrUnprocessable
- type ErrUnprocessables
- type Plan
- type Service
- type Transport
Examples ¶
Constants ¶
View Source
const ( StatusUnprocessableEntity = 422 // DefaultRateLimitInterval controls the default rate limit // interval DefaultRateLimitInterval = 600 * time.Millisecond // DefaultRateLimitBurstSize control the default rate Limit // burst size DefaultRateLimitBurstSize = 1 DefaultRateLimitRetryAttempts = 3 DefaultRateLimitMaxRetryAfter = 125 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func NewClientBasicAuth ¶
func NewClientBasicAuthWithRateLimit ¶ added in v0.4.1
func NewClientWithRateLimit ¶ added in v0.4.1
Types ¶
type ErrUnexpectedResponse ¶
type ErrUnexpectedResponse struct { // The expected StatusCode ExpectedCode int // Resp.Body will always be closed. Resp *http.Response // BodyContents will contain the contents of Resp.Body if // Unprocessables is nil. BodyContents []byte // Unprocessables will not be nil if Resp.StatusCode was 422 // StatusUnprocessableEntity. Unprocessables ErrUnprocessables }
func (*ErrUnexpectedResponse) Error ¶
func (eir *ErrUnexpectedResponse) Error() string
type ErrUnprocessable ¶
func (*ErrUnprocessable) Error ¶
func (eu *ErrUnprocessable) Error() string
func (*ErrUnprocessable) MarshalJSON ¶
func (eu *ErrUnprocessable) MarshalJSON() ([]byte, error)
func (*ErrUnprocessable) UnmarshalJSON ¶
func (eu *ErrUnprocessable) UnmarshalJSON(data []byte) error
type ErrUnprocessables ¶
type ErrUnprocessables []*ErrUnprocessable
func (ErrUnprocessables) Error ¶
func (eus ErrUnprocessables) Error() string
type Service ¶
type Service struct { BasePath string Client *http.Client // RateLimitRetryRequests controls whether *Service.RoundTrip // will automatically retry rate-limited requests that receive // a 429 Too Many Requests response. RateLimitRetryRequests bool // RateLimitRetryAttempts controls how many attempts // *Service.RoundTrip will make for a rate-limited request // before giving up. If RateLimitRetryRequests is set and // RateLimitRetryAttempts is zero, the value of // DefaultRateLimitRetryAttempts is used. // RateLimitRetryAttempts is ignored if RateLimitRetryRequests // is not set. RateLimitRetryAttempts int // RateLimitMaxRetryAfter controls the maximum time // *Service.RoundTrip will wait between each retry attempt. // *Service.RoundTrip uses the number of seconds returned in // the X-Rate-Limit-Retry-After header of the 429 Too Many // Requests response as the amount of time to wait between // each attempt, using RateLimitMaxRetryAfter as an upper // bound on this value. If RateLimitRetryRequests is set and // RateLimitMaxRetryAfter is zero, the value of // DefaultRateLimitMaxRetryAfter is used. // RateLimitMaxRetryAfter is ignored if RateLimitRetryRequests // is not set. RateLimitMaxRetryAfter time.Duration }
func NewService ¶
Example ¶
package main import ( "fmt" "log" "github.com/nwidger/lighthouse" "github.com/nwidger/lighthouse/tickets" ) func main() { // Create an *http.Client which will authenticate with your Lighthouse // API token. client := lighthouse.NewClient("your-api-token") // Create a *lighthouse.Service with your Lighthouse account and client. // 'https://your-account-name.lighthouseapp.com'. s := lighthouse.NewService("your-account-name", client) // Create a *tickets.Service instance for interacting with // project 123456's tickets. // http://help.lighthouseapp.com/kb/api/tickets ticketsService := tickets.NewService(s, 123456) // Search the project's tickets. // http://help.lighthouseapp.com/kb/getting-started/how-do-i-search-for-tickets ts, err := ticketsService.List(&tickets.ListOptions{ Query: `responsible:me milestone:v1.2 tagged:bug sort:updated`, Limit: tickets.MaxLimit, Page: 1, }) if err != nil { log.Fatal(err) } for _, t := range ts { fmt.Println(t.Number, t.Title, t.Tags, t.Priority, t.State) } }
Output:
func (*Service) Plan ¶
Get account plan details. Undocumented, see http://help.lighthouseapp.com/discussions/api-developers/1100-check-if-using-free-plan.
type Transport ¶
type Transport struct { // API token to use for authentication. If set this is used // instead of Email/Password. Token string // If Token is set and TokenAsBasicAuth is true, send API // token in Authorization header using Basic Authentication // with the API token as the username and 'x' as the password. TokenAsBasicAuth bool // If Token is set, TokenAsBasicAuth is false and // TokenAsParameter is true, send API token in '_token' URL // parameter. TokenAsParameter bool // Email and password to use for authentication. Email, Password string // Base specifies the mechanism by which individual HTTP // requests are made. If Base is nil, http.DefaultTransport // is used. Base http.RoundTripper // RateLimitInterval controls the rate limit interval using a // token bucket. If not set no rate limiting will occur. See // https://en.wikipedia.org/wiki/Token_bucket for more about // token buckets. RateLimitInterval time.Duration // RateLimitBurstSize controls the rate limit burst size. If // RateLimitInterval is not set, RateLimitBurstSize is // ignored. RateLimitBurstSize int // contains filtered or unexported fields }
Transport wraps another http.RoundTripper and ensures the outgoing request is properly authenticated
Directories
¶
Path | Synopsis |
---|---|
Package bins provides access to a project's ticket bins via the Lighthouse API.
|
Package bins provides access to a project's ticket bins via the Lighthouse API. |
Package changesets provides access to a project's changesets via the Lighthouse API.
|
Package changesets provides access to a project's changesets via the Lighthouse API. |
cmd
|
|
Package messages provides access to a project's messages via the Lighthouse API.
|
Package messages provides access to a project's messages via the Lighthouse API. |
Package milestones provides access to a project's milestones via the Lighthouse API.
|
Package milestones provides access to a project's milestones via the Lighthouse API. |
Package profiles provides access to profiles via the Lighthouse API.
|
Package profiles provides access to profiles via the Lighthouse API. |
Package projects provides access to projects via the Lighthouse API.
|
Package projects provides access to projects via the Lighthouse API. |
Package tickets provides access to a project's tickets via the Lighthouse API.
|
Package tickets provides access to a project's tickets via the Lighthouse API. |
Package tokens provides access to tokens via the Lighthouse API.
|
Package tokens provides access to tokens via the Lighthouse API. |
Package users provides access to users via the Lighthouse API.
|
Package users provides access to users via the Lighthouse API. |
Click to show internal directories.
Click to hide internal directories.