Documentation
¶
Overview ¶
Package api re-exports the HTTP middleware stack from api/internal/httpx so callers outside the api/ subtree (notably pkg/cmd/factory) can wrap their http.Client transports without needing access to the internal package.
Index ¶
- Variables
- func WithRetry(ctx context.Context, policy RetryPolicy) context.Context
- func WrapTransport(inner http.RoundTripper) http.RoundTripper
- type AppProperties
- type AuthConfig
- type Client
- func (c *Client) ApprovePR(project, slug string, id int) error
- func (c *Client) CreatePR(project, slug string, input CreatePRInput) (PullRequest, error)
- func (c *Client) CreateRepo(project string, input CreateRepoInput) (Repository, error)
- func (c *Client) Delete(path string) error
- func (c *Client) DeleteBranch(project, slug, branch string) error
- func (c *Client) DeleteRepo(project, slug string) error
- func (c *Client) GetApplicationProperties() (AppProperties, error)
- func (c *Client) GetCurrentUser() (User, error)
- func (c *Client) GetJSON(path string, v any) error
- func (c *Client) GetPR(project, slug string, id int) (PullRequest, error)
- func (c *Client) GetPRDiff(project, slug string, id int) (string, error)
- func (c *Client) GetRepo(project, slug string) (Repository, error)
- func (c *Client) GetText(path string) (string, error)
- func (c *Client) ListPRs(project, slug, state string, limit int) ([]PullRequest, error)
- func (c *Client) ListRepos(limit int) ([]Repository, error)
- func (c *Client) MergePR(project, slug string, id int, input MergePRInput) (PullRequest, error)
- func (c *Client) PostJSON(path string, body any, v any) error
- func (c *Client) PutJSON(path string, body any, v any) error
- type CloneLink
- type CreatePRInput
- type CreateRepoInput
- type HTTPClient
- type HTTPError
- type MergePRInput
- type PRLinks
- type PRParticipant
- type PRRef
- type PagedResponse
- type Project
- type PullRequest
- type RepoLinks
- type Repository
- type RetryPolicy
- type SelfLink
- type User
Constants ¶
This section is empty.
Variables ¶
var DefaultRetryPolicy = httpx.DefaultRetryPolicy
DefaultRetryPolicy is 3 attempts, 200 ms → 2 s, with jitter.
Functions ¶
func WithRetry ¶ added in v1.34.0
func WithRetry(ctx context.Context, policy RetryPolicy) context.Context
WithRetry returns a new context carrying policy. Attach it to a request to enable retries through a transport produced by WrapTransport.
func WrapTransport ¶ added in v1.34.0
func WrapTransport(inner http.RoundTripper) http.RoundTripper
WrapTransport wraps inner with the httpx middleware stack (retry → ETag cache → rate limit). See api/internal/httpx for details.
Types ¶
type AppProperties ¶
type AppProperties struct {
Version string `json:"version"`
BuildNumber string `json:"buildNumber"`
DisplayName string `json:"displayName"`
}
AppProperties holds Bitbucket version info.
type AuthConfig ¶
AuthConfig holds credentials for one host.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps HTTPClient with auth injection and JSON helpers.
func NewClient ¶
func NewClient(httpClient HTTPClient, baseURL string, auth AuthConfig) *Client
NewClient constructs a Client.
func (*Client) CreatePR ¶
func (c *Client) CreatePR(project, slug string, input CreatePRInput) (PullRequest, error)
CreatePR creates a new pull request.
func (*Client) CreateRepo ¶
func (c *Client) CreateRepo(project string, input CreateRepoInput) (Repository, error)
CreateRepo creates a new repository in project.
func (*Client) DeleteBranch ¶
DeleteBranch deletes a branch in a repository.
func (*Client) DeleteRepo ¶
DeleteRepo deletes a repository.
func (*Client) GetApplicationProperties ¶
func (c *Client) GetApplicationProperties() (AppProperties, error)
GetApplicationProperties fetches Bitbucket version info.
func (*Client) GetCurrentUser ¶
GetCurrentUser fetches the authenticated user.
func (*Client) GetPR ¶
func (c *Client) GetPR(project, slug string, id int) (PullRequest, error)
GetPR fetches a single pull request.
func (*Client) GetRepo ¶
func (c *Client) GetRepo(project, slug string) (Repository, error)
GetRepo fetches a single repository.
func (*Client) ListPRs ¶
func (c *Client) ListPRs(project, slug, state string, limit int) ([]PullRequest, error)
ListPRs lists pull requests for a repository.
func (*Client) ListRepos ¶
func (c *Client) ListRepos(limit int) ([]Repository, error)
ListRepos lists repositories accessible to the authenticated user.
func (*Client) MergePR ¶
func (c *Client) MergePR(project, slug string, id int, input MergePRInput) (PullRequest, error)
MergePR merges a pull request.
type CreatePRInput ¶
type CreatePRInput struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
Draft bool `json:"draft,omitempty"`
FromRef PRRef `json:"fromRef"`
ToRef PRRef `json:"toRef"`
}
CreatePRInput is the request body for PR creation.
type CreateRepoInput ¶
type CreateRepoInput struct {
Name string `json:"name"`
ScmID string `json:"scmId"`
Public bool `json:"public"`
Description string `json:"description,omitempty"`
}
CreateRepoInput is the request body for repo creation.
type HTTPClient ¶
HTTPClient is the interface for making HTTP requests.
type MergePRInput ¶
type MergePRInput struct {
Version int `json:"version"`
Message string `json:"message,omitempty"`
Strategy string `json:"strategy,omitempty"`
}
MergePRInput is the request body for PR merge.
type PRParticipant ¶
type PRParticipant struct {
User User `json:"user"`
Role string `json:"role"`
Approved bool `json:"approved"`
}
PRParticipant is a PR author or reviewer.
type PRRef ¶
type PRRef struct {
ID string `json:"id"`
DisplayID string `json:"displayId"`
Repository Repository `json:"repository"`
}
PRRef is a branch reference in a PR.
type PagedResponse ¶
type PagedResponse[T any] struct { Values []T `json:"values"` Size int `json:"size"` IsLastPage bool `json:"isLastPage"` NextPageStart *int `json:"nextPageStart"` Start int `json:"start"` }
PagedResponse is the Bitbucket paged list envelope.
type PullRequest ¶
type PullRequest struct {
ID int `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
State string `json:"state"`
Draft bool `json:"draft"`
Author PRParticipant `json:"author"`
Reviewers []PRParticipant `json:"reviewers"`
FromRef PRRef `json:"fromRef"`
ToRef PRRef `json:"toRef"`
Links PRLinks `json:"links"`
}
PullRequest represents a Bitbucket pull request.
type Repository ¶
type Repository struct {
ID int `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
Project Project `json:"project"`
ScmID string `json:"scmId"`
State string `json:"state"`
Public bool `json:"public"`
Links RepoLinks `json:"links"`
}
Repository represents a Bitbucket repository.
type RetryPolicy ¶ added in v1.34.0
type RetryPolicy = httpx.RetryPolicy
RetryPolicy is re-exported from api/internal/httpx so callers under pkg/cmd (which cannot import internal packages) can opt in to retry behaviour on a per-request basis via WithRetry.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cloud does not implement AdminClient.
|
Package cloud does not implement AdminClient. |
|
internal
|
|
|
httpx
Package httpx is the shared HTTP transport used by the Bitbucket Server/DC and Cloud API adapters.
|
Package httpx is the shared HTTP transport used by the Bitbucket Server/DC and Cloud API adapters. |
|
paging
Package paging bounds typed pagination above httpx.Transport.GetAllJSON.
|
Package paging bounds typed pagination above httpx.Transport.GetAllJSON. |
|
Package server is the Bitbucket Data Center (a.k.a.
|
Package server is the Bitbucket Data Center (a.k.a. |