Documentation
¶
Overview ¶
Package pipelineanalytics is a client for the pipeline-analytics REST API (github.com/alrayyes/pipeline-analytics).
Every operation except GetVersion and the two webhook receivers requires an authenticated session. pipeline-analytics authenticates browsers with WebAuthn, not an API token -- there is no headless credential-grant flow in the spec. Obtain a session cookie by logging into the dashboard in a browser and copying the "session" cookie's value; pass it to New or set PIPELINE_ANALYTICS_SESSION. See the README for the full explanation and an example.
Index ¶
Constants ¶
const SessionCookieEnvVar = "PIPELINE_ANALYTICS_SESSION"
SessionCookieEnvVar is the environment variable New falls back to when no session cookie is passed explicitly via WithSessionCookie.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError is returned by DecodeError for any pipeline-analytics response carrying an error body -- every 4xx/5xx in the spec shares the same {code, message} shape.
func DecodeError ¶
DecodeError builds an *APIError from a generated response's status, body and headers, or returns nil when statusCode isn't an error. Every operation's generated response type carries these three fields under the same names (StatusCode via HTTPResponse, Body, and the headers on HTTPResponse), so this one helper covers all of them:
resp, err := client.ListReposWithResponse(ctx, nil)
if err != nil {
return err // transport failure, already retried
}
if apiErr := pipelineanalytics.DecodeError(resp.HTTPResponse.StatusCode, resp.Body, resp.HTTPResponse.Header); apiErr != nil {
return apiErr
}
type Client ¶
type Client struct {
*genclient.ClientWithResponses
}
Client is a pipeline-analytics API client. Construct one with New.
func New ¶
New builds a Client against baseURL (the pipeline-analytics instance's origin, e.g. "https://pipeline-analytics.example.com").
func (*Client) ListRepos ¶
func (c *Client) ListRepos(ctx context.Context, params *genclient.ListReposParams) *RepoIterator
ListRepos returns an iterator over every repo matching params, walking offset pages transparently. Range over it with a for-range loop; a non-nil error from Err (checked once the loop ends) means the walk stopped early on either a transport failure or an API error.
type Option ¶
type Option func(*config)
Option configures a Client constructed by New.
func WithHTTPClient ¶
func WithHTTPClient(hc genclient.HttpRequestDoer) Option
WithHTTPClient replaces the underlying HTTP client. The retry transport (WithRetry) wraps whatever Transport this client has set, so pass a client with a custom Transport already configured (proxies, mTLS, ...) rather than replacing RoundTrip yourself afterward.
func WithRetry ¶
WithRetry overrides the default retry policy. maxRetries is the number of additional attempts after the first; base is the starting backoff before jitter and any server-sent Retry-After.
func WithSessionCookie ¶
WithSessionCookie sets the session cookie sent on every request, overriding PIPELINE_ANALYTICS_SESSION.
type RepoIterator ¶
type RepoIterator struct {
// contains filtered or unexported fields
}
RepoIterator walks every page of a ListRepos call. Get Err after ranging to see whether the walk completed or stopped on an error.
func (*RepoIterator) All ¶
func (it *RepoIterator) All() iter.Seq[genclient.Repo]
All returns a range-over-func iterator (Go 1.23+) yielding one Repo per call: `for repo := range it.All() { ... }`.
func (*RepoIterator) Err ¶
func (it *RepoIterator) Err() error
Err returns the error that stopped iteration, or nil if it ran to completion (or hasn't started).