server

package
v1.83.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 15 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) 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) AddPRComment added in v1.6.0

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

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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) GetRepo

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

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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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.

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