Documentation
¶
Overview ¶
Package bitbucket is a minimal Bitbucket Cloud REST API client covering only the endpoints notifycat needs for validation and path routing. It is intentionally narrow — adding a new endpoint means adding one method, not pulling in a full SDK.
Index ¶
- Variables
- type APIError
- type Client
- func (c *Client) GetPullRequest(ctx context.Context, workspace, repoSlug string, id int) (PullRequestState, error)
- func (c *Client) GetRepository(ctx context.Context, workspace, repoSlug string) (Repository, error)
- func (c *Client) ListHookEvents(ctx context.Context, workspace, repoSlug, urlSuffix string) ([]string, error)
- func (c *Client) ListPullRequestFiles(ctx context.Context, workspace, repoSlug string, id int) ([]string, error)
- func (c *Client) ListWorkspaceRepos(ctx context.Context, workspace string) ([]string, error)
- type Hook
- type Option
- type PullRequestState
- type Repository
Constants ¶
This section is empty.
Variables ¶
ErrDiffstatUnavailable is returned by ListPullRequestFiles when Bitbucket redirects the diffstat request to a stale source ref (spec=None), meaning the changed-file set cannot be resolved. Callers treat it as a soft failure.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the Bitbucket Cloud REST API.
func NewClient ¶
NewClient builds a Client. The httpClient is used as-is; callers should configure timeouts on it. token is the Bitbucket access token; email, when non-empty, switches auth to HTTP Basic (base64 of email:token) instead of a bearer token.
func (*Client) GetPullRequest ¶
func (c *Client) GetPullRequest(ctx context.Context, workspace, repoSlug string, id int) (PullRequestState, error)
GetPullRequest fetches a single PR's state and draft flag. A non-2xx response is returned as a typed *APIError.
func (*Client) GetRepository ¶
GetRepository fetches a single repository. A non-2xx response is returned as a typed *APIError (e.g. Status 404 for a missing or inaccessible repo).
func (*Client) ListHookEvents ¶
func (c *Client) ListHookEvents(ctx context.Context, workspace, repoSlug, urlSuffix string) ([]string, error)
ListHookEvents returns the union of events configured across active hooks pointing at notifycat (matched by `urlSuffix` against hook.url). Returns an empty slice when no matching hook exists, so callers can distinguish "no notifycat hook" from "hook misconfigured".
func (*Client) ListPullRequestFiles ¶
func (c *Client) ListPullRequestFiles(ctx context.Context, workspace, repoSlug string, id int) ([]string, error)
ListPullRequestFiles returns the repo-relative paths of every file changed in a PR, following Bitbucket's diffstat pagination. Bitbucket 302-redirects the diffstat request to a spec-pinned URL; this call follows the redirect while replaying auth. A redirect to a stale source ref (spec=None) surfaces as ErrDiffstatUnavailable so path routing can soft-fail to the repo tier.
func (*Client) ListWorkspaceRepos ¶
ListWorkspaceRepos returns the slugs of every repository in the workspace, following Bitbucket's pagination envelope. An empty result is a normal outcome (empty workspace or all repos filtered by token scope).
type Hook ¶
type Hook struct {
UUID string `json:"uuid"`
URL string `json:"url"`
Active bool `json:"active"`
Events []string `json:"events"`
}
Hook is the subset of a repository webhook record we care about.
type Option ¶
type Option func(*Client)
Option configures Client construction.
func WithBaseURL ¶
WithBaseURL overrides the Bitbucket API base URL.
type PullRequestState ¶
PullRequestState is the subset of a PR's status the stuck-PR digest needs. The State field is Bitbucket's raw value (OPEN, MERGED, DECLINED, SUPERSEDED) and is not normalized.
type Repository ¶
type Repository struct {
FullName string `json:"full_name"`
Slug string `json:"slug"`
IsPrivate bool `json:"is_private"`
}
Repository is the subset of a repository record notifycat validates against.