bitbucket

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 5

Documentation

Overview

Package bitbucket provides request/response/payload types, and Timpani activity names and wrapper functions, for interacting with Bitbucket Cloud.

Index

Constants

View Source
const (
	CommitsDiffActivityName     = "bitbucket.commits.diff"
	CommitsDiffstatActivityName = "bitbucket.commits.diffstat"
)
View Source
const (
	PullRequestsApproveActivityName         = "bitbucket.pullrequests.approve"
	PullRequestsCreateCommentActivityName   = "bitbucket.pullrequests.createComment"
	PullRequestsDeclineActivityName         = "bitbucket.pullrequests.decline"
	PullRequestsDeleteCommentActivityName   = "bitbucket.pullrequests.deleteComment"
	PullRequestsDiffstatActivityName        = "bitbucket.pullrequests.diffstat"
	PullRequestsGetActivityName             = "bitbucket.pullrequests.get"
	PullRequestsGetCommentActivityName      = "bitbucket.pullrequests.getComment"
	PullRequestsListActivityLogActivityName = "bitbucket.pullrequests.listActivityLog"
	PullRequestsListCommitsActivityName     = "bitbucket.pullrequests.listCommits"
	PullRequestsListForCommitActivityName   = "bitbucket.pullrequests.listForCommit"
	PullRequestsListTasksActivityName       = "bitbucket.pullrequests.listTasks"
	PullRequestsMergeActivityName           = "bitbucket.pullrequests.merge"
	PullRequestsUnapproveActivityName       = "bitbucket.pullrequests.unapprove"
	PullRequestsUpdateActivityName          = "bitbucket.pullrequests.update"
	PullRequestsUpdateCommentActivityName   = "bitbucket.pullrequests.updateComment"
)
View Source
const (
	SourceGetFileActivityName = "bitbucket.source.getFile"
)
View Source
const (
	UsersGetActivityName = "bitbucket.users.get"
)
View Source
const (
	WorkspacesListMembersActivityName = "bitbucket.workspaces.listMembers"
)

Variables

This section is empty.

Functions

func PullRequestsDeleteComment added in v1.5.0

func PullRequestsDeleteComment(ctx workflow.Context, thrippyLinkID, workspace, repo, prID, commentID string) error

PullRequestsDeleteComment is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-comments-comment-id-delete

func PullRequestsListActivityLog added in v1.5.0

func PullRequestsListActivityLog(ctx workflow.Context, thrippyLinkID, workspace, repo, prID string) ([]map[string]any, error)

PullRequestsListActivityLog is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-activity-get

It retrieves the full list of activity log entries by handling pagination internally.

func PullRequestsListForCommit added in v1.5.0

func PullRequestsListForCommit(ctx workflow.Context, thrippyLinkID, workspace, repo, commit string) ([]map[string]any, error)

PullRequestsListForCommit is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-commit-commit-pullrequests-get

It retrieves the full list of PRs by handling pagination internally.

func PullRequestsUpdate added in v1.7.0

func PullRequestsUpdate(ctx workflow.Context, thrippyLinkID, workspace, repo, prID string, update map[string]any) (map[string]any, error)

PullRequestsUpdate is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-put

func PullRequestsUpdateComment added in v1.5.0

func PullRequestsUpdateComment(ctx workflow.Context, thrippyLinkID, workspace, repo, prID, commentID, markdown string) error

PullRequestsUpdateComment is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-comments-comment-id-put

func SourceGetFile added in v1.5.0

func SourceGetFile(ctx workflow.Context, thrippyLinkID, workspace, repo, commit, path string) (string, error)

SourceGetFile is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#api-repositories-workspace-repo-slug-src-commit-path-get

Types

type Comment added in v1.8.0

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

	CreatedOn time.Time `json:"created_on"`
	UpdatedOn time.Time `json:"updated_on,omitzero"`
	Deleted   bool      `json:"deleted,omitempty"`
	Pending   bool      `json:"pending,omitempty"`

	Parent *Parent `json:"parent,omitempty"`

	Links map[string]Link `json:"links"`
}

Comment is based on: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Comment

func PullRequestsGetComment added in v1.8.0

func PullRequestsGetComment(ctx workflow.Context, thrippyLinkID, workspace, repo, prID, commentID string) (*Comment, error)

PullRequestsGetComment is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-comments-comment-id-get

type Commit added in v0.5.0

type Commit struct {
	Hash    string   `json:"hash"`
	Date    string   `json:"date,omitempty"`
	Author  *User    `json:"author,omitempty"`
	Message string   `json:"message,omitempty"`
	Parents []Commit `json:"parents,omitempty"`

	Links map[string]Link `json:"links"`
}

Commit is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-get

func PullRequestsListCommits added in v1.5.0

func PullRequestsListCommits(ctx workflow.Context, thrippyLinkID, workspace, repo, prID string) ([]Commit, error)

PullRequestsListCommits is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-commits-get

It retrieves the full list of commits by handling pagination internally.

type CommitFile added in v1.4.0

type CommitFile struct {
	Path        string `json:"path"`
	EscapedPath string `json:"escaped_path"`

	Links map[string]Link `json:"links"`
}

CommitFile is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-diffstat-spec-get

type CommitsDiffstatRequest added in v1.5.0

type CommitsDiffstatRequest struct {
	CommitsRequest

	IgnoreWhitespace bool `json:"ignore_whitespace,omitempty"`
	Merge            bool `json:"merge,omitempty"`
	Renames          bool `json:"renames,omitempty"`
	Topic            bool `json:"topic,omitempty"`

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	PageLen string `json:"pagelen,omitempty"`
	Page    string `json:"page,omitempty"`

	Next string `json:"next,omitempty"` // Populated and used only in Timpani, for pagination.
}

CommitsDiffstatRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-diffstat-spec-get

type CommitsDiffstatResponse added in v1.5.0

type CommitsDiffstatResponse struct {
	Values []Diffstat `json:"values"`

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	Size    int    `json:"size,omitempty"`
	PageLen int    `json:"pagelen,omitempty"`
	Page    int    `json:"page,omitempty"`
	Next    string `json:"next,omitempty"`
}

CommitsDiffstatResponse is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-diffstat-spec-get

type CommitsRequest added in v1.7.2

type CommitsRequest struct {
	ThrippyLinkID string `json:"thrippy_link_id,omitempty"`

	Workspace string `json:"workspace"`
	RepoSlug  string `json:"repo_slug"`
	Spec      string `json:"spec"`

	Path string `json:"path,omitempty"`
}

CommitsRequest contains common fields for commit-related requests.

type Diffstat added in v1.5.0

type Diffstat struct {
	Status string `json:"status"`

	LinesAdded   int `json:"lines_added"`
	LinesRemoved int `json:"lines_removed"`

	Old *CommitFile `json:"old,omitempty"`
	New *CommitFile `json:"new,omitempty"`
}

Diffstat is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-diffstat-spec-get

func CommitsDiffstat added in v1.5.0

func CommitsDiffstat(ctx workflow.Context, req CommitsDiffstatRequest) ([]Diffstat, error)

CommitsDiffstat is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-diffstat-spec-get

It retrieves the full list of diffstat entries by handling pagination internally.

func PullRequestsDiffstat added in v1.5.0

func PullRequestsDiffstat(ctx workflow.Context, thrippyLinkID, workspace, repo, prID string) ([]Diffstat, error)

PullRequestsDiffstat is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-diffstat-get

It retrieves the full list of diffstat entries by handling pagination internally.

type Inline added in v1.8.0

type Inline struct {
	Path string `json:"path"`

	StartFrom *int `json:"start_from,omitempty"`
	StartTo   *int `json:"start_to,omitempty"`
	From      *int `json:"from,omitempty"`
	To        *int `json:"to,omitempty"`

	ContextLines string `json:"context_lines"`
	Outdated     bool   `json:"outdated,omitempty"`

	SrcRev  string `json:"src_rev"`
	DestRev string `json:"dest_rev"`
}

Inline is based on: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Comment

type Link struct {
	HRef string `json:"href"`

} //revive:enable:exported

type Membership added in v0.1.2

type Membership struct {
	User User `json:"user"`
}

Membership is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-workspaces/#api-workspaces-workspace-members-get

type PullRequestsCreateCommentRequest added in v0.1.3

type PullRequestsCreateCommentRequest struct {
	PullRequestsRequest

	Markdown string `json:"text"`

	ParentID string `json:"parent_id,omitempty"`
}

PullRequestsCreateCommentRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-comments-post

type PullRequestsDeleteCommentRequest added in v0.2.0

type PullRequestsDeleteCommentRequest struct {
	PullRequestsRequest

	CommentID string `json:"comment_id"`
}

PullRequestsDeleteCommentRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-comments-comment-id-delete

type PullRequestsDiffstatRequest added in v1.5.0

type PullRequestsDiffstatRequest struct {
	PullRequestsRequest

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	PageLen string `json:"pagelen,omitempty"`
	Page    string `json:"page,omitempty"`

	Next string `json:"next,omitempty"` // Populated and used only in Timpani, for pagination.
}

PullRequestsDiffstatRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-diffstat-get

type PullRequestsListActivityLogRequest added in v1.0.0

type PullRequestsListActivityLogRequest struct {
	PullRequestsRequest

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	PageLen string `json:"pagelen,omitempty"`
	Page    string `json:"page,omitempty"`

	Next string `json:"next,omitempty"` // Populated and used only in Timpani, for pagination.
}

PullRequestsListActivityLogRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-activity-get

type PullRequestsListActivityLogResponse added in v1.0.0

type PullRequestsListActivityLogResponse struct {
	Values []map[string]any `json:"values"`

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	PageLen int    `json:"pagelen,omitempty"`
	Next    string `json:"next,omitempty"`
}

PullRequestsListActivityLogResponse is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-activity-get

type PullRequestsListCommitsRequest added in v0.5.0

type PullRequestsListCommitsRequest struct {
	PullRequestsRequest

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	PageLen string `json:"pagelen,omitempty"`
	Page    string `json:"page,omitempty"`

	Next string `json:"next,omitempty"` // Populated and used only in Timpani, for pagination.
}

PullRequestsListCommitsRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-commits-get

type PullRequestsListCommitsResponse added in v0.5.0

type PullRequestsListCommitsResponse struct {
	Values []Commit `json:"values"`

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	PageLen int    `json:"pagelen,omitempty"`
	Page    int    `json:"page,omitempty"`
	Next    string `json:"next,omitempty"`
}

PullRequestsListCommitsResponse is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-commits-get

type PullRequestsListForCommitRequest added in v1.0.0

type PullRequestsListForCommitRequest struct {
	ThrippyLinkID string `json:"thrippy_link_id,omitempty"`

	Workspace string `json:"workspace"`
	RepoSlug  string `json:"repo_slug"`
	Commit    string `json:"commit"`

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	PageLen string `json:"pagelen,omitempty"`
	Page    string `json:"page,omitempty"`

	Next string `json:"next,omitempty"` // Populated and used only in Timpani, for pagination.
}

PullRequestsListForCommitRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-commit-commit-pullrequests-get

type PullRequestsListForCommitResponse added in v1.0.0

type PullRequestsListForCommitResponse struct {
	Values []map[string]any `json:"values"`

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	PageLen int    `json:"pagelen,omitempty"`
	Page    int    `json:"page,omitempty"`
	Next    string `json:"next,omitempty"`
}

PullRequestsListForCommitResponse is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-commit-commit-pullrequests-get

type PullRequestsListTasksRequest added in v1.13.0

type PullRequestsListTasksRequest struct {
	PullRequestsRequest

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	PageLen string `json:"pagelen,omitempty"`
	Page    string `json:"page,omitempty"`

	Next string `json:"next,omitempty"` // Populated and used only in Timpani, for pagination.
}

PullRequestsListTasksRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-tasks-get

type PullRequestsListTasksResponse added in v1.13.0

type PullRequestsListTasksResponse struct {
	Values []Task `json:"values"`

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	Size    int    `json:"size,omitempty"`
	PageLen int    `json:"pagelen,omitempty"`
	Page    int    `json:"page,omitempty"`
	Next    string `json:"next,omitempty"`
}

PullRequestsListTasksResponse is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-tasks-get

type PullRequestsMergeRequest added in v1.0.0

type PullRequestsMergeRequest struct {
	PullRequestsRequest

	Type              string `json:"type,omitempty"`
	Message           string `json:"message,omitempty"`
	MergeStrategy     string `json:"merge_strategy,omitempty"`
	CloseSourceBranch bool   `json:"close_source_branch,omitempty"`
}

PullRequestsMergeRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-merge-post

type PullRequestsRequest added in v1.7.2

type PullRequestsRequest struct {
	ThrippyLinkID string `json:"thrippy_link_id,omitempty"`

	Workspace     string `json:"workspace"`
	RepoSlug      string `json:"repo_slug"`
	PullRequestID string `json:"pull_request_id"`
}

PullRequestsRequest contains common fields for PR-related requests.

type PullRequestsUpdateCommentRequest added in v0.2.0

type PullRequestsUpdateCommentRequest struct {
	PullRequestsRequest

	CommentID string `json:"comment_id"`
	Markdown  string `json:"text"`
}

PullRequestsUpdateCommentRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-comments-comment-id-put

type PullRequestsUpdateRequest added in v1.7.0

type PullRequestsUpdateRequest struct {
	PullRequestsRequest

	PullRequest map[string]any `json:"pullrequest"`
}

PullRequestsUpdateRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-put

type Rendered added in v0.5.0

type Rendered struct {
	Raw    string `json:"raw"`
	Markup string `json:"markup"`
	HTML   string `json:"html"`

} //revive:enable:exported

type SourceGetRequest added in v1.1.0

type SourceGetRequest struct {
	ThrippyLinkID string `json:"thrippy_link_id,omitempty"`

	Workspace string `json:"workspace"`
	RepoSlug  string `json:"repo_slug"`
	Commit    string `json:"commit"`
	Path      string `json:"path"`

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#filtering
	Filter string `json:"q,omitempty"`
	Sort   string `json:"sort,omitempty"`

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	PageLen string `json:"pagelen,omitempty"`
	Page    string `json:"page,omitempty"`

	Next string `json:"next,omitempty"`
}

SourceGetRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#api-repositories-workspace-repo-slug-src-commit-path-get

type Task added in v1.13.0

type Task struct {
	ID      int      `json:"id"`
	State   string   `json:"state"`
	Content Rendered `json:"content"`
	Creator User     `json:"creator"`

	CreatedOn time.Time `json:"created_on"`
	UpdatedOn time.Time `json:"updated_on,omitzero"`
	Pending   bool      `json:"pending,omitempty"`

	ResolvedBy *User     `json:"resolved_by,omitempty"`
	ResolvedOn time.Time `json:"resolved_on,omitzero"`
}

Task is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-tasks-get

func PullRequestsListTasks added in v1.13.0

func PullRequestsListTasks(ctx workflow.Context, thrippyLinkID, workspace, repo, prID string) ([]Task, error)

PullRequestsListTasks is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-tasks-get

It retrieves the full list of tasks by handling pagination internally.

type User added in v0.1.2

type User struct {
	Type string `json:"type"` // "user" or "app_user".

	DisplayName string `json:"display_name"`
	Nickname    string `json:"nickname"`
	AccountID   string `json:"account_id"`
	UUID        string `json:"uuid"`

	Links map[string]Link `json:"links"`
}

User is based on:

func UsersGetByAccountID added in v1.10.0

func UsersGetByAccountID(ctx workflow.Context, accountID string) (*User, error)

UsersGetByAccountID is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-users/#api-users-selected-user-get

func UsersGetCurrent added in v1.10.0

func UsersGetCurrent(ctx workflow.Context) (*User, error)

UsersGetCurrent is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-users/#api-user-get

func WorkspacesListMembers added in v1.5.0

func WorkspacesListMembers(ctx workflow.Context, workspace string, emailsFilter []string) ([]User, error)

WorkspacesListMembers is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-workspaces/#api-workspaces-workspace-members-get

type UsersGetRequest

type UsersGetRequest struct {
	AccountID string `json:"account_id,omitempty"`
	UUID      string `json:"uuid,omitempty"`
}

UsersGetRequest is based on:

type WorkspacesListMembersRequest

type WorkspacesListMembersRequest struct {
	Workspace    string   `json:"workspace"`
	EmailsFilter []string `json:"emails_filter"`
}

WorkspacesListMembersRequest is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-workspaces/#api-workspaces-workspace-members-get

type WorkspacesListMembersResponse added in v0.1.2

type WorkspacesListMembersResponse struct {
	Values []Membership `json:"values,omitempty"`

	// https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination
	PageLen int    `json:"pagelen,omitempty"`
	Page    int    `json:"page,omitempty"`
	Next    string `json:"next,omitempty"`
}

WorkspacesListMembersResponse is based on: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-workspaces/#api-workspaces-workspace-members-get

Jump to

Keyboard shortcuts

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