Documentation
¶
Overview ¶
Package cloud is the Bitbucket Cloud adapter for the backend.Client interface.
Index ¶
- type Client
- func (c *Client) AddPRComment(ns, slug string, id int, in backend.AddPRCommentInput) (backend.PRComment, error)
- func (c *Client) ApprovePR(ns, slug string, id int) error
- func (c *Client) CreateBranch(ns, slug string, in backend.CreateBranchInput) (backend.Branch, error)
- func (c *Client) CreateIssue(ns, slug string, in backend.CreateIssueInput) (backend.Issue, error)
- func (c *Client) CreatePR(ns, slug string, in backend.CreatePRInput) (backend.PullRequest, error)
- func (c *Client) CreateRepo(ns string, in backend.CreateRepoInput) (backend.Repository, error)
- func (c *Client) CreateTag(ns, slug string, in backend.CreateTagInput) (backend.Tag, error)
- func (c *Client) CreateWebhook(ns, slug string, in backend.CreateWebhookInput) (backend.Webhook, error)
- func (c *Client) DeclinePR(ns, slug string, id int) error
- func (c *Client) DeleteBranch(ns, slug, branch string) error
- func (c *Client) DeletePipelineVariable(ns, slug, key string) error
- func (c *Client) DeleteRepo(ns, slug string) error
- func (c *Client) DeleteTag(ns, slug, name string) error
- func (c *Client) DeleteWebhook(ns, slug, id string) error
- func (c *Client) ForkRepo(ns, slug string, in backend.ForkRepoInput) (backend.Repository, error)
- func (c *Client) GetCommit(ns, slug, hash string) (backend.Commit, error)
- func (c *Client) GetCurrentUser() (backend.User, error)
- func (c *Client) GetIssue(ns, slug string, id int) (backend.Issue, error)
- func (c *Client) GetPR(ns, slug string, id int) (backend.PullRequest, error)
- func (c *Client) GetPRDiff(ns, slug string, id int) (string, error)
- func (c *Client) GetPipeline(ns, slug, uuid string) (backend.Pipeline, error)
- func (c *Client) GetPipelineStepLog(ns, slug, pipelineUUID, stepUUID string) (io.ReadCloser, error)
- func (c *Client) GetRepo(ns, slug string) (backend.Repository, error)
- func (c *Client) GetWebhook(ns, slug, id string) (backend.Webhook, error)
- func (c *Client) ListBranches(ns, slug string, limit int) ([]backend.Branch, error)
- func (c *Client) ListCommitStatuses(ns, slug, hash string) ([]backend.CommitStatus, error)
- func (c *Client) ListCommits(ns, slug, branch string, limit int) ([]backend.Commit, error)
- func (c *Client) ListIssues(ns, slug, state string, limit int) ([]backend.Issue, error)
- func (c *Client) ListPRComments(ns, slug string, id int) ([]backend.PRComment, error)
- func (c *Client) ListPRs(ns, slug, state string, limit int) ([]backend.PullRequest, error)
- func (c *Client) ListPipelineSteps(ns, slug, uuid string) ([]backend.PipelineStep, error)
- func (c *Client) ListPipelineVariables(ns, slug string) ([]backend.PipelineVariable, error)
- func (c *Client) ListPipelines(ns, slug string, limit int) ([]backend.Pipeline, error)
- func (c *Client) ListProjects(workspace string, limit int) ([]backend.Project, error)
- func (c *Client) ListRepos(ns string, limit int) ([]backend.Repository, error)
- func (c *Client) ListTags(ns, slug string, limit int) ([]backend.Tag, error)
- func (c *Client) ListWebhooks(ns, slug string) ([]backend.Webhook, error)
- func (c *Client) ListWorkspaces(limit int) ([]backend.Workspace, error)
- func (c *Client) MergePR(ns, slug string, id int, in backend.MergePRInput) (backend.PullRequest, error)
- func (c *Client) ReadyPR(ns, slug string, id int) error
- func (c *Client) RenameRepo(ns, slug, newName string) (backend.Repository, error)
- func (c *Client) RequestChangesPR(ns, slug string, id int) error
- func (c *Client) RequestReview(ns, slug string, id int, users []string) error
- func (c *Client) RunPipeline(ns, slug string, in backend.RunPipelineInput) (backend.Pipeline, error)
- func (c *Client) SetPipelineVariable(ns, slug string, in backend.PipelineVariableInput) (backend.PipelineVariable, error)
- func (c *Client) UnapprovePR(ns, slug string, id int) error
- func (c *Client) UpdateIssue(ns, slug string, id int, in backend.UpdateIssueInput) (backend.Issue, error)
- func (c *Client) UpdatePR(ns, slug string, id int, in backend.UpdatePRInput) (backend.PullRequest, error)
- type HTTPClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Bitbucket Cloud HTTP client.
func NewClient ¶
func NewClient(httpClient HTTPClient, baseURL, token, username string) *Client
NewClient constructs a Cloud Client. If token is non-empty Bearer auth is used; else if username is non-empty Basic auth is used with username:token as credentials.
func (*Client) AddPRComment ¶ added in v1.6.0
func (*Client) ApprovePR ¶
ApprovePR approves a PR on behalf of the authenticated user. A nil body is intentional: Bitbucket Cloud returns HTTP 400 when Content-Type: application/json is sent with an empty body on this endpoint. The ContentTypeWhenBody policy on the Cloud transport ensures no Content-Type is set for nil-body POSTs.
func (*Client) CreateBranch ¶
func (c *Client) CreateBranch(ns, slug string, in backend.CreateBranchInput) (backend.Branch, error)
CreateBranch creates a new branch in the given repository. Cloud requires a commit hash as the target; if StartAt is a branch name (not a 40-char hex string) it is resolved to its HEAD commit hash first.
func (*Client) CreateIssue ¶ added in v1.17.0
func (*Client) CreatePR ¶
func (c *Client) CreatePR(ns, slug string, in backend.CreatePRInput) (backend.PullRequest, error)
func (*Client) CreateRepo ¶
func (c *Client) CreateRepo(ns string, in backend.CreateRepoInput) (backend.Repository, error)
func (*Client) CreateWebhook ¶ added in v1.15.0
func (*Client) DeclinePR ¶
DeclinePR declines an open pull request. A nil body is intentional: ContentTypeWhenBody ensures no Content-Type is set, which is required for this endpoint on Bitbucket Cloud.
func (*Client) DeleteBranch ¶
func (*Client) DeletePipelineVariable ¶ added in v1.15.0
DeletePipelineVariable looks up the variable by Key and DELETEs it. Returns a typed ErrNotFound DomainError when no variable matches the key.
func (*Client) DeleteRepo ¶
func (*Client) DeleteWebhook ¶ added in v1.15.0
func (*Client) ForkRepo ¶ added in v1.16.0
func (c *Client) ForkRepo(ns, slug string, in backend.ForkRepoInput) (backend.Repository, error)
func (*Client) GetPipeline ¶
GetPipeline fetches a single pipeline run by UUID. Bitbucket Cloud requires pipeline UUIDs to be enclosed in curly braces in the URL path (e.g. "{abc-123}"), so we normalise the caller-supplied uuid.
func (*Client) GetPipelineStepLog ¶ added in v1.15.0
func (c *Client) GetPipelineStepLog(ns, slug, pipelineUUID, stepUUID string) (io.ReadCloser, error)
GetPipelineStepLog returns a streaming reader for the plaintext log of a single pipeline step. The caller is responsible for calling Close on the returned reader.
func (*Client) GetWebhook ¶ added in v1.15.0
func (*Client) ListBranches ¶
ListBranches lists branches for a repository, capping the total returned at limit (limit <= 0 means unbounded).
func (*Client) ListCommitStatuses ¶ added in v1.6.0
func (c *Client) ListCommitStatuses(ns, slug, hash string) ([]backend.CommitStatus, error)
func (*Client) ListCommits ¶
func (*Client) ListIssues ¶ added in v1.17.0
ListIssues fetches issues from a repository's tracker. The state argument is appended as a `q=state="..."` filter when non-empty. Bitbucket Cloud's query language is case-sensitive on field names but accepts lowercase state values exactly.
func (*Client) ListPRComments ¶ added in v1.6.0
func (*Client) ListPipelineSteps ¶ added in v1.15.0
func (c *Client) ListPipelineSteps(ns, slug, uuid string) ([]backend.PipelineStep, error)
ListPipelineSteps lists the steps in a pipeline run.
func (*Client) ListPipelineVariables ¶ added in v1.15.0
func (c *Client) ListPipelineVariables(ns, slug string) ([]backend.PipelineVariable, error)
ListPipelineVariables returns repository-level pipeline variables. The Bitbucket Cloud API never includes the value of secured variables in the response, so PipelineVariable.Value is empty when Secured is true.
func (*Client) ListPipelines ¶
func (*Client) ListProjects ¶ added in v1.17.0
ListProjects lists projects in the given workspace. Workspace is required; an empty value yields an explicit error so callers don't accidentally hit /workspaces//projects (the API would 404, but the error message would be less helpful).
func (*Client) ListWebhooks ¶ added in v1.15.0
func (*Client) ListWorkspaces ¶ added in v1.17.0
ListWorkspaces lists workspaces the authenticated user is a member of. Pagination is driven by paging.Collect; limit caps total items (0 = no cap, follow Cloud's default page size to exhaustion).
func (*Client) MergePR ¶
func (c *Client) MergePR(ns, slug string, id int, in backend.MergePRInput) (backend.PullRequest, error)
func (*Client) RenameRepo ¶ added in v1.16.0
func (c *Client) RenameRepo(ns, slug, newName string) (backend.Repository, error)
func (*Client) RequestChangesPR ¶
RequestChangesPR requests changes on a pull request (Cloud only). A nil body is intentional: ContentTypeWhenBody ensures no Content-Type is set, which is required for this endpoint on Bitbucket Cloud.
func (*Client) RequestReview ¶
RequestReview adds reviewers to a pull request using PUT /pullrequests/{id}. It first GETs the current PR to preserve existing reviewers, then PUTs the merged list. This is the only Cloud-supported approach (the /participants endpoint does not support adding reviewers).
func (*Client) RunPipeline ¶
func (c *Client) RunPipeline(ns, slug string, in backend.RunPipelineInput) (backend.Pipeline, error)
RunPipeline triggers a new pipeline run on a branch.
func (*Client) SetPipelineVariable ¶ added in v1.15.0
func (c *Client) SetPipelineVariable(ns, slug string, in backend.PipelineVariableInput) (backend.PipelineVariable, error)
SetPipelineVariable upserts a pipeline variable by Key. If a variable with the same Key already exists, it is updated via PUT; otherwise a new one is created via POST. Hides the UUID-vs-key wrinkle from the caller.
func (*Client) UnapprovePR ¶
UnapprovePR removes the authenticated user's approval from a pull request.
func (*Client) UpdateIssue ¶ added in v1.17.0
func (*Client) UpdatePR ¶
func (c *Client) UpdatePR(ns, slug string, id int, in backend.UpdatePRInput) (backend.PullRequest, error)
UpdatePR updates the title and/or description of a pull request.
type HTTPClient ¶
HTTPClient is the transport interface for making HTTP requests.