server

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: 17 Imported by: 0

Documentation

Overview

Package server is the Bitbucket Data Center (a.k.a. "Server") adapter for the backend.Client interface.

Index

Constants

View Source
const FeaturePRReviewRequestChanges backend.Feature = "pr-review-request-changes"

FeaturePRReviewRequestChanges names the request-changes branch of the compound `pr review` action for typed-error reporting. Bitbucket Server / Data Center has no request-changes endpoint — only Cloud does — so the action surfaces as a typed *DomainError(Kind=ErrUnsupportedOnHost) rather than a generic 405/404 on Server.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the Bitbucket Data Center HTTP client.

func NewClient

func NewClient(httpClient HTTPClient, baseURL, token, username string) *Client

NewClient constructs a Client. If token is non-empty Bearer auth is used; else if username is non-empty Basic auth is used with username:token as credentials.

func (*Client) ActivateUser added in v1.101.0

func (c *Client) ActivateUser(slug string) error

ActivateUser activates a user account. PUT /rest/api/1.0/admin/users with body {"active": true}

func (*Client) AddAnnotations added in v1.23.0

func (c *Client) AddAnnotations(project, slug, hash, key string, in []backend.CodeInsightsAnnotationInput) error

AddAnnotations bulk-POSTs all annotations in a single request.

func (*Client) AddCommentReaction added in v1.40.0

func (c *Client) AddCommentReaction(ns, slug string, prID, commentID int, emoji string) error

AddCommentReaction adds an emoji reaction to a pull-request comment.

API: POST /rest/api/1.0/projects/{ns}/repos/{slug}/pull-requests/{prID}/comments/{commentID}/reactions

func (*Client) AddCommitComment added in v1.27.0

func (c *Client) AddCommitComment(ns, slug, hash string, in backend.AddCommitCommentInput) (backend.CommitComment, error)

AddCommitComment posts a new comment on a commit.

func (*Client) AddCommitCommentReaction added in v1.41.0

func (c *Client) AddCommitCommentReaction(ns, slug, hash string, commentID int, emoji string) error

AddCommitCommentReaction adds an emoji reaction to a commit comment.

API: POST /rest/api/1.0/projects/{ns}/repos/{slug}/commits/{hash}/comments/{commentID}/reactions

func (*Client) AddDefaultReviewer added in v1.50.0

func (c *Client) AddDefaultReviewer(ns, slug, userSlug string) error

AddDefaultReviewer adds a default reviewer to a repository. PUT /rest/default-reviewers/1.0/projects/{ns}/repos/{slug}/reviewers/{userSlug}

func (*Client) AddDeployKey added in v1.47.0

func (c *Client) AddDeployKey(ns, slug string, input backend.DeployKeyInput) (backend.DeployKey, error)

AddDeployKey adds a deploy key to a repository. POST /rest/api/1.0/projects/{ns}/repos/{slug}/ssh

func (*Client) AddGroupMember added in v1.95.0

func (c *Client) AddGroupMember(groupName, user string) error

AddGroupMember adds user to the named admin group.

func (*Client) AddPRComment added in v1.6.0

func (c *Client) AddPRComment(ns, slug string, id int, in backend.AddPRCommentInput) (backend.PRComment, error)

func (*Client) AddSSHKey added in v1.109.0

func (c *Client) AddSSHKey(input backend.SSHKeyInput) (backend.SSHKey, error)

AddSSHKey adds an SSH key for the current user. POST /rest/ssh/1.0/keys

func (*Client) ApplySuggestion added in v1.68.0

func (c *Client) ApplySuggestion(ns, slug string, prID, commentID, suggestionID int) (backend.SuggestionApplyResult, error)

ApplySuggestion commits a suggested change to the PR source branch.

Bitbucket Server uses optimistic concurrency on PR lifecycle endpoints: the POST body must include the current PR version (from GET), otherwise the server returns HTTP 409. Mirrors MergePR's GET-then-POST(version) pattern.

func (*Client) ApprovePR

func (c *Client) ApprovePR(ns, slug string, id int) error

ApprovePR approves a PR on behalf of the authenticated user. Bitbucket Server (like Cloud) exposes a dedicated POST .../approve endpoint; the participants/{userSlug} path requires an actual slug and does not accept ~.

func (*Client) CherryPickCommit added in v1.108.0

func (c *Client) CherryPickCommit(ns, slug string, in backend.CherryPickInput) (backend.Commit, error)

CherryPickCommit cherry-picks the given commit hash onto targetBranch using Bitbucket Server's branch-utils REST plugin.

func (*Client) ClearBanner added in v1.103.0

func (c *Client) ClearBanner() error

ClearBanner removes the site-wide announcement banner. DELETE /rest/api/1.0/admin/banner

func (*Client) CompareRefs added in v1.110.0

func (c *Client) CompareRefs(ns, slug, base, head string, limit int) (backend.RefComparison, error)

CompareRefs returns commits ahead and behind for head relative to base. Server API: GET /rest/api/1.0/projects/{key}/repos/{slug}/compare/commits?from={ref}&to={other}&limit={n} "from" is the source ref (HEAD of the comparison), "to" is the target ref. Commits in from that are not in to == ahead; commits in to not in from == behind.

func (*Client) CreateBranch

func (c *Client) CreateBranch(ns, slug string, in backend.CreateBranchInput) (backend.Branch, error)

CreateBranch creates a new branch in the given repository. Server accepts both branch names and commit hashes in startPoint.

func (*Client) CreateBranchProtection added in v1.17.0

func (c *Client) CreateBranchProtection(ns, slug string, in backend.CreateBranchProtectionInput) (backend.BranchProtection, error)

CreateBranchProtection creates a single branch restriction. Empty MatcherKind defaults to "BRANCH" — the most common case for users passing a literal branch name on the CLI.

func (*Client) CreateGroup added in v1.95.0

func (c *Client) CreateGroup(name string) (backend.Group, error)

CreateGroup creates an admin group with the given name.

func (*Client) CreatePAT added in v1.99.0

func (c *Client) CreatePAT(userSlug string, in backend.CreatePATInput) (backend.PATWithSecret, error)

CreatePAT creates a new personal access token for the given user. The returned PATWithSecret contains the raw token — display once, never log.

func (*Client) CreatePR

func (c *Client) CreatePR(ns, slug string, in backend.CreatePRInput) (backend.PullRequest, error)

func (*Client) CreateRepo

func (c *Client) CreateRepo(ns string, in backend.CreateRepoInput) (backend.Repository, error)

func (*Client) CreateRepoLabel added in v1.100.0

func (c *Client) CreateRepoLabel(ns, slug string, in backend.CreateRepoLabelInput) (backend.RepoLabel, error)

CreateRepoLabel creates a new label on a Server/DC repository.

func (*Client) CreateReviewerGroup added in v1.69.0

func (c *Client) CreateReviewerGroup(ns, slug string, in backend.CreateReviewerGroupInput) (backend.ReviewerGroup, error)

CreateReviewerGroup creates a new reviewer-group condition. POST /rest/default-reviewers/1.0/projects/{ns}/repos/{slug}/conditions

func (*Client) CreateServerProject added in v1.98.0

func (c *Client) CreateServerProject(in backend.CreateServerProjectInput) (backend.ServerProject, error)

CreateServerProject creates a new project on Bitbucket Server/DC.

func (*Client) CreateTag

func (c *Client) CreateTag(ns, slug string, in backend.CreateTagInput) (backend.Tag, error)

func (*Client) CreateWebhook added in v1.15.0

func (c *Client) CreateWebhook(ns, slug string, in backend.CreateWebhookInput) (backend.Webhook, error)

func (*Client) DeactivateUser added in v1.101.0

func (c *Client) DeactivateUser(slug string) error

DeactivateUser deactivates a user account. PUT /rest/api/1.0/admin/users with body {"active": false}

func (*Client) DeclinePR

func (c *Client) DeclinePR(ns, slug string, id int) error

DeclinePR declines an open pull request.

func (*Client) DefaultReviewers added in v1.17.0

func (c *Client) DefaultReviewers(ns, slug, fromBranch, toBranch string) ([]backend.User, error)

DefaultReviewers fetches the configured default reviewers for a PR with the given source/target refs. We do an extra GET on the repo to learn its numeric ID — Bitbucket Server's default-reviewers endpoint requires sourceRepoId and targetRepoId as query params, and same-repo PRs are the overwhelmingly common case (so source and target are the same ID).

Cross-repo (fork) PRs would need a different code path that takes a distinct source repo; that's out of scope here. The current contract targets the 99% same-repo case and falls back gracefully (returns no reviewers) when the response is empty.

func (*Client) DeleteAnnotations added in v1.23.0

func (c *Client) DeleteAnnotations(project, slug, hash, key string) error

DeleteAnnotations removes all annotations under a given report key.

func (*Client) DeleteBranch

func (c *Client) DeleteBranch(ns, slug, branch string) error

func (*Client) DeleteBranchProtection added in v1.17.0

func (c *Client) DeleteBranchProtection(ns, slug string, id int) error

DeleteBranchProtection removes the restriction with the given numeric ID.

func (*Client) DeleteCommitComment added in v1.27.0

func (c *Client) DeleteCommitComment(ns, slug, hash string, commentID int) error

DeleteCommitComment removes a commit comment. Server requires the current version as a query param for optimistic concurrency.

func (*Client) DeleteDeployKey added in v1.47.0

func (c *Client) DeleteDeployKey(ns, slug string, id int) error

DeleteDeployKey removes a deploy key from a repository. DELETE /rest/api/1.0/projects/{ns}/repos/{slug}/ssh/{id}

func (*Client) DeleteGroup added in v1.95.0

func (c *Client) DeleteGroup(name string) error

DeleteGroup deletes the admin group with the given name.

func (*Client) DeleteMergeCheck added in v1.23.0

func (c *Client) DeleteMergeCheck(project, slug, key string) error

DeleteMergeCheck removes a merge-check configuration.

func (*Client) DeletePRComment added in v1.24.0

func (c *Client) DeletePRComment(ns, slug string, id, commentID int) error

func (*Client) DeleteRepo

func (c *Client) DeleteRepo(ns, slug string) error

func (*Client) DeleteRepoLabel added in v1.100.0

func (c *Client) DeleteRepoLabel(ns, slug string, id int) error

DeleteRepoLabel removes a label from a Server/DC repository.

func (*Client) DeleteReport added in v1.23.0

func (c *Client) DeleteReport(project, slug, hash, key string) error

DeleteReport removes a Code Insights report and all its annotations.

func (*Client) DeleteReviewerGroup added in v1.69.0

func (c *Client) DeleteReviewerGroup(ns, slug string, id int) error

DeleteReviewerGroup deletes a reviewer-group condition by its numeric ID. DELETE /rest/default-reviewers/1.0/projects/{ns}/repos/{slug}/conditions/{id}

func (*Client) DeleteSSHKey added in v1.109.0

func (c *Client) DeleteSSHKey(id int) error

DeleteSSHKey removes an SSH key by ID for the current user. DELETE /rest/ssh/1.0/keys/{id}

func (*Client) DeleteServerProject added in v1.98.0

func (c *Client) DeleteServerProject(key string) error

DeleteServerProject deletes a project by key.

func (*Client) DeleteTag

func (c *Client) DeleteTag(ns, slug, name string) error

func (*Client) DeleteWebhook added in v1.15.0

func (c *Client) DeleteWebhook(ns, slug, id string) error

func (*Client) DisableAutoMerge added in v1.30.0

func (c *Client) DisableAutoMerge(ns, slug string, id int) error

DisableAutoMerge cancels a queued auto-merge on Bitbucket Server / DC.

func (*Client) DisableRepoHook added in v1.129.0

func (c *Client) DisableRepoHook(project, slug, hookKey string) error

DisableRepoHook disables the named hook script on the repository.

func (*Client) DryRunMergePR added in v1.124.0

func (c *Client) DryRunMergePR(ns, slug string, prID int, _ string) (backend.MergeDryRunResult, error)

DryRunMergePR performs a dry-run merge check on a Bitbucket Server / DC pull request.

Server endpoint: POST /rest/api/1.0/projects/{KEY}/repos/{slug}/pull-requests/{id}/merge/dry-run Body: {} (always empty — the Server endpoint ignores strategy for dry-run). Response: {"canMerge": bool, "vetoes": [{"summaryMessage":"...","detailedMessage":"..."}]}

func (*Client) EditCommitComment added in v1.27.0

func (c *Client) EditCommitComment(ns, slug, hash string, commentID int, body string) (backend.CommitComment, error)

EditCommitComment updates the body of a commit comment. Server requires the current version for optimistic concurrency — the comment is fetched first to obtain it, then the PUT is issued.

func (*Client) EditPRComment added in v1.24.0

func (c *Client) EditPRComment(ns, slug string, id, commentID int, body string) (backend.PRComment, error)

func (*Client) EditRepo added in v1.89.0

func (c *Client) EditRepo(ns, slug string, in backend.EditRepoInput) (backend.Repository, error)

EditRepo updates mutable repository metadata on a Bitbucket Server / Data Center instance. Only Description is forwarded; Cloud-only fields (Website, Language, ForkPolicy, HasIssues, HasWiki) are silently dropped.

func (*Client) EnableAutoMerge added in v1.30.0

func (c *Client) EnableAutoMerge(ns, slug string, id int, strategy string) error

EnableAutoMerge queues a PR for automatic merge on Bitbucket Server / DC. The Server API uses POST (not PUT) for this endpoint.

func (*Client) EnableRepoHook added in v1.129.0

func (c *Client) EnableRepoHook(project, slug, hookKey string) error

EnableRepoHook enables the named hook script on the repository.

func (*Client) GetBanner added in v1.103.0

func (c *Client) GetBanner() (backend.BannerConfig, error)

GetBanner returns the current site-wide announcement banner configuration. GET /rest/api/1.0/admin/banner

func (*Client) GetClusterNodes added in v1.101.0

func (c *Client) GetClusterNodes() ([]backend.ClusterNode, error)

GetClusterNodes returns the nodes in the Bitbucket Server/DC cluster. GET /rest/api/1.0/admin/cluster

func (*Client) GetCommit

func (c *Client) GetCommit(ns, slug, hash string) (backend.Commit, error)

func (*Client) GetCurrentUser

func (c *Client) GetCurrentUser() (backend.User, error)

GetCurrentUser fetches the authenticated user. Bitbucket Server does not support GET /users/~ (Cloud-only), so when a userSlug was provided at construction time we call GET /users/{slug} instead.

func (*Client) GetDiff added in v1.49.0

func (c *Client) GetDiff(ns, slug, from, to string) (string, error)

GetDiff returns a unified diff between two refs for a repository on Server/DC. Server endpoint: GET /rest/api/1.0/projects/{ns}/repos/{slug}/diff?since={from}&until={to}&contextLines=5

func (*Client) GetDiffStat added in v1.49.0

func (c *Client) GetDiffStat(ns, slug, from, to string) (backend.DiffStat, error)

GetDiffStat returns the diff summary between two refs for a repository on Server/DC. It reuses the same JSON response as GetDiff and counts files/lines from hunk segments.

func (*Client) GetFileContent added in v1.22.0

func (c *Client) GetFileContent(ns, slug, ref, pathInRepo string) ([]byte, error)

GetFileContent returns the raw bytes of a file at ref. Server's /raw endpoint always returns the file's bytes verbatim, so directory paths are caught by Server returning a 404 (mapped to ErrNotFound by the transport's DomainError classifier) and surface to the caller with the same shape as Cloud.

func (*Client) GetHostInfo added in v1.126.0

func (c *Client) GetHostInfo() (backend.HostInfo, error)

GetHostInfo fetches /rest/api/1.0/application-properties and returns a HostInfo struct populated with the backend type, version, and the list of Feature constants that the Server/DC adapter implements.

func (*Client) GetLicense added in v1.101.0

func (c *Client) GetLicense() (backend.AdminLicense, error)

GetLicense returns the current license details for the instance. GET /rest/api/1.0/admin/license

func (*Client) GetLoggingConfig added in v1.38.0

func (c *Client) GetLoggingConfig() (backend.LoggingConfig, error)

GetLoggingConfig returns the current log level and async-logging setting. GET /rest/api/1.0/admin/logging

func (*Client) GetMailServerConfig added in v1.102.0

func (c *Client) GetMailServerConfig() (backend.MailServerConfig, error)

GetMailServerConfig returns the current mail-server configuration. GET /rest/api/1.0/admin/mail-server

func (*Client) GetMergeCheck added in v1.23.0

func (c *Client) GetMergeCheck(project, slug, key string) (backend.MergeCheck, error)

GetMergeCheck fetches the current merge-check configuration for a key.

func (*Client) GetMirrorServer added in v1.113.0

func (c *Client) GetMirrorServer(id string) (backend.MirrorServer, error)

GetMirrorServer returns a single Smart Mirror server by ID. GET /rest/mirroring/latest/mirrorServers/{id}

func (*Client) GetPR

func (c *Client) GetPR(ns, slug string, id int) (backend.PullRequest, error)

func (*Client) GetPRActivity added in v1.26.0

func (c *Client) GetPRActivity(ns, slug string, id int, limit int) ([]backend.PRActivityEvent, error)

func (*Client) GetPRDiff

func (c *Client) GetPRDiff(ns, slug string, id int) (string, error)

func (*Client) GetRateLimitConfig added in v1.134.0

func (c *Client) GetRateLimitConfig() (backend.RateLimitConfig, error)

GetRateLimitConfig returns the current rate-limiting configuration. GET /rest/api/1.0/admin/rate-limiting

func (*Client) GetRepo

func (c *Client) GetRepo(ns, slug string) (backend.Repository, error)

func (*Client) GetRepoHook added in v1.129.0

func (c *Client) GetRepoHook(project, slug, hookKey string) (backend.RepoHook, error)

GetRepoHook fetches a single hook script by its plugin key.

func (*Client) GetRepoHookSettings added in v1.129.0

func (c *Client) GetRepoHookSettings(project, slug, hookKey string) (json.RawMessage, error)

GetRepoHookSettings returns the opaque JSON settings for a hook script.

func (*Client) GetRepoPRSettings added in v1.94.0

func (c *Client) GetRepoPRSettings(ns, slug string) (backend.RepoPRSettings, error)

GetRepoPRSettings returns the current pull-request gate settings for a repository on Bitbucket Server / Data Center.

func (*Client) GetReport added in v1.23.0

func (c *Client) GetReport(project, slug, hash, key string) (backend.CodeInsightsReport, error)

GetReport fetches a single Code Insights report by key.

func (*Client) GetServerProject added in v1.98.0

func (c *Client) GetServerProject(key string) (backend.ServerProject, error)

GetServerProject fetches a single project by its key.

func (*Client) GetServerVersion added in v1.46.0

func (c *Client) GetServerVersion() backend.ServerVersion

GetServerVersion fetches and caches the Bitbucket Server version. The result is cached for the lifetime of the Client; subsequent calls return the cached value without an HTTP request. On error, the zero ServerVersion is returned (AtLeast always returns false).

func (*Client) GetSuggestionPreview added in v1.68.0

func (c *Client) GetSuggestionPreview(ns, slug string, prID, commentID int) (string, error)

GetSuggestionPreview fetches the comment body text from Bitbucket Server and returns it so the caller can display the suggestion without applying it.

func (*Client) GetWebhook added in v1.15.0

func (c *Client) GetWebhook(ns, slug, id string) (backend.Webhook, error)

func (*Client) GrantProjectPermission added in v1.37.0

func (c *Client) GrantProjectPermission(_ context.Context, project string, subject backend.PermissionSubject, perm string) error

GrantProjectPermission grants (or upgrades/downgrades) a user or group permission on a project.

func (*Client) GrantRepoPermission added in v1.37.0

func (c *Client) GrantRepoPermission(_ context.Context, project, slug string, subject backend.PermissionSubject, perm string) error

GrantRepoPermission grants (or upgrades/downgrades) a user or group permission on a repository.

func (*Client) ListAdminUsers added in v1.101.0

func (c *Client) ListAdminUsers(filter string, limit int) ([]backend.AdminUser, error)

ListAdminUsers returns admin users on Bitbucket Server/DC, optionally filtered by a query string. GET /rest/api/1.0/admin/users?filter=QUERY&limit=N&start=P

func (*Client) ListAnnotations added in v1.23.0

func (c *Client) ListAnnotations(project, slug, hash, key string) ([]backend.CodeInsightsAnnotation, error)

ListAnnotations returns all annotations under a given report key.

func (*Client) ListBranchProtections added in v1.17.0

func (c *Client) ListBranchProtections(ns, slug string, limit int) ([]backend.BranchProtection, error)

ListBranchProtections lists branch restrictions for the given repo.

func (*Client) ListBranches

func (c *Client) ListBranches(ns, slug string, limit int) ([]backend.Branch, error)

func (*Client) ListCommentReactions added in v1.40.0

func (c *Client) ListCommentReactions(ns, slug string, prID, commentID int) ([]backend.CommentReaction, error)

ListCommentReactions lists the reactions on a pull-request comment, grouped by emoji.

API: GET /rest/api/1.0/projects/{ns}/repos/{slug}/pull-requests/{prID}/comments/{commentID}/reactions

func (*Client) ListCommitCommentReactions added in v1.41.0

func (c *Client) ListCommitCommentReactions(ns, slug, hash string, commentID int) ([]backend.CommentReaction, error)

ListCommitCommentReactions lists the reactions on a commit comment, grouped by emoji.

API: GET /rest/api/1.0/projects/{ns}/repos/{slug}/commits/{hash}/comments/{commentID}/reactions

func (*Client) ListCommitComments added in v1.27.0

func (c *Client) ListCommitComments(ns, slug, hash string, limit int) ([]backend.CommitComment, error)

ListCommitComments lists all comments on a commit using the standard Bitbucket Server paged response. Uses paging.Collect to handle pagination.

func (*Client) ListCommitFiles added in v1.55.0

func (c *Client) ListCommitFiles(ns, slug, hash string) ([]backend.DiffStatEntry, error)

ListCommitFiles returns the files changed in a specific commit. Server endpoint: GET /rest/api/1.0/projects/{ns}/repos/{slug}/commits/{hash}/changes

func (*Client) ListCommitStatuses added in v1.6.0

func (c *Client) ListCommitStatuses(_, _, hash string) ([]backend.CommitStatus, error)

ListCommitStatuses lists build / CI statuses reported against a commit hash. Bitbucket Server / Data Center exposes these on a separate REST root, /rest/build-status/1.0, rather than the regular /rest/api/1.0 base.

The ns/slug arguments are unused by the Server build-status API (statuses are keyed only by commit hash) but are kept for interface symmetry.

func (*Client) ListCommits

func (c *Client) ListCommits(ns, slug, branch string, limit int) ([]backend.Commit, error)

func (*Client) ListDefaultReviewers added in v1.50.0

func (c *Client) ListDefaultReviewers(ns, slug string) ([]backend.DefaultReviewer, error)

ListDefaultReviewers returns all configured default reviewers for a repository. GET /rest/default-reviewers/1.0/projects/{ns}/repos/{slug}/reviewers

func (*Client) ListDeployKeys added in v1.47.0

func (c *Client) ListDeployKeys(ns, slug string) ([]backend.DeployKey, error)

ListDeployKeys returns all deploy keys for a repository. GET /rest/api/1.0/projects/{ns}/repos/{slug}/ssh

func (*Client) ListGroupMembers added in v1.95.0

func (c *Client) ListGroupMembers(groupName string, limit int) ([]backend.GroupMember, error)

ListGroupMembers returns the members of the named admin group.

func (*Client) ListGroups added in v1.95.0

func (c *Client) ListGroups(filter string, limit int) ([]backend.Group, error)

ListGroups returns admin groups on Bitbucket Server/DC, optionally filtered by a name prefix.

func (*Client) ListMirrorServers added in v1.113.0

func (c *Client) ListMirrorServers(limit int) ([]backend.MirrorServer, error)

ListMirrorServers returns all Smart Mirror servers. GET /rest/mirroring/latest/mirrorServers

func (*Client) ListMirroredRepos added in v1.113.0

func (c *Client) ListMirroredRepos(mirrorID string, limit int) ([]backend.MirroredRepo, error)

ListMirroredRepos returns all repos mirrored by the given mirror server. GET /rest/mirroring/latest/mirrorServers/{mirrorID}/repos

func (*Client) ListMyPRs added in v1.28.0

func (c *Client) ListMyPRs(ns, slug string) ([]backend.MyPREntry, error)

ListMyPRs returns the authenticated user's open PRs. REVIEWER PRs come from /inbox/pull-requests. AUTHOR PRs come from the scoped repo endpoint filtered by author slug.

func (*Client) ListPATs added in v1.99.0

func (c *Client) ListPATs(userSlug string, limit int) ([]backend.PAT, error)

ListPATs returns all personal access tokens for the given user on Bitbucket Server/DC.

func (*Client) ListPRComments added in v1.6.0

func (c *Client) ListPRComments(ns, slug string, id int) ([]backend.PRComment, error)

func (*Client) ListPRCommits added in v1.56.0

func (c *Client) ListPRCommits(ns, slug string, prID int) ([]backend.Commit, error)

ListPRCommits returns the commits in a pull request, paginated.

func (*Client) ListPRFiles added in v1.57.0

func (c *Client) ListPRFiles(ns, slug string, prID int) ([]backend.DiffStatEntry, error)

ListPRFiles returns the files changed in a pull request, paginated. Server endpoint: GET /rest/api/1.0/projects/{ns}/repos/{slug}/pull-requests/{id}/changes

func (*Client) ListPRParticipants added in v1.60.0

func (c *Client) ListPRParticipants(ns, slug string, prID int) ([]backend.PRParticipant, error)

ListPRParticipants returns the participants of a pull request. Server endpoint: GET /rest/api/1.0/projects/{ns}/repos/{slug}/pull-requests/{id}/participants

func (*Client) ListPRs

func (c *Client) ListPRs(ns, slug, state string, limit int) ([]backend.PullRequest, error)

func (*Client) ListProjectPermissions added in v1.37.0

func (c *Client) ListProjectPermissions(_ context.Context, project string) ([]backend.PermissionGrant, error)

ListProjectPermissions returns all user and group permission grants for the given project, merged and sorted by permission level then subject name.

func (*Client) ListRepoForks added in v1.64.0

func (c *Client) ListRepoForks(ns, slug string, limit int) ([]backend.Repository, error)

ListRepoForks lists forks of a repository on Bitbucket Server / Data Center. limit controls the maximum number of results (0 = no cap).

func (*Client) ListRepoHooks added in v1.129.0

func (c *Client) ListRepoHooks(project, slug string) ([]backend.RepoHook, error)

ListRepoHooks returns all plugin hook scripts installed on a repository.

func (*Client) ListRepoLabels added in v1.100.0

func (c *Client) ListRepoLabels(ns, slug string) ([]backend.RepoLabel, error)

ListRepoLabels fetches all labels for a Server/DC repository.

func (*Client) ListRepoPermissions added in v1.37.0

func (c *Client) ListRepoPermissions(_ context.Context, project, slug string) ([]backend.PermissionGrant, error)

ListRepoPermissions returns all user and group permission grants for the given repository, merged and sorted by permission level then subject name.

func (*Client) ListRepoWatchers added in v1.58.0

func (c *Client) ListRepoWatchers(ns, slug string) ([]backend.User, error)

ListRepoWatchers returns all users watching a repository. Server endpoint: GET /rest/api/1.0/projects/{ns}/repos/{slug}/watchers

func (*Client) ListReports added in v1.23.0

func (c *Client) ListReports(project, slug, hash string) ([]backend.CodeInsightsReport, error)

ListReports returns all Code Insights reports attached to a commit.

func (*Client) ListRepos

func (c *Client) ListRepos(_ string, limit int) ([]backend.Repository, error)

ListRepos lists all repositories accessible to the authenticated user. ns is ignored for Bitbucket Server (the REST API lists across all projects).

func (*Client) ListReviewerGroups added in v1.69.0

func (c *Client) ListReviewerGroups(ns, slug string) ([]backend.ReviewerGroup, error)

ListReviewerGroups returns all reviewer-group conditions for a repository. GET /rest/default-reviewers/1.0/projects/{ns}/repos/{slug}/conditions

func (*Client) ListSSHKeys added in v1.109.0

func (c *Client) ListSSHKeys() ([]backend.SSHKey, error)

ListSSHKeys returns all SSH keys for the current user. GET /rest/ssh/1.0/keys

func (*Client) ListServerProjects added in v1.98.0

func (c *Client) ListServerProjects(filter string, limit int) ([]backend.ServerProject, error)

ListServerProjects returns projects on Bitbucket Server/DC, optionally filtered by a name prefix.

func (*Client) ListTags

func (c *Client) ListTags(ns, slug string, limit int) ([]backend.Tag, error)

func (*Client) ListTree added in v1.22.0

func (c *Client) ListTree(ns, slug, ref, pathInRepo string) ([]backend.TreeEntry, error)

ListTree returns the immediate children of pathInRepo at ref. Server's /browse endpoint nests the entries under "children.values" with its standard {start, isLastPage, nextPageStart} pagination, but the transport's serverPaginator inspects the top-level fields — which Server replicates at the outer level too. Iterating with GetAllJSON + re-decoding the children block per page covers both single- and multi-page directories.

func (*Client) ListWebhooks added in v1.15.0

func (c *Client) ListWebhooks(ns, slug string) ([]backend.Webhook, error)

func (*Client) MergePR

func (c *Client) MergePR(ns, slug string, id int, in backend.MergePRInput) (backend.PullRequest, error)

MergePR merges a pull request. Bitbucket Server uses optimistic concurrency: the POST body must include the current PR version (from GET), otherwise the server returns HTTP 409.

func (*Client) PutFile added in v1.102.0

func (c *Client) PutFile(ns, slug, path string, in backend.PutFileInput) error

PutFile creates or updates a file on a branch via the Bitbucket Server browse endpoint. PUT /rest/api/1.0/projects/{ns}/repos/{slug}/browse/{path} with a multipart/form-data body containing:

  • content — the file's raw content
  • branch — the target branch name
  • message — the commit message
  • sourceCommitId — (optional) expected HEAD SHA for conflict detection

func (*Client) ReadyPR

func (c *Client) ReadyPR(ns, slug string, id int) error

ReadyPR marks a draft pull request as ready for review.

Bitbucket Server's PUT endpoint for a PR requires the full PR object (title, fromRef, toRef, ...), so we GET the current PR first, flip the draft flag, and PUT the full body back.

func (*Client) RemoveCommentReaction added in v1.40.0

func (c *Client) RemoveCommentReaction(ns, slug string, prID, commentID int, emoji string) error

RemoveCommentReaction removes an emoji reaction from a pull-request comment.

API: DELETE /rest/api/1.0/projects/{ns}/repos/{slug}/pull-requests/{prID}/comments/{commentID}/reactions/{emoji}

func (*Client) RemoveCommitCommentReaction added in v1.41.0

func (c *Client) RemoveCommitCommentReaction(ns, slug, hash string, commentID int, emoji string) error

RemoveCommitCommentReaction removes an emoji reaction from a commit comment.

API: DELETE /rest/api/1.0/projects/{ns}/repos/{slug}/commits/{hash}/comments/{commentID}/reactions/{emoji}

func (*Client) RemoveDefaultReviewer added in v1.50.0

func (c *Client) RemoveDefaultReviewer(ns, slug, userSlug string) error

RemoveDefaultReviewer removes a default reviewer from a repository. DELETE /rest/default-reviewers/1.0/projects/{ns}/repos/{slug}/reviewers/{userSlug}

func (*Client) RemoveGroupMember added in v1.95.0

func (c *Client) RemoveGroupMember(groupName, user string) error

RemoveGroupMember removes user from the named admin group.

func (*Client) RemoveReviewers added in v1.76.0

func (c *Client) RemoveReviewers(ns, slug string, id int, users []string) error

RemoveReviewers removes the given users from a pull request's reviewer list. Server exposes DELETE /pull-requests/{id}/participants/{userSlug} per user. A 404 (user is not a participant) is silently ignored.

func (*Client) RenameRepo added in v1.16.0

func (c *Client) RenameRepo(ns, slug, newName string) (backend.Repository, error)

func (*Client) RenameUser added in v1.101.0

func (c *Client) RenameUser(slug, newSlug string) error

RenameUser renames a user (changes their username/slug). PUT /rest/api/1.0/admin/users with body {"name": "new-slug"}

func (*Client) ReopenPR added in v1.21.0

func (c *Client) ReopenPR(ns, slug string, id int) error

ReopenPR reverses a decline, returning the PR to OPEN.

Bitbucket Server uses optimistic concurrency on its PR lifecycle endpoints: the POST body must include the current PR version (from GET), otherwise the server returns HTTP 409 "Pull request was updated…" against any non-zero- version declined PR. Mirrors MergePR's GET-then-POST(version) pattern.

func (*Client) ReportCommitStatus added in v1.59.0

func (c *Client) ReportCommitStatus(_, _, hash string, input backend.CommitStatusInput) (backend.CommitStatus, error)

ReportCommitStatus posts a build status against a commit hash. Bitbucket Server / Data Center exposes this on the separate REST root, /rest/build-status/1.0. The ns/slug arguments are unused (statuses are keyed only by commit hash) but are kept for interface symmetry.

func (*Client) RequestReview

func (c *Client) RequestReview(ns, slug string, id int, users []string) error

func (*Client) RevokePAT added in v1.99.0

func (c *Client) RevokePAT(userSlug, tokenID string) error

RevokePAT deletes a personal access token by ID for the given user.

func (*Client) RevokeProjectPermission added in v1.37.0

func (c *Client) RevokeProjectPermission(_ context.Context, project string, subject backend.PermissionSubject) error

RevokeProjectPermission removes any permission grant a user or group has on a project.

func (*Client) RevokeRepoPermission added in v1.37.0

func (c *Client) RevokeRepoPermission(_ context.Context, project, slug string, subject backend.PermissionSubject) error

RevokeRepoPermission removes any permission grant a user or group has on a repository.

func (*Client) RotateSecrets added in v1.38.0

func (c *Client) RotateSecrets() error

RotateSecrets rotates the cluster's internal HTTPS secret. POST /rest/api/1.0/admin/secrets — no request body; 200 OK = success.

func (*Client) SearchCommits added in v1.135.0

func (c *Client) SearchCommits(ns, slug string, opts backend.CommitSearchOpts) ([]backend.Commit, error)

SearchCommits fetches commits from the Server API and filters them client-side. Server's REST API does not support full-text message search, so we fetch with optional author/since/until params and filter by message query locally.

func (*Client) SetBanner added in v1.103.0

func (c *Client) SetBanner(in backend.BannerConfig) error

SetBanner creates or replaces the site-wide announcement banner. PUT /rest/api/1.0/admin/banner

func (*Client) SetLoggingConfig added in v1.38.0

func (c *Client) SetLoggingConfig(in backend.LoggingConfigInput) error

SetLoggingConfig updates the log level and/or async-logging setting. If in.Persistent is true: PUT /rest/api/1.0/admin/logging/properties Otherwise: PUT /rest/api/1.0/admin/logging

func (*Client) SetMailServerConfig added in v1.102.0

func (c *Client) SetMailServerConfig(in backend.MailServerConfig) error

SetMailServerConfig writes a new mail-server configuration. PUT /rest/api/1.0/admin/mail-server

func (*Client) SetMergeCheck added in v1.23.0

func (c *Client) SetMergeCheck(project, slug, key string, in backend.MergeCheckInput) error

SetMergeCheck creates or replaces a merge-check configuration. Uses the partly-undocumented /rest/insights/latest/.../merge-check/ path.

func (*Client) SetPRCommentState added in v1.39.0

func (c *Client) SetPRCommentState(ns, slug string, id, commentID int, state string) error

SetPRCommentState sets the state of a task comment (BLOCKER severity) on a pull request. It first fetches the current comment to get the version token (GET), then issues a PUT with the new state and the fetched version. state must be "OPEN" or "RESOLVED".

func (*Client) SetRateLimitConfig added in v1.134.0

func (c *Client) SetRateLimitConfig(in backend.RateLimitConfig) error

SetRateLimitConfig writes a new rate-limiting configuration. PUT /rest/api/1.0/admin/rate-limiting — 204 No Content on success.

func (*Client) SetRepoDefaultBranch added in v1.85.0

func (c *Client) SetRepoDefaultBranch(ns, slug, branch string) error

SetRepoDefaultBranch sets the default branch of a repository. Server: PUT /rest/api/1.0/projects/{project}/repos/{slug} body: {"defaultBranch": "branch"}

func (*Client) SetRepoHookSettings added in v1.129.0

func (c *Client) SetRepoHookSettings(project, slug, hookKey string, cfg json.RawMessage) error

SetRepoHookSettings replaces the opaque JSON settings for a hook script.

func (*Client) SetRepoVisibility added in v1.65.0

func (c *Client) SetRepoVisibility(ns, slug string, isPrivate bool) error

func (*Client) SetReport added in v1.23.0

func (c *Client) SetReport(project, slug, hash, key string, in backend.CodeInsightsReportInput) (backend.CodeInsightsReport, error)

SetReport creates or replaces a Code Insights report (PUT / upsert).

func (*Client) StopPipeline added in v1.90.0

func (c *Client) StopPipeline(_, _, _ string) error

StopPipeline always returns ErrUnsupportedOnHost because Bitbucket Server does not have a Pipelines API.

func (*Client) SubmitReview added in v1.25.0

func (c *Client) SubmitReview(ns, slug string, id int, in backend.SubmitReviewInput) error

SubmitReview implements backend.PRReviewer for Bitbucket Server / DC. Mirrors the Cloud sequence (body → inline → action) but rejects "request_changes" up front with a typed ErrUnsupportedOnHost — Server has no equivalent endpoint.

func (*Client) TransferRepo added in v1.52.0

func (c *Client) TransferRepo(ns, slug, target string) (backend.Repository, error)

TransferRepo transfers a Server repository to another project. PUT /rest/api/1.0/projects/{ns}/repos/{slug}

func (*Client) UnapprovePR

func (c *Client) UnapprovePR(ns, slug string, id int) error

UnapprovePR removes the authenticated user's approval from a pull request. Mirrors the approve endpoint: DELETE .../approve (not DELETE .../participants/~, which requires an actual user slug and is rejected by Bitbucket Server).

func (*Client) UnreadyPR added in v1.75.0

func (c *Client) UnreadyPR(ns, slug string, id int) error

UnreadyPR marks an open pull request as draft (Server 8.0+).

Bitbucket Server's PUT endpoint for a PR requires the full PR object (title, fromRef, toRef, ...), so we GET the current PR first, flip the draft flag to true, and PUT the full body back.

func (*Client) UpdatePR

func (c *Client) UpdatePR(ns, slug string, id int, in backend.UpdatePRInput) (backend.PullRequest, error)

func (*Client) UpdatePRBranch added in v1.28.0

func (c *Client) UpdatePRBranch(ns, slug string, prID int) error

UpdatePRBranch rebases a PR's source branch onto its base branch. POST /rest/api/1.0/projects/{key}/repos/{slug}/pull-requests/{prID}/rebase 200 OK on success.

func (*Client) UpdateRepoLabel added in v1.100.0

func (c *Client) UpdateRepoLabel(ns, slug string, id int, in backend.UpdateRepoLabelInput) (backend.RepoLabel, error)

UpdateRepoLabel updates an existing label on a Server/DC repository.

func (*Client) UpdateRepoPRSettings added in v1.94.0

func (c *Client) UpdateRepoPRSettings(ns, slug string, in backend.RepoPRSettingsInput) (backend.RepoPRSettings, error)

UpdateRepoPRSettings updates the pull-request gate settings for a repository on Bitbucket Server / Data Center. Nil pointer fields in in are left unchanged by first fetching the current settings and merging the non-nil fields.

func (*Client) UpdateServerProject added in v1.98.0

func (c *Client) UpdateServerProject(key string, in backend.UpdateServerProjectInput) (backend.ServerProject, error)

UpdateServerProject patches a project on Bitbucket Server/DC. Only non-nil fields in in are changed.

type HTTPClient

type HTTPClient = httpx.Doer

HTTPClient is the transport interface for making HTTP requests. It is retained as an alias at the package boundary so callers in this repository continue to compile without importing the internal httpx package.

type PagedResponse

type PagedResponse[T any] struct {
	Values        []T  `json:"values"`
	Size          int  `json:"size"`
	IsLastPage    bool `json:"isLastPage"`
	NextPageStart *int `json:"nextPageStart"`
	Start         int  `json:"start"`
}

PagedResponse is the Bitbucket Data Center paged list envelope.

Directories

Path Synopsis
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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