bitbucket

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Comment  *Comment  `json:"comment,omitempty"`
	Approval *Approval `json:"approval,omitempty"`
	Update   *PRUpdate `json:"update,omitempty"`
}

type Actor

type Actor struct {
	DisplayName string `json:"display_name"`
}

Actor is a Bitbucket user reference.

type AddCommentInput

type AddCommentInput struct {
	Content Content `json:"content"`
	Inline  *Inline `json:"inline,omitempty"`
	Parent  *Parent `json:"parent,omitempty"`
}

AddCommentInput holds the request body for adding a comment.

type AddDeployKeyInput

type AddDeployKeyInput struct {
	Label string `json:"label"`
	Key   string `json:"key"`
}

type Approval

type Approval struct {
	User Actor  `json:"user"`
	Date string `json:"date"`
}

type Branch

type Branch struct {
	Name   string       `json:"name"`
	Target BranchTarget `json:"target"`
	Links  Links        `json:"links"`
}

type BranchResource

type BranchResource struct {
	// contains filtered or unexported fields
}

BranchResource provides operations on repository branches.

func (*BranchResource) Create

func (r *BranchResource) Create(ctx context.Context, name, target string) (Branch, error)

Create creates a new branch from the given commit hash or branch name.

func (*BranchResource) Delete

func (r *BranchResource) Delete(ctx context.Context, name string) error

Delete removes a branch from the repository.

func (*BranchResource) List

func (r *BranchResource) List(ctx context.Context) ([]Branch, error)

List returns all branches in the repository.

type BranchRestriction

type BranchRestriction struct {
	ID              int    `json:"id"`
	Kind            string `json:"kind"`
	BranchMatchKind string `json:"branch_match_kind"`
	Pattern         string `json:"pattern"`
	Value           *int   `json:"value,omitempty"`
	Links           Links  `json:"links"`
}

type BranchRestrictionResource

type BranchRestrictionResource struct {
	// contains filtered or unexported fields
}

BranchRestrictionResource provides operations on repository branch restrictions.

func (*BranchRestrictionResource) Create

Create adds a new branch restriction to the repository.

func (*BranchRestrictionResource) Delete

func (r *BranchRestrictionResource) Delete(ctx context.Context, id int) error

Delete removes a branch restriction by its integer ID.

func (*BranchRestrictionResource) List

List returns all branch restrictions for the repository.

type BranchTarget

type BranchTarget struct {
	Hash string `json:"hash"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the Bitbucket Cloud HTTP client.

func New

func New(cfg *config.Config) *Client

New creates a Client from cfg using the live Bitbucket API.

func NewWithBaseURL

func NewWithBaseURL(cfg *config.Config, baseURL string) *Client

NewWithBaseURL creates a Client with a custom base URL. Used in tests.

func (*Client) Branches

func (c *Client) Branches(workspace, repo string) *BranchResource

Branches returns a resource for branch operations on the given repo.

func (*Client) Comments

func (c *Client) Comments(workspace, repo string, prID int) *CommentResource

Comments returns a CommentResource scoped to a specific PR.

func (*Client) Commits

func (c *Client) Commits(workspace, repo string) *CommitResource

Commits returns a resource for commit history and file access on the given repo.

func (*Client) DeployKeys

func (c *Client) DeployKeys(workspace, repo string) *DeployKeyResource

DeployKeys returns a resource for deploy key operations on the given repo.

func (*Client) Deployments

func (c *Client) Deployments(workspace, repo string) *DeploymentResource

Deployments returns a resource for deployment operations on the given repo.

func (*Client) Downloads

func (c *Client) Downloads(workspace, repo string) *DownloadResource

Downloads returns a resource for download artifact operations on the given repo.

func (*Client) Environments

func (c *Client) Environments(workspace, repo string) *EnvironmentResource

Environments returns a resource for deployment environment operations on the given repo.

func (*Client) Issues

func (c *Client) Issues(workspace, repo string) *IssueResource

Issues returns a resource for issue operations on the given repo.

func (*Client) Members

func (c *Client) Members(workspace string) *MemberResource

Members returns a resource for workspace member operations.

func (*Client) PRs

func (c *Client) PRs(workspace, repo string) *PRResource

PRs returns a PRResource scoped to the given workspace and repo.

func (*Client) Pipelines

func (c *Client) Pipelines(workspace, repo string) *PipelineResource

Pipelines returns a resource for pipeline operations on the given repo.

func (*Client) Repos

func (c *Client) Repos(workspace string) *RepoResource

Repos returns a resource for listing repositories in a workspace.

func (*Client) Restrictions

func (c *Client) Restrictions(workspace, repo string) *BranchRestrictionResource

Restrictions returns a resource for branch restriction operations on the given repo.

func (*Client) Tags

func (c *Client) Tags(workspace, repo string) *TagResource

Tags returns a resource for tag operations on the given repo.

func (*Client) Tasks

func (c *Client) Tasks(workspace, repo string, prID int) *TaskResource

Tasks returns a TaskResource scoped to a specific PR.

func (*Client) User

func (c *Client) User() *UserResource

User returns a resource for authenticated user operations.

func (*Client) Webhooks

func (c *Client) Webhooks(workspace, repo string) *WebhookResource

Webhooks returns a resource for webhook operations on the given repo.

type Comment

type Comment struct {
	ID      int     `json:"id"`
	Content Content `json:"content"`
	User    Actor   `json:"user"`
	Inline  *Inline `json:"inline,omitempty"`
	Parent  *Parent `json:"parent,omitempty"`
}

Comment represents a PR comment.

type CommentResource

type CommentResource struct {
	// contains filtered or unexported fields
}

CommentResource provides operations on pull request comments.

func (*CommentResource) Add

Add posts a new comment. Set input.Inline for an inline comment on a specific file/line.

func (*CommentResource) List

func (r *CommentResource) List(ctx context.Context) ([]Comment, error)

List returns all comments on the pull request.

func (*CommentResource) Reply

func (r *CommentResource) Reply(ctx context.Context, parentID int, text string) (Comment, error)

Reply posts a reply to an existing comment identified by parentID.

type Commit

type Commit struct {
	Hash    string         `json:"hash"`
	Date    string         `json:"date"`
	Message string         `json:"message"`
	Author  CommitAuthor   `json:"author"`
	Parents []CommitParent `json:"parents"`
}

type CommitAuthor

type CommitAuthor struct {
	Raw  string `json:"raw"`
	User *Actor `json:"user,omitempty"`
}

type CommitParent

type CommitParent struct {
	Hash string `json:"hash"`
}

type CommitResource

type CommitResource struct {
	// contains filtered or unexported fields
}

CommitResource provides operations on commits and file contents within a repository.

func (*CommitResource) File

func (r *CommitResource) File(ctx context.Context, ref, filePath string) (string, error)

File returns the raw content of a file at the given ref (branch, tag, or commit hash). The response is plain text, not JSON.

func (*CommitResource) Get

func (r *CommitResource) Get(ctx context.Context, hash string) (Commit, error)

Get returns a single commit by hash. Note: Bitbucket uses the singular "/commit/" path for single commit lookup.

func (*CommitResource) List

func (r *CommitResource) List(ctx context.Context, branch string) ([]Commit, error)

List returns commits on a branch, newest first.

type Content

type Content struct {
	Raw string `json:"raw"`
}

Content holds the raw text of a comment.

type CreateBranchInput

type CreateBranchInput struct {
	Name   string       `json:"name"`
	Target BranchTarget `json:"target"`
}

type CreateBranchRestrictionInput

type CreateBranchRestrictionInput struct {
	Kind            string `json:"kind"`
	BranchMatchKind string `json:"branch_match_kind"`
	Pattern         string `json:"pattern"`
	Value           *int   `json:"value,omitempty"`
}

type CreateIssueInput

type CreateIssueInput struct {
	Title    string   `json:"title"`
	Content  *Content `json:"content,omitempty"`
	Kind     string   `json:"kind,omitempty"`
	Priority string   `json:"priority,omitempty"`
}

type CreatePRInput

type CreatePRInput struct {
	Title             string   `json:"title"`
	Description       string   `json:"description,omitempty"`
	Source            Endpoint `json:"source"`
	Destination       Endpoint `json:"destination"`
	CloseSourceBranch bool     `json:"close_source_branch"`
}

CreatePRInput holds the request body for creating a PR.

type CreateTagInput

type CreateTagInput struct {
	Name   string       `json:"name"`
	Target BranchTarget `json:"target"`
}

type CreateWebhookInput

type CreateWebhookInput struct {
	Description string   `json:"description,omitempty"`
	URL         string   `json:"url"`
	Active      bool     `json:"active"`
	Events      []string `json:"events"`
}

type DeployKey

type DeployKey struct {
	ID        int    `json:"id"`
	Label     string `json:"label"`
	Key       string `json:"key"`
	CreatedOn string `json:"created_on"`
	Links     Links  `json:"links"`
}

type DeployKeyResource

type DeployKeyResource struct {
	// contains filtered or unexported fields
}

DeployKeyResource provides operations on repository deploy keys.

func (*DeployKeyResource) Add

func (r *DeployKeyResource) Add(ctx context.Context, label, key string) (DeployKey, error)

Add creates a new deploy key with the given label and SSH public key.

func (*DeployKeyResource) Delete

func (r *DeployKeyResource) Delete(ctx context.Context, id int) error

Delete removes a deploy key by its integer ID.

func (*DeployKeyResource) List

func (r *DeployKeyResource) List(ctx context.Context) ([]DeployKey, error)

List returns all deploy keys for the repository.

type Deployable

type Deployable struct {
	Commit   *DeployableCommit   `json:"commit,omitempty"`
	Pipeline *DeployablePipeline `json:"pipeline,omitempty"`
}

type DeployableCommit

type DeployableCommit struct {
	Hash string `json:"hash"`
}

type DeployablePipeline

type DeployablePipeline struct {
	UUID string `json:"uuid"`
}

type Deployment

type Deployment struct {
	UUID           string           `json:"uuid"`
	State          DeploymentState  `json:"state"`
	Environment    DeploymentEnvRef `json:"environment"`
	Deployable     Deployable       `json:"deployable"`
	LastUpdateTime string           `json:"last_update_time"`
}

type DeploymentEnvRef

type DeploymentEnvRef struct {
	UUID string `json:"uuid"`
}

type DeploymentResource

type DeploymentResource struct {
	// contains filtered or unexported fields
}

DeploymentResource provides operations on repository deployments.

func (*DeploymentResource) List

List returns the most recent deployments, newest first.

type DeploymentState

type DeploymentState struct {
	Name   string            `json:"name"`
	Status *DeploymentStatus `json:"status,omitempty"`
}

type DeploymentStatus

type DeploymentStatus struct {
	Name string `json:"name"` // "SUCCESSFUL", "FAILED"
}

type Download

type Download struct {
	Name  string `json:"name"`
	Size  int64  `json:"size"`
	Links Links  `json:"links"`
}

type DownloadResource

type DownloadResource struct {
	// contains filtered or unexported fields
}

DownloadResource provides operations on repository downloads.

func (*DownloadResource) Delete

func (r *DownloadResource) Delete(ctx context.Context, filename string) error

Delete removes a download artifact by filename.

func (*DownloadResource) List

func (r *DownloadResource) List(ctx context.Context) ([]Download, error)

List returns all downloads attached to the repository.

func (*DownloadResource) Upload

func (r *DownloadResource) Upload(ctx context.Context, name string, content io.Reader) error

Upload uploads a file as a repository download artifact. name is the filename as it will appear in Bitbucket (typically filepath.Base of the local path). content is the file data to upload.

type Endpoint

type Endpoint struct {
	Branch struct {
		Name string `json:"name"`
	} `json:"branch"`
}

Endpoint is a branch reference used in PR source/destination.

func NewEndpoint

func NewEndpoint(branchName string) Endpoint

NewEndpoint builds an Endpoint from a branch name.

type Environment

type Environment struct {
	UUID            string          `json:"uuid"`
	Name            string          `json:"name"`
	EnvironmentType EnvironmentType `json:"environment_type"`
	Lock            EnvironmentLock `json:"lock"`
}

type EnvironmentLock

type EnvironmentLock struct {
	Name string `json:"name"` // "UNLOCKED", "LOCKED"
}

type EnvironmentResource

type EnvironmentResource struct {
	// contains filtered or unexported fields
}

EnvironmentResource provides operations on repository deployment environments.

func (*EnvironmentResource) List

List returns all deployment environments in the repository.

type EnvironmentType

type EnvironmentType struct {
	Name string `json:"name"` // "Production", "Staging", "Test"
}

type Inline

type Inline struct {
	Path string `json:"path"`
	To   int    `json:"to"`
}

Inline identifies the file and line for an inline comment.

type Issue

type Issue struct {
	ID        int     `json:"id"`
	Title     string  `json:"title"`
	State     string  `json:"state"`
	Priority  string  `json:"priority"`
	Kind      string  `json:"kind"`
	Content   Content `json:"content"`
	Reporter  Actor   `json:"reporter"`
	Assignee  *Actor  `json:"assignee,omitempty"`
	CreatedOn string  `json:"created_on"`
	UpdatedOn string  `json:"updated_on"`
	Links     Links   `json:"links"`
}

type IssueResource

type IssueResource struct {
	// contains filtered or unexported fields
}

IssueResource provides operations on repository issues.

func (*IssueResource) Create

func (r *IssueResource) Create(ctx context.Context, input CreateIssueInput) (Issue, error)

Create creates a new issue with the provided fields.

func (*IssueResource) Get

func (r *IssueResource) Get(ctx context.Context, id int) (Issue, error)

Get returns a single issue by its integer ID.

func (*IssueResource) List

func (r *IssueResource) List(ctx context.Context) ([]Issue, error)

List returns all issues in the repository.

type Links struct {
	HTML struct {
		Href string `json:"href"`
	} `json:"html"`
}

Links holds href references returned by the API.

type MemberResource

type MemberResource struct {
	// contains filtered or unexported fields
}

MemberResource provides operations on workspace members.

func (*MemberResource) List

List returns all members of the workspace.

type PR

type PR struct {
	ID          int      `json:"id"`
	Title       string   `json:"title"`
	State       string   `json:"state"`
	Description string   `json:"description"`
	Source      Endpoint `json:"source"`
	Destination Endpoint `json:"destination"`
	Author      Actor    `json:"author"`
	Links       Links    `json:"links"`
}

PR represents a Bitbucket pull request.

type PRResource

type PRResource struct {
	// contains filtered or unexported fields
}

PRResource provides operations on pull requests within a specific repo.

func (*PRResource) Activity

func (r *PRResource) Activity(ctx context.Context, prID int) ([]Activity, error)

Activity returns the full activity timeline for a pull request.

func (*PRResource) Approve

func (r *PRResource) Approve(ctx context.Context, prID int) error

Approve approves the pull request.

func (*PRResource) Create

func (r *PRResource) Create(ctx context.Context, input CreatePRInput) (PR, error)

Create opens a new pull request.

func (*PRResource) Decline

func (r *PRResource) Decline(ctx context.Context, prID int) error

Decline declines the pull request.

func (*PRResource) Diff

func (r *PRResource) Diff(ctx context.Context, prID int) (string, error)

Diff returns the raw patch text for the pull request. The response is plain text (not JSON).

func (*PRResource) Get

func (r *PRResource) Get(ctx context.Context, prID int) (PR, error)

Get returns a single pull request by ID.

func (*PRResource) List

func (r *PRResource) List(ctx context.Context, state string) ([]PR, error)

List returns pull requests filtered by state (e.g. "OPEN", "MERGED").

func (*PRResource) Merge

func (r *PRResource) Merge(ctx context.Context, prID int, strategy string) error

Merge merges the pull request using the given strategy. strategy: "merge_commit", "squash", or "fast_forward".

func (*PRResource) Statuses

func (r *PRResource) Statuses(ctx context.Context, prID int) ([]PRStatus, error)

Statuses returns the build statuses associated with the pull request's source commit.

type PRStatus

type PRStatus struct {
	State       string `json:"state"`
	Key         string `json:"key"`
	Name        string `json:"name"`
	Description string `json:"description"`
	URL         string `json:"url"`
	CreatedOn   string `json:"created_on"`
}

type PRUpdate

type PRUpdate struct {
	State  string `json:"state"`
	Author Actor  `json:"author"`
	Date   string `json:"date"`
}

type Parent

type Parent struct {
	ID int `json:"id"`
}

Parent is a reference to a parent comment for replies.

type Pipeline

type Pipeline struct {
	UUID        string         `json:"uuid"`
	BuildNumber int            `json:"build_number"`
	State       PipelineState  `json:"state"`
	Target      PipelineTarget `json:"target"`
	CreatedOn   string         `json:"created_on"`
	CompletedOn string         `json:"completed_on"`
}

type PipelineCommit

type PipelineCommit struct {
	Hash string `json:"hash"`
}

type PipelineResource

type PipelineResource struct {
	// contains filtered or unexported fields
}

PipelineResource provides operations on repository pipelines.

func (*PipelineResource) Get

func (r *PipelineResource) Get(ctx context.Context, pipelineUUID string) (Pipeline, error)

Get returns a single pipeline by UUID.

func (*PipelineResource) List

func (r *PipelineResource) List(ctx context.Context) ([]Pipeline, error)

List returns the most recent pipelines, newest first.

func (*PipelineResource) Log

func (r *PipelineResource) Log(ctx context.Context, pipelineUUID, stepUUID string) (string, error)

Log returns the raw log output for a pipeline step (plain text, not JSON).

func (*PipelineResource) Steps

func (r *PipelineResource) Steps(ctx context.Context, pipelineUUID string) ([]PipelineStep, error)

Steps returns all steps of a pipeline.

func (*PipelineResource) Stop

func (r *PipelineResource) Stop(ctx context.Context, pipelineUUID string) error

Stop requests cancellation of a running pipeline.

func (*PipelineResource) Trigger

func (r *PipelineResource) Trigger(ctx context.Context, branch string) (Pipeline, error)

Trigger starts a new pipeline on the given branch.

type PipelineResult

type PipelineResult struct {
	Name string `json:"name"`
}

type PipelineState

type PipelineState struct {
	Name   string          `json:"name"`
	Result *PipelineResult `json:"result,omitempty"`
}

type PipelineStep

type PipelineStep struct {
	UUID        string        `json:"uuid"`
	Name        string        `json:"name"`
	State       PipelineState `json:"state"`
	StartedOn   string        `json:"started_on"`
	CompletedOn string        `json:"completed_on"`
}

type PipelineTarget

type PipelineTarget struct {
	RefType string          `json:"ref_type"`
	RefName string          `json:"ref_name"`
	Commit  *PipelineCommit `json:"commit,omitempty"`
}

type Repo

type Repo struct {
	Slug        string `json:"slug"`
	Name        string `json:"name"`
	Description string `json:"description"`
	IsPrivate   bool   `json:"is_private"`
	FullName    string `json:"full_name"`
	Links       Links  `json:"links"`
}

type RepoResource

type RepoResource struct {
	// contains filtered or unexported fields
}

RepoResource provides operations on repositories within a workspace.

func (*RepoResource) List

func (r *RepoResource) List(ctx context.Context) ([]Repo, error)

List returns all repositories the authenticated user has access to in the workspace.

type Tag

type Tag struct {
	Name   string       `json:"name"`
	Target BranchTarget `json:"target"`
	Links  Links        `json:"links"`
}

type TagResource

type TagResource struct {
	// contains filtered or unexported fields
}

TagResource provides operations on repository tags.

func (*TagResource) Create

func (r *TagResource) Create(ctx context.Context, name, target string) (Tag, error)

Create creates a new tag pointing at the given commit hash or branch name.

func (*TagResource) Delete

func (r *TagResource) Delete(ctx context.Context, name string) error

Delete removes a tag from the repository.

func (*TagResource) List

func (r *TagResource) List(ctx context.Context) ([]Tag, error)

List returns all tags in the repository.

type Task

type Task struct {
	ID          int    `json:"id"`
	Description string `json:"description"`
	State       string `json:"state"` // RESOLVED or UNRESOLVED
}

Task represents a PR task.

type TaskResource

type TaskResource struct {
	// contains filtered or unexported fields
}

TaskResource provides operations on pull request tasks.

func (*TaskResource) List

func (r *TaskResource) List(ctx context.Context) ([]Task, error)

List returns all tasks on the pull request.

func (*TaskResource) SetState

func (r *TaskResource) SetState(ctx context.Context, taskID int, resolved bool) error

SetState marks a task as resolved (true) or unresolved (false).

type TriggerPipelineInput

type TriggerPipelineInput struct {
	Target TriggerTarget `json:"target"`
}

type TriggerTarget

type TriggerTarget struct {
	RefType string `json:"ref_type"`
	Type    string `json:"type"`
	RefName string `json:"ref_name"`
}

type User

type User struct {
	AccountID   string `json:"account_id"`
	DisplayName string `json:"display_name"`
	Nickname    string `json:"nickname"`
	Links       Links  `json:"links"`
}

type UserResource

type UserResource struct {
	// contains filtered or unexported fields
}

UserResource provides operations on the authenticated user.

func (*UserResource) Me

func (r *UserResource) Me(ctx context.Context) (User, error)

Me returns the authenticated user's profile.

type Webhook

type Webhook struct {
	UUID        string   `json:"uuid"`
	Description string   `json:"description"`
	URL         string   `json:"url"`
	Active      bool     `json:"active"`
	Events      []string `json:"events"`
	CreatedAt   string   `json:"created_at"`
	Links       Links    `json:"links"`
}

type WebhookResource

type WebhookResource struct {
	// contains filtered or unexported fields
}

WebhookResource provides operations on repository webhooks.

func (*WebhookResource) Create

Create adds a new webhook to the repository.

func (*WebhookResource) Delete

func (r *WebhookResource) Delete(ctx context.Context, uuid string) error

Delete removes a webhook by its UUID string.

func (*WebhookResource) List

func (r *WebhookResource) List(ctx context.Context) ([]Webhook, error)

List returns all webhooks for the repository.

type WorkspaceMember

type WorkspaceMember struct {
	User  User  `json:"user"`
	Links Links `json:"links"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL