Documentation
¶
Index ¶
- func CheckResponse(resp *http.Response) error
- func DefaultContext() context.Context
- type Branch
- type Client
- func (c *Client) CreateRepository(ctx context.Context, workspace, name string, isPrivate bool, ...) (string, error)
- func (c *Client) GetRepository(ctx context.Context, workspace, slug string) (*Repository, error)
- func (c *Client) GetURL(ctx context.Context, url string) (*http.Response, error)
- func (c *Client) ListRepositories(ctx context.Context, workspace string) ([]Repository, error)
- func (c *Client) Request(ctx context.Context, method, path string, body interface{}) (*http.Response, error)
- func (c *Client) RequestRaw(ctx context.Context, method, path, contentType string, body io.Reader) (*http.Response, error)
- type Pipeline
- type PullRequest
- type RepoContext
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
Client wraps the generated Bitbucket client with authentication
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 ¶
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 ¶
GetRepository returns a single repository by workspace and slug.
func (*Client) GetURL ¶
GetURL makes an authenticated GET request to an arbitrary URL. Used to follow Bitbucket pagination "next" links.
func (*Client) ListRepositories ¶
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 ¶
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.