backend

package
v1.135.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const AssigneeNone = "__none__"

AssigneeNone is a sentinel value for UpdateIssueInput.Assignee that signals "unassign" (set assignee to null on the wire).

Variables

View Source
var (
	ErrNotFound          = errors.New("not found")
	ErrAuth              = errors.New("authentication required")
	ErrPermission        = errors.New("permission denied")
	ErrUnsupportedOnHost = errors.New("operation unsupported on this host")
	// ErrUnknownHost is returned when a caller names a hostname that is not
	// present in the local configuration (hosts.yml). Distinct from
	// ErrUnsupportedOnHost (host is known, but the feature isn't) and ErrAuth
	// (host is known, but the token is bad): the host itself is unrecognised,
	// so no HTTP should be attempted against it.
	ErrUnknownHost    = errors.New("unknown host")
	ErrConflict       = errors.New("conflict")
	ErrTransport      = errors.New("transport error")
	ErrInvalidRequest = errors.New("invalid request")
	// ErrEndpointDeprecated is returned when a Bitbucket API endpoint returns
	// HTTP 410 Gone indicating the endpoint has been removed (e.g. CHANGE-2770).
	ErrEndpointDeprecated = errors.New("endpoint deprecated")
)

Sentinel errors describing the bounded set of domain-level failure modes. Adapters classify wire errors into one of these so commands and the MCP surface can branch deterministically via errors.Is.

AllCodes lists every published ErrorCode. The errfmt test suite iterates this slice and asserts each code has a catalogue entry, so adding a new constant above without a matching errfmt entry fails the build.

When adding a new code:

  1. Append it to the const block above.
  2. Append it here.
  3. Add the matching catalogue entry in pkg/errfmt/errfmt.go.
View Source
var AllFeatureSpecs = []FeatureSpec{
	{
		Name:          "AdminClient",
		HumanLabel:    "admin operations",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(AdminClient); return ok },
		Feature:       FeatureAdmin,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "BranchProtector",
		HumanLabel:    "branch protection",
		Check:         func(c Client) bool { _, ok := c.(BranchProtector); return ok },
		Feature:       FeatureBranchProtect,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "BranchModelClient",
		HumanLabel:    "branching model",
		Check:         func(c Client) bool { _, ok := c.(BranchModelClient); return ok },
		Feature:       FeatureBranchModel,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "BranchRuleClient",
		HumanLabel:    "branch restriction rules",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(BranchRuleClient); return ok },
		Feature:       FeatureBranchRules,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "CloudCodeInsightsClient",
		HumanLabel:    "cloud code insights",
		Check:         func(c Client) bool { _, ok := c.(CloudCodeInsightsClient); return ok },
		Feature:       FeatureCloudCodeInsights,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "CodeInsightsClient",
		HumanLabel:    "code insights",
		Check:         func(c Client) bool { _, ok := c.(CodeInsightsClient); return ok },
		Feature:       FeatureCodeInsights,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "CodeSearcher",
		HumanLabel:    "code search",
		Check:         func(c Client) bool { _, ok := c.(CodeSearcher); return ok },
		Feature:       FeatureCodeSearch,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "CloudProjectClient",
		HumanLabel:    "Cloud workspace projects",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(CloudProjectClient); return ok },
		Feature:       FeatureCloudProjects,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "CommentReactor",
		HumanLabel:    "pr comment reactions",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(CommentReactor); return ok },
		Feature:       FeatureCommentReactions,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "CommitCommentReactor",
		HumanLabel:    "commit comment reactions",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(CommitCommentReactor); return ok },
		Feature:       FeatureCommitCommentReactions,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "CommitFileClient",
		HumanLabel:    "listing commit files",
		Check:         func(c Client) bool { _, ok := c.(CommitFileClient); return ok },
		Feature:       FeatureCommitFiles,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "CommitSearcher",
		HumanLabel:    "commit search",
		Check:         func(c Client) bool { _, ok := c.(CommitSearcher); return ok },
		Feature:       FeatureCommitSearch,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "DefaultReviewerClient",
		HumanLabel:    "default reviewer management",
		Check:         func(c Client) bool { _, ok := c.(DefaultReviewerClient); return ok },
		Feature:       FeatureDefaultReviewerClient,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "DefaultReviewersResolver",
		HumanLabel:    "default reviewers lookup",
		Check:         func(c Client) bool { _, ok := c.(DefaultReviewersResolver); return ok },
		Feature:       FeatureDefaultReviewers,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "DeployKeyClient",
		HumanLabel:    "deploy keys",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(DeployKeyClient); return ok },
		Feature:       FeatureDeployKeys,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "DeploymentClient",
		HumanLabel:    "deployments",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(DeploymentClient); return ok },
		Feature:       FeatureDeployments,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "DiffClient",
		HumanLabel:    "diff",
		Check:         func(c Client) bool { _, ok := c.(DiffClient); return ok },
		Feature:       FeatureDiff,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "GroupClient",
		HumanLabel:    "group management",
		Check:         func(c Client) bool { _, ok := c.(GroupClient); return ok },
		Feature:       FeatureGroup,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "GroupMemberClient",
		HumanLabel:    "group member management",
		Check:         func(c Client) bool { _, ok := c.(GroupMemberClient); return ok },
		Feature:       FeatureGroupMember,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "IssueAttacher",
		HumanLabel:    "issue attachments",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(IssueAttacher); return ok },
		Feature:       FeatureIssueAttachments,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "IssueClient",
		HumanLabel:    "issues",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(IssueClient); return ok },
		Feature:       FeatureIssues,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "IssueVoter",
		HumanLabel:    "issue voting",
		Check:         func(c Client) bool { _, ok := c.(IssueVoter); return ok },
		Feature:       FeatureIssueVoting,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "IssueWatcher",
		HumanLabel:    "issue watching",
		Check:         func(c Client) bool { _, ok := c.(IssueWatcher); return ok },
		Feature:       FeatureIssueWatching,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "MirrorClient",
		HumanLabel:    "mirror servers",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(MirrorClient); return ok },
		Feature:       FeatureMirror,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "IssueVersionClient",
		HumanLabel:    "issue versions",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(IssueVersionClient); return ok },
		Feature:       FeatureIssueVersions,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "MilestoneClient",
		HumanLabel:    "issue milestones",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(MilestoneClient); return ok },
		Feature:       FeatureMilestones,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "PRCommitClient",
		HumanLabel:    "PR commits",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(PRCommitClient); return ok },
		Feature:       FeaturePRCommits,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "PRCommentResolver",
		HumanLabel:    "pr comment resolve",
		Check:         func(c Client) bool { _, ok := c.(PRCommentResolver); return ok },
		Feature:       FeaturePRCommentResolve,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "PRCommentStateSetter",
		HumanLabel:    "pr task resolve/reopen",
		Check:         func(c Client) bool { _, ok := c.(PRCommentStateSetter); return ok },
		Feature:       FeaturePRCommentStateSet,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "PRFileClient",
		HumanLabel:    "PR files",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(PRFileClient); return ok },
		Feature:       FeaturePRFiles,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "PRParticipantClient",
		HumanLabel:    "PR participants",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(PRParticipantClient); return ok },
		Feature:       FeaturePRParticipants,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "PRParticipantUpdater",
		HumanLabel:    "PR participant update",
		Check:         func(c Client) bool { _, ok := c.(PRParticipantUpdater); return ok },
		Feature:       FeaturePRParticipantUpdate,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "PRReopener",
		HumanLabel:    "pr reopen",
		Check:         func(c Client) bool { _, ok := c.(PRReopener); return ok },
		Feature:       FeaturePRReopen,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "PermissionsClient",
		HumanLabel:    "permission management",
		Check:         func(c Client) bool { _, ok := c.(PermissionsClient); return ok },
		Feature:       FeaturePermissions,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "PipelineCacheClient",
		HumanLabel:    "pipeline caches",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(PipelineCacheClient); return ok },
		Feature:       FeaturePipelineCache,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "PipelineClient",
		HumanLabel:    "pipelines",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(PipelineClient); return ok },
		Feature:       FeaturePipelines,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "PipelineScheduleClient",
		HumanLabel:    "pipeline schedules",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(PipelineScheduleClient); return ok },
		Feature:       FeaturePipelineSchedules,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "PipelineArtifactClient",
		HumanLabel:    "pipeline artifacts",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(PipelineArtifactClient); return ok },
		Feature:       FeaturePipelineArtifacts,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "PipelineTriggerClient",
		HumanLabel:    "pipeline trigger",
		Check:         func(c Client) bool { _, ok := c.(PipelineTriggerClient); return ok },
		Feature:       FeaturePipelineTrigger,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "PipelineTestReportClient",
		HumanLabel:    "pipeline test reports",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(PipelineTestReportClient); return ok },
		Feature:       FeaturePipelineTestReports,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "RefComparer",
		HumanLabel:    "branch compare",
		Check:         func(c Client) bool { _, ok := c.(RefComparer); return ok },
		Feature:       FeatureRefCompare,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "RepoDownloadClient",
		HumanLabel:    "repo downloads",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(RepoDownloadClient); return ok },
		Feature:       FeatureRepoDownloads,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "RepoEditor",
		HumanLabel:    "repo edit",
		Check:         func(c Client) bool { _, ok := c.(RepoEditor); return ok },
		Feature:       FeatureRepoEdit,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "RepoPRSettingsClient",
		HumanLabel:    "repo PR settings",
		Check:         func(c Client) bool { _, ok := c.(RepoPRSettingsClient); return ok },
		Feature:       FeatureRepoPRSettings,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "RepoForker",
		HumanLabel:    "repo fork",
		Check:         func(c Client) bool { _, ok := c.(RepoForker); return ok },
		Feature:       FeatureRepoFork,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "RepoForksLister",
		HumanLabel:    "repo fork list",
		Check:         func(c Client) bool { _, ok := c.(RepoForksLister); return ok },
		Feature:       FeatureRepoForks,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "RepoTransferClient",
		HumanLabel:    "repo transfer",
		Check:         func(c Client) bool { _, ok := c.(RepoTransferClient); return ok },
		Feature:       FeatureRepoTransfer,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "RepoHookClient",
		HumanLabel:    "repo hook scripts",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(RepoHookClient); return ok },
		Feature:       FeatureRepoHooks,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "RepoSyncer",
		HumanLabel:    "repository sync",
		Check:         func(c Client) bool { _, ok := c.(RepoSyncer); return ok },
		Feature:       FeatureRepoSync,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "RepoLabelClient",
		HumanLabel:    "repository labels",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(RepoLabelClient); return ok },
		Feature:       FeatureRepoLabels,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "RepoWatcherClient",
		HumanLabel:    "repo watchers",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(RepoWatcherClient); return ok },
		Feature:       FeatureRepoWatchers,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "ReviewerGroupClient",
		HumanLabel:    "reviewer group management",
		Check:         func(c Client) bool { _, ok := c.(ReviewerGroupClient); return ok },
		Feature:       FeatureReviewerGroup,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "PATClient",
		HumanLabel:    "personal access token management",
		Check:         func(c Client) bool { _, ok := c.(PATClient); return ok },
		Feature:       FeaturePAT,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "ServerProjectClient",
		HumanLabel:    "server project management",
		Check:         func(c Client) bool { _, ok := c.(ServerProjectClient); return ok },
		Feature:       FeatureServerProject,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "SnippetClient",
		HumanLabel:    "snippets",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(SnippetClient); return ok },
		Feature:       FeatureSnippets,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "SSHKeyClient",
		HumanLabel:    "user SSH keys",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(SSHKeyClient); return ok },
		Feature:       FeatureSSHKeys,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "SuggestionApplier",
		HumanLabel:    "pr suggestion apply",
		Check:         func(c Client) bool { _, ok := c.(SuggestionApplier); return ok },
		Feature:       FeaturePRSuggestion,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "VersionedServer",
		HumanLabel:    "server version",
		Check:         func(c Client) bool { _, ok := c.(VersionedServer); return ok },
		Feature:       FeatureServerVersion,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "WorkspaceClient",
		HumanLabel:    "workspaces",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(WorkspaceClient); return ok },
		Feature:       FeatureWorkspaces,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "WorkspaceMemberClient",
		HumanLabel:    "workspace members",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(WorkspaceMemberClient); return ok },
		Feature:       FeatureWorkspaceMembers,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "WorkspacePermsClient",
		HumanLabel:    "workspace permissions",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(WorkspacePermsClient); return ok },
		Feature:       FeatureWorkspacePerms,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "WorkspaceVariableClient",
		HumanLabel:    "workspace variables",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(WorkspaceVariableClient); return ok },
		Feature:       FeatureWorkspaceVariables,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "WorkspacePipelineVariableClient",
		HumanLabel:    "workspace pipeline variables",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(WorkspacePipelineVariableClient); return ok },
		Feature:       FeatureWorkspacePipelineVars,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "WorkspaceWebhookClient",
		HumanLabel:    "workspace webhooks",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(WorkspaceWebhookClient); return ok },
		Feature:       FeatureWorkspaceWebhooks,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "RunnerClient",
		HumanLabel:    "pipeline runners",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(RunnerClient); return ok },
		Feature:       FeatureRunner,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "AuditClient",
		HumanLabel:    "audit log",
		Plural:        false,
		Check:         func(c Client) bool { _, ok := c.(AuditClient); return ok },
		Feature:       FeatureAudit,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "IPAllowlistClient",
		HumanLabel:    "IP allowlist",
		Plural:        false,
		Check:         func(c Client) bool { _, ok := c.(IPAllowlistClient); return ok },
		Feature:       FeatureIPAllowlist,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "SourceWriter",
		HumanLabel:    "writing files via the API",
		Check:         func(c Client) bool { _, ok := c.(SourceWriter); return ok },
		Feature:       FeatureSourceWrite,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "CommitCherryPicker",
		HumanLabel:    "cherry-pick",
		Check:         func(c Client) bool { _, ok := c.(CommitCherryPicker); return ok },
		Feature:       FeatureCherryPick,
		CloudSupport:  false,
		ServerSupport: true,
	},
	{
		Name:          "PipelineConfigClient",
		HumanLabel:    "pipeline config",
		Check:         func(c Client) bool { _, ok := c.(PipelineConfigClient); return ok },
		Feature:       FeaturePipelineConfig,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "PipelineSSHKeyPairClient",
		HumanLabel:    "pipeline SSH key pair",
		Check:         func(c Client) bool { _, ok := c.(PipelineSSHKeyPairClient); return ok },
		Feature:       FeaturePipelineSSHKeyPair,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "PipelineKnownHostsClient",
		HumanLabel:    "pipeline known hosts",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(PipelineKnownHostsClient); return ok },
		Feature:       FeaturePipelineKnownHosts,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "IssueActivityClient",
		HumanLabel:    "issue activity log",
		Plural:        false,
		Check:         func(c Client) bool { _, ok := c.(IssueActivityClient); return ok },
		Feature:       FeatureIssueActivity,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "WorkspaceSearcher",
		HumanLabel:    "workspace search",
		Plural:        false,
		Check:         func(c Client) bool { _, ok := c.(WorkspaceSearcher); return ok },
		Feature:       FeatureWorkspaceSearch,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "WorkspaceProjectPermsClient",
		HumanLabel:    "workspace project permissions",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(WorkspaceProjectPermsClient); return ok },
		Feature:       FeatureWorkspaceProjectPerms,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "WorkspaceProjectDefaultReviewerClient",
		HumanLabel:    "workspace project default reviewers",
		Plural:        true,
		Check:         func(c Client) bool { _, ok := c.(WorkspaceProjectDefaultReviewerClient); return ok },
		Feature:       FeatureWorkspaceProjectDefaultReviewers,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "PRMergePreviewClient",
		HumanLabel:    "PR merge preview",
		Check:         func(c Client) bool { _, ok := c.(PRMergePreviewClient); return ok },
		Feature:       FeaturePRMergePreview,
		CloudSupport:  true,
		ServerSupport: true,
	},
	{
		Name:          "PipelineOIDCClient",
		HumanLabel:    "pipeline OIDC configuration",
		Check:         func(c Client) bool { _, ok := c.(PipelineOIDCClient); return ok },
		Feature:       FeaturePipelineOIDC,
		CloudSupport:  true,
		ServerSupport: false,
	},
	{
		Name:          "HostInfoClient",
		HumanLabel:    "host info",
		Check:         func(c Client) bool { _, ok := c.(HostInfoClient); return ok },
		Feature:       FeatureHostInfo,
		CloudSupport:  true,
		ServerSupport: true,
	},
}

AllFeatureSpecs enumerates every optional capability in declaration order. Adding a new As<X>Client function requires adding an entry here so the capability contract test catches any support-declaration mismatch.

Functions

func DefaultBranch added in v1.8.0

func DefaultBranch(bl BranchLister, ns, slug string) (string, error)

DefaultBranch resolves a repository's default branch by inspecting the IsDefault flag on its branch list. It returns "" with no error when no branch in the list is marked default (e.g. on Bitbucket Cloud, whose branch endpoint omits IsDefault), so callers can fall back to local git state or another heuristic.

Errors from the underlying ListBranches call are propagated unchanged so no command silently masks them with a literal "main".

func NormaliseEmoji added in v1.40.0

func NormaliseEmoji(emoji string) string

NormaliseEmoji converts any accepted emoji form (colon-wrapped Server values, shortcodes with colons, or canonical underscore form) to the canonical underscore form. Returns the input unchanged when the emoji is not in the known set.

func StampCode added in v1.19.0

func StampCode(err error, code ErrorCode, resource, id, feature string) error

StampCode is an adapter convenience: when err is a *DomainError, sets the fields on a copy and returns the copy as an error; otherwise returns err unchanged. This lets call sites annotate post-classification errors with operation-specific codes (e.g. pr.merge.conflict vs the bare ErrConflict kind) without per-call boilerplate.

Empty arguments are skipped so a caller can stamp only Code while leaving Resource/ID/Feature alone, or fill in just Resource+ID for a not-found path.

The returned error preserves Kind, Host, Cause, and Message — only the specified fields are overwritten.

func ToCloudMergeStrategy added in v1.30.0

func ToCloudMergeStrategy(s string) string

ToCloudMergeStrategy translates CLI strategy names to Bitbucket Cloud API values used on the auto-merge endpoint.

func ToServerMergeStrategy added in v1.30.0

func ToServerMergeStrategy(s string) string

ToServerMergeStrategy translates CLI strategy names to Bitbucket Server / Data Center API values used on the auto-merge endpoint.

func ValidateMutablePRState added in v1.127.6

func ValidateMutablePRState(pr PullRequest) error

ValidateMutablePRState returns a typed *DomainError (Kind ErrInvalidRequest) when the pull request is in a terminal state (DECLINED, MERGED, SUPERSEDED) and therefore cannot accept review or edit mutations. It returns nil for open or unknown states so callers may proceed.

Call this from approve / unapprove / request-changes / edit BEFORE issuing the mutation, after fetching the PR via GetPR.

Types

type AddCommitCommentInput added in v1.27.0

type AddCommitCommentInput struct {
	Body string
}

AddCommitCommentInput carries parameters for creating a commit comment.

type AddPRCommentInput added in v1.6.0

type AddPRCommentInput struct {
	Text     string
	Inline   *PRCommentInline
	Parent   *int
	Severity string // "BLOCKER" to create a task; "" for normal comment (Server only)
}

AddPRCommentInput carries the parameters for adding a comment to a PR. Inline is non-nil for inline (file:line) review comments and nil for general PR comments. Parent is non-nil to post a reply nested under an existing comment thread.

Severity controls the comment type on Bitbucket Server / Data Center: set to "BLOCKER" to create a task comment. Cloud ignores this field and always creates a regular comment.

type AdminClient added in v1.38.0

type AdminClient interface {
	RotateSecrets() error
	GetLoggingConfig() (LoggingConfig, error)
	SetLoggingConfig(in LoggingConfigInput) error

	// User management (Server/DC only)
	ListAdminUsers(filter string, limit int) ([]AdminUser, error)
	RenameUser(slug, newSlug string) error
	ActivateUser(slug string) error
	DeactivateUser(slug string) error

	// System info (Server/DC only)
	GetLicense() (AdminLicense, error)
	GetClusterNodes() ([]ClusterNode, error)

	// Mail server config (Server/DC only)
	GetMailServerConfig() (MailServerConfig, error)
	SetMailServerConfig(in MailServerConfig) error

	// Banner config (Server/DC only)
	GetBanner() (BannerConfig, error)
	SetBanner(in BannerConfig) error
	ClearBanner() error

	// Rate-limit config (Server/DC only)
	GetRateLimitConfig() (RateLimitConfig, error)
	SetRateLimitConfig(in RateLimitConfig) error
}

AdminClient exposes Bitbucket Server / Data Center administration operations. Bitbucket Cloud does not expose these endpoints — calls against Cloud return ErrUnsupportedOnHost via AsAdminClient.

func AsAdminClient added in v1.38.0

func AsAdminClient(c Client, host string) (AdminClient, error)

AsAdminClient returns the AdminClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a backend that doesn't implement admin operations (currently Bitbucket Cloud).

type AdminLicense added in v1.101.0

type AdminLicense struct {
	Tier          string
	Users         int
	ServerId      string
	License       string
	ExpiryDate    string
	SupportExpiry string
	CreationDate  string
}

AdminLicense holds the license details for a Bitbucket Server / DC instance.

type AdminUser added in v1.101.0

type AdminUser struct {
	Slug        string
	DisplayName string
	Email       string
	Active      bool
	Type        string // "NORMAL", "SERVICE", etc.
}

AdminUser is the domain representation of a Bitbucket Server / DC user as returned by the admin users endpoint.

type AuditActor added in v1.105.0

type AuditActor struct {
	AccountID   string `json:"account_id"`
	DisplayName string `json:"display_name"`
	NickName    string `json:"nickname"`
}

AuditActor is the user who performed the action.

type AuditClient added in v1.105.0

type AuditClient interface {
	ListAuditLog(workspace string, opts AuditLogOpts) ([]AuditEvent, error)
}

AuditClient lists workspace audit log events.

func AsAuditClient added in v1.105.0

func AsAuditClient(c Client, host string) (AuditClient, error)

AsAuditClient asserts AuditClient on c. Returns a typed DomainError{ErrUnsupportedOnHost} when the backend does not support it.

type AuditEvent added in v1.105.0

type AuditEvent struct {
	Actor     AuditActor  `json:"actor"`
	Action    string      `json:"action"`
	Object    AuditObject `json:"object"`
	CreatedAt string      `json:"created_on"`
}

AuditEvent is one entry in the workspace audit log.

type AuditLogOpts added in v1.105.0

type AuditLogOpts struct {
	Action string // filter by action (e.g. "workspace.member.create")
	From   string // ISO 8601 date-time; returns events at or after this time
	Limit  int    // 0 = no cap (use paging default)
}

AuditLogOpts filters the audit log query.

type AuditObject added in v1.105.0

type AuditObject struct {
	Type string `json:"type"`
	Name string `json:"name"`
}

AuditObject is the resource affected by the action.

type AutoMergeState added in v1.30.0

type AutoMergeState struct {
	Enabled  bool
	Strategy string // "merge" | "squash" | "rebase"
}

AutoMergeState records the auto-merge configuration for a pull request. Strategy is one of "merge", "squash", or "rebase" (the CLI vocabulary).

type BannerConfig added in v1.103.0

type BannerConfig struct {
	Message  string `json:"message"`
	Audience string `json:"audience"` // "ALL" | "AUTHENTICATED" | "UNAUTHENTICATED"
	Enabled  bool   `json:"enabled"`
}

BannerConfig holds the site-wide announcement banner settings for a Bitbucket Server / DC instance.

type Branch

type Branch struct {
	Name       string
	IsDefault  bool
	LatestHash string
}

Branch is the domain representation of a repository branch.

type BranchCreator

type BranchCreator interface {
	CreateBranch(ns, slug string, in CreateBranchInput) (Branch, error)
}

BranchCreator creates a branch.

type BranchDeleter

type BranchDeleter interface {
	DeleteBranch(ns, slug, branch string) error
}

BranchDeleter deletes a branch.

type BranchLister

type BranchLister interface {
	ListBranches(ns, slug string, limit int) ([]Branch, error)
}

BranchLister lists branches in a repository.

type BranchModel added in v1.92.0

type BranchModel struct {
	Development BranchModelBranch  `json:"development"`
	Production  *BranchModelBranch `json:"production,omitempty"`
	BranchTypes []BranchType       `json:"branch_types"`
}

BranchModel is the effective branching model for a repository.

type BranchModelBranch added in v1.92.0

type BranchModelBranch struct {
	Name          string `json:"name"`
	IsValid       bool   `json:"is_valid"`
	UseMainbranch bool   `json:"use_mainbranch"`
}

BranchModelBranch describes a development or production branch in the model.

type BranchModelClient added in v1.92.0

type BranchModelClient interface {
	GetBranchModel(ws, slug string) (BranchModel, error)
	GetBranchModelSettings(ws, slug string) (BranchModelSettings, error)
	UpdateBranchModelSettings(ws, slug string, in BranchModelSettingsInput) (BranchModelSettings, error)
}

BranchModelClient is implemented only by Bitbucket Cloud clients. Bitbucket Server / Data Center has no branch model API.

func AsBranchModelClient added in v1.92.0

func AsBranchModelClient(c Client, host string) (BranchModelClient, error)

AsBranchModelClient returns the BranchModelClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type BranchModelSettings added in v1.92.0

type BranchModelSettings struct {
	Development BranchModelSettingsBranch `json:"development"`
	Production  BranchModelSettingsBranch `json:"production"`
	BranchTypes []BranchTypeSettings      `json:"branch_types"`
}

BranchModelSettings is the editable branching model configuration.

type BranchModelSettingsBranch added in v1.92.0

type BranchModelSettingsBranch struct {
	IsValid       bool   `json:"is_valid"`
	Name          string `json:"name"`
	UseMainbranch bool   `json:"use_mainbranch"`
}

BranchModelSettingsBranch describes a configured branch in the settings.

type BranchModelSettingsInput added in v1.92.0

type BranchModelSettingsInput struct {
	Development *BranchModelSettingsBranch `json:"development,omitempty"`
	Production  *BranchModelSettingsBranch `json:"production,omitempty"`
	BranchTypes []BranchTypeSettings       `json:"branch_types,omitempty"`
}

BranchModelSettingsInput is the PUT body for updating branching model settings.

type BranchProtection added in v1.17.0

type BranchProtection struct {
	ID          int
	Type        string
	MatcherID   string
	MatcherKind string
	Users       []string
	Groups      []string
}

BranchProtection is a single branch-restriction record on Bitbucket Server / Data Center. Cloud has a similar concept under a different, non-trivial wire shape that we don't model yet — BranchProtection is surfaced only via the BranchProtector optional interface.

Type values match BBS exactly (lowercased, dash-separated):

read-only           — disallow all writes
no-deletes          — disallow branch deletion
fast-forward-only   — disallow non-fast-forward writes
pull-request-only   — only PR merges may write

MatcherKind is the BBS matcher type id ("BRANCH", "PATTERN", "MODEL_BRANCH", "MODEL_CATEGORY") and MatcherID is the corresponding value (a branch name, glob, or model id). Users / Groups list slugs that are exempted from the restriction.

type BranchProtector added in v1.17.0

type BranchProtector interface {
	ListBranchProtections(ns, slug string, limit int) ([]BranchProtection, error)
	CreateBranchProtection(ns, slug string, in CreateBranchProtectionInput) (BranchProtection, error)
	DeleteBranchProtection(ns, slug string, id int) error
}

BranchProtector exposes branch-restriction management on Bitbucket Server / Data Center. The Cloud backend has a different "branch restrictions" shape that's not modelled here — calls against a Cloud client surface ErrUnsupportedOnHost via AsBranchProtector.

func AsBranchProtector added in v1.17.0

func AsBranchProtector(c Client, host string) (BranchProtector, error)

AsBranchProtector returns the BranchProtector view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a backend that doesn't model branch protections (currently Cloud).

type BranchRule added in v1.53.0

type BranchRule struct {
	ID      int    `json:"id"`
	Kind    string `json:"kind"`
	Pattern string `json:"pattern"`
	Value   int    `json:"value,omitempty"`
}

BranchRule is the domain representation of a Bitbucket Cloud branch restriction rule.

type BranchRuleClient added in v1.53.0

type BranchRuleClient interface {
	ListBranchRules(ns, slug string) ([]BranchRule, error)
	AddBranchRule(ns, slug string, input BranchRuleInput) (BranchRule, error)
	DeleteBranchRule(ns, slug string, id int) error
	UpdateBranchRule(ns, slug string, id int, in UpdateBranchRuleInput) (BranchRule, error)
}

BranchRuleClient is implemented only by Bitbucket Cloud clients. Bitbucket Server / Data Center has no equivalent branch restriction API, so the entire surface is gated behind AsBranchRuleClient.

func AsBranchRuleClient added in v1.53.0

func AsBranchRuleClient(c Client, host string) (BranchRuleClient, error)

AsBranchRuleClient returns the BranchRuleClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type BranchRuleInput added in v1.53.0

type BranchRuleInput struct {
	Kind    string
	Pattern string
	Value   int
}

BranchRuleInput carries the parameters for adding a branch restriction rule.

type BranchType added in v1.92.0

type BranchType struct {
	Kind   string `json:"kind"`
	Prefix string `json:"prefix"`
}

BranchType is a named branch type with a prefix used by the "Create branch" wizard.

type BranchTypeSettings added in v1.92.0

type BranchTypeSettings struct {
	Enabled bool   `json:"enabled"`
	Kind    string `json:"kind"`
	Prefix  string `json:"prefix"`
}

BranchTypeSettings is the per-kind configuration for the "Create branch" wizard.

type CherryPickInput added in v1.108.0

type CherryPickInput struct {
	SourceHash   string // commit hash to cherry-pick
	TargetBranch string // destination branch name
	Message      string // optional commit message override (empty = use original)
}

CherryPickInput carries the parameters for cherry-picking a commit.

type Client

Client is the composite capability interface that every backend adapter must satisfy. Capability interfaces that only some backends implement (e.g. PipelineClient, IssueClient, BranchProtector) are NOT embedded here; they are accessed via their respective AsXxx helper which returns a typed ErrUnsupportedOnHost when the backend doesn't implement the capability.

Per-feature interface declarations live in client_<feature>.go files in this package so that new features can add interfaces without touching this file. The composite Client embedding block is the single intended conflict point for parallel development — per-feature optional interfaces never touch it.

type CloneURL added in v1.116.0

type CloneURL struct {
	Name string // "ssh", "https", or "http"
	URL  string
}

CloneURL is a single clone-protocol entry returned by the Bitbucket repo API.

type CloudCodeInsightsClient added in v1.130.0

type CloudCodeInsightsClient interface {
	ListCodeInsightsReports(project, slug, hash string) ([]CodeInsightsReport, error)
	GetCodeInsightsReport(project, slug, hash, key string) (CodeInsightsReport, error)
	PutCodeInsightsReport(project, slug, hash, key string, in CodeInsightsReportInput) (CodeInsightsReport, error)
	DeleteCodeInsightsReport(project, slug, hash, key string) error
	ListCodeInsightsAnnotations(project, slug, hash, key string) ([]CodeInsightsAnnotation, error)
	PutCodeInsightsAnnotations(project, slug, hash, key string, in []CodeInsightsAnnotationInput) error
}

CloudCodeInsightsClient exposes Bitbucket Cloud Code Insights reports and annotations. Server/DC uses CodeInsightsClient instead.

func AsCloudCodeInsightsClient added in v1.130.0

func AsCloudCodeInsightsClient(c Client, host string) (CloudCodeInsightsClient, error)

AsCloudCodeInsightsClient returns the CloudCodeInsightsClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a backend that doesn't implement Cloud Code Insights (currently Bitbucket Server / DC).

type CloudProjectClient added in v1.112.0

type CloudProjectClient interface {
	CreateWorkspaceProject(ws string, input CreateWorkspaceProjectInput) (WorkspaceProject, error)
	GetWorkspaceProject(ws, key string) (WorkspaceProject, error)
	UpdateWorkspaceProject(ws, key string, input UpdateWorkspaceProjectInput) (WorkspaceProject, error)
	DeleteWorkspaceProject(ws, key string) error
}

CloudProjectClient is implemented only by Bitbucket Cloud clients. It provides CRUD access to workspace projects.

func AsCloudProjectClient added in v1.112.0

func AsCloudProjectClient(c Client, host string) (CloudProjectClient, error)

AsCloudProjectClient returns the CloudProjectClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type ClusterNode added in v1.101.0

type ClusterNode struct {
	NodeId  string
	Name    string
	Address string
	State   string
	Local   bool
}

ClusterNode represents a node in a Bitbucket Server / DC cluster.

type CodeInsightsAnnotation added in v1.23.0

type CodeInsightsAnnotation struct {
	ExternalID string `json:"external_id,omitempty"`
	Path       string `json:"path"`
	Line       int    `json:"line,omitempty"`
	Message    string `json:"message"`
	Severity   string `json:"severity,omitempty"`
	Type       string `json:"type,omitempty"`
	Link       string `json:"link,omitempty"`
}

CodeInsightsAnnotation is a single file/line annotation posted under a Code Insights report. This type serves as both the API response shape and the input payload (CodeInsightsAnnotationInput is an alias).

Severity values: "LOW", "MEDIUM", "HIGH", "CRITICAL". Type values: "VULNERABILITY", "CODE_SMELL", "BUG".

type CodeInsightsAnnotationInput added in v1.23.0

type CodeInsightsAnnotationInput = CodeInsightsAnnotation

CodeInsightsAnnotationInput is an alias of CodeInsightsAnnotation used on the write side of the interface to keep the signature intent clear.

type CodeInsightsClient added in v1.23.0

type CodeInsightsClient interface {
	// Report operations
	ListReports(project, slug, hash string) ([]CodeInsightsReport, error)
	GetReport(project, slug, hash, key string) (CodeInsightsReport, error)
	// SetReport upserts (PUT) a report by key.
	SetReport(project, slug, hash, key string, in CodeInsightsReportInput) (CodeInsightsReport, error)
	DeleteReport(project, slug, hash, key string) error

	// Annotation operations
	ListAnnotations(project, slug, hash, key string) ([]CodeInsightsAnnotation, error)
	// AddAnnotations bulk-POSTs all annotations in a single request.
	AddAnnotations(project, slug, hash, key string, in []CodeInsightsAnnotationInput) error
	DeleteAnnotations(project, slug, hash, key string) error

	// Merge-check operations (experimental — partly undocumented API)
	SetMergeCheck(project, slug, key string, in MergeCheckInput) error
	GetMergeCheck(project, slug, key string) (MergeCheck, error)
	DeleteMergeCheck(project, slug, key string) error
}

CodeInsightsClient exposes Bitbucket Server / Data Center Code Insights management. Cloud has no native equivalent — AsCodeInsightsClient returns ErrUnsupportedOnHost when called against a Cloud backend.

The merge-check sub-API (SetMergeCheck / GetMergeCheck / DeleteMergeCheck) uses a partly undocumented endpoint at /rest/insights/latest/.../merge-check/ and is marked experimental in CLI help text.

func AsCodeInsightsClient added in v1.23.0

func AsCodeInsightsClient(c Client, host string) (CodeInsightsClient, error)

AsCodeInsightsClient returns the CodeInsightsClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a backend that doesn't implement Code Insights (currently Bitbucket Cloud).

type CodeInsightsReport added in v1.23.0

type CodeInsightsReport struct {
	Key        string                    `json:"key"`
	Title      string                    `json:"title"`
	Result     string                    `json:"result"`
	ReportType string                    `json:"report_type,omitempty"`
	Details    string                    `json:"details,omitempty"`
	Reporter   string                    `json:"reporter,omitempty"`
	Link       string                    `json:"link,omitempty"`
	LogoURL    string                    `json:"logo_url,omitempty"`
	Data       []CodeInsightsReportDatum `json:"data,omitempty"`
	CreatedAt  string                    `json:"created_at,omitempty"`
	UpdatedAt  string                    `json:"updated_at,omitempty"`
}

CodeInsightsReport is a Bitbucket Server / Data Center Code Insights report attached to a specific commit. Reports aggregate quality/security/build annotations and roll up to a single PASS/FAIL/PENDING result. This type is used for both API responses and the input shape (CodeInsightsReportInput).

Result values: "PASS", "FAIL", "PENDING" (empty = PENDING). ReportType values: "TESTING", "COVERAGE", "BUG", "SECURITY", "DUPLICATION", "DEPENDENCY" (empty uses TESTING as default on Server).

type CodeInsightsReportDatum added in v1.23.0

type CodeInsightsReportDatum struct {
	Title string `json:"title"`
	Type  string `json:"type"`
	Value any    `json:"value"`
}

CodeInsightsReportDatum is a single key/value data point attached to a Code Insights report. Type values: "BOOLEAN", "DATE", "DURATION", "LINK", "NUMBER", "PERCENTAGE", "TEXT".

type CodeInsightsReportInput added in v1.23.0

type CodeInsightsReportInput struct {
	Title      string
	Result     string // "PASS", "FAIL", "PENDING"
	ReportType string
	Details    string
	Reporter   string
	Link       string
	LogoURL    string
	Data       []CodeInsightsReportDatum
}

CodeInsightsReportInput is the upsert payload for SetReport. All fields map 1:1 to CodeInsightsReport; the separation exists only so the input shape stays explicit in the interface signature.

type CodeSearchHit added in v1.21.0

type CodeSearchHit struct {
	Repository        string
	Path              string
	PathMatches       []SearchSegment
	ContentMatches    []ContentMatch
	ContentMatchCount int
	FileURL           string
}

CodeSearchHit is one result row from Bitbucket Cloud's workspace-scoped code search. The hit may match on the file path (PathMatches non-empty), on file content (ContentMatches non-empty), or both. Renderers use the SearchSegment.Match flag to bold the matched runs.

Repository is "workspace/slug" — the Cloud "full_name" form, kept verbatim so JSON consumers can split it themselves and the table renderer needs no extra column.

type CodeSearcher added in v1.21.0

type CodeSearcher interface {
	SearchCode(workspace, query string, limit int) ([]CodeSearchHit, error)
}

CodeSearcher performs workspace-scoped code search on Bitbucket Cloud. Bitbucket Server / Data Center does not expose a first-class REST code- search endpoint (search there is provided by the separate Sourcegraph integration or third-party plugins), so the entire surface is gated behind AsCodeSearcher. Server adapters intentionally do NOT implement this interface — the type-assertion in AsCodeSearcher is what surfaces the typed host.unsupported error to callers.

func AsCodeSearcher added in v1.21.0

func AsCodeSearcher(c Client, host string) (CodeSearcher, error)

AsCodeSearcher returns the CodeSearcher view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a backend that doesn't model code search (currently Server/DC).

type CommentReaction added in v1.40.0

type CommentReaction struct {
	Emoji string // canonical shortcode: thumbs_up | thumbs_down | heart | laugh | hooray | confused
	Users []User // all users who reacted with this emoji
}

CommentReaction is the domain representation of an emoji reaction on a pull-request comment. Emoji is the canonical shortcode (underscore form): "thumbs_up", "thumbs_down", "heart", "laugh", "hooray", "confused". Users lists every user who reacted with that emoji.

type CommentReactor added in v1.40.0

type CommentReactor interface {
	ListCommentReactions(ns, slug string, prID, commentID int) ([]CommentReaction, error)
	AddCommentReaction(ns, slug string, prID, commentID int, emoji string) error
	RemoveCommentReaction(ns, slug string, prID, commentID int, emoji string) error
}

CommentReactor manages emoji reactions on pull-request comments. Implemented only by Bitbucket Server / Data Center. Bitbucket Cloud has no equivalent API. Callers route through AsCommentReactor to surface the constraint as a typed ErrUnsupportedOnHost.

func AsCommentReactor added in v1.40.0

func AsCommentReactor(c Client, host string) (CommentReactor, error)

AsCommentReactor returns the CommentReactor view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when the backend at host has no reaction primitive (currently Bitbucket Cloud).

type Commit

type Commit struct {
	Hash      string
	Message   string // subject line only (first line of commit message)
	Author    User
	Timestamp time.Time
	WebURL    string
}

Commit is the domain representation of a single repository commit.

type CommitCherryPicker added in v1.108.0

type CommitCherryPicker interface {
	CherryPickCommit(ns, slug string, in CherryPickInput) (Commit, error)
}

CommitCherryPicker can cherry-pick a commit onto a target branch.

func AsCommitCherryPicker added in v1.108.0

func AsCommitCherryPicker(c Client, host string) (CommitCherryPicker, error)

AsCommitCherryPicker returns the CommitCherryPicker view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a backend that doesn't implement cherry-pick operations.

type CommitComment added in v1.27.0

type CommitComment struct {
	ID        int
	Author    User
	Body      string
	CreatedAt time.Time
	UpdatedAt time.Time
	Reactions []CommentReaction // only populated when explicitly requested; Server/DC only
}

CommitComment is a comment attached to a specific commit. Reactions is only populated when explicitly requested (e.g. --reactions flag or include_reactions MCP parameter). Server/DC only.

type CommitCommentReactor added in v1.41.0

type CommitCommentReactor interface {
	ListCommitCommentReactions(ns, slug, hash string, commentID int) ([]CommentReaction, error)
	AddCommitCommentReaction(ns, slug, hash string, commentID int, emoji string) error
	RemoveCommitCommentReaction(ns, slug, hash string, commentID int, emoji string) error
}

CommitCommentReactor manages emoji reactions on commit comments. Implemented only by Bitbucket Server / Data Center. Bitbucket Cloud has no equivalent API. Callers route through AsCommitCommentReactor to surface the constraint as a typed ErrUnsupportedOnHost.

func AsCommitCommentReactor added in v1.41.0

func AsCommitCommentReactor(c Client, host string) (CommitCommentReactor, error)

AsCommitCommentReactor returns the CommitCommentReactor view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when the backend at host has no reaction primitive (currently Bitbucket Cloud).

type CommitCommenter added in v1.27.0

type CommitCommenter interface {
	ListCommitComments(ns, slug, hash string, limit int) ([]CommitComment, error)
	AddCommitComment(ns, slug, hash string, in AddCommitCommentInput) (CommitComment, error)
	EditCommitComment(ns, slug, hash string, commentID int, body string) (CommitComment, error)
	DeleteCommitComment(ns, slug, hash string, commentID int) error
}

CommitCommenter manages comments on individual commits.

type CommitFileClient added in v1.55.0

type CommitFileClient interface {
	ListCommitFiles(ns, slug, hash string) ([]DiffStatEntry, error)
}

CommitFileClient is implemented by both Cloud and Server backends.

func AsCommitFileClient added in v1.55.0

func AsCommitFileClient(c Client, host string) (CommitFileClient, error)

AsCommitFileClient returns the CommitFileClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the CommitFiles capability.

type CommitLister

type CommitLister interface {
	ListCommits(ns, slug, branch string, limit int) ([]Commit, error)
}

CommitLister lists commits in a repository.

type CommitReader

type CommitReader interface {
	GetCommit(ns, slug, hash string) (Commit, error)
}

CommitReader reads a single commit by hash.

type CommitSearchOpts added in v1.135.0

type CommitSearchOpts struct {
	Query  string // message keyword filter (substring match)
	Author string // author slug/account_id
	Since  string // ISO 8601 date or commit SHA (inclusive start)
	Until  string // ISO 8601 date or commit SHA (inclusive end)
	Limit  int
}

CommitSearchOpts controls which commits SearchCommits returns.

type CommitSearcher added in v1.135.0

type CommitSearcher interface {
	SearchCommits(ns, slug string, opts CommitSearchOpts) ([]Commit, error)
}

CommitSearcher searches commits in a repository by message, author, or date.

func AsCommitSearcher added in v1.135.0

func AsCommitSearcher(c Client, host string) (CommitSearcher, error)

AsCommitSearcher returns the CommitSearcher view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when the backend doesn't implement commit search.

type CommitStatus added in v1.6.0

type CommitStatus struct {
	Key         string
	State       string // SUCCESSFUL | FAILED | INPROGRESS | STOPPED
	Name        string
	Description string
	URL         string
}

CommitStatus is a build / CI status reported against a commit hash.

type CommitStatusInput added in v1.59.0

type CommitStatusInput struct {
	Key         string
	State       string // SUCCESSFUL | FAILED | INPROGRESS | STOPPED
	Name        string
	URL         string
	Description string
}

CommitStatusInput carries the parameters for reporting a build status.

type CommitStatusLister added in v1.6.0

type CommitStatusLister interface {
	ListCommitStatuses(ns, slug, hash string) ([]CommitStatus, error)
}

CommitStatusLister lists build/CI statuses reported against a commit hash.

type CommitStatusReporter added in v1.59.0

type CommitStatusReporter interface {
	ReportCommitStatus(ns, slug, hash string, input CommitStatusInput) (CommitStatus, error)
}

CommitStatusReporter posts a build status against a commit hash.

type ContentMatch added in v1.21.0

type ContentMatch struct {
	Line     int
	Segments []SearchSegment
}

ContentMatch is a single matched line within a file: the 1-based line number plus a sequence of segments. Cloud groups consecutive matched lines into "content_matches" objects each with a "lines" array; bitbottle flattens those to a single ContentMatch slice in arrival order.

type CreateBranchInput

type CreateBranchInput struct {
	Name    string
	StartAt string // branch name or commit hash
}

CreateBranchInput carries the parameters for creating a branch.

type CreateBranchProtectionInput added in v1.17.0

type CreateBranchProtectionInput struct {
	Type        string
	MatcherID   string
	MatcherKind string
	Users       []string
	Groups      []string
}

CreateBranchProtectionInput carries the parameters for adding a branch-restriction. All fields except Type and MatcherID are optional. MatcherKind defaults to "BRANCH" when empty (the most common case).

type CreateEnvironmentInput added in v1.29.0

type CreateEnvironmentInput struct {
	Name string
	Type string
	Rank int
}

CreateEnvironmentInput carries the parameters for creating a deployment environment.

type CreateIPAllowlistInput added in v1.106.0

type CreateIPAllowlistInput struct {
	CIDR        string
	Description string
	Enabled     bool
}

CreateIPAllowlistInput carries parameters for adding an allowlist entry.

type CreateIssueInput added in v1.17.0

type CreateIssueInput struct {
	Title    string
	Content  string
	Kind     string
	Priority string
}

CreateIssueInput carries the parameters for opening a new issue. Bitbucket Cloud applies sane defaults (kind=bug, priority=major) when fields are empty, so callers can omit everything but Title.

type CreatePATInput added in v1.99.0

type CreatePATInput struct {
	Name        string
	Permissions []string // REPO_READ, REPO_WRITE, PR_READ, PR_WRITE, PROJECT_READ, PROJECT_WRITE
	ExpiryDays  *int     // nil = no expiry
}

CreatePATInput carries the parameters for creating a PAT.

type CreatePRInput

type CreatePRInput struct {
	Title       string
	Description string
	Draft       bool
	FromBranch  string
	ToBranch    string
	Reviewers   []string
}

CreatePRInput carries the parameters for creating a pull request.

Reviewers are user slugs (Server) or usernames / account IDs (Cloud). Both adapters serialise the same logical list into their backend's wire shape. A nil or empty slice creates a PR with no reviewers — Bitbucket does NOT auto-apply repo "default reviewers" on the create endpoint, so callers that want that behaviour must fetch them via DefaultReviewersResolver and merge the result here.

type CreateRepoInput

type CreateRepoInput struct {
	Name        string
	SCM         string
	Public      bool
	Description string
}

CreateRepoInput carries the parameters for creating a repository.

type CreateRepoLabelInput added in v1.100.0

type CreateRepoLabelInput struct {
	Name  string
	Color string
}

CreateRepoLabelInput carries the parameters for creating a repository label.

type CreateReviewerGroupInput added in v1.69.0

type CreateReviewerGroupInput struct {
	Name              string   // used as sourceMatcher displayId / id
	UserSlugs         []string // reviewer user slugs
	RequiredApprovals int      // default 1
}

CreateReviewerGroupInput carries the parameters for creating a reviewer group condition.

type CreateRunnerInput added in v1.104.0

type CreateRunnerInput struct {
	Name     string
	Labels   []string
	Platform RunnerPlatform
}

CreateRunnerInput is the input for creating a new runner.

type CreateServerProjectInput added in v1.98.0

type CreateServerProjectInput struct {
	Key         string
	Name        string
	Description string
	Public      bool
}

CreateServerProjectInput carries the fields for creating a new project.

type CreateSnippetInput added in v1.91.0

type CreateSnippetInput struct {
	Title     string
	IsPrivate bool
	Files     []SnippetFile
}

CreateSnippetInput holds the parameters for creating a new snippet.

type CreateTagInput

type CreateTagInput struct {
	Name    string
	StartAt string // branch name or commit hash
	Message string // empty = lightweight tag; non-empty = annotated tag
}

CreateTagInput carries the parameters for creating a tag.

type CreateWebhookInput added in v1.15.0

type CreateWebhookInput struct {
	URL    string
	Events []string
	Active bool
	Secret string
}

CreateWebhookInput carries the parameters for creating a webhook. Secret is write-only — neither backend returns it on read.

type CreateWorkspaceProjectInput added in v1.112.0

type CreateWorkspaceProjectInput struct {
	Key         string
	Name        string
	Description string
	IsPrivate   bool
}

CreateWorkspaceProjectInput carries the parameters for creating a workspace project.

type DefaultReviewer added in v1.50.0

type DefaultReviewer struct {
	UserSlug     string `json:"userSlug"`
	DisplayName  string `json:"displayName"`
	EmailAddress string `json:"emailAddress,omitempty"`
}

DefaultReviewer is the domain representation of a repository default reviewer.

type DefaultReviewerClient added in v1.50.0

type DefaultReviewerClient interface {
	ListDefaultReviewers(ns, slug string) ([]DefaultReviewer, error)
	AddDefaultReviewer(ns, slug, userSlug string) error
	RemoveDefaultReviewer(ns, slug, userSlug string) error
}

DefaultReviewerClient is implemented by both Cloud and Server backends.

func AsDefaultReviewerClient added in v1.50.0

func AsDefaultReviewerClient(c Client, host string) (DefaultReviewerClient, error)

AsDefaultReviewerClient returns the DefaultReviewerClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the DefaultReviewerClient capability.

type DefaultReviewersResolver added in v1.17.0

type DefaultReviewersResolver interface {
	DefaultReviewers(ns, slug, fromBranch, toBranch string) ([]User, error)
}

DefaultReviewersResolver looks up the configured "default reviewers" for a repository given a source/target ref pair. Only Bitbucket Server / Data Center exposes this — Cloud has a similar feature with a different, non-trivial wire shape that we don't model yet.

Implementations may need additional context (e.g. numeric repo ID) which they obtain themselves; callers pass only the values they natively know.

func AsDefaultReviewersResolver added in v1.17.0

func AsDefaultReviewersResolver(c Client, host string) (DefaultReviewersResolver, error)

AsDefaultReviewersResolver returns the DefaultReviewersResolver view of c, or a typed *DomainError when the backend doesn't implement it (currently Cloud). Callers use the returned error to decide whether to skip the auto-apply step entirely.

type DeployKey added in v1.47.0

type DeployKey struct {
	ID       int    `json:"id"`
	Label    string `json:"label"`
	Key      string `json:"key"`
	ReadOnly bool   `json:"readOnly,omitempty"`
}

DeployKey is the domain representation of a repository deploy key (SSH public key).

type DeployKeyClient added in v1.47.0

type DeployKeyClient interface {
	ListDeployKeys(ns, slug string) ([]DeployKey, error)
	AddDeployKey(ns, slug string, input DeployKeyInput) (DeployKey, error)
	DeleteDeployKey(ns, slug string, id int) error
}

DeployKeyClient is implemented by both Cloud and Server backends.

func AsDeployKeyClient added in v1.47.0

func AsDeployKeyClient(c Client, host string) (DeployKeyClient, error)

AsDeployKeyClient returns the DeployKeyClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the DeployKeys capability.

type DeployKeyInput added in v1.47.0

type DeployKeyInput struct {
	Label      string
	Key        string
	Permission string // "read" | "read_write"; empty → omit from wire (default: read). Cloud only.
}

DeployKeyInput carries the parameters for adding a deploy key.

type Deployment added in v1.29.0

type Deployment struct {
	UUID        string
	State       string
	Environment Environment
	Release     struct {
		Name       string
		URL        string
		CommitHash string
	}
}

Deployment is the domain representation of a Bitbucket Cloud deployment. State values: PENDING, IN_PROGRESS, COMPLETED, STOPPED, FAILED.

type DeploymentClient added in v1.29.0

type DeploymentClient interface {
	ListDeployments(ns, slug string, limit int) ([]Deployment, error)
	GetDeployment(ns, slug, uuid string) (Deployment, error)

	ListEnvironments(ns, slug string) ([]Environment, error)
	CreateEnvironment(ns, slug string, in CreateEnvironmentInput) (Environment, error)
	DeleteEnvironment(ns, slug, uuid string) error

	ListEnvVariables(ns, slug, envUUID string) ([]EnvVariable, error)
	SetEnvVariable(ns, slug, envUUID string, in EnvVariableInput) (EnvVariable, error)
	DeleteEnvVariable(ns, slug, envUUID, varUUID string) error
}

DeploymentClient is implemented by Cloud only; Server returns ErrUnsupportedOnHost.

func AsDeploymentClient added in v1.29.0

func AsDeploymentClient(c Client, host string) (DeploymentClient, error)

AsDeploymentClient returns the DeploymentClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the Deployments capability.

type DiffClient added in v1.49.0

type DiffClient interface {
	GetDiff(ns, slug, from, to string) (string, error)
	GetDiffStat(ns, slug, from, to string) (DiffStat, error)
}

DiffClient is implemented by both Cloud and Server backends.

func AsDiffClient added in v1.49.0

func AsDiffClient(c Client, host string) (DiffClient, error)

AsDiffClient returns the DiffClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the Diff capability.

type DiffStat added in v1.49.0

type DiffStat struct {
	FilesChanged int
	Additions    int
	Deletions    int
	Files        []DiffStatEntry
}

DiffStat is the domain representation of a repository diff summary.

type DiffStatEntry added in v1.49.0

type DiffStatEntry struct {
	Path      string
	Status    string // "added", "modified", "deleted", "renamed"
	Additions int
	Deletions int
}

DiffStatEntry is the domain representation of a single file's diff summary.

type DomainError added in v1.8.0

type DomainError struct {
	Kind     error
	Code     ErrorCode
	Host     string
	Feature  string
	Resource string
	ID       string
	Message  string
	Cause    error
}

DomainError wraps an underlying cause with structured context for renderers (CLI plain-text, MCP structured payload). Kind is one of the package-level sentinels; errors.Is(err, backend.ErrXxx) walks Kind, enabling deterministic branching without parsing prose.

Optional fields populated when known:

  • Host: the hostname the request was directed at
  • Feature: capability name, populated for ErrUnsupportedOnHost
  • Resource: domain kind ("pull-request", "branch", "repository", ...)
  • ID: resource identifier ("42", "feat/x", "ws/repo", ...)
  • Code: dotted ErrorCode token used by errfmt to look up the user-facing title + hint. Auto-attached for HTTP 401 by ClassifyHTTPError; otherwise stamped by adapters at the call site (where they have op-specific context). May be empty — Render then falls back to a Kind-based humanisation.

func ClassifyHTTPError added in v1.8.0

func ClassifyHTTPError(host string, err *HTTPError) *DomainError

ClassifyHTTPError translates an HTTPError into a DomainError, picking a Kind sentinel from the response status code. Statuses outside the bounded domain set leave Kind unset; the original HTTPError is preserved as Cause in every case so adapters can attach further context (resource, ID, etc.).

Only HTTP 401 receives an automatic Code (CodeAuthInvalidToken) — re-login is an unambiguous remedy that does not need adapter context. 403/404/409 each map to multiple user-facing situations (which resource? which write op?) and so the adapter that issued the request stamps the appropriate Code at the call site, where the necessary context lives.

func ClassifyTransportError added in v1.19.0

func ClassifyTransportError(host string, err error) *DomainError

ClassifyTransportError translates a transport-level error (one that failed before an HTTP response existed — TLS handshake failure, DNS resolution timeout, dial timeout, read timeout, etc.) into a DomainError carrying a network-cluster ErrorCode. host is attached so the renderer can name which Bitbucket instance produced the failure.

Returns nil if err is nil, or if err is not a recognised transport failure shape — callers should treat the original error as untranslated and either return it as-is or fall through to a generic renderer. The intent is "do no harm": never mis-label an error.

Recognised shapes:

  • x509.UnknownAuthorityError (anywhere in the unwrap chain) → CodeNetworkTLSUnknownAuthority. Triggered by self-signed CAs; the catalogue hints at -k / skip_tls_verify.
  • context.DeadlineExceeded (anywhere in the unwrap chain) → CodeTransportTimeout. Triggered by per-request deadlines.
  • any net.Error whose Timeout() returns true → CodeTransportTimeout. Covers dial timeouts and read timeouts surfaced as *net.OpError.

Kind is set to ErrTransport in every classified case so callers can branch on errors.Is(err, backend.ErrTransport).

func (*DomainError) Error added in v1.8.0

func (e *DomainError) Error() string

Error renders a single-line human-readable form. Structured emission (e.g. MCP) should read the fields directly rather than parsing this string.

func (*DomainError) HTTPStatus added in v1.19.0

func (e *DomainError) HTTPStatus() int

HTTPStatus returns the HTTP status code that produced this DomainError, or 0 if the underlying cause is not an *HTTPError. Useful for adapters that need to refine call-site Code stamping based on status (e.g. 404 → not found, 409 → conflict). Walks the unwrap chain via errors.As.

func (*DomainError) Is added in v1.8.0

func (e *DomainError) Is(target error) bool

Is matches against the Kind sentinel. The wrapped Cause is reached via Unwrap by errors.Is's default walk — intentionally not duplicated here.

func (*DomainError) Unwrap added in v1.8.0

func (e *DomainError) Unwrap() error

Unwrap exposes the underlying cause for errors.Is / errors.As walks.

type EditRepoInput added in v1.89.0

type EditRepoInput struct {
	Description *string
	Website     *string
	Language    *string
	ForkPolicy  *string
	HasIssues   *bool
	HasWiki     *bool
}

EditRepoInput holds the fields to update. Nil pointer = leave unchanged.

type EnvVariable added in v1.29.0

type EnvVariable struct {
	UUID    string
	Key     string
	Value   string // empty if Secured
	Secured bool
}

EnvVariable is a deployment-environment variable on Bitbucket Cloud. Value is empty when Secured is true (the API never returns secured values).

type EnvVariableInput added in v1.29.0

type EnvVariableInput struct {
	Key     string
	Value   string
	Secured bool
}

EnvVariableInput carries the parameters for creating or updating an environment variable.

type Environment added in v1.29.0

type Environment struct {
	UUID string
	Name string
	Type string // Test | Staging | Production
	Rank int
}

Environment is a Bitbucket Cloud deployment environment (e.g. Test, Staging, Production). Rank is the numeric ordering position.

type ErrorCode added in v1.18.0

type ErrorCode string

ErrorCode is a stable, dotted token identifying a specific user-visible failure mode (e.g. "auth.invalid_token"). Codes are the join key between the API layer (which classifies wire errors) and the errfmt renderer (which looks up titles + hints). Treat them as part of the public API: add new codes freely, never repurpose existing ones.

const (
	// auth cluster — credentials missing, expired, or insufficient
	CodeAuthNoToken       ErrorCode = "auth.no_token"
	CodeAuthInvalidToken  ErrorCode = "auth.invalid_token"
	CodePermWriteRequired ErrorCode = "perm.write_required"

	// repo cluster — repository-shaped failures
	CodeRepoNotFound ErrorCode = "repo.not_found"

	// pr cluster — pull-request lifecycle failures
	CodePRNotFound              ErrorCode = "pr.not_found"
	CodePRMergeConflict         ErrorCode = "pr.merge.conflict"
	CodePRMergeBehind           ErrorCode = "pr.merge.behind"
	CodePRCreateDuplicateBranch ErrorCode = "pr.create.duplicate_branch"
	CodePRReviewerUnknown       ErrorCode = "pr.reviewer.unknown"
	// CodePRAutoMergeBetaDisabled is returned by Bitbucket Cloud when the
	// auto-merge beta endpoint is unavailable because the workspace has not
	// opted into the feature.
	CodePRAutoMergeBetaDisabled ErrorCode = "pr.automerge.beta_disabled"
	// CodePRTerminalState is returned when a mutation is attempted on a pull
	// request that is already in a terminal state (DECLINED, MERGED, SUPERSEDED).
	CodePRTerminalState ErrorCode = "pr.terminal_state"

	// branch cluster — branch-protection / write-side failures
	CodeBranchProtected ErrorCode = "branch.protected"

	// host cluster — feature unavailable on the targeted Bitbucket flavour,
	// or the named host is not configured at all
	CodeHostUnsupported ErrorCode = "host.unsupported"
	CodeHostUnknown     ErrorCode = "host.unknown"

	// network cluster — pre-classify codes attached at the transport
	// layer before an HTTPError exists. ClassifyTransportError stamps
	// these.
	CodeNetworkTLSUnknownAuthority ErrorCode = "network.tls_unknown_authority"
	CodeTransportTimeout           ErrorCode = "transport.timeout"

	// request cluster — malformed or invalid input
	CodeInvalidRequest ErrorCode = "request.invalid"

	// endpoint cluster — API endpoint removed or deprecated
	CodeEndpointDeprecated ErrorCode = "endpoint.deprecated"
)

Catalogue of error codes. Group by cluster prefix; keep alphabetical inside each cluster. errfmt has a matching catalogue of titles + hints.

type Feature added in v1.8.0

type Feature string

Feature names a capability that some backends may not implement. The As<X> helpers map each Feature to the optional interface a Client must satisfy to expose that capability.

const FeatureAdmin Feature = "admin"

FeatureAdmin names the admin capability.

const FeatureAudit Feature = "Audit"

FeatureAudit is the feature key for AuditClient.

const FeatureBranchModel Feature = "branch_model"

FeatureBranchModel names the branch-model capability for typed-error reporting.

const FeatureBranchProtect Feature = "branch-protect"

FeatureBranchProtect names the branch-protection capability for typed- error reporting.

const FeatureBranchRules Feature = "branch_rules"

FeatureBranchRules names the branch-rules capability for typed-error reporting.

const FeatureCherryPick Feature = "CommitCherryPicker"

FeatureCherryPick names the cherry-pick capability.

const FeatureCloudCodeInsights Feature = "cloud-code-insights"

FeatureCloudCodeInsights names the Cloud Code Insights capability for typed-error reporting.

const FeatureCloudProjects Feature = "cloud_projects"

FeatureCloudProjects names the Cloud workspace projects capability for typed-error reporting.

const FeatureCodeInsights Feature = "code-insights"

FeatureCodeInsights names the Code Insights capability for typed-error reporting.

const FeatureCodeSearch Feature = "code-search"

FeatureCodeSearch names the code-search capability for typed-error reporting.

const FeatureCommentReactions Feature = "pr-comment-reactions"

FeatureCommentReactions names the PR comment reaction capability.

const FeatureCommitCommentReactions Feature = "commit-comment-reactions"

FeatureCommitCommentReactions names the commit comment reaction capability.

const FeatureCommitFiles Feature = "commit_files"

FeatureCommitFiles names the commit-files capability for typed-error reporting.

const FeatureCommitSearch Feature = "commit-search"

FeatureCommitSearch names the commit-search capability.

const FeatureDefaultReviewerClient Feature = "default_reviewer_client"

FeatureDefaultReviewerClient names the default-reviewer-client capability for typed-error reporting.

const FeatureDefaultReviewers Feature = "default-reviewers"

FeatureDefaultReviewers names the default-reviewers capability for typed-error reporting.

const FeatureDeployKeys Feature = "deploy_keys"

FeatureDeployKeys names the deploy-keys capability for typed-error reporting.

const FeatureDeployments Feature = "deployments"

FeatureDeployments names the deployments capability for typed-error reporting.

const FeatureDiff Feature = "diff"

FeatureDiff names the diff capability for typed-error reporting.

const FeatureGroup Feature = "group"

FeatureGroup names the group management capability for typed-error reporting.

const FeatureGroupMember Feature = "group_member"

FeatureGroupMember names the group-member management capability.

const FeatureHostInfo Feature = "host_info"

FeatureHostInfo names the host-info capability for typed-error reporting.

const FeatureIPAllowlist Feature = "IPAllowlist"

FeatureIPAllowlist is the feature key for IPAllowlistClient.

const FeatureIssueActivity Feature = "issue_activity"

FeatureIssueActivity names the issue-activity capability for typed-error reporting.

const FeatureIssueAttachments Feature = "issue-attachments"

FeatureIssueAttachments names the issue attachments capability.

const FeatureIssueVersions Feature = "issue_versions"

FeatureIssueVersions names the issue versions capability for typed-error reporting.

const FeatureIssueVoting Feature = "issue-voting"

FeatureIssueVoting names the issue voting capability.

const FeatureIssueWatching Feature = "issue-watching"

FeatureIssueWatching names the issue watching capability.

const FeatureIssues Feature = "issues"

FeatureIssues names the issues capability for typed-error reporting.

const FeatureMilestones Feature = "milestones"

FeatureMilestones names the milestones capability for typed-error reporting.

const FeatureMirror Feature = "mirror"

FeatureMirror names the mirror capability for typed-error reporting.

const FeaturePAT Feature = "pat"

FeaturePAT names the PAT management capability.

const FeaturePRCommentResolve Feature = "pr-comment-resolve"

FeaturePRCommentResolve names the inline-comment resolution capability for typed-error reporting via AsPRCommentResolver.

const FeaturePRCommentStateSet Feature = "pr-task"

PRCommentStateSetterFeature names the PR task (comment-state) capability.

const FeaturePRCommits Feature = "pr_commits"

FeaturePRCommits names the PR-commits capability for typed-error reporting.

const FeaturePRFiles Feature = "pr_files"

FeaturePRFiles names the PR-files capability for typed-error reporting.

const FeaturePRMergePreview Feature = "pr_merge_preview"

FeaturePRMergePreview names the PR merge-preview capability.

const FeaturePRParticipantUpdate Feature = "pr_participant_update"

FeaturePRParticipantUpdate names the PR-participant-update capability.

const FeaturePRParticipants Feature = "pr_participants"

FeaturePRParticipants names the PR-participants capability for typed-error reporting.

const FeaturePRReopen Feature = "pr-reopen"

FeaturePRReopen names the PR-reopen capability for typed-error reporting. Bitbucket Cloud has no reopen primitive (BCLOUD-23807), so callers gate the feature behind AsPRReopener.

const FeaturePRSuggestion Feature = "pr-suggestion"

FeaturePRSuggestion names the PR suggestion capability.

const FeaturePermissions Feature = "permissions"

FeaturePermissions names the permissions management capability.

const FeaturePipelineArtifacts Feature = "pipeline-artifacts"

FeaturePipelineArtifacts names the pipeline-artifacts capability for typed-error reporting.

const FeaturePipelineCache Feature = "pipeline-cache"

FeaturePipelineCache names the pipeline-cache capability for typed-error reporting.

const FeaturePipelineConfig Feature = "pipeline_config"

FeaturePipelineConfig names the pipeline-config capability for typed-error reporting.

const FeaturePipelineKnownHosts Feature = "pipeline_known_hosts"

FeaturePipelineKnownHosts names the pipeline-known-hosts capability.

const FeaturePipelineOIDC Feature = "pipeline_oidc"

FeaturePipelineOIDC names the pipeline OIDC capability for typed-error reporting.

const FeaturePipelineSSHKeyPair Feature = "pipeline_ssh_key_pair"

FeaturePipelineSSHKeyPair names the pipeline-SSH-key-pair capability.

const FeaturePipelineSchedules Feature = "pipeline_schedules"

FeaturePipelineSchedules names the pipeline-schedules capability for typed-error reporting.

const FeaturePipelineTestReports Feature = "pipeline_test_reports"

FeaturePipelineTestReports names the pipeline-test-reports capability.

const FeaturePipelineTrigger Feature = "pipeline_trigger"

FeaturePipelineTrigger names the pipeline-trigger capability for typed-error reporting.

const FeaturePipelines Feature = "pipelines"

FeaturePipelines names the pipelines capability for typed-error reporting.

const FeatureRefCompare Feature = "ref_compare"

FeatureRefCompare names the ref-compare capability.

const FeatureRepoDownloads Feature = "repo_downloads"

FeatureRepoDownloads names the repo downloads capability for typed-error reporting.

const FeatureRepoEdit Feature = "repo_edit"

FeatureRepoEdit names the repo-edit capability for typed-error reporting.

const FeatureRepoFork Feature = "repo-fork"

FeatureRepoFork names the repo-fork capability for typed-error reporting.

const FeatureRepoForks Feature = "repo-forks"

FeatureRepoForks names the repo-forks-list capability for typed-error reporting.

const FeatureRepoHooks Feature = "repo-hooks"

FeatureRepoHooks names the repo hook scripts capability for typed-error reporting.

const FeatureRepoLabels Feature = "repo-labels"

FeatureRepoLabels names the repository labels capability.

const FeatureRepoPRSettings Feature = "repo_pr_settings"

FeatureRepoPRSettings names the repo-pr-settings capability for typed-error reporting.

const FeatureRepoSync Feature = "repo-sync"

FeatureRepoSync names the repo-sync capability for typed-error reporting.

const FeatureRepoTransfer Feature = "repo_transfer"

FeatureRepoTransfer names the repo-transfer capability for typed-error reporting.

const FeatureRepoWatchers Feature = "repo_watchers"

FeatureRepoWatchers names the repo-watchers capability for typed-error reporting.

const FeatureReviewerGroup Feature = "reviewer-group"

FeatureReviewerGroup names the reviewer-group capability for typed-error reporting.

const FeatureRunner Feature = "Runner"

FeatureRunner is the feature key for RunnerClient.

const FeatureSSHKeys Feature = "ssh_keys"

FeatureSSHKeys names the ssh-keys capability for typed-error reporting.

const FeatureServerProject Feature = "server-project"

FeatureServerProject names the server project management capability.

const FeatureServerVersion Feature = "server-version"

FeatureServerVersion names the server-version capability for typed-error reporting.

const FeatureSnippets Feature = "snippets"

FeatureSnippets names the snippets capability for typed-error reporting.

const FeatureSourceWrite Feature = "SourceWriter"

FeatureSourceWrite names the source-write capability.

const FeatureWorkspaceMembers Feature = "workspace_members"
const FeatureWorkspacePerms Feature = "workspace_perms"

FeatureWorkspacePerms names the workspace-permissions capability for typed-error reporting.

const FeatureWorkspacePipelineVars Feature = "workspace-pipeline-vars"
const FeatureWorkspaceProjectDefaultReviewers Feature = "workspace_project_default_reviewers"

FeatureWorkspaceProjectDefaultReviewers names the workspace-project-default-reviewers capability for typed-error reporting.

const FeatureWorkspaceProjectPerms Feature = "workspace_project_perms"

FeatureWorkspaceProjectPerms names the workspace-project-permissions capability for typed-error reporting.

const FeatureWorkspaceSearch Feature = "workspace_search"

FeatureWorkspaceSearch names the workspace-search capability for typed-error reporting.

const FeatureWorkspaceVariables Feature = "workspace-variables"
const FeatureWorkspaceWebhooks Feature = "workspace-webhooks"

FeatureWorkspaceWebhooks names the workspace-webhook capability.

const FeatureWorkspaces Feature = "workspaces"

FeatureWorkspaces names the workspace/project listing capability for typed-error reporting.

type FeatureSpec added in v1.73.0

type FeatureSpec struct {
	// Name is the interface name, e.g. "PipelineClient".
	Name string
	// HumanLabel is a short lowercase phrase used in unsupported-host messages,
	// e.g. "pipelines", "code insights", "branch protection".
	HumanLabel string
	// Plural controls whether the unsupported-host message uses "are not supported"
	// (true) or "is not supported" (false). Set true when HumanLabel is a plural noun.
	Plural bool
	// Check reports whether c implements this capability via a type assertion.
	Check func(c Client) bool
	// Feature is the Feature constant associated with this spec.
	Feature Feature
	// CloudSupport declares whether the Cloud adapter implements this interface.
	CloudSupport bool
	// ServerSupport declares whether the Server adapter implements this interface.
	ServerSupport bool
}

FeatureSpec describes one optional backend capability.

type ForkRepoInput added in v1.16.0

type ForkRepoInput struct {
	Workspace string
	Name      string
}

ForkRepoInput carries the parameters for forking a Bitbucket Cloud repository. Workspace is required (the fork's destination workspace). Name is optional — when empty, Bitbucket Cloud reuses the source name.

type Group added in v1.95.0

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

Group is the domain representation of a Bitbucket Server/DC admin group.

type GroupClient added in v1.95.0

type GroupClient interface {
	ListGroups(filter string, limit int) ([]Group, error)
	CreateGroup(name string) (Group, error)
	DeleteGroup(name string) error
}

GroupClient manages Bitbucket Server/DC admin groups. This capability is Server-only; Cloud returns ErrUnsupportedOnHost for all methods.

func AsGroupClient added in v1.95.0

func AsGroupClient(c Client, host string) (GroupClient, error)

AsGroupClient returns the GroupClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the Group capability.

type GroupMember added in v1.95.0

type GroupMember struct {
	Name         string `json:"name"`
	DisplayName  string `json:"displayName"`
	EmailAddress string `json:"emailAddress"`
}

GroupMember is a user that belongs to a Bitbucket Server/DC admin group.

type GroupMemberClient added in v1.95.0

type GroupMemberClient interface {
	ListGroupMembers(groupName string, limit int) ([]GroupMember, error)
	AddGroupMember(groupName, user string) error
	RemoveGroupMember(groupName, user string) error
}

GroupMemberClient manages members of Bitbucket Server/DC admin groups. This capability is Server-only; Cloud returns ErrUnsupportedOnHost.

func AsGroupMemberClient added in v1.95.0

func AsGroupMemberClient(c Client, host string) (GroupMemberClient, error)

AsGroupMemberClient returns the GroupMemberClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the GroupMember capability.

type HTTPError

type HTTPError struct {
	StatusCode int
	Message    string
	RequestURL string
}

HTTPError represents an error HTTP response from the Bitbucket API.

func (*HTTPError) Error

func (e *HTTPError) Error() string

Error implements the error interface.

type HostInfo added in v1.126.0

type HostInfo struct {
	BackendType       string   `json:"backend_type"` // "cloud" | "server" | "datacenter"
	BaseURL           string   `json:"base_url"`
	Version           string   `json:"version,omitempty"`      // Server/DC only
	BuildNumber       string   `json:"build_number,omitempty"` // Server/DC only
	DisplayName       string   `json:"display_name"`
	SupportedFeatures []string `json:"supported_features"`
}

HostInfo describes the connected Bitbucket host: its backend type, base URL, optional version information (Server/DC only), and the Feature constants it supports. Used by `host info` and the `get_host_info` MCP tool as a single-call orientation primitive.

type HostInfoClient added in v1.126.0

type HostInfoClient interface {
	GetHostInfo() (HostInfo, error)
}

HostInfoClient is implemented by both Cloud and Server/DC backends. It returns static metadata about the connected host: backend type, base URL, optional version (Server/DC only), and the list of Feature constants this backend supports.

func AsHostInfoClient added in v1.126.0

func AsHostInfoClient(c Client, host string) (HostInfoClient, error)

AsHostInfoClient returns the HostInfoClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when the backend does not implement this capability.

type IPAllowlist added in v1.106.0

type IPAllowlist struct {
	UUID        string `json:"uuid"`
	CIDR        string `json:"cidr"`
	Description string `json:"description"`
	Enabled     bool   `json:"enabled"`
}

IPAllowlist is a single IP allowlist entry for a workspace.

type IPAllowlistClient added in v1.106.0

type IPAllowlistClient interface {
	ListIPAllowlists(workspace string) ([]IPAllowlist, error)
	CreateIPAllowlist(workspace string, in CreateIPAllowlistInput) (IPAllowlist, error)
	DeleteIPAllowlist(workspace, entryUUID string) error
}

IPAllowlistClient manages Bitbucket Cloud workspace IP allowlists.

func AsIPAllowlistClient added in v1.106.0

func AsIPAllowlistClient(c Client, host string) (IPAllowlistClient, error)

AsIPAllowlistClient asserts IPAllowlistClient capability. Returns a typed DomainError{ErrUnsupportedOnHost} when the backend does not support it.

type Issue added in v1.17.0

type Issue struct {
	ID        int
	Title     string
	State     string // new, open, on hold, resolved, duplicate, invalid, wontfix, closed
	Kind      string // bug, enhancement, proposal, task
	Priority  string // trivial, minor, major, critical, blocker
	Reporter  User
	Assignee  *User // nil when unassigned
	CreatedOn time.Time
	UpdatedOn time.Time
	WebURL    string
	Content   string // raw markdown body
}

Issue is a Bitbucket Cloud issue. Issues are a Cloud-only feature gated by per-repository "issue tracker" enablement; the API returns 404 on repositories where the tracker is disabled. We surface that as the adapter's standard ErrNotFound.

Assignee is a pointer so the zero value cleanly distinguishes "unassigned" from "assigned to user with empty username". Reporter is always present on Cloud and uses the value type.

type IssueActivityClient added in v1.118.0

type IssueActivityClient interface {
	ListIssueActivity(ns, slug string, issueID int, limit int) ([]IssueChange, error)
}

IssueActivityClient is Cloud-only; Server returns host.unsupported.

func AsIssueActivityClient added in v1.118.0

func AsIssueActivityClient(c Client, host string) (IssueActivityClient, error)

AsIssueActivityClient returns the IssueActivityClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the IssueActivity capability.

type IssueAttacher added in v1.100.0

type IssueAttacher interface {
	ListIssueAttachments(ns, slug string, id int) ([]IssueAttachment, error)
	DeleteIssueAttachment(ns, slug string, id int, filename string) error
}

IssueAttacher is implemented only by Bitbucket Cloud clients. It manages file attachments on issues.

func AsIssueAttacher added in v1.100.0

func AsIssueAttacher(c Client, host string) (IssueAttacher, error)

AsIssueAttacher returns the IssueAttacher view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type IssueAttachment added in v1.100.0

type IssueAttachment struct {
	Name     string
	Size     int64
	MIMEType string
	Links    struct{ Self string }
}

IssueAttachment is a file attached to a Bitbucket Cloud issue.

type IssueChange added in v1.118.0

type IssueChange struct {
	ID        int       `json:"id"`
	Kind      string    `json:"kind"`
	OldVal    string    `json:"old_val"`
	NewVal    string    `json:"new_val"`
	CreatedOn time.Time `json:"created_on"`
	User      User      `json:"user"`
}

IssueChange represents one change event in a Cloud issue's audit trail. Kind is the field that changed: "status", "priority", "assignee", "component", "milestone", "title", "content", or "comment".

type IssueClient added in v1.17.0

type IssueClient interface {
	ListIssues(ns, slug, state string, limit int) ([]Issue, error)
	GetIssue(ns, slug string, id int) (Issue, error)
	CreateIssue(ns, slug string, in CreateIssueInput) (Issue, error)
	UpdateIssue(ns, slug string, id int, in UpdateIssueInput) (Issue, error)
	ReopenIssue(ns, slug string, id int) error
	AssignIssue(ns, slug string, id int, assignee string) error
	ListIssueComments(ns, slug string, id int) ([]IssueComment, error)
	AddIssueComment(ns, slug string, id int, body string) (IssueComment, error)
	EditIssueComment(ns, slug string, id, commentID int, body string) (IssueComment, error)
	DeleteIssueComment(ns, slug string, id, commentID int) error
}

IssueClient is implemented only by Bitbucket Cloud clients. Bitbucket Server / Data Center has no built-in issue tracker, so the entire issue surface is gated behind AsIssueClient.

func AsIssueClient added in v1.17.0

func AsIssueClient(c Client, host string) (IssueClient, error)

AsIssueClient returns the IssueClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type IssueComment added in v1.23.0

type IssueComment struct {
	ID        int
	Author    User
	Content   string
	CreatedOn time.Time
	UpdatedOn time.Time
}

IssueComment is a comment on a Bitbucket Cloud issue.

type IssueVersion added in v1.112.0

type IssueVersion struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

IssueVersion is the domain representation of a Bitbucket Cloud issue version.

type IssueVersionClient added in v1.112.0

type IssueVersionClient interface {
	ListIssueVersions(ns, slug string, limit int) ([]IssueVersion, error)
	GetIssueVersion(ns, slug string, id int) (IssueVersion, error)
	CreateIssueVersion(ns, slug, name string) (IssueVersion, error)
	DeleteIssueVersion(ns, slug string, id int) error
}

IssueVersionClient is implemented only by Bitbucket Cloud clients. It provides CRUD access to issue versions on the Cloud issue tracker.

func AsIssueVersionClient added in v1.112.0

func AsIssueVersionClient(c Client, host string) (IssueVersionClient, error)

AsIssueVersionClient returns the IssueVersionClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type IssueVoter added in v1.100.0

type IssueVoter interface {
	VoteIssue(ns, slug string, id int) error
	UnvoteIssue(ns, slug string, id int) error
}

IssueVoter is implemented only by Bitbucket Cloud clients. It manages votes on issues.

func AsIssueVoter added in v1.100.0

func AsIssueVoter(c Client, host string) (IssueVoter, error)

AsIssueVoter returns the IssueVoter view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type IssueWatcher added in v1.100.0

type IssueWatcher interface {
	WatchIssue(ns, slug string, id int) error
	UnwatchIssue(ns, slug string, id int) error
}

IssueWatcher is implemented only by Bitbucket Cloud clients. It manages watches on issues.

func AsIssueWatcher added in v1.100.0

func AsIssueWatcher(c Client, host string) (IssueWatcher, error)

AsIssueWatcher returns the IssueWatcher view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type Link struct {
	Href string `json:"href,omitempty"`
}

Link is a single {href} entry, the atom of Bitbucket Cloud's HAL-style links objects.

type LoggingConfig added in v1.38.0

type LoggingConfig struct {
	Level      string // DEBUG | INFO | WARN | ERROR
	Async      bool
	Persistent bool // write-only flag; ignored in GetLoggingConfig response
}

LoggingConfig is the domain representation of the Bitbucket Server / Data Center logging configuration. Level is one of DEBUG, INFO, WARN, ERROR. Async controls whether log events are written asynchronously. Persistent, when true, directs SetLoggingConfig to write to log4j.properties so the change survives restarts; false = runtime-only.

type LoggingConfigInput added in v1.38.0

type LoggingConfigInput = LoggingConfig

LoggingConfigInput is the upsert payload for SetLoggingConfig. It mirrors LoggingConfig; the alias exists so the interface signature stays explicit.

type MailServerConfig added in v1.102.0

type MailServerConfig struct {
	Hostname        string
	Port            int
	Protocol        string // "smtp" | "smtps"
	UseStartTLS     bool
	RequireStartTLS bool
	Username        string
	SenderAddress   string
	// Password is write-only — not returned by GET; include for the set command.
	// The json:"-" tag ensures it is never serialised in --json output.
	Password string `json:"-"`
}

MailServerConfig holds the mail-server settings for a Bitbucket Server / DC instance.

type MergeCheck added in v1.23.0

type MergeCheck struct {
	Key         string `json:"key"`
	ReportKey   string `json:"report_key"`
	MustPass    bool   `json:"must_pass"`
	MinSeverity string `json:"min_severity,omitempty"`
}

MergeCheck represents a Code Insights merge-check configuration. Merge checks block PR merges when report criteria are not met. This feature is partly undocumented in the Bitbucket Server REST API — treat output as best-effort.

MinSeverity values: "LOW", "MEDIUM", "HIGH", "CRITICAL" (empty = no threshold).

type MergeCheckInput added in v1.23.0

type MergeCheckInput = MergeCheck

MergeCheckInput is an alias of MergeCheck used on the write side.

type MergeDryRunResult added in v1.124.0

type MergeDryRunResult struct {
	CanMerge        bool        `json:"can_merge"`
	Message         string      `json:"message,omitempty"`
	ConflictedFiles []string    `json:"conflicted_files,omitempty"`
	Vetoes          []MergeVeto `json:"vetoes,omitempty"`
}

MergeDryRunResult is the result of a dry-run merge check on a pull request. CanMerge is true when the PR can be merged without conflicts. Message is a human-readable summary from the backend (may be empty). ConflictedFiles lists file paths that have merge conflicts (Cloud only; empty on Server because the Server dry-run endpoint does not enumerate conflicted files — vetoes carry the conflict description instead). Vetoes lists blocking conditions returned by Bitbucket Server / Data Center.

type MergePRInput

type MergePRInput struct {
	Message  string
	Strategy string
}

MergePRInput carries the parameters for merging a pull request.

type MergeVeto added in v1.124.0

type MergeVeto struct {
	SummaryMessage string `json:"summary_message"`
	DetailMessage  string `json:"detail_message,omitempty"`
}

MergeVeto is a single blocking condition returned by the Bitbucket Server dry-run merge endpoint. SummaryMessage is a short label; DetailMessage is the full explanation.

type Milestone added in v1.111.0

type Milestone struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Milestone is the domain representation of a Bitbucket Cloud issue milestone.

type MilestoneClient added in v1.111.0

type MilestoneClient interface {
	ListMilestones(ns, slug string, limit int) ([]Milestone, error)
	GetMilestone(ns, slug string, id int) (Milestone, error)
}

MilestoneClient is implemented only by Bitbucket Cloud clients. It provides read access to issue milestones.

func AsMilestoneClient added in v1.111.0

func AsMilestoneClient(c Client, host string) (MilestoneClient, error)

AsMilestoneClient returns the MilestoneClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type MirrorClient added in v1.113.0

type MirrorClient interface {
	ListMirrorServers(limit int) ([]MirrorServer, error)
	GetMirrorServer(id string) (MirrorServer, error)
	ListMirroredRepos(mirrorID string, limit int) ([]MirroredRepo, error)
}

MirrorClient is implemented only by Bitbucket Server/DC clients. Bitbucket Cloud has no Smart Mirror API, so the entire mirror surface is gated behind AsMirrorClient.

func AsMirrorClient added in v1.113.0

func AsMirrorClient(c Client, host string) (MirrorClient, error)

AsMirrorClient returns the MirrorClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Cloud backend.

type MirrorServer added in v1.113.0

type MirrorServer struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	BaseURL string `json:"base_url"`
	Enabled bool   `json:"enabled"`
}

MirrorServer represents a Bitbucket Smart Mirror server (Server/DC only).

type MirroredRepo added in v1.113.0

type MirroredRepo struct {
	Slug       string    `json:"slug"`
	MirrorID   string    `json:"mirror_id"`
	LastSyncAt time.Time `json:"last_sync_at"`
	Status     string    `json:"status"`
}

MirroredRepo represents a repository mirrored by a Smart Mirror server.

type MyPREntry added in v1.28.0

type MyPREntry struct {
	PullRequest        // embed — carries ID, Title, State, Author, WebURL, HeadCommitHash
	Repo        string // "PROJECT/REPO" (Server) or "workspace/slug" (Cloud)
	Role        string // "AUTHOR" | "REVIEWER"
}

MyPREntry is a cross-repo PR summary for the status dashboard.

type Options added in v1.1.1

type Options struct {
	Token         string
	SkipTLSVerify bool
	// Email is the Atlassian account email address used as the HTTP Basic auth
	// identity for Bitbucket Cloud when authenticating with an Atlassian API
	// token. Leave empty when using a Bearer / OAuth2 token.
	Email string
	// Username is the Bitbucket Server/DC username used as the HTTP Basic auth
	// identity. Not used for Bitbucket Cloud.
	Username string
}

Options overrides the stored config when constructing a backend client. Used by auth login to validate a new token before it is persisted.

type PAT added in v1.99.0

type PAT struct {
	ID          string
	Name        string
	Permissions []string
	CreatedDate time.Time
	ExpiryDate  *time.Time
	LastUsed    *time.Time
}

PAT is a Bitbucket Server/DC personal access token (read-only fields).

type PATClient added in v1.99.0

type PATClient interface {
	ListPATs(userSlug string, limit int) ([]PAT, error)
	CreatePAT(userSlug string, in CreatePATInput) (PATWithSecret, error)
	RevokePAT(userSlug, tokenID string) error
}

PATClient is implemented by Bitbucket Server/DC only. Bitbucket Cloud API token management is not available via the REST API.

func AsPATClient added in v1.99.0

func AsPATClient(c Client, host string) (PATClient, error)

AsPATClient returns the PATClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not support PAT management.

type PATWithSecret added in v1.99.0

type PATWithSecret struct {
	PAT
	Token string
}

PATWithSecret is returned only by CreatePAT. Token is the raw secret — display once, never log.

type PRActivityEvent added in v1.26.0

type PRActivityEvent struct {
	Type      string
	Actor     User
	CreatedAt time.Time
	Detail    map[string]any
}

PRActivityEvent is one event in the pull-request activity stream. Type is a normalised event kind: "approval", "unapproval", "comment", "update", "merge", "declined", "rescoped". Detail carries the raw sub-object so callers can surface backend-specific fields via --json.

type PRActivityReader added in v1.26.0

type PRActivityReader interface {
	GetPRActivity(ns, slug string, id int, limit int) ([]PRActivityEvent, error)
}

PRActivityReader reads the activity event stream for a pull request.

type PRApprover

type PRApprover interface {
	ApprovePR(ns, slug string, id int) error
}

PRApprover approves a pull request.

type PRBranchUpdater added in v1.28.0

type PRBranchUpdater interface {
	UpdatePRBranch(ns, slug string, prID int) error
}

PRBranchUpdater syncs a PR's source branch with its base branch.

type PRChangesRequester

type PRChangesRequester interface {
	RequestChangesPR(ns, slug string, id int) error
}

PRChangesRequester can request changes on a pull request (Cloud only). Access via type assertion — not embedded in Client.

type PRComment added in v1.6.0

type PRComment struct {
	ID        int
	Author    User
	Text      string
	CreatedAt time.Time
	UpdatedAt time.Time
	Inline    *PRCommentInline
	ParentID  int
	Resolved  bool
	Severity  string            // "" | "BLOCKER" (Server task comments)
	State     string            // "" | "OPEN" | "RESOLVED" (Server task comments)
	Version   int               // optimistic-lock token (Server only)
	Reactions []CommentReaction // only populated when explicitly requested; Server/DC only
}

PRComment is the domain representation of a comment on a pull request. Inline is non-nil for inline (file:line) review comments and nil for general PR comments. ParentID is 0 for top-level comments and the parent comment's ID for replies. Resolved reflects backend-native resolution state (Cloud `resolution`); on Server it is always false because the equivalent concept lives on tasks (RV3 scope).

Severity, State, and Version are populated on Bitbucket Server / Data Center for task-like comments (comments with severity="BLOCKER"). Severity is "BLOCKER" for tasks and "" for regular comments. State is "OPEN" or "RESOLVED" for tasks and "" for regular comments. Version is the optimistic-lock token required by SetPRCommentState on Server.

Reactions is only populated when explicitly requested (e.g. --reactions flag or include_reactions MCP parameter). Server/DC only.

type PRCommentAdder added in v1.6.0

type PRCommentAdder interface {
	AddPRComment(ns, slug string, id int, in AddPRCommentInput) (PRComment, error)
}

PRCommentAdder adds a general comment to a pull request.

type PRCommentDeleter added in v1.24.0

type PRCommentDeleter interface {
	DeletePRComment(ns, slug string, id, commentID int) error
}

PRCommentDeleter removes a comment from a pull request.

type PRCommentEditor added in v1.24.0

type PRCommentEditor interface {
	EditPRComment(ns, slug string, id, commentID int, body string) (PRComment, error)
}

PRCommentEditor updates the body of an existing comment on a pull request.

type PRCommentInline added in v1.22.0

type PRCommentInline struct {
	Path      string
	Side      string // "old" | "new"
	Line      int
	StartLine int // 0 = single-line
}

PRCommentInline anchors a PR comment to a file and line range in the diff. Side is "old" (LHS / from-side) or "new" (RHS / to-side). StartLine is 0 for single-line comments and set to the first line of the range for multi-line comments; Line is the last (or only) line.

type PRCommentLister added in v1.6.0

type PRCommentLister interface {
	ListPRComments(ns, slug string, id int) ([]PRComment, error)
}

PRCommentLister lists top-level comments on a pull request.

type PRCommentResolver added in v1.24.0

type PRCommentResolver interface {
	ResolvePRComment(ns, slug string, id, commentID int) error
}

PRCommentResolver marks a PR comment as resolved. Implemented only by Bitbucket Cloud (whose comments carry a native `resolution` field). Bitbucket Server has no equivalent concept on regular comments — the closest analogue lives on tasks, which is a separate feature scope — so callers route through AsPRCommentResolver and surface the constraint as a typed ErrUnsupportedOnHost.

func AsPRCommentResolver added in v1.24.0

func AsPRCommentResolver(c Client, host string) (PRCommentResolver, error)

AsPRCommentResolver returns the PRCommentResolver view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when the backend at host has no resolution primitive (currently Bitbucket Server / Data Center).

type PRCommentStateSetter added in v1.39.0

type PRCommentStateSetter interface {
	SetPRCommentState(ns, slug string, id, commentID int, state string) error
}

PRCommentStateSetter sets the state of a PR comment (task). Implemented only by Bitbucket Server / Data Center (where tasks are BLOCKER comments with an OPEN/RESOLVED state). Bitbucket Cloud has no equivalent concept, so callers route through AsPRCommentStateSetter to surface the constraint as a typed ErrUnsupportedOnHost.

func AsPRCommentStateSetter added in v1.39.0

func AsPRCommentStateSetter(c Client, host string) (PRCommentStateSetter, error)

AsPRCommentStateSetter returns the PRCommentStateSetter view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when the backend has no task-state primitive (currently Bitbucket Cloud).

type PRCommitClient added in v1.56.0

type PRCommitClient interface {
	ListPRCommits(ns, slug string, prID int) ([]Commit, error)
}

PRCommitClient is implemented by both Cloud and Server backends.

func AsPRCommitClient added in v1.56.0

func AsPRCommitClient(c Client, host string) (PRCommitClient, error)

AsPRCommitClient returns the PRCommitClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the PRCommits capability.

type PRCreator

type PRCreator interface {
	CreatePR(ns, slug string, in CreatePRInput) (PullRequest, error)
}

PRCreator creates a pull request.

type PRDecliner

type PRDecliner interface {
	DeclinePR(ns, slug string, id int) error
}

PRDecliner declines a pull request.

type PRDiffer

type PRDiffer interface {
	GetPRDiff(ns, slug string, id int) (string, error)
}

PRDiffer returns the unified diff for a pull request.

type PREditor

type PREditor interface {
	UpdatePR(ns, slug string, id int, in UpdatePRInput) (PullRequest, error)
}

PREditor updates a pull request's title or description.

type PRFileClient added in v1.57.0

type PRFileClient interface {
	ListPRFiles(ns, slug string, prID int) ([]DiffStatEntry, error)
}

PRFileClient is implemented by both Cloud and Server backends.

func AsPRFileClient added in v1.57.0

func AsPRFileClient(c Client, host string) (PRFileClient, error)

AsPRFileClient returns the PRFileClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the PRFiles capability.

type PRLister

type PRLister interface {
	ListPRs(ns, slug, state string, limit int) ([]PullRequest, error)
}

PRLister lists pull requests.

type PRMergePreviewClient added in v1.124.0

type PRMergePreviewClient interface {
	DryRunMergePR(ns, slug string, prID int, strategy string) (MergeDryRunResult, error)
}

PRMergePreviewClient performs a dry-run merge check on a pull request. Both Bitbucket Cloud and Bitbucket Server / Data Center expose dedicated dry-run endpoints that report conflicts without actually merging.

func AsPRMergePreviewClient added in v1.124.0

func AsPRMergePreviewClient(c Client, host string) (PRMergePreviewClient, error)

AsPRMergePreviewClient returns the PRMergePreviewClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when the backend does not implement the dry-run capability.

type PRMerger

type PRMerger interface {
	MergePR(ns, slug string, id int, in MergePRInput) (PullRequest, error)
	// EnableAutoMerge queues a PR for automatic merge once all checks pass.
	// strategy is the CLI vocabulary value: "merge" | "squash" | "rebase".
	EnableAutoMerge(ns, slug string, id int, strategy string) error
	// DisableAutoMerge cancels a queued auto-merge for the given PR.
	DisableAutoMerge(ns, slug string, id int) error
}

PRMerger merges a pull request and manages auto-merge queuing.

type PRParticipant added in v1.60.0

type PRParticipant struct {
	User     User
	Role     string // AUTHOR | REVIEWER | PARTICIPANT
	Approved bool
	State    string // APPROVED | CHANGES_REQUESTED | "" (empty = unapproved)
}

PRParticipant is a user involved in a pull request.

type PRParticipantClient added in v1.60.0

type PRParticipantClient interface {
	ListPRParticipants(ns, slug string, prID int) ([]PRParticipant, error)
}

PRParticipantClient is implemented by both Cloud and Server backends.

func AsPRParticipantClient added in v1.60.0

func AsPRParticipantClient(c Client, host string) (PRParticipantClient, error)

AsPRParticipantClient returns the PRParticipantClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the PRParticipants capability.

type PRParticipantUpdater added in v1.117.0

type PRParticipantUpdater interface {
	UpdatePRParticipant(ns, slug string, prID int, accountID, state string) (PRParticipant, error)
}

PRParticipantUpdater is Cloud-only; Server returns host.unsupported.

func AsPRParticipantUpdater added in v1.117.0

func AsPRParticipantUpdater(c Client, host string) (PRParticipantUpdater, error)

AsPRParticipantUpdater returns the PRParticipantUpdater view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend doesn't support it.

type PRReader

type PRReader interface {
	GetPR(ns, slug string, id int) (PullRequest, error)
}

PRReader reads a single pull request.

type PRReadier

type PRReadier interface {
	ReadyPR(ns, slug string, id int) error
}

PRReadier marks a draft pull request as ready for review.

type PRReopener added in v1.21.0

type PRReopener interface {
	ReopenPR(ns, slug string, id int) error
}

PRReopener reverses a decline. Implemented only by Bitbucket Server / Data Center (POST /pull-requests/{id}/reopen). Bitbucket Cloud has no reopen primitive — declined PRs are terminal there (BCLOUD-23807) — so callers route through AsPRReopener so the Cloud-only constraint surfaces as a typed ErrUnsupportedOnHost rather than a panic.

func AsPRReopener added in v1.21.0

func AsPRReopener(c Client, host string) (PRReopener, error)

AsPRReopener returns the PRReopener view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when the backend at host has no reopen primitive (currently Bitbucket Cloud).

type PRReviewRequester

type PRReviewRequester interface {
	RequestReview(ns, slug string, id int, users []string) error
}

PRReviewRequester requests reviewers on a pull request.

type PRReviewer added in v1.25.0

type PRReviewer interface {
	SubmitReview(ns, slug string, id int, in SubmitReviewInput) error
}

PRReviewer submits a compound review on a pull request — an optional top-level body comment, zero or more inline comments, and a review action (approve / request_changes / comment). The adapter sequences the writes internally so callers express "what the review looks like" rather than "how to assemble it".

type PRReviewerRemover added in v1.76.0

type PRReviewerRemover interface {
	RemoveReviewers(ns, slug string, id int, users []string) error
}

PRReviewerRemover removes reviewers from a pull request.

type PRStatusLister added in v1.28.0

type PRStatusLister interface {
	ListMyPRs(ns, slug string) ([]MyPREntry, error)
}

PRStatusLister returns the authenticated user's open PRs across all repos.

type PRUnapprover

type PRUnapprover interface {
	UnapprovePR(ns, slug string, id int) error
}

PRUnapprover removes approval from a pull request.

type PRUnreadier added in v1.75.0

type PRUnreadier interface {
	UnreadyPR(ns, slug string, id int) error
}

PRUnreadier marks an open pull request back to draft state.

type PermissionGrant added in v1.37.0

type PermissionGrant struct {
	Subject    PermissionSubject
	Permission string
}

PermissionGrant pairs a subject (user or group) with a permission level. Permission values:

PROJECT_READ, PROJECT_WRITE, PROJECT_ADMIN
REPO_READ, REPO_WRITE, REPO_ADMIN

type PermissionSubject added in v1.37.0

type PermissionSubject struct {
	Kind        string // "user" | "group"
	Slug        string // user slug (Kind=user)
	Name        string // group name (Kind=group)
	DisplayName string // populated on read; ignored on write
}

PermissionSubject identifies a user or group in a permission grant. Kind is "user" or "group". For users, Slug is the login slug. For groups, Name is the group name (may contain spaces). DisplayName is populated on read from the API and ignored on write.

type PermissionsClient added in v1.37.0

type PermissionsClient interface {
	ListProjectPermissions(ctx context.Context, project string) ([]PermissionGrant, error)
	GrantProjectPermission(ctx context.Context, project string, subject PermissionSubject, perm string) error
	RevokeProjectPermission(ctx context.Context, project string, subject PermissionSubject) error

	ListRepoPermissions(ctx context.Context, project, slug string) ([]PermissionGrant, error)
	GrantRepoPermission(ctx context.Context, project, slug string, subject PermissionSubject, perm string) error
	RevokeRepoPermission(ctx context.Context, project, slug string, subject PermissionSubject) error
}

PermissionsClient exposes Bitbucket Server / Data Center permission management for projects and repositories. Bitbucket Cloud has a different permissions model — AsPermissionsClient returns ErrUnsupportedOnHost when called against a Cloud backend.

func AsPermissionsClient added in v1.37.0

func AsPermissionsClient(c Client, host string) (PermissionsClient, error)

AsPermissionsClient returns the PermissionsClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a backend that doesn't implement permissions management (currently Bitbucket Cloud).

type Pipeline

type Pipeline struct {
	UUID        string
	BuildNumber int
	State       string // PENDING, IN_PROGRESS, SUCCESSFUL, FAILED, ERROR, STOPPED
	RefType     string // "branch", "tag", "commit"
	RefName     string
	CreatedOn   string
	Duration    int // seconds
	WebURL      string
}

Pipeline is the domain representation of a Bitbucket Cloud pipeline run.

type PipelineArtifact added in v1.93.0

type PipelineArtifact struct {
	Name      string `json:"name"`
	SizeBytes int64  `json:"size_bytes"`
	URL       string `json:"url"`
}

PipelineArtifact represents a single build artifact produced by a pipeline step.

type PipelineArtifactClient added in v1.93.0

type PipelineArtifactClient interface {
	ListPipelineArtifacts(ws, slug, pipelineUUID, stepUUID string, limit int) ([]PipelineArtifact, error)
	DownloadPipelineArtifact(ws, slug, pipelineUUID, stepUUID, name string, out io.Writer) error
}

PipelineArtifactClient is implemented only by Bitbucket Cloud clients.

func AsPipelineArtifactClient added in v1.93.0

func AsPipelineArtifactClient(c Client, host string) (PipelineArtifactClient, error)

AsPipelineArtifactClient returns the PipelineArtifactClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host has no pipeline-artifacts primitive (Bitbucket Server / Data Center).

type PipelineCache added in v1.67.0

type PipelineCache struct {
	UUID          string `json:"uuid"`
	Name          string `json:"name"`
	Path          string `json:"path"`
	FileSizeBytes int64  `json:"fileSizeBytes"`
	CreatedOn     string `json:"createdOn"`
}

PipelineCache is a named cache entry for a Bitbucket Cloud pipeline.

type PipelineCacheClient added in v1.67.0

type PipelineCacheClient interface {
	ListPipelineCaches(ns, slug string) ([]PipelineCache, error)
	DeletePipelineCache(ns, slug, uuid string) error
}

PipelineCacheClient is implemented only by Bitbucket Cloud clients.

func AsPipelineCacheClient added in v1.67.0

func AsPipelineCacheClient(c Client, host string) (PipelineCacheClient, error)

AsPipelineCacheClient returns the PipelineCacheClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host has no pipeline-cache primitive (Bitbucket Server / Data Center).

type PipelineClient

type PipelineClient interface {
	ListPipelines(ns, slug string, limit int) ([]Pipeline, error)
	GetPipeline(ns, slug, uuid string) (Pipeline, error)
	RunPipeline(ns, slug string, in RunPipelineInput) (Pipeline, error)
	StopPipeline(ws, slug, pipelineUUID string) error
	RerunPipeline(ns, slug, sourceUUID string) (Pipeline, error)
	ListPipelineSteps(ns, slug, uuid string) ([]PipelineStep, error)
	GetPipelineStepLog(ns, slug, pipelineUUID, stepUUID string) (io.ReadCloser, error)
	ListPipelineVariables(ns, slug string) ([]PipelineVariable, error)
	SetPipelineVariable(ns, slug string, in PipelineVariableInput) (PipelineVariable, error)
	DeletePipelineVariable(ns, slug, key string) error
}

PipelineClient is implemented only by Bitbucket Cloud clients.

func AsPipelineClient

func AsPipelineClient(c Client, host string) (PipelineClient, error)

AsPipelineClient returns the PipelineClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the Pipelines capability.

type PipelineConfig added in v1.109.0

type PipelineConfig struct {
	Enabled bool `json:"enabled"`
}

PipelineConfig is the domain representation of a repository's Bitbucket Cloud pipeline configuration.

type PipelineConfigClient added in v1.109.0

type PipelineConfigClient interface {
	GetPipelinesConfig(ws, slug string) (PipelineConfig, error)
	UpdatePipelinesConfig(ws, slug string, input PipelineConfig) (PipelineConfig, error)
}

PipelineConfigClient is implemented by Cloud backends. Bitbucket Server/DC does not have a repository-level pipeline config API.

func AsPipelineConfigClient added in v1.109.0

func AsPipelineConfigClient(c Client, host string) (PipelineConfigClient, error)

AsPipelineConfigClient returns the PipelineConfigClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the PipelineConfig capability.

type PipelineKnownHost added in v1.114.0

type PipelineKnownHost struct {
	UUID      string               `json:"uuid"`
	Hostname  string               `json:"hostname"`
	PublicKey PipelineSSHPublicKey `json:"public_key"`
}

PipelineKnownHost is the domain representation of a Bitbucket Cloud Pipelines known-host entry.

type PipelineKnownHostInput added in v1.114.0

type PipelineKnownHostInput struct {
	Hostname  string
	PublicKey PipelineSSHPublicKey
}

PipelineKnownHostInput carries the parameters for adding a known host.

type PipelineKnownHostsClient added in v1.114.0

type PipelineKnownHostsClient interface {
	ListPipelineKnownHosts(ns, slug string) ([]PipelineKnownHost, error)
	GetPipelineKnownHost(ns, slug, uuid string) (PipelineKnownHost, error)
	AddPipelineKnownHost(ns, slug string, in PipelineKnownHostInput) (PipelineKnownHost, error)
	DeletePipelineKnownHost(ns, slug, uuid string) error
}

PipelineKnownHostsClient is implemented by Cloud backends. Bitbucket Server/DC does not have a pipeline known-hosts API.

func AsPipelineKnownHostsClient added in v1.114.0

func AsPipelineKnownHostsClient(c Client, host string) (PipelineKnownHostsClient, error)

AsPipelineKnownHostsClient returns the PipelineKnownHostsClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend does not implement the capability.

type PipelineOIDCClient added in v1.125.0

type PipelineOIDCClient interface {
	GetPipelineOIDCConfig(workspace string) (PipelineOIDCConfig, error)
	GetPipelineOIDCKeys(workspace string) (PipelineOIDCKeys, error)
}

PipelineOIDCClient is implemented only by Bitbucket Cloud clients. It exposes the OIDC discovery document and JWKS key-set that Bitbucket Cloud Pipelines publishes for workload-identity federation (AWS, GCP, Azure).

func AsPipelineOIDCClient added in v1.125.0

func AsPipelineOIDCClient(c Client, host string) (PipelineOIDCClient, error)

AsPipelineOIDCClient returns the PipelineOIDCClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type PipelineOIDCConfig added in v1.125.0

type PipelineOIDCConfig struct {
	Issuer                 string   `json:"issuer"`
	JWKSURI                string   `json:"jwks_uri"`
	SubjectTypesSupported  []string `json:"subject_types_supported"`
	ResponseTypesSupported []string `json:"response_types_supported"`
	ClaimsSupported        []string `json:"claims_supported"`
}

PipelineOIDCConfig is the OIDC discovery document published by Bitbucket Cloud Pipelines for workload-identity federation.

type PipelineOIDCKey added in v1.125.0

type PipelineOIDCKey struct {
	Kid string `json:"kid"`
	Kty string `json:"kty"`
	Alg string `json:"alg"`
	Use string `json:"use"`
	N   string `json:"n"`
	E   string `json:"e"`
}

PipelineOIDCKey is a single JSON Web Key from the Bitbucket Cloud Pipelines JWKS endpoint.

type PipelineOIDCKeys added in v1.125.0

type PipelineOIDCKeys struct {
	Keys []PipelineOIDCKey `json:"keys"`
}

PipelineOIDCKeys is the JWKS key-set published by Bitbucket Cloud Pipelines.

type PipelineSSHKeyPair added in v1.114.0

type PipelineSSHKeyPair struct {
	PublicKey    string    `json:"public_key"`
	KeyTypeLabel string    `json:"key_type"`
	Created      time.Time `json:"created"`
}

PipelineSSHKeyPair is the domain representation of a Bitbucket Cloud repository-level SSH key pair used by Pipelines.

type PipelineSSHKeyPairClient added in v1.114.0

type PipelineSSHKeyPairClient interface {
	GetPipelineSSHKeyPair(ns, slug string) (PipelineSSHKeyPair, error)
	RegeneratePipelineSSHKeyPair(ns, slug string, bits int) (PipelineSSHKeyPair, error)
}

PipelineSSHKeyPairClient is implemented by Cloud backends. Bitbucket Server/DC does not have a pipeline SSH key-pair API.

func AsPipelineSSHKeyPairClient added in v1.114.0

func AsPipelineSSHKeyPairClient(c Client, host string) (PipelineSSHKeyPairClient, error)

AsPipelineSSHKeyPairClient returns the PipelineSSHKeyPairClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend does not implement the capability.

type PipelineSSHPublicKey added in v1.114.0

type PipelineSSHPublicKey struct {
	KeyType string `json:"key_type"`
	Key     string `json:"key"` // base64-encoded key material
	MD5     string `json:"md5_fingerprint"`
	SHA256  string `json:"sha256_fingerprint"`
}

PipelineSSHPublicKey is a public key entry in a pipeline known host.

type PipelineSchedule added in v1.54.0

type PipelineSchedule struct {
	UUID           string `json:"uuid"`
	Enabled        bool   `json:"enabled"`
	CronExpression string `json:"cronExpression"`
	Branch         string `json:"branch"`
}

PipelineSchedule is the domain representation of a Bitbucket Cloud pipeline schedule.

type PipelineScheduleClient added in v1.54.0

type PipelineScheduleClient interface {
	ListPipelineSchedules(ns, slug string) ([]PipelineSchedule, error)
	CreatePipelineSchedule(ns, slug string, input PipelineScheduleInput) (PipelineSchedule, error)
	DeletePipelineSchedule(ns, slug, uuid string) error
}

PipelineScheduleClient is implemented only by Bitbucket Cloud clients.

func AsPipelineScheduleClient added in v1.54.0

func AsPipelineScheduleClient(c Client, host string) (PipelineScheduleClient, error)

AsPipelineScheduleClient returns the PipelineScheduleClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the PipelineSchedules capability.

type PipelineScheduleInput added in v1.54.0

type PipelineScheduleInput struct {
	CronExpression string
	Branch         string
	Enabled        bool
}

PipelineScheduleInput carries the parameters for creating a pipeline schedule.

type PipelineStep added in v1.15.0

type PipelineStep struct {
	UUID     string
	Name     string
	State    string // PENDING, IN_PROGRESS, SUCCESSFUL, FAILED, ERROR, STOPPED
	Result   string // populated when State has flattened from COMPLETED
	Duration int    // seconds
}

PipelineStep is the domain representation of a single step within a Bitbucket Cloud pipeline run.

type PipelineTestCase added in v1.110.0

type PipelineTestCase struct {
	Name           string `json:"name"`
	ClassName      string `json:"class_name"`
	Status         string `json:"status"` // PASSED | FAILED | SKIPPED
	DurationMS     int64  `json:"duration_ms"`
	FailureMessage string `json:"failure_message,omitempty"`
}

PipelineTestCase is the domain representation of one test case in a Bitbucket Cloud pipeline step test report.

type PipelineTestReport added in v1.110.0

type PipelineTestReport struct {
	Total      int   `json:"total"`
	Passed     int   `json:"passed"`
	Failed     int   `json:"failed"`
	Skipped    int   `json:"skipped"`
	DurationMS int64 `json:"duration_ms"`
}

PipelineTestReport is the domain representation of a Bitbucket Cloud pipeline test report summary for a step.

type PipelineTestReportClient added in v1.110.0

type PipelineTestReportClient interface {
	GetPipelineTestReport(ws, slug, pipelineUUID, stepUUID string) (PipelineTestReport, error)
	ListPipelineTestCases(ws, slug, pipelineUUID, stepUUID string, filter TestCaseFilter) ([]PipelineTestCase, error)
}

PipelineTestReportClient is implemented by Cloud backends. Bitbucket Server/DC does not have a pipeline test-report API.

func AsPipelineTestReportClient added in v1.110.0

func AsPipelineTestReportClient(c Client, host string) (PipelineTestReportClient, error)

AsPipelineTestReportClient returns the PipelineTestReportClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend does not implement the capability.

type PipelineTriggerClient added in v1.48.0

type PipelineTriggerClient interface {
	TriggerPipeline(ns, slug string, input PipelineTriggerInput) (PipelineTriggerResult, error)
}

PipelineTriggerClient is implemented only by Bitbucket Cloud clients.

func AsPipelineTriggerClient added in v1.48.0

func AsPipelineTriggerClient(c Client, host string) (PipelineTriggerClient, error)

AsPipelineTriggerClient returns the PipelineTriggerClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the PipelineTrigger capability.

type PipelineTriggerInput added in v1.48.0

type PipelineTriggerInput struct {
	Branch    string
	Variables []PipelineVariable
}

PipelineTriggerInput carries the parameters for triggering a pipeline via the PipelineTriggerClient interface. Variables supplements the per-run environment; each entry maps to a Bitbucket pipeline variable object.

type PipelineTriggerResult added in v1.48.0

type PipelineTriggerResult struct {
	UUID  string `json:"uuid"`
	State string `json:"state"`
	Link  string `json:"link"`
}

PipelineTriggerResult is returned by TriggerPipeline on success.

type PipelineVariable added in v1.15.0

type PipelineVariable struct {
	UUID    string
	Key     string
	Value   string
	Secured bool
}

PipelineVariable is a repository-level pipeline variable on Bitbucket Cloud. Value is empty when Secured is true (the API never returns secured values).

type PipelineVariableInput added in v1.15.0

type PipelineVariableInput struct {
	Key     string
	Value   string
	Secured bool
}

PipelineVariableInput carries the parameters for upserting a pipeline variable by Key.

type Project added in v1.17.0

type Project struct {
	Key    string
	Name   string
	UUID   string
	WebURL string
}

Project is a Bitbucket Cloud project (a logical group of repositories inside a workspace). The naming clashes with Server/DC's "project" — which is the namespace itself — but Cloud's project sits one level deeper. Listed via WorkspaceClient.ListProjects(workspace).

type ProjectDefaultReviewer added in v1.122.0

type ProjectDefaultReviewer struct {
	AccountID   string
	DisplayName string
	Nickname    string
	AvatarURL   string
}

ProjectDefaultReviewer is the domain representation of one default reviewer on a Cloud workspace project.

type PullRequest

type PullRequest struct {
	ID             int
	Title          string
	Description    string
	State          string
	Draft          bool
	Author         User
	FromBranch     string
	ToBranch       string
	WebURL         string
	HeadCommitHash string
	AutoMerge      *AutoMergeState // nil when auto-merge is not enabled
	// Version is the optimistic-concurrency token used by Bitbucket Server / DC.
	// It is zero for Cloud PRs (Cloud does not expose a version field).
	// Use omitempty so Cloud JSON output does not include a spurious "version":0.
	Version int `json:"version,omitempty"`
}

PullRequest is the domain representation of a Bitbucket pull request.

type PutFileInput added in v1.102.0

type PutFileInput struct {
	Content      string // raw file content
	Branch       string // target branch name
	Message      string // commit message
	SourceCommit string // optional: expected HEAD SHA for conflict detection
}

PutFileInput holds the parameters for creating or updating a file.

type RateLimitConfig added in v1.134.0

type RateLimitConfig struct {
	Enabled         bool `json:"enabled"`
	RequestsPerHour int  `json:"requests_per_hour"`
	ThrottleWaitMS  int  `json:"throttle_wait_ms"`
}

RateLimitConfig holds Bitbucket Server/DC REST API rate-limit settings.

type RefComparer added in v1.110.0

type RefComparer interface {
	CompareRefs(ns, slug, base, head string, limit int) (RefComparison, error)
}

RefComparer is implemented by Cloud and Server/DC backends that support branch comparison.

func AsRefComparer added in v1.110.0

func AsRefComparer(c Client, host string) (RefComparer, error)

AsRefComparer returns the RefComparer view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend does not implement the capability.

type RefComparison added in v1.110.0

type RefComparison struct {
	Base          string   `json:"base"`
	Head          string   `json:"head"`
	AheadBy       int      `json:"ahead_by"`
	BehindBy      int      `json:"behind_by"`
	CommitsAhead  []Commit `json:"commits_ahead"`
	CommitsBehind []Commit `json:"commits_behind"`
}

RefComparison is the domain representation of the result of comparing two refs (branches or commits). AheadBy is the number of commits that Head has ahead of Base; BehindBy is the number of commits that Base has ahead of Head.

type RepoDefaultBranchSetter added in v1.85.0

type RepoDefaultBranchSetter interface {
	SetRepoDefaultBranch(ns, slug, branch string) error
}

RepoDefaultBranchSetter sets the default branch of a repository.

type RepoDeleter

type RepoDeleter interface {
	DeleteRepo(ns, slug string) error
}

RepoDeleter deletes a repository.

type RepoDownload added in v1.111.0

type RepoDownload struct {
	Name      string    `json:"name"`
	Size      int64     `json:"size"`
	Downloads int       `json:"downloads"`
	CreatedOn time.Time `json:"created_on"`
}

RepoDownload is the domain representation of a Bitbucket Cloud repository download artifact.

type RepoDownloadClient added in v1.111.0

type RepoDownloadClient interface {
	ListRepoDownloads(ns, slug string, limit int) ([]RepoDownload, error)
	UploadRepoDownload(ns, slug, name string, body io.Reader) (RepoDownload, error)
	DownloadRepoDownload(ns, slug, name string, out io.Writer) error
	DeleteRepoDownload(ns, slug, name string) error
}

RepoDownloadClient is implemented only by Bitbucket Cloud clients. It manages repository download artifacts.

func AsRepoDownloadClient added in v1.111.0

func AsRepoDownloadClient(c Client, host string) (RepoDownloadClient, error)

AsRepoDownloadClient returns the RepoDownloadClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type RepoEditor added in v1.89.0

type RepoEditor interface {
	EditRepo(ns, slug string, in EditRepoInput) (Repository, error)
}

RepoEditor updates mutable repository metadata fields.

func AsRepoEditor added in v1.89.0

func AsRepoEditor(c Client, host string) (RepoEditor, error)

AsRepoEditor returns the RepoEditor view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the RepoEdit capability.

type RepoForker added in v1.16.0

type RepoForker interface {
	ForkRepo(ns, slug string, in ForkRepoInput) (Repository, error)
}

RepoForker is implemented only by Bitbucket Cloud clients — Bitbucket Server / Data Center has no fork primitive in its REST API. Access via AsRepoForker so the Cloud-only constraint surfaces as a typed ErrUnsupportedOnHost error rather than a panic.

func AsRepoForker added in v1.16.0

func AsRepoForker(c Client, host string) (RepoForker, error)

AsRepoForker returns the RepoForker view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host has no fork primitive (Bitbucket Server / Data Center).

type RepoForksLister added in v1.64.0

type RepoForksLister interface {
	ListRepoForks(ns, slug string, limit int) ([]Repository, error)
}

RepoForksLister lists forks of a repository. Both Cloud and Server support this.

func AsRepoForksLister added in v1.64.0

func AsRepoForksLister(c Client, host string) (RepoForksLister, error)

AsRepoForksLister returns the RepoForksLister view of c, or a typed *DomainError.

type RepoHook added in v1.129.0

type RepoHook struct {
	Key        string
	Name       string
	Version    string
	Enabled    bool
	Configured bool
}

RepoHook represents a plugin hook script installed on a repository.

type RepoHookClient added in v1.129.0

type RepoHookClient interface {
	ListRepoHooks(project, slug string) ([]RepoHook, error)
	GetRepoHook(project, slug, hookKey string) (RepoHook, error)
	EnableRepoHook(project, slug, hookKey string) error
	DisableRepoHook(project, slug, hookKey string) error
	GetRepoHookSettings(project, slug, hookKey string) (json.RawMessage, error)
	SetRepoHookSettings(project, slug, hookKey string, cfg json.RawMessage) error
}

RepoHookClient manages per-repository plugin hook script settings on Bitbucket Server / Data Center.

func AsRepoHookClient added in v1.129.0

func AsRepoHookClient(c Client, host string) (RepoHookClient, error)

AsRepoHookClient returns the RepoHookClient view of c, or a typed ErrUnsupportedOnHost when c does not implement it (e.g. Cloud).

type RepoLabel added in v1.100.0

type RepoLabel struct {
	ID    int
	Name  string
	Color string
}

RepoLabel is a label that can be attached to a Bitbucket repository.

type RepoLabelClient added in v1.100.0

type RepoLabelClient interface {
	ListRepoLabels(ns, slug string) ([]RepoLabel, error)
	CreateRepoLabel(ns, slug string, in CreateRepoLabelInput) (RepoLabel, error)
	UpdateRepoLabel(ns, slug string, id int, in UpdateRepoLabelInput) (RepoLabel, error)
	DeleteRepoLabel(ns, slug string, id int) error
}

RepoLabelClient manages labels on a repository. Implemented by both Cloud and Server/DC backends.

func AsRepoLabelClient added in v1.100.0

func AsRepoLabelClient(c Client, host string) (RepoLabelClient, error)

AsRepoLabelClient returns the RepoLabelClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when the backend does not implement the capability.

type RepoLister

type RepoLister interface {
	ListRepos(ns string, limit int) ([]Repository, error)
}

RepoLister lists repositories. ns is the workspace (Bitbucket Cloud) or project key (Bitbucket Server); pass "" for Server to list all repos.

type RepoPRSettings added in v1.94.0

type RepoPRSettings struct {
	RequiredApprovers        int      `json:"requiredApprovers"`
	RequiredAllApprovers     bool     `json:"requiredAllApprovers"`
	RequiredAllTasksComplete bool     `json:"requiredAllTasksComplete"`
	RequiredSuccessfulBuilds int      `json:"requiredSuccessfulBuilds"`
	MergeStrategy            string   `json:"mergeStrategy"`
	AllowedStrategies        []string `json:"allowedStrategies"`
}

RepoPRSettings is the domain representation of per-repo PR gate settings.

type RepoPRSettingsClient added in v1.94.0

type RepoPRSettingsClient interface {
	GetRepoPRSettings(ns, slug string) (RepoPRSettings, error)
	UpdateRepoPRSettings(ns, slug string, in RepoPRSettingsInput) (RepoPRSettings, error)
}

RepoPRSettingsClient reads and writes the per-repo pull-request gate configuration. This capability is Server-only; Cloud returns ErrUnsupportedOnHost for both methods.

func AsRepoPRSettingsClient added in v1.94.0

func AsRepoPRSettingsClient(c Client, host string) (RepoPRSettingsClient, error)

AsRepoPRSettingsClient returns the RepoPRSettingsClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the RepoPRSettings capability.

type RepoPRSettingsInput added in v1.94.0

type RepoPRSettingsInput struct {
	RequiredApprovers        *int
	RequiredAllApprovers     *bool
	RequiredAllTasksComplete *bool
	RequiredSuccessfulBuilds *int
	MergeStrategy            *string
	AllowedStrategies        *[]string
}

RepoPRSettingsInput carries the fields to update. Nil pointer = leave unchanged.

type RepoReader

type RepoReader interface {
	GetRepo(ns, slug string) (Repository, error)
}

RepoReader reads a single repository.

type RepoRenamer added in v1.16.0

type RepoRenamer interface {
	RenameRepo(ns, slug, newName string) (Repository, error)
}

RepoRenamer renames a repository.

type RepoSyncer added in v1.133.0

type RepoSyncer interface {
	SyncRepo(ns, slug, branch string) (SyncResult, error)
}

RepoSyncer synchronises a fork branch with its upstream. Implemented only by the Bitbucket Cloud adapter; Bitbucket Server / Data Center has no fork-upstream concept and returns ErrUnsupportedOnHost via AsRepoSyncer.

func AsRepoSyncer added in v1.133.0

func AsRepoSyncer(c Client, host string) (RepoSyncer, error)

AsRepoSyncer returns the RepoSyncer view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type RepoTransferClient added in v1.52.0

type RepoTransferClient interface {
	TransferRepo(ns, slug, target string) (Repository, error)
}

RepoTransferClient transfers a repository to another project (Server) or workspace (Cloud).

func AsRepoTransferClient added in v1.52.0

func AsRepoTransferClient(c Client, host string) (RepoTransferClient, error)

AsRepoTransferClient returns the RepoTransferClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the RepoTransfer capability.

type RepoVisibilitySetter added in v1.65.0

type RepoVisibilitySetter interface {
	SetRepoVisibility(ns, slug string, isPrivate bool) error
}

RepoVisibilitySetter sets a repository's public/private visibility.

type RepoWatcherClient added in v1.58.0

type RepoWatcherClient interface {
	ListRepoWatchers(ns, slug string) ([]User, error)
}

RepoWatcherClient is implemented by both Cloud and Server backends.

func AsRepoWatcherClient added in v1.58.0

func AsRepoWatcherClient(c Client, host string) (RepoWatcherClient, error)

AsRepoWatcherClient returns the RepoWatcherClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the RepoWatchers capability.

type RepoWriter

type RepoWriter interface {
	CreateRepo(ns string, in CreateRepoInput) (Repository, error)
}

RepoWriter creates a repository.

type Repository

type Repository struct {
	Slug        string
	Name        string
	Namespace   string
	SCM         string
	WebURL      string
	Description string
	IsPrivate   bool
	ID          int
	CloneURLs   []CloneURL
}

Repository is the domain representation of a Bitbucket repository.

ID is the backend's numeric identifier (Server / Data Center). Cloud uses opaque UUIDs surfaced through other channels; for Cloud repos this field stays zero. ID is exposed so the BBS default-reviewers endpoint (which requires source/target repo IDs as query params) has what it needs without an adapter-internal cache.

type ReviewerGroup added in v1.69.0

type ReviewerGroup struct {
	ID                int    `json:"id"`
	Name              string `json:"name"`
	RequiredApprovals int    `json:"requiredApprovals"`
	Reviewers         []User `json:"reviewers"`
}

ReviewerGroup is the domain representation of a Bitbucket Server / Data Center default-reviewers condition. Each condition defines a set of reviewers that are automatically required for PRs matching a source/target ref pattern.

type ReviewerGroupClient added in v1.69.0

type ReviewerGroupClient interface {
	ListReviewerGroups(ns, slug string) ([]ReviewerGroup, error)
	CreateReviewerGroup(ns, slug string, in CreateReviewerGroupInput) (ReviewerGroup, error)
	DeleteReviewerGroup(ns, slug string, id int) error
}

ReviewerGroupClient manages named reviewer-group conditions on a Bitbucket Server / Data Center repository. Cloud does not expose a compatible API, so AsReviewerGroupClient returns ErrUnsupportedOnHost for Cloud backends.

func AsReviewerGroupClient added in v1.69.0

func AsReviewerGroupClient(c Client, host string) (ReviewerGroupClient, error)

AsReviewerGroupClient returns the ReviewerGroupClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend does not implement the capability (currently Cloud).

type RunPipelineInput

type RunPipelineInput struct {
	Branch string
}

RunPipelineInput carries the parameters for triggering a pipeline run.

type Runner added in v1.104.0

type Runner struct {
	UUID      string
	Name      string
	State     string // "ONLINE" | "OFFLINE" | "DISABLED"
	Platform  RunnerPlatform
	Labels    []string
	CreatedOn string
}

Runner represents a Bitbucket Cloud Pipelines self-hosted runner.

type RunnerClient added in v1.104.0

type RunnerClient interface {
	ListRunners(workspace string) ([]Runner, error)
	CreateRunner(workspace string, in CreateRunnerInput) (Runner, error)
	DeleteRunner(workspace, runnerUUID string) error
}

RunnerClient manages Bitbucket Cloud Pipelines self-hosted runners.

func AsRunnerClient added in v1.104.0

func AsRunnerClient(c Client, host string) (RunnerClient, error)

AsRunnerClient asserts RunnerClient capability on c. Returns a typed DomainError{ErrUnsupportedOnHost} when the backend does not support it.

type RunnerPlatform added in v1.104.0

type RunnerPlatform struct {
	Operating string // "LINUX" | "WINDOWS" | "MACOS"
	Arch      string // "AMD64" | "ARM64"
}

RunnerPlatform describes the OS and architecture of a runner.

type SSHKey added in v1.51.0

type SSHKey struct {
	ID    int    `json:"id"`
	Label string `json:"label"`
	Key   string `json:"key"`
}

SSHKey is the domain representation of a user SSH key on Bitbucket Cloud.

type SSHKeyClient added in v1.51.0

type SSHKeyClient interface {
	ListSSHKeys() ([]SSHKey, error)
	AddSSHKey(input SSHKeyInput) (SSHKey, error)
	DeleteSSHKey(id int) error
}

SSHKeyClient is implemented by both Cloud and Server/DC backends. Cloud calls the /users/{username}/ssh-keys API. Server/DC calls the /rest/ssh/1.0/keys API for the authenticated user.

func AsSSHKeyClient added in v1.51.0

func AsSSHKeyClient(c Client, host string) (SSHKeyClient, error)

AsSSHKeyClient returns the SSHKeyClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the SSHKeys capability.

type SSHKeyInput added in v1.51.0

type SSHKeyInput struct {
	Label string
	Key   string
}

SSHKeyInput carries the parameters for adding a user SSH key.

type SearchSegment added in v1.21.0

type SearchSegment struct {
	Text  string
	Match bool
}

SearchSegment is one run of text in a path or content match. Match=true marks the substring that triggered the hit so renderers can highlight it.

type ServerProject added in v1.98.0

type ServerProject struct {
	Key         string `json:"key"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Public      bool   `json:"public"`
	WebURL      string `json:"webURL"`
}

ServerProject is the domain representation of a Bitbucket Server/DC project.

type ServerProjectClient added in v1.98.0

type ServerProjectClient interface {
	ListServerProjects(filter string, limit int) ([]ServerProject, error)
	GetServerProject(key string) (ServerProject, error)
	CreateServerProject(in CreateServerProjectInput) (ServerProject, error)
	UpdateServerProject(key string, in UpdateServerProjectInput) (ServerProject, error)
	DeleteServerProject(key string) error
}

ServerProjectClient is implemented only by Bitbucket Server/DC clients. Cloud workspaces have no equivalent project-management API.

func AsServerProjectClient added in v1.98.0

func AsServerProjectClient(c Client, host string) (ServerProjectClient, error)

AsServerProjectClient returns the ServerProjectClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not support server project management.

type ServerVersion added in v1.46.0

type ServerVersion struct {
	Major int
	Minor int
	Patch int
	Raw   string // original string, e.g. "8.5.0"
}

ServerVersion holds a parsed Bitbucket Server version number.

func (ServerVersion) AtLeast added in v1.46.0

func (v ServerVersion) AtLeast(major, minor int) bool

AtLeast reports whether the version is ≥ major.minor.0.

type Snippet added in v1.91.0

type Snippet struct {
	ID        string        `json:"id"`
	Title     string        `json:"title"`
	Owner     string        `json:"owner"`
	IsPrivate bool          `json:"is_private"`
	CreatedOn time.Time     `json:"created_on"`
	Files     []SnippetFile `json:"files"`
	WebURL    string        `json:"web_url"`
}

Snippet is the domain representation of a Bitbucket Cloud snippet.

type SnippetClient added in v1.91.0

type SnippetClient interface {
	ListSnippets(workspace string, limit int) ([]Snippet, error)
	GetSnippet(workspace, id string) (Snippet, error)
	CreateSnippet(workspace string, in CreateSnippetInput) (Snippet, error)
	DeleteSnippet(workspace, id string) error
	ListSnippetComments(workspace, snippetID string, limit int) ([]SnippetComment, error)
	AddSnippetComment(workspace, snippetID, body string) (SnippetComment, error)
	DeleteSnippetComment(workspace, snippetID string, commentID int) error
}

SnippetClient is implemented only by Bitbucket Cloud clients. Bitbucket Server / Data Center has no snippets API, so the entire snippet surface is gated behind AsSnippetClient.

func AsSnippetClient added in v1.91.0

func AsSnippetClient(c Client, host string) (SnippetClient, error)

AsSnippetClient returns the SnippetClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type SnippetComment added in v1.123.0

type SnippetComment struct {
	ID        int    `json:"id"`
	Body      string `json:"body"`
	CreatedOn string `json:"created_on"`
	UpdatedOn string `json:"updated_on"`
	Author    string `json:"author"` // display name
	WebURL    string `json:"web_url"`
}

SnippetComment is the domain representation of a comment on a Bitbucket Cloud snippet.

type SnippetFile added in v1.91.0

type SnippetFile struct {
	Name    string `json:"name"`
	Content string `json:"content"`
}

SnippetFile is a file attached to a snippet.

type SourceReader added in v1.22.0

type SourceReader interface {
	GetFileContent(ns, slug, ref, path string) ([]byte, error)
	ListTree(ns, slug, ref, path string) ([]TreeEntry, error)
}

SourceReader reads file content and directory listings at a ref. Both backends implement it (Cloud via /src/{ref}/{path}, Server via /raw/{path}?at={ref} and /browse/{path}?at={ref}).

GetFileContent returns the raw bytes of a file at ref. When path resolves to a directory the backend returns a 404 (Server) or directory listing (Cloud) — adapters normalise both to ErrNotFound so the cmd layer can suggest ListTree.

ListTree returns immediate children of path at ref. path "" lists the repository root. Each entry has Type "file" or "dir" — backends with richer type vocabularies (Server's "FILE"/"DIRECTORY"/"SUBMODULE", Cloud's "commit_file"/"commit_directory") are normalised at the adapter boundary. Submodules are surfaced as Type "dir" so the renderer treats them as recursable; the Hash field carries the submodule pointer.

type SourceWriter added in v1.102.0

type SourceWriter interface {
	PutFile(ns, slug, path string, in PutFileInput) error
}

SourceWriter can create or update a file on a branch via the API.

func AsSourceWriter added in v1.102.0

func AsSourceWriter(c Client, host string) (SourceWriter, error)

AsSourceWriter returns the SourceWriter view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a backend that doesn't implement source-write operations.

type SubmitReviewInline added in v1.25.0

type SubmitReviewInline struct {
	Path      string
	Line      int
	StartLine int    // 0 = single-line
	Side      string // "new" or "old"; defaults to "new" when empty
	Body      string
}

SubmitReviewInline is one inline comment in a compound review. The shape mirrors PRCommentInline + the comment body, so the adapter can splat each entry into AddPRComment without an intermediate translation.

type SubmitReviewInput added in v1.25.0

type SubmitReviewInput struct {
	Action string
	Body   string
	Inline []SubmitReviewInline
}

SubmitReviewInput bundles the review action, optional top-level body, and optional inline comments for a compound `pr review` call. The adapter posts the body comment first (if any), then each inline comment in order, then applies the action — so partial failures surface at the first failing step rather than corrupting the review state silently.

Action is one of:

  • "approve" — calls ApprovePR after comments
  • "request_changes" — calls RequestChangesPR (Cloud only; Server returns a typed *DomainError with Kind=ErrUnsupportedOnHost)
  • "comment" — comment-only review; no action call after the comments are posted

type SuggestionApplier added in v1.68.0

type SuggestionApplier interface {
	// ApplySuggestion commits a suggested change to the PR source branch.
	// The adapter is responsible for fetching the current PR version for
	// optimistic locking before issuing the POST.
	ApplySuggestion(ns, slug string, prID, commentID, suggestionID int) (SuggestionApplyResult, error)

	// GetSuggestionPreview returns the suggestion body text from the comment
	// without applying the change.
	GetSuggestionPreview(ns, slug string, prID, commentID int) (string, error)
}

SuggestionApplier applies Bitbucket Data Center inline code suggestions. Bitbucket Cloud has no equivalent primitive, so callers route through AsSuggestionApplier to surface the constraint as a typed ErrUnsupportedOnHost.

func AsSuggestionApplier added in v1.68.0

func AsSuggestionApplier(c Client, host string) (SuggestionApplier, error)

AsSuggestionApplier returns the SuggestionApplier view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when the backend has no suggestion apply primitive (currently Bitbucket Cloud).

type SuggestionApplyResult added in v1.68.0

type SuggestionApplyResult struct {
	CommitHash    string
	CommitMessage string
}

SuggestionApplyResult is returned when a suggested change is successfully applied.

type SyncResult added in v1.133.0

type SyncResult struct {
	Behind        int `json:"behind"`
	CommitsMerged int `json:"commits_merged"`
}

SyncResult is returned by SyncRepo.

type Tag

type Tag struct {
	Name    string
	Hash    string
	Message string // empty for lightweight tags; first line for annotated
	WebURL  string
}

Tag is the domain representation of a repository tag.

type TagCreator

type TagCreator interface {
	CreateTag(ns, slug string, in CreateTagInput) (Tag, error)
}

TagCreator creates a tag.

type TagDeleter

type TagDeleter interface {
	DeleteTag(ns, slug, name string) error
}

TagDeleter deletes a tag.

type TagLister

type TagLister interface {
	ListTags(ns, slug string, limit int) ([]Tag, error)
}

TagLister lists tags in a repository.

type TestCaseFilter added in v1.110.0

type TestCaseFilter struct {
	Status string // PASSED | FAILED | SKIPPED | "" (all)
	Limit  int
}

TestCaseFilter controls which test cases are returned by ListPipelineTestCases.

type TreeEntry added in v1.22.0

type TreeEntry struct {
	Path string
	Type string
	Size int64
	Hash string
}

TreeEntry is a single child of a directory listing under a ref. Type is the normalised "file" or "dir" — adapters fold their backend-specific vocabularies (Cloud "commit_file"/"commit_directory", Server "FILE"/"DIRECTORY"/"SUBMODULE") to one of these two values. Submodules surface as "dir" with the submodule pointer in Hash so renderers treat them as recursable.

Path is the full repo-relative path (including the parent prefix), so a renderer doesn't need to know what path was requested to display the listing. Size is 0 for directories.

type UpdateBranchRuleInput added in v1.121.0

type UpdateBranchRuleInput struct {
	Pattern *string
	Users   *[]string
	Groups  *[]string
	Value   *int
}

UpdateBranchRuleInput carries the patch parameters for updating a branch restriction rule. A nil pointer means "no change"; non-nil overwrites the current value. For Users and Groups, a non-nil empty slice clears the existing entries.

type UpdateIssueInput added in v1.17.0

type UpdateIssueInput struct {
	Title    string
	Content  string
	State    string
	Kind     string
	Priority string
	Assignee string // "" = no change; AssigneeNone = clear
}

UpdateIssueInput carries the parameters for changing an issue. Empty strings mean "no change". `issue close` sets State="closed" and leaves the rest untouched. Assignee is the Bitbucket Cloud username to assign to; set to the special sentinel AssigneeNone to explicitly clear the assignee.

type UpdatePRInput

type UpdatePRInput struct {
	Title       string // empty = no change
	Description string // empty = no change
}

UpdatePRInput carries the parameters for editing a pull request.

type UpdateRepoLabelInput added in v1.100.0

type UpdateRepoLabelInput struct {
	Name  string
	Color string
}

UpdateRepoLabelInput carries the parameters for updating a repository label.

type UpdateServerProjectInput added in v1.98.0

type UpdateServerProjectInput struct {
	Name        *string
	Description *string
	Public      *bool
}

UpdateServerProjectInput carries optional patch fields for updating a project. Nil pointer fields are left unchanged on the server.

type UpdateWorkspaceProjectInput added in v1.112.0

type UpdateWorkspaceProjectInput struct {
	Name        *string
	Description *string
	IsPrivate   *bool
}

UpdateWorkspaceProjectInput carries the parameters for updating a workspace project. Nil pointer fields are left unchanged.

type User

type User struct {
	Slug        string     `json:"slug,omitempty"`
	DisplayName string     `json:"name,omitempty"`
	AccountID   string     `json:"account_id,omitempty"`
	UUID        string     `json:"uuid,omitempty"`
	CreatedOn   string     `json:"created_on,omitempty"`
	HTMLURL     string     `json:"-"`
	Links       *UserLinks `json:"links,omitempty"`
}

User is the domain representation of a Bitbucket user.

AccountID, UUID, CreatedOn and HTMLURL are Cloud-stable machine-readable identifiers. They are empty on Bitbucket Server/DC (which has no equivalent) and on read paths that don't request them; the omitempty tags keep the wire shape clean. MCP's get_current_user marshals this struct directly, so the json tags here are the public contract: callers get a durable handle (account_id / uuid) that survives nickname/display-name changes, plus the profile URL under links.html.href to mirror Bitbucket Cloud's own shape.

type UserGetter

type UserGetter interface {
	GetCurrentUser() (User, error)
}

UserGetter returns the currently authenticated user.

type UserLinks struct {
	HTML *Link `json:"html,omitempty"`
}

UserLinks mirrors the subset of Bitbucket Cloud's user "links" object that bitbottle exposes. Only the html.href profile URL is carried today.

type VersionedServer added in v1.46.0

type VersionedServer interface {
	GetServerVersion() ServerVersion
}

VersionedServer is implemented by backends that report their server version. Currently Server/DC only — Cloud has no equivalent endpoint.

func AsVersionedServer added in v1.46.0

func AsVersionedServer(c Client, host string) (VersionedServer, error)

AsVersionedServer returns the VersionedServer accessor for c if the backend supports it, or ErrUnsupportedOnHost if not.

type Webhook added in v1.15.0

type Webhook struct {
	ID     string
	URL    string
	Events []string
	Active bool
}

Webhook is the domain representation of a repository webhook. Both Bitbucket Cloud and Server/DC expose a similar shape — a remote URL, a list of subscribed events, and an active flag. ID is the backend's stable identifier (UUID on Cloud, integer-as-string on Server/DC).

type WebhookCreator added in v1.15.0

type WebhookCreator interface {
	CreateWebhook(ns, slug string, in CreateWebhookInput) (Webhook, error)
}

WebhookCreator creates a webhook.

type WebhookDeleter added in v1.15.0

type WebhookDeleter interface {
	DeleteWebhook(ns, slug, id string) error
}

WebhookDeleter deletes a webhook.

type WebhookLister added in v1.15.0

type WebhookLister interface {
	ListWebhooks(ns, slug string) ([]Webhook, error)
}

WebhookLister lists webhooks for a repository.

type WebhookReader added in v1.15.0

type WebhookReader interface {
	GetWebhook(ns, slug, id string) (Webhook, error)
}

WebhookReader reads a single webhook by ID.

type Workspace added in v1.17.0

type Workspace struct {
	Slug   string
	Name   string
	UUID   string
	WebURL string
}

Workspace is a Bitbucket Cloud workspace (the top-level ownership unit containing repositories and projects). Bitbucket Server / Data Center has no analogous concept — projects sit directly under the instance — so Workspace is Cloud-only and surfaced via the WorkspaceClient optional interface.

type WorkspaceClient added in v1.17.0

type WorkspaceClient interface {
	ListWorkspaces(limit int) ([]Workspace, error)
	ListProjects(workspace string, limit int) ([]Project, error)
}

WorkspaceClient is implemented only by Bitbucket Cloud clients. Bitbucket Server / Data Center has no workspace concept — its projects live directly under the instance — so the workspace and project list operations are Cloud-only and accessed via the AsWorkspaceClient type assertion.

func AsWorkspaceClient added in v1.17.0

func AsWorkspaceClient(c Client, host string) (WorkspaceClient, error)

AsWorkspaceClient returns the WorkspaceClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not support workspaces.

type WorkspaceGroup added in v1.120.0

type WorkspaceGroup struct {
	Slug string
	Name string
}

WorkspaceGroup is the Cloud representation of a workspace group as used in project and workspace permission APIs. It is distinct from the Server-side Group type (which only carries Name).

type WorkspaceMember added in v1.62.0

type WorkspaceMember struct {
	User      User
	Workspace string // workspace slug
}

WorkspaceMember is a member of a Bitbucket Cloud workspace.

type WorkspaceMemberClient added in v1.62.0

type WorkspaceMemberClient interface {
	ListWorkspaceMembers(workspace string, limit int) ([]WorkspaceMember, error)
}

WorkspaceMemberClient lists members of a Bitbucket Cloud workspace. Cloud-only — Server returns ErrUnsupportedOnHost.

func AsWorkspaceMemberClient added in v1.62.0

func AsWorkspaceMemberClient(c Client, host string) (WorkspaceMemberClient, error)

AsWorkspaceMemberClient returns the WorkspaceMemberClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not support workspace members.

type WorkspaceMemberPerm added in v1.113.0

type WorkspaceMemberPerm struct {
	User       string `json:"user"`
	Permission string `json:"permission"`
}

WorkspaceMemberPerm represents a workspace-level permission for a user (Bitbucket Cloud only).

type WorkspacePermsClient added in v1.113.0

type WorkspacePermsClient interface {
	ListWorkspaceMemberPerms(ws string, limit int) ([]WorkspaceMemberPerm, error)
	ListWorkspaceRepoPerms(ws string, limit int) ([]WorkspaceRepoPerm, error)
	GrantWorkspacePerm(ws, user, permission string) error
	RevokeWorkspacePerm(ws, user string) error
}

WorkspacePermsClient is implemented only by Bitbucket Cloud clients. Bitbucket Server / Data Center does not have workspace permission APIs, so this surface is gated behind AsWorkspacePermsClient.

func AsWorkspacePermsClient added in v1.113.0

func AsWorkspacePermsClient(c Client, host string) (WorkspacePermsClient, error)

AsWorkspacePermsClient returns the WorkspacePermsClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type WorkspacePipelineVariableClient added in v1.115.0

type WorkspacePipelineVariableClient interface {
	ListWorkspacePipelineVariables(workspace string) ([]PipelineVariable, error)
	GetWorkspacePipelineVariable(workspace, uuid string) (PipelineVariable, error)
	SetWorkspacePipelineVariable(workspace string, in PipelineVariableInput) (PipelineVariable, error)
	DeleteWorkspacePipelineVariable(workspace, uuid string) error
}

WorkspacePipelineVariableClient is implemented by Bitbucket Cloud only.

func AsWorkspacePipelineVariableClient added in v1.115.0

func AsWorkspacePipelineVariableClient(c Client, host string) (WorkspacePipelineVariableClient, error)

AsWorkspacePipelineVariableClient returns the WorkspacePipelineVariableClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if not available.

type WorkspaceProject added in v1.112.0

type WorkspaceProject struct {
	Key         string `json:"key"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	IsPrivate   bool   `json:"is_private"`
}

WorkspaceProject is the domain representation of a Bitbucket Cloud workspace project.

type WorkspaceProjectDefaultReviewerClient added in v1.122.0

type WorkspaceProjectDefaultReviewerClient interface {
	ListProjectDefaultReviewers(workspace, projectKey string, limit int) ([]ProjectDefaultReviewer, error)
	AddProjectDefaultReviewer(workspace, projectKey, accountID string) error
	RemoveProjectDefaultReviewer(workspace, projectKey, accountID string) error
}

WorkspaceProjectDefaultReviewerClient is Cloud-only; Server/DC returns host.unsupported.

func AsWorkspaceProjectDefaultReviewerClient added in v1.122.0

func AsWorkspaceProjectDefaultReviewerClient(c Client, host string) (WorkspaceProjectDefaultReviewerClient, error)

AsWorkspaceProjectDefaultReviewerClient returns the WorkspaceProjectDefaultReviewerClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type WorkspaceProjectPerm added in v1.120.0

type WorkspaceProjectPerm struct {
	Permission string
	User       *User           // nil if this is a group permission
	Group      *WorkspaceGroup // nil if this is a user permission
}

WorkspaceProjectPerm is the domain representation of one permission entry for a Cloud workspace project. Exactly one of User/Group is non-nil.

type WorkspaceProjectPermInput added in v1.120.0

type WorkspaceProjectPermInput struct {
	Permission string
	UserSlug   string // set when granting a user permission
	GroupSlug  string // set when granting a group permission
}

WorkspaceProjectPermInput carries the subject and permission level for GrantWorkspaceProjectPerm. Set exactly one of UserSlug/GroupSlug.

type WorkspaceProjectPermsClient added in v1.120.0

type WorkspaceProjectPermsClient interface {
	ListWorkspaceProjectPerms(workspace, projectKey string, limit int) ([]WorkspaceProjectPerm, error)
	GrantWorkspaceProjectPerm(workspace, projectKey string, in WorkspaceProjectPermInput) error
	RevokeWorkspaceProjectPerm(workspace, projectKey, subjectSlug string, isGroup bool) error
}

WorkspaceProjectPermsClient is Cloud-only; Server/DC returns host.unsupported.

func AsWorkspaceProjectPermsClient added in v1.120.0

func AsWorkspaceProjectPermsClient(c Client, host string) (WorkspaceProjectPermsClient, error)

AsWorkspaceProjectPermsClient returns the WorkspaceProjectPermsClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) when called against a Server/DC backend.

type WorkspaceRepoPerm added in v1.113.0

type WorkspaceRepoPerm struct {
	Repo       string `json:"repo"`
	User       string `json:"user"`
	Permission string `json:"permission"`
}

WorkspaceRepoPerm represents a repository-level workspace permission for a user (Bitbucket Cloud only).

type WorkspaceSearchOpts added in v1.119.0

type WorkspaceSearchOpts struct {
	Query string // slug/name prefix match
	Role  string // owner | collaborator | member | "" (all)
	Limit int
}

WorkspaceSearchOpts carries filter options for SearchWorkspaces.

type WorkspaceSearcher added in v1.119.0

type WorkspaceSearcher interface {
	SearchWorkspaces(opts WorkspaceSearchOpts) ([]Workspace, error)
}

WorkspaceSearcher is Cloud-only; Server/DC returns host.unsupported.

func AsWorkspaceSearcher added in v1.119.0

func AsWorkspaceSearcher(c Client, host string) (WorkspaceSearcher, error)

AsWorkspaceSearcher returns the WorkspaceSearcher view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if the backend at host does not implement the WorkspaceSearch capability.

type WorkspaceVariableClient added in v1.31.0

type WorkspaceVariableClient interface {
	ListWorkspaceVariables(ns string) ([]PipelineVariable, error)
	SetWorkspaceVariable(ns string, in PipelineVariableInput) (PipelineVariable, error)
	DeleteWorkspaceVariable(ns, key string) error
}

WorkspaceVariableClient is implemented by Bitbucket Cloud only.

func AsWorkspaceVariableClient added in v1.31.0

func AsWorkspaceVariableClient(c Client, host string) (WorkspaceVariableClient, error)

AsWorkspaceVariableClient returns the WorkspaceVariableClient view of c, or a typed *DomainError (Kind=ErrUnsupportedOnHost) if not available.

type WorkspaceWebhookClient added in v1.66.0

type WorkspaceWebhookClient interface {
	WorkspaceWebhookLister
	WorkspaceWebhookCreator
	WorkspaceWebhookDeleter
}

WorkspaceWebhookClient bundles the three workspace-webhook operations.

func AsWorkspaceWebhookClient added in v1.66.0

func AsWorkspaceWebhookClient(c Client, host string) (WorkspaceWebhookClient, error)

AsWorkspaceWebhookClient returns the WorkspaceWebhookClient view of c, or a typed *DomainError (ErrUnsupportedOnHost) if the backend is not Cloud.

type WorkspaceWebhookCreator added in v1.66.0

type WorkspaceWebhookCreator interface {
	CreateWorkspaceWebhook(workspace string, in CreateWebhookInput) (Webhook, error)
}

WorkspaceWebhookCreator creates a workspace-level webhook.

type WorkspaceWebhookDeleter added in v1.66.0

type WorkspaceWebhookDeleter interface {
	DeleteWorkspaceWebhook(workspace, uuid string) error
}

WorkspaceWebhookDeleter deletes a workspace-level webhook by UUID.

type WorkspaceWebhookLister added in v1.66.0

type WorkspaceWebhookLister interface {
	ListWorkspaceWebhooks(workspace string) ([]Webhook, error)
}

WorkspaceWebhookLister lists webhooks scoped to a workspace.

Source Files

Jump to

Keyboard shortcuts

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