server

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

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) AddPRComment added in v1.6.0

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

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

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

func (*Client) DeclinePR

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

DeclinePR declines an open pull request.

func (*Client) DeleteBranch

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

func (*Client) DeleteRepo

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

func (*Client) DeleteTag

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

func (*Client) GetApplicationProperties

func (c *Client) GetApplicationProperties() (backend.AppProperties, error)

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

func (c *Client) GetPR(ns, slug string, id int) (backend.PullRequest, 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) ListBranches

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

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) ListPRComments added in v1.6.0

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

func (*Client) ListPRs

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

func (*Client) ListRepos

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

func (*Client) ListTags

func (c *Client) ListTags(ns, slug string, limit int) ([]backend.Tag, 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) RequestReview

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

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

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

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.

Jump to

Keyboard shortcuts

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