api

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON(resp *http.Response, target interface{}) error

DecodeJSON reads a JSON response body into the target struct.

func Paginate

func Paginate[T any](client *Client, path string, limit int) ([]T, error)

Paginate fetches all pages of a paginated endpoint up to the given limit. If limit <= 0, all pages are fetched.

func PaginateRaw

func PaginateRaw(client *Client, path string, limit int) ([]json.RawMessage, error)

PaginateRaw fetches all pages and returns raw JSON messages for custom decoding.

func ValidateSlug

func ValidateSlug(name, value string) error

ValidateSlug checks that a path segment is safe for URL interpolation.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
	Detail     string
}

APIError represents an error from the Bitbucket API.

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the Bitbucket API client.

func NewClient

func NewClient(creds *auth.Credentials) *Client

NewClient creates a new API client with the given credentials.

func (*Client) Delete

func (c *Client) Delete(path string) (*http.Response, error)

Delete performs a DELETE request.

func (*Client) Get

func (c *Client) Get(path string) (*http.Response, error)

Get performs a GET request to the given API path.

func (*Client) GetURL

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

GetURL performs a GET request to an absolute URL (for pagination).

func (*Client) Post

func (c *Client) Post(path string, body interface{}) (*http.Response, error)

Post performs a POST request with a JSON body.

func (*Client) Put

func (c *Client) Put(path string, body interface{}) (*http.Response, error)

Put performs a PUT request with a JSON body.

type PaginatedResponse

type PaginatedResponse[T any] struct {
	Size     int    `json:"size"`
	Page     int    `json:"page"`
	PageLen  int    `json:"pagelen"`
	Next     string `json:"next"`
	Previous string `json:"previous"`
	Values   []T    `json:"values"`
}

PaginatedResponse represents a Bitbucket paginated API response.

Jump to

Keyboard shortcuts

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