bitbucket

package
v1.13.8 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBaseURL = "https://api.bitbucket.org/2.0"

DefaultBaseURL is the default base URL for the Bitbucket API.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnotationType

type AnnotationType string

AnnotationType: VULNERABILITY, CODE_SMELL, BUG

const (
	AnnotationTypeVulnerability AnnotationType = "VULNERABILITY"
	AnnotationTypeCodeSmell     AnnotationType = "CODE_SMELL"
	AnnotationTypeBug           AnnotationType = "BUG"
)

AnnotationType values.

type Client

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

Client is the Bitbucket client.

func NewClient

func NewClient(workspace, repoSlug string, opts ...ClientOption) (*Client, error)

NewClient returns a new Bitbucket client.

func (*Client) CreateReport

func (b *Client) CreateReport(ctx context.Context, commit string, r *CommitReport) (*CommitReport, error)

CreateReport creates a commit report for the given commit.

func (*Client) CreateReportAnnotations

func (b *Client) CreateReportAnnotations(ctx context.Context, commit, reportID string, annotations []ReportAnnotation) ([]ReportAnnotation, error)

func (*Client) PullRequestComments

func (b *Client) PullRequestComments(ctx context.Context, prID int) (result []PullRequestComment, err error)

PullRequestComments returns the comments of a pull request.

func (*Client) PullRequestCreateComment

func (b *Client) PullRequestCreateComment(ctx context.Context, prID int, raw string) (*PullRequestComment, error)

PullRequestCreateComment creates a comment on a pull request.

func (*Client) PullRequestUpdateComment

func (b *Client) PullRequestUpdateComment(ctx context.Context, prID, id int, raw string) (*PullRequestComment, error)

PullRequestUpdateComment updates a comment on a pull request.

type ClientOption

type ClientOption func(*Client) error

ClientOption is the option when creating a new client.

func WithProxy

func WithProxy(proxyFn func() (*url.URL, error)) ClientOption

WithProxy returns a ClientOption that sets the proxy for the client.

func WithToken

func WithToken(t *oauth2.Token) ClientOption

WithToken returns a ClientOption that sets the token for the client.

type CommitReport

type CommitReport struct {
	Title             string     `json:"title"`
	Details           string     `json:"details"`
	ReportType        ReportType `json:"report_type"`
	ExternalID        string     `json:"external_id,omitempty"`
	Reporter          string     `json:"reporter,omitempty"`
	Link              string     `json:"link,omitempty"`
	RemoteLinkEnabled bool       `json:"remote_link_enabled,omitempty"`
	LogoURL           string     `json:"logo_url,omitempty"`
	Result            Result     `json:"result,omitempty"`
	// Map of data to be reported.
	// Maximum of 10 data points.
	Data []ReportData `json:"data,omitempty"`
}

CommitReport is a report for a commit.

func (*CommitReport) AddBoolean

func (r *CommitReport) AddBoolean(title string, value bool)

AddBoolean adds a boolean data to the commit report.

func (*CommitReport) AddDate

func (r *CommitReport) AddDate(title string, value time.Time)

AddDate adds a date data to the commit report.

func (*CommitReport) AddDuration

func (r *CommitReport) AddDuration(title string, value time.Duration)

AddDuration adds a duration data to the commit report.

func (r *CommitReport) AddLink(title string, text string, u *url.URL)

AddLink adds a link data to the commit report.

func (*CommitReport) AddNumber

func (r *CommitReport) AddNumber(title string, value int64)

AddNumber adds a number data to the commit report.

func (*CommitReport) AddPercentage

func (r *CommitReport) AddPercentage(title string, value float64)

AddPercentage adds a percentage data to the commit report.

func (*CommitReport) AddText

func (r *CommitReport) AddText(title, value string)

AddText adds a text data to the commit report.

type Error

type Error struct {
	ID      string              `json:"id"`
	Message string              `json:"message"`
	Detail  string              `json:"detail"`
	Fields  map[string][]string `json:"fields"`
	Data    map[string]string   `json:"data"`
}

Error is an API error.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

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 is a paginated response.

type PullRequestComment

type PullRequestComment struct {
	Content Rendered `json:"content"`
	ID      int      `json:"id,omitempty"`
}

PullRequestComment is a comment.

type Rendered

type Rendered struct {
	Raw    string `json:"raw"`
	Markup string `json:"markup,omitempty"`
	Html   string `json:"html,omitempty"`
}

type ReportAnnotation

type ReportAnnotation struct {
	AnnotationType AnnotationType `json:"annotation_type"`
	Summary        string         `json:"summary"`
	Result         Result         `json:"result,omitempty"`
	Severity       Severity       `json:"severity,omitempty"`
	ExternalID     string         `json:"external_id,omitempty"`
	Path           string         `json:"path,omitempty"`
	Line           int            `json:"line,omitempty"`
	Details        string         `json:"details,omitempty"`
	Link           string         `json:"link,omitempty"`
}

ReportAnnotation is the annotation to be reported.

type ReportData

type ReportData struct {
	Title string `json:"title"`
	Value any    `json:"value"`
	Type  string `json:"type,omitempty"`
}

ReportData is the data to be reported.

type ReportType

type ReportType string

ReportType: SECURITY, COVERAGE, TEST, BUG

const (
	ReportTypeSecurity ReportType = "SECURITY"
	ReportTypeCoverage ReportType = "COVERAGE"
	ReportTypeTest     ReportType = "TEST"
	ReportTypeBug      ReportType = "BUG"
)

ReportType values.

type Result

type Result string

Result: PASSED, FAILED, PENDING, SKIPPED, IGNORED

const (
	ResultPassed  Result = "PASSED"
	ResultFailed  Result = "FAILED"
	ResultPending Result = "PENDING"
	ResultSkipped Result = "SKIPPED"
	ResultIgnored Result = "IGNORED"
)

Result values.

type Severity

type Severity string

Severity: LOW, MEDIUM, HIGH, CRITICAL

const (
	SeverityLow      Severity = "LOW"
	SeverityMedium   Severity = "MEDIUM"
	SeverityHigh     Severity = "HIGH"
	SeverityCritical Severity = "CRITICAL"
)

Severity values.

Jump to

Keyboard shortcuts

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