Help us shape the future of Go! Take the 2026 Go Developer Survey

bitbucket

package
v0.3.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(resp *http.Response) error

Helper to check response status

func DefaultContext

func DefaultContext() context.Context

Context helper

Types

type Branch

type Branch struct {
	Name   string
	Target string
}

Branch represents a simplified branch structure

type Client

type Client struct {
	*bitbucket.Client
	// contains filtered or unexported fields
}

Client wraps the generated Bitbucket client with authentication

func NewClient

func NewClient() (*Client, error)

NewClient creates a new authenticated Bitbucket API client

func NewClientOptional

func NewClientOptional() *Client

NewClientOptional returns an authenticated client, or nil when no credentials are configured (no BITBUCKET_API_TOKEN and no stored OAuth tokens). Useful for callers that treat Bitbucket access as optional.

func NewUnauthenticatedClient

func NewUnauthenticatedClient() (*Client, error)

NewUnauthenticatedClient creates a client without authentication (for public endpoints)

func (*Client) CreateRepository

func (c *Client) CreateRepository(ctx context.Context, workspace, name string, isPrivate bool, description string) (string, error)

CreateRepository creates a repository and returns its SSH clone URL.

func (*Client) GetRepository

func (c *Client) GetRepository(ctx context.Context, workspace, slug string) (*Repository, error)

GetRepository returns a single repository by workspace and slug.

func (*Client) GetURL

func (c *Client) GetURL(ctx context.Context, url string) (*http.Response, error)

GetURL makes an authenticated GET request to an arbitrary URL. Used to follow Bitbucket pagination "next" links.

func (*Client) ListRepositories

func (c *Client) ListRepositories(ctx context.Context, workspace string) ([]Repository, error)

ListRepositories returns all repositories in a workspace, following pagination.

func (*Client) Request

func (c *Client) Request(ctx context.Context, method, path string, body interface{}) (*http.Response, error)

Request makes an authenticated request with an optional JSON body and returns the raw response. It routes through the same credential/refresh layer as the generated client, and is used for Bitbucket endpoints the generated client doesn't cover (e.g. pipeline/repository variables). A path beginning with "http" is used verbatim; otherwise it is resolved against the API base URL.

func (*Client) RequestRaw

func (c *Client) RequestRaw(ctx context.Context, method, path, contentType string, body io.Reader) (*http.Response, error)

RequestRaw is like Request but sends a pre-encoded body with an explicit content type (e.g. multipart/form-data), for endpoints the generated client doesn't cover that aren't simple JSON.

type Pipeline

type Pipeline struct {
	UUID        string
	BuildNum    int
	State       string
	Result      string
	CreatedOn   string
	CompletedOn string
	Duration    int
	Target      string
}

Pipeline represents a simplified pipeline structure

type PullRequest

type PullRequest struct {
	ID          int
	Title       string
	Description string
	State       string
	Author      string
	Source      string
	Destination string
	CreatedOn   string
	UpdatedOn   string
}

PullRequest represents a simplified PR structure

type RepoContext

type RepoContext struct {
	Workspace string
	RepoSlug  string
}

Workspace/repo context helper

func ParseRepoContext

func ParseRepoContext(fullName string) (*RepoContext, error)

ParseRepoContext parses "workspace/repo" format

type Repository

type Repository struct {
	Slug        string    `json:"slug"`
	Name        string    `json:"name"`
	FullName    string    `json:"full_name"`
	Description string    `json:"description"`
	IsPrivate   bool      `json:"is_private"`
	UpdatedOn   time.Time `json:"updated_on"`
	CreatedOn   time.Time `json:"created_on"`
	SCM         string    `json:"scm"`
	Links       struct {
		Clone []struct {
			Href string `json:"href"`
			Name string `json:"name"`
		} `json:"clone"`
		HTML struct {
			Href string `json:"href"`
		} `json:"html"`
	} `json:"links"`
	Mainbranch struct {
		Name string `json:"name"`
	} `json:"mainbranch"`
	Workspace struct {
		Slug string `json:"slug"`
	} `json:"workspace"`
}

Repository is a Bitbucket repository as returned by the 2.0 REST API.

func (*Repository) HTTPSCloneURL

func (r *Repository) HTTPSCloneURL() string

HTTPSCloneURL returns the HTTPS clone URL, or "" if none is present.

func (*Repository) IsArchived

func (r *Repository) IsArchived() bool

IsArchived reports whether the repo name or slug carries an archived/deprecated prefix.

func (*Repository) IsStale

func (r *Repository) IsStale(threshold time.Duration) bool

IsStale reports whether the repo hasn't been updated within the given duration.

func (*Repository) SSHCloneURL

func (r *Repository) SSHCloneURL() string

SSHCloneURL returns the SSH clone URL, falling back to one constructed from full_name.

Jump to

Keyboard shortcuts

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