bitbucket

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeResponse

func DecodeResponse(resp *http.Response, v interface{}) error

func ReadRawBody

func ReadRawBody(resp *http.Response) (string, error)

Types

type Branch

type Branch struct {
	Name string `json:"name"`
}

type Client

type Client interface {
	Get(ctx context.Context, path string, query url.Values) (*http.Response, error)
	Post(ctx context.Context, path string, body interface{}) (*http.Response, error)
	Put(ctx context.Context, path string, body interface{}) (*http.Response, error)
	Delete(ctx context.Context, path string) (*http.Response, error)
}

type Comment

type Comment struct {
	ID        int       `json:"id"`
	Content   Content   `json:"content"`
	User      User      `json:"user"`
	CreatedOn time.Time `json:"created_on"`
	UpdatedOn time.Time `json:"updated_on"`
	Inline    *Inline   `json:"inline,omitempty"`
}

type Commit

type Commit struct {
	Hash string `json:"hash"`
}

type Content

type Content struct {
	Raw    string `json:"raw"`
	Markup string `json:"markup"`
	HTML   string `json:"html"`
}

type CreatePRRequest

type CreatePRRequest struct {
	Title             string `json:"title"`
	Description       string `json:"description,omitempty"`
	Source            Ref    `json:"source"`
	Destination       Ref    `json:"destination"`
	CloseSourceBranch bool   `json:"close_source_branch"`
	Reviewers         []User `json:"reviewers,omitempty"`
}

type HTTPClient

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

func NewClient

func NewClient(authProvider auth.Provider) *HTTPClient

func (*HTTPClient) Delete

func (c *HTTPClient) Delete(ctx context.Context, path string) (*http.Response, error)

func (*HTTPClient) Get

func (c *HTTPClient) Get(ctx context.Context, path string, query url.Values) (*http.Response, error)

func (*HTTPClient) Post

func (c *HTTPClient) Post(ctx context.Context, path string, body interface{}) (*http.Response, error)

func (*HTTPClient) Put

func (c *HTTPClient) Put(ctx context.Context, path string, body interface{}) (*http.Response, error)

type Inline

type Inline struct {
	Path string `json:"path"`
	From *int   `json:"from,omitempty"`
	To   *int   `json:"to,omitempty"`
}
type Link struct {
	Href string `json:"href"`
}
type Links struct {
	Self   *Link `json:"self,omitempty"`
	HTML   *Link `json:"html,omitempty"`
	Avatar *Link `json:"avatar,omitempty"`
}

type ListPRsOpts

type ListPRsOpts struct {
	State string
	Page  int
}

type MergeOpts

type MergeOpts struct {
	MergeStrategy     string `json:"merge_strategy,omitempty"`
	CloseSourceBranch *bool  `json:"close_source_branch,omitempty"`
	Message           string `json:"message,omitempty"`
}

type PR

type PR struct {
	ID                int           `json:"id"`
	Title             string        `json:"title"`
	Description       string        `json:"description"`
	State             string        `json:"state"`
	Author            User          `json:"author"`
	Source            Ref           `json:"source"`
	Destination       Ref           `json:"destination"`
	CloseSourceBranch bool          `json:"close_source_branch"`
	CreatedOn         time.Time     `json:"created_on"`
	UpdatedOn         time.Time     `json:"updated_on"`
	MergeCommit       *Commit       `json:"merge_commit,omitempty"`
	CommentCount      int           `json:"comment_count"`
	TaskCount         int           `json:"task_count"`
	Reviewers         []User        `json:"reviewers"`
	Participants      []Participant `json:"participants"`
	Links             Links         `json:"links"`
}

type PRService

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

func NewPRService

func NewPRService(client Client, workspace, repoSlug string) *PRService

func (*PRService) AddComment

func (s *PRService) AddComment(ctx context.Context, id int, body string) (*Comment, error)

func (*PRService) Approve

func (s *PRService) Approve(ctx context.Context, id int) error

func (*PRService) Create

func (s *PRService) Create(ctx context.Context, req CreatePRRequest) (*PR, error)

func (*PRService) Decline

func (s *PRService) Decline(ctx context.Context, id int) (*PR, error)

func (*PRService) Diff

func (s *PRService) Diff(ctx context.Context, id int) (string, error)

func (*PRService) Get

func (s *PRService) Get(ctx context.Context, id int) (*PR, error)

func (*PRService) List

func (s *PRService) List(ctx context.Context, opts ListPRsOpts) (*Paginated[PR], error)

func (*PRService) ListComments

func (s *PRService) ListComments(ctx context.Context, id int) (*Paginated[Comment], error)

func (*PRService) Merge

func (s *PRService) Merge(ctx context.Context, id int, opts MergeOpts) (*PR, error)

func (*PRService) Unapprove

func (s *PRService) Unapprove(ctx context.Context, id int) error

type Paginated

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

type Participant

type Participant struct {
	User     User   `json:"user"`
	Role     string `json:"role"`
	Approved bool   `json:"approved"`
	State    string `json:"state"`
}

type RawResponse added in v0.2.0

type RawResponse struct {
	Response *http.Response
}

type Ref

type Ref struct {
	Branch     Branch     `json:"branch"`
	Repository Repository `json:"repository"`
}

type Repository

type Repository struct {
	FullName string `json:"full_name"`
	Name     string `json:"name"`
	UUID     string `json:"uuid"`
	Links    Links  `json:"links"`
}

type User

type User struct {
	DisplayName string `json:"display_name"`
	UUID        string `json:"uuid"`
	Nickname    string `json:"nickname"`
	AccountID   string `json:"account_id"`
	Links       Links  `json:"links"`
}

Jump to

Keyboard shortcuts

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