Documentation
¶
Overview ¶
Package server is the Bitbucket Data Center (a.k.a. "Server") adapter for the backend.Client interface.
Index ¶
- Constants
- type Client
- func (c *Client) ActivateUser(slug string) error
- func (c *Client) AddAnnotations(project, slug, hash, key string, in []backend.CodeInsightsAnnotationInput) error
- func (c *Client) AddCommentReaction(ns, slug string, prID, commentID int, emoji string) error
- func (c *Client) AddCommitComment(ns, slug, hash string, in backend.AddCommitCommentInput) (backend.CommitComment, error)
- func (c *Client) AddCommitCommentReaction(ns, slug, hash string, commentID int, emoji string) error
- func (c *Client) AddDefaultReviewer(ns, slug, userSlug string) error
- func (c *Client) AddDeployKey(ns, slug string, input backend.DeployKeyInput) (backend.DeployKey, error)
- func (c *Client) AddGroupMember(groupName, user string) error
- func (c *Client) AddPRComment(ns, slug string, id int, in backend.AddPRCommentInput) (backend.PRComment, error)
- func (c *Client) AddSSHKey(input backend.SSHKeyInput) (backend.SSHKey, error)
- func (c *Client) ApplySuggestion(ns, slug string, prID, commentID, suggestionID int) (backend.SuggestionApplyResult, error)
- func (c *Client) ApprovePR(ns, slug string, id int) error
- func (c *Client) CherryPickCommit(ns, slug string, in backend.CherryPickInput) (backend.Commit, error)
- func (c *Client) ClearBanner() error
- func (c *Client) CompareRefs(ns, slug, base, head string, limit int) (backend.RefComparison, error)
- func (c *Client) CreateBranch(ns, slug string, in backend.CreateBranchInput) (backend.Branch, error)
- func (c *Client) CreateBranchProtection(ns, slug string, in backend.CreateBranchProtectionInput) (backend.BranchProtection, error)
- func (c *Client) CreateGroup(name string) (backend.Group, error)
- func (c *Client) CreatePAT(userSlug string, in backend.CreatePATInput) (backend.PATWithSecret, error)
- func (c *Client) CreatePR(ns, slug string, in backend.CreatePRInput) (backend.PullRequest, error)
- func (c *Client) CreateRepo(ns string, in backend.CreateRepoInput) (backend.Repository, error)
- func (c *Client) CreateRepoLabel(ns, slug string, in backend.CreateRepoLabelInput) (backend.RepoLabel, error)
- func (c *Client) CreateReviewerGroup(ns, slug string, in backend.CreateReviewerGroupInput) (backend.ReviewerGroup, error)
- func (c *Client) CreateServerProject(in backend.CreateServerProjectInput) (backend.ServerProject, error)
- func (c *Client) CreateTag(ns, slug string, in backend.CreateTagInput) (backend.Tag, error)
- func (c *Client) CreateWebhook(ns, slug string, in backend.CreateWebhookInput) (backend.Webhook, error)
- func (c *Client) DeactivateUser(slug string) error
- func (c *Client) DeclinePR(ns, slug string, id int) error
- func (c *Client) DefaultReviewers(ns, slug, fromBranch, toBranch string) ([]backend.User, error)
- func (c *Client) DeleteAnnotations(project, slug, hash, key string) error
- func (c *Client) DeleteBranch(ns, slug, branch string) error
- func (c *Client) DeleteBranchProtection(ns, slug string, id int) error
- func (c *Client) DeleteCommitComment(ns, slug, hash string, commentID int) error
- func (c *Client) DeleteDeployKey(ns, slug string, id int) error
- func (c *Client) DeleteGroup(name string) error
- func (c *Client) DeleteMergeCheck(project, slug, key string) error
- func (c *Client) DeletePRComment(ns, slug string, id, commentID int) error
- func (c *Client) DeleteRepo(ns, slug string) error
- func (c *Client) DeleteRepoLabel(ns, slug string, id int) error
- func (c *Client) DeleteReport(project, slug, hash, key string) error
- func (c *Client) DeleteReviewerGroup(ns, slug string, id int) error
- func (c *Client) DeleteSSHKey(id int) error
- func (c *Client) DeleteServerProject(key string) error
- func (c *Client) DeleteTag(ns, slug, name string) error
- func (c *Client) DeleteWebhook(ns, slug, id string) error
- func (c *Client) DisableAutoMerge(ns, slug string, id int) error
- func (c *Client) DisableRepoHook(project, slug, hookKey string) error
- func (c *Client) DryRunMergePR(ns, slug string, prID int, _ string) (backend.MergeDryRunResult, error)
- func (c *Client) EditCommitComment(ns, slug, hash string, commentID int, body string) (backend.CommitComment, error)
- func (c *Client) EditPRComment(ns, slug string, id, commentID int, body string) (backend.PRComment, error)
- func (c *Client) EditRepo(ns, slug string, in backend.EditRepoInput) (backend.Repository, error)
- func (c *Client) EnableAutoMerge(ns, slug string, id int, strategy string) error
- func (c *Client) EnableRepoHook(project, slug, hookKey string) error
- func (c *Client) GetBanner() (backend.BannerConfig, error)
- func (c *Client) GetClusterNodes() ([]backend.ClusterNode, error)
- func (c *Client) GetCommit(ns, slug, hash string) (backend.Commit, error)
- func (c *Client) GetCurrentUser() (backend.User, error)
- func (c *Client) GetDiff(ns, slug, from, to string) (string, error)
- func (c *Client) GetDiffStat(ns, slug, from, to string) (backend.DiffStat, error)
- func (c *Client) GetFileContent(ns, slug, ref, pathInRepo string) ([]byte, error)
- func (c *Client) GetHostInfo() (backend.HostInfo, error)
- func (c *Client) GetLicense() (backend.AdminLicense, error)
- func (c *Client) GetLoggingConfig() (backend.LoggingConfig, error)
- func (c *Client) GetMailServerConfig() (backend.MailServerConfig, error)
- func (c *Client) GetMergeCheck(project, slug, key string) (backend.MergeCheck, error)
- func (c *Client) GetMirrorServer(id string) (backend.MirrorServer, error)
- func (c *Client) GetPR(ns, slug string, id int) (backend.PullRequest, error)
- func (c *Client) GetPRActivity(ns, slug string, id int, limit int) ([]backend.PRActivityEvent, error)
- func (c *Client) GetPRDiff(ns, slug string, id int) (string, error)
- func (c *Client) GetRateLimitConfig() (backend.RateLimitConfig, error)
- func (c *Client) GetRepo(ns, slug string) (backend.Repository, error)
- func (c *Client) GetRepoHook(project, slug, hookKey string) (backend.RepoHook, error)
- func (c *Client) GetRepoHookSettings(project, slug, hookKey string) (json.RawMessage, error)
- func (c *Client) GetRepoPRSettings(ns, slug string) (backend.RepoPRSettings, error)
- func (c *Client) GetReport(project, slug, hash, key string) (backend.CodeInsightsReport, error)
- func (c *Client) GetServerProject(key string) (backend.ServerProject, error)
- func (c *Client) GetServerVersion() backend.ServerVersion
- func (c *Client) GetSuggestionPreview(ns, slug string, prID, commentID int) (string, error)
- func (c *Client) GetWebhook(ns, slug, id string) (backend.Webhook, error)
- func (c *Client) GrantProjectPermission(_ context.Context, project string, subject backend.PermissionSubject, ...) error
- func (c *Client) GrantRepoPermission(_ context.Context, project, slug string, subject backend.PermissionSubject, ...) error
- func (c *Client) ListAdminUsers(filter string, limit int) ([]backend.AdminUser, error)
- func (c *Client) ListAnnotations(project, slug, hash, key string) ([]backend.CodeInsightsAnnotation, error)
- func (c *Client) ListBranchProtections(ns, slug string, limit int) ([]backend.BranchProtection, error)
- func (c *Client) ListBranches(ns, slug string, limit int) ([]backend.Branch, error)
- func (c *Client) ListCommentReactions(ns, slug string, prID, commentID int) ([]backend.CommentReaction, error)
- func (c *Client) ListCommitCommentReactions(ns, slug, hash string, commentID int) ([]backend.CommentReaction, error)
- func (c *Client) ListCommitComments(ns, slug, hash string, limit int) ([]backend.CommitComment, error)
- func (c *Client) ListCommitFiles(ns, slug, hash string) ([]backend.DiffStatEntry, error)
- func (c *Client) ListCommitStatuses(_, _, hash string) ([]backend.CommitStatus, error)
- func (c *Client) ListCommits(ns, slug, branch string, limit int) ([]backend.Commit, error)
- func (c *Client) ListDefaultReviewers(ns, slug string) ([]backend.DefaultReviewer, error)
- func (c *Client) ListDeployKeys(ns, slug string) ([]backend.DeployKey, error)
- func (c *Client) ListGroupMembers(groupName string, limit int) ([]backend.GroupMember, error)
- func (c *Client) ListGroups(filter string, limit int) ([]backend.Group, error)
- func (c *Client) ListMirrorServers(limit int) ([]backend.MirrorServer, error)
- func (c *Client) ListMirroredRepos(mirrorID string, limit int) ([]backend.MirroredRepo, error)
- func (c *Client) ListMyPRs(ns, slug string) ([]backend.MyPREntry, error)
- func (c *Client) ListPATs(userSlug string, limit int) ([]backend.PAT, error)
- func (c *Client) ListPRComments(ns, slug string, id int) ([]backend.PRComment, error)
- func (c *Client) ListPRCommits(ns, slug string, prID int) ([]backend.Commit, error)
- func (c *Client) ListPRFiles(ns, slug string, prID int) ([]backend.DiffStatEntry, error)
- func (c *Client) ListPRParticipants(ns, slug string, prID int) ([]backend.PRParticipant, error)
- func (c *Client) ListPRs(ns, slug, state string, limit int) ([]backend.PullRequest, error)
- func (c *Client) ListProjectPermissions(_ context.Context, project string) ([]backend.PermissionGrant, error)
- func (c *Client) ListRepoForks(ns, slug string, limit int) ([]backend.Repository, error)
- func (c *Client) ListRepoHooks(project, slug string) ([]backend.RepoHook, error)
- func (c *Client) ListRepoLabels(ns, slug string) ([]backend.RepoLabel, error)
- func (c *Client) ListRepoPermissions(_ context.Context, project, slug string) ([]backend.PermissionGrant, error)
- func (c *Client) ListRepoWatchers(ns, slug string) ([]backend.User, error)
- func (c *Client) ListReports(project, slug, hash string) ([]backend.CodeInsightsReport, error)
- func (c *Client) ListRepos(_ string, limit int) ([]backend.Repository, error)
- func (c *Client) ListReviewerGroups(ns, slug string) ([]backend.ReviewerGroup, error)
- func (c *Client) ListSSHKeys() ([]backend.SSHKey, error)
- func (c *Client) ListServerProjects(filter string, limit int) ([]backend.ServerProject, error)
- func (c *Client) ListTags(ns, slug string, limit int) ([]backend.Tag, error)
- func (c *Client) ListTree(ns, slug, ref, pathInRepo string) ([]backend.TreeEntry, error)
- func (c *Client) ListWebhooks(ns, slug string) ([]backend.Webhook, error)
- func (c *Client) MergePR(ns, slug string, id int, in backend.MergePRInput) (backend.PullRequest, error)
- func (c *Client) PutFile(ns, slug, path string, in backend.PutFileInput) error
- func (c *Client) ReadyPR(ns, slug string, id int) error
- func (c *Client) RemoveCommentReaction(ns, slug string, prID, commentID int, emoji string) error
- func (c *Client) RemoveCommitCommentReaction(ns, slug, hash string, commentID int, emoji string) error
- func (c *Client) RemoveDefaultReviewer(ns, slug, userSlug string) error
- func (c *Client) RemoveGroupMember(groupName, user string) error
- func (c *Client) RemoveReviewers(ns, slug string, id int, users []string) error
- func (c *Client) RenameRepo(ns, slug, newName string) (backend.Repository, error)
- func (c *Client) RenameUser(slug, newSlug string) error
- func (c *Client) ReopenPR(ns, slug string, id int) error
- func (c *Client) ReportCommitStatus(_, _, hash string, input backend.CommitStatusInput) (backend.CommitStatus, error)
- func (c *Client) RequestReview(ns, slug string, id int, users []string) error
- func (c *Client) RevokePAT(userSlug, tokenID string) error
- func (c *Client) RevokeProjectPermission(_ context.Context, project string, subject backend.PermissionSubject) error
- func (c *Client) RevokeRepoPermission(_ context.Context, project, slug string, subject backend.PermissionSubject) error
- func (c *Client) RotateSecrets() error
- func (c *Client) SearchCommits(ns, slug string, opts backend.CommitSearchOpts) ([]backend.Commit, error)
- func (c *Client) SetBanner(in backend.BannerConfig) error
- func (c *Client) SetLoggingConfig(in backend.LoggingConfigInput) error
- func (c *Client) SetMailServerConfig(in backend.MailServerConfig) error
- func (c *Client) SetMergeCheck(project, slug, key string, in backend.MergeCheckInput) error
- func (c *Client) SetPRCommentState(ns, slug string, id, commentID int, state string) error
- func (c *Client) SetRateLimitConfig(in backend.RateLimitConfig) error
- func (c *Client) SetRepoDefaultBranch(ns, slug, branch string) error
- func (c *Client) SetRepoHookSettings(project, slug, hookKey string, cfg json.RawMessage) error
- func (c *Client) SetRepoVisibility(ns, slug string, isPrivate bool) error
- func (c *Client) SetReport(project, slug, hash, key string, in backend.CodeInsightsReportInput) (backend.CodeInsightsReport, error)
- func (c *Client) StopPipeline(_, _, _ string) error
- func (c *Client) SubmitReview(ns, slug string, id int, in backend.SubmitReviewInput) error
- func (c *Client) TransferRepo(ns, slug, target string) (backend.Repository, error)
- func (c *Client) UnapprovePR(ns, slug string, id int) error
- func (c *Client) UnreadyPR(ns, slug string, id int) error
- func (c *Client) UpdatePR(ns, slug string, id int, in backend.UpdatePRInput) (backend.PullRequest, error)
- func (c *Client) UpdatePRBranch(ns, slug string, prID int) error
- func (c *Client) UpdateRepoLabel(ns, slug string, id int, in backend.UpdateRepoLabelInput) (backend.RepoLabel, error)
- func (c *Client) UpdateRepoPRSettings(ns, slug string, in backend.RepoPRSettingsInput) (backend.RepoPRSettings, error)
- func (c *Client) UpdateServerProject(key string, in backend.UpdateServerProjectInput) (backend.ServerProject, error)
- type HTTPClient
- type PagedResponse
Constants ¶
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
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
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
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
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
AddGroupMember adds user to the named admin group.
func (*Client) AddPRComment ¶ added in v1.6.0
func (*Client) AddSSHKey ¶ added in v1.109.0
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 ¶
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
ClearBanner removes the site-wide announcement banner. DELETE /rest/api/1.0/admin/banner
func (*Client) CompareRefs ¶ added in v1.110.0
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
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) CreateWebhook ¶ added in v1.15.0
func (*Client) DeactivateUser ¶ added in v1.101.0
DeactivateUser deactivates a user account. PUT /rest/api/1.0/admin/users with body {"active": false}
func (*Client) DefaultReviewers ¶ added in v1.17.0
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
DeleteAnnotations removes all annotations under a given report key.
func (*Client) DeleteBranch ¶
func (*Client) DeleteBranchProtection ¶ added in v1.17.0
DeleteBranchProtection removes the restriction with the given numeric ID.
func (*Client) DeleteCommitComment ¶ added in v1.27.0
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
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
DeleteGroup deletes the admin group with the given name.
func (*Client) DeleteMergeCheck ¶ added in v1.23.0
DeleteMergeCheck removes a merge-check configuration.
func (*Client) DeletePRComment ¶ added in v1.24.0
func (*Client) DeleteRepo ¶
func (*Client) DeleteRepoLabel ¶ added in v1.100.0
DeleteRepoLabel removes a label from a Server/DC repository.
func (*Client) DeleteReport ¶ added in v1.23.0
DeleteReport removes a Code Insights report and all its annotations.
func (*Client) DeleteReviewerGroup ¶ added in v1.69.0
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
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
DeleteServerProject deletes a project by key.
func (*Client) DeleteWebhook ¶ added in v1.15.0
func (*Client) DisableAutoMerge ¶ added in v1.30.0
DisableAutoMerge cancels a queued auto-merge on Bitbucket Server / DC.
func (*Client) DisableRepoHook ¶ added in v1.129.0
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 (*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
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
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) GetCurrentUser ¶
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
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
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
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
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) GetPRActivity ¶ added in v1.26.0
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) GetRepoHook ¶ added in v1.129.0
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
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 (*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
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 (*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 (*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
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
ListGroupMembers returns the members of the named admin group.
func (*Client) ListGroups ¶ added in v1.95.0
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
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
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
ListPATs returns all personal access tokens for the given user on Bitbucket Server/DC.
func (*Client) ListPRComments ¶ added in v1.6.0
func (*Client) ListPRCommits ¶ added in v1.56.0
ListPRCommits returns the commits in a pull request, paginated.
func (*Client) ListPRFiles ¶ added in v1.57.0
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
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) 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
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
ListRepoHooks returns all plugin hook scripts installed on a repository.
func (*Client) ListRepoLabels ¶ added in v1.100.0
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
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 ¶
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
ListSSHKeys returns all SSH keys for the current user. GET /rest/ssh/1.0/keys
func (*Client) ListServerProjects ¶ added in v1.98.0
ListServerProjects returns projects on Bitbucket Server/DC, optionally filtered by a name prefix.
func (*Client) ListTree ¶ added in v1.22.0
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 (*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 ¶
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
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
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
RemoveGroupMember removes user from the named admin group.
func (*Client) RemoveReviewers ¶ added in v1.76.0
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
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
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 (*Client) RevokePAT ¶ added in v1.99.0
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
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
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
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 (*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
StopPipeline always returns ErrUnsupportedOnHost because Bitbucket Server does not have a Pipelines API.
func (*Client) SubmitReview ¶ added in v1.25.0
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 ¶
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
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
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 ¶
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.
Source Files
¶
- admin.go
- branch_protect.go
- branches.go
- cherry_pick.go
- client.go
- codeinsights.go
- commit.go
- commit_comment.go
- commit_comment_reactions.go
- commit_files.go
- commit_search.go
- commit_status.go
- default_reviewers.go
- default_reviewers_mgmt.go
- deploy_keys.go
- diff.go
- group.go
- host_info.go
- mirror.go
- pat.go
- permissions.go
- pipelines.go
- pr_activity.go
- pr_comments.go
- pr_commits.go
- pr_files.go
- pr_lifecycle.go
- pr_merge_preview.go
- pr_participants.go
- pr_review.go
- pr_status.go
- pr_update_branch.go
- project_server.go
- prs.go
- reactions.go
- ref_compare.go
- repo_default_branch.go
- repo_edit.go
- repo_forks.go
- repo_hook.go
- repo_labels.go
- repo_pr_settings.go
- repo_transfer.go
- repo_watchers.go
- repos.go
- reviewer_groups.go
- source.go
- source_write.go
- ssh_keys.go
- suggestion.go
- tag.go
- version.go
- webhooks.go