Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get latest changes from ktrysmt:go-bitbucket:master #8

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
721741c
Bump golang.org/x/net from 0.14.0 to 0.15.0 (#253)
dependabot[bot] Sep 14, 2023
2b7cff1
Bump golang.org/x/oauth2 from 0.11.0 to 0.12.0 (#254)
dependabot[bot] Sep 19, 2023
4835597
feat: support multiple files in WriteFileBlob (commit) (#256)
peter-svensson Oct 12, 2023
7d0d083
Bump golang.org/x/oauth2 from 0.12.0 to 0.13.0 (#259)
dependabot[bot] Oct 14, 2023
6b1a577
Bump golang.org/x/net from 0.15.0 to 0.17.0 (#260)
dependabot[bot] Oct 14, 2023
6eae88d
feat: add support for webhook secrets (#261)
zachsmith1 Nov 8, 2023
3a73a00
Bump golang.org/x/net from 0.17.0 to 0.18.0 (#262)
dependabot[bot] Nov 17, 2023
697c97b
Bump golang.org/x/oauth2 from 0.13.0 to 0.14.0 (#263)
dependabot[bot] Nov 17, 2023
1d007e1
Bump golang.org/x/net from 0.18.0 to 0.19.0 (#264)
dependabot[bot] Dec 8, 2023
da461f2
Bump golang.org/x/oauth2 from 0.14.0 to 0.15.0 (#265)
dependabot[bot] Dec 8, 2023
be7ae07
feat: add comment parent id (#269)
zachsmith1 Jan 23, 2024
1849ed5
Bump golang.org/x/oauth2 from 0.15.0 to 0.16.0 (#266)
dependabot[bot] Jan 23, 2024
6e555c5
add ability to delete files (#270)
lucademian Feb 6, 2024
405e545
feat: delete comment (#272)
zachsmith1 Feb 13, 2024
f442526
Bump github.com/stretchr/testify from 1.8.4 to 1.9.0 (#274)
dependabot[bot] Mar 24, 2024
ca089ec
Bump golang.org/x/oauth2 from 0.16.0 to 0.18.0 (#275)
dependabot[bot] Mar 24, 2024
81bfa62
ListProject function for Repositories (#281)
travisnburton Apr 16, 2024
2bd57c5
Bump golang.org/x/net from 0.22.0 to 0.24.0 (#278)
dependabot[bot] Apr 23, 2024
2fc2e79
Add FromPullRequest to GetDiffStat (#282)
CescHolly Apr 23, 2024
7998d04
Bump golang.org/x/oauth2 from 0.18.0 to 0.19.0 (#279)
dependabot[bot] Apr 23, 2024
98da4fb
Bump golang.org/x/oauth2 from 0.19.0 to 0.20.0 (#283)
dependabot[bot] May 19, 2024
bfc0803
feat: Added context based execution to POST apis methods (#285)
Ash-exp May 22, 2024
499c3ec
Bump golang.org/x/net from 0.24.0 to 0.25.0 (#284)
dependabot[bot] May 25, 2024
c56d071
Add missing query parameters to GetDiff (#291)
CescHolly Aug 8, 2024
90ada25
Add user SSH keys. Add List deploy keys. Fix keyword search in List r…
fernandoStrong Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 137 additions & 22 deletions bitbucket.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package bitbucket

import "context"

type users interface {
Get(username string) (*User, error)
Followers(username string) (interface{}, error)
Expand Down Expand Up @@ -85,6 +87,7 @@ type repository interface {
type repositories interface {
ListForAccount(opt RepositoriesOptions) (interface{}, error)
ListForTeam(opt RepositoriesOptions) (interface{}, error)
ListProject(opt RepositoriesOptions) (interface{}, error)
ListPublic() (interface{}, error)
}

Expand Down Expand Up @@ -140,6 +143,7 @@ type pipelines interface {

type RepositoriesOptions struct {
Owner string `json:"owner"`
Project string `json:"project"`
Role string `json:"role"` // role=[owner|admin|contributor|member]
Page *int `json:"page"`
Keyword *string `json:"keyword"`
Expand All @@ -158,6 +162,12 @@ type RepositoryOptions struct {
HasIssues string `json:"has_issues"`
HasWiki string `json:"has_wiki"`
Project string `json:"project"`
ctx context.Context
}

func (ro *RepositoryOptions) WithContext(ctx context.Context) *RepositoryOptions {
ro.ctx = ctx
return ro
}

type RepositoryForkOptions struct {
Expand All @@ -174,6 +184,12 @@ type RepositoryForkOptions struct {
HasIssues string `json:"has_issues"`
HasWiki string `json:"has_wiki"`
Project string `json:"project"`
ctx context.Context
}

func (fo *RepositoryForkOptions) WithContext(ctx context.Context) *RepositoryForkOptions {
fo.ctx = ctx
return fo
}

type RepositoryFilesOptions struct {
Expand All @@ -191,15 +207,28 @@ type RepositoryBlobOptions struct {
Path string `json:"path"`
}

type File struct {
Path string
Name string
}

// Based on https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/src#post
type RepositoryBlobWriteOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
FilePath string `json:"filepath"`
FileName string `json:"filename"`
Author string `json:"author"`
Message string `json:"message"`
Branch string `json:"branch"`
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
FilePath string `json:"filepath"`
FileName string `json:"filename"`
Files []File `json:"files"`
FilesToDelete []string `json:"files_to_delete"`
Author string `json:"author"`
Message string `json:"message"`
Branch string `json:"branch"`
ctx context.Context
}

func (ro *RepositoryBlobWriteOptions) WithContext(ctx context.Context) *RepositoryBlobWriteOptions {
ro.ctx = ctx
return ro
}

// RepositoryRefOptions represents the options for describing a repository's refs (i.e.
Expand Down Expand Up @@ -240,7 +269,7 @@ type RepositoryBranchDeleteOptions struct {
RepoSlug string `json:"repo_slug"`
RepoUUID string `json:"uuid"`
RefName string `json:"name"`
RefUUID string `json:uuid`
RefUUID string `json:"uuid"`
}

type RepositoryBranchTarget struct {
Expand Down Expand Up @@ -285,6 +314,12 @@ type PullRequestsOptions struct {
States []string `json:"states"`
Query string `json:"query"`
Sort string `json:"sort"`
ctx context.Context
}

func (po *PullRequestsOptions) WithContext(ctx context.Context) *PullRequestsOptions {
po.ctx = ctx
return po
}

type PullRequestCommentOptions struct {
Expand All @@ -293,6 +328,13 @@ type PullRequestCommentOptions struct {
PullRequestID string `json:"id"`
Content string `json:"content"`
CommentId string `json:"-"`
Parent *int `json:"parent"`
ctx context.Context
}

func (pco *PullRequestCommentOptions) WithContext(ctx context.Context) *PullRequestCommentOptions {
pco.ctx = ctx
return pco
}

type IssuesOptions struct {
Expand All @@ -311,6 +353,12 @@ type IssuesOptions struct {
Priority string `json:"priority"`
Version string `json:"version"`
Assignee string `json:"assignee"`
ctx context.Context
}

func (io *IssuesOptions) WithContext(ctx context.Context) *IssuesOptions {
io.ctx = ctx
return io
}

type IssueCommentsOptions struct {
Expand Down Expand Up @@ -342,6 +390,12 @@ type CommitsOptions struct {
Exclude string `json:"exclude"`
CommentID string `json:"comment_id"`
Page *int `json:"page"`
ctx context.Context
}

func (cm *CommitsOptions) WithContext(ctx context.Context) *CommitsOptions {
cm.ctx = ctx
return cm
}

type CommitStatusOptions struct {
Expand All @@ -363,36 +417,59 @@ type BranchRestrictionsOptions struct {
FullSlug string `json:"full_slug"`
Name string `json:"name"`
Value interface{} `json:"value"`
ctx context.Context
}

func (b *BranchRestrictionsOptions) WithContext(ctx context.Context) *BranchRestrictionsOptions {
b.ctx = ctx
return b
}

type DiffOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Spec string `json:"spec"`
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Spec string `json:"spec"`
Context int `json:"context"`
Path string `json:"path"`
FromPullRequestID int `json:"from_pullrequest_id"`
Whitespace bool `json:"ignore_whitespace"`
Binary bool `json:"binary"`
Renames bool `json:"renames"`
Topic bool `json:"topic"`
}

type DiffStatOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Spec string `json:"spec"`
Whitespace bool `json:"ignore_whitespace"`
Merge bool `json:"merge"`
Path string `json:"path"`
Renames bool `json:"renames"`
PageNum int `json:"page"`
Pagelen int `json:"pagelen"`
MaxDepth int `json:"max_depth"`
Fields []string
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Spec string `json:"spec"`
FromPullRequestID int `json:"from_pullrequest_id"`
Whitespace bool `json:"ignore_whitespace"`
// Deprecated: Merge is deprecated use Topic
Merge bool `json:"merge"`
Path string `json:"path"`
Renames bool `json:"renames"`
Topic bool `json:"topic"`
PageNum int `json:"page"`
Pagelen int `json:"pagelen"`
MaxDepth int `json:"max_depth"`
Fields []string
}

type WebhooksOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Uuid string `json:"uuid"`
Secret string `json:"secret"`
Description string `json:"description"`
Url string `json:"url"`
Active bool `json:"active"`
Events []string `json:"events"` // EX: {'repo:push','issue:created',..} REF: https://bit.ly/3FjRHHu
ctx context.Context
}

func (wo *WebhooksOptions) WithContext(ctx context.Context) *WebhooksOptions {
wo.ctx = ctx
return wo
}

type RepositoryPipelineOptions struct {
Expand Down Expand Up @@ -424,6 +501,12 @@ type RepositoryPipelineVariableOptions struct {
Key string `json:"key"`
Value string `json:"value"`
Secured bool `json:"secured"`
ctx context.Context
}

func (rpvo *RepositoryPipelineVariableOptions) WithContext(ctx context.Context) *RepositoryPipelineVariableOptions {
rpvo.ctx = ctx
return rpvo
}

type RepositoryPipelineVariableDeleteOptions struct {
Expand Down Expand Up @@ -455,6 +538,13 @@ type DownloadsOptions struct {
RepoSlug string `json:"repo_slug"`
FilePath string `json:"filepath"`
FileName string `json:"filename"`
Files []File `json:"files"`
ctx context.Context
}

func (do *DownloadsOptions) WithContext(ctx context.Context) *DownloadsOptions {
do.ctx = ctx
return do
}

type PageRes struct {
Expand Down Expand Up @@ -512,6 +602,12 @@ type RepositoryEnvironmentOptions struct {
Name string `json:"name"`
EnvironmentType RepositoryEnvironmentTypeOption `json:"environment_type"`
Rank int `json:"rank"`
ctx context.Context
}

func (reo *RepositoryEnvironmentOptions) WithContext(ctx context.Context) *RepositoryEnvironmentOptions {
reo.ctx = ctx
return reo
}

type RepositoryEnvironmentDeleteOptions struct {
Expand Down Expand Up @@ -539,6 +635,12 @@ type RepositoryDeploymentVariableOptions struct {
Key string `json:"key"`
Value string `json:"value"`
Secured bool `json:"secured"`
ctx context.Context
}

func (rdvo *RepositoryDeploymentVariableOptions) WithContext(ctx context.Context) *RepositoryDeploymentVariableOptions {
rdvo.ctx = ctx
return rdvo
}

type RepositoryDeploymentVariableDeleteOptions struct {
Expand All @@ -554,4 +656,17 @@ type DeployKeyOptions struct {
Id int `json:"id"`
Label string `json:"label"`
Key string `json:"key"`
ctx context.Context
}

func (dk *DeployKeyOptions) WithContext(ctx context.Context) *DeployKeyOptions {
dk.ctx = ctx
return dk
}

type SSHKeyOptions struct {
Owner string `json:"owner"`
Uuid string `json:"uuid"`
Label string `json:"label"`
Key string `json:"key"`
}
2 changes: 1 addition & 1 deletion branchrestrictions.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (b *BranchRestrictions) Create(bo *BranchRestrictionsOptions) (*BranchRestr
return nil, err
}
urlStr := b.c.requestUrl("/repositories/%s/%s/branch-restrictions", bo.Owner, bo.RepoSlug)
response, err := b.c.execute("POST", urlStr, data)
response, err := b.c.executeWithContext("POST", urlStr, data, bo.ctx)
if err != nil {
return nil, err
}
Expand Down
Loading