forked from ktrysmt/go-bitbucket
/
bitbucket.go
191 lines (168 loc) · 6.35 KB
/
bitbucket.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
package bitbucket
var apiBaseURL = "https://api.bitbucket.org/2.0"
func GetApiBaseURL() string {
return apiBaseURL
}
func SetApiBaseURL(urlStr string) {
apiBaseURL = urlStr
}
type users interface {
Get(username string) (interface{}, error)
Followers(username string) (interface{}, error)
Following(username string) (interface{}, error)
Repositories(username string) (interface{}, error)
}
type user interface {
Profile() (interface{}, error)
Emails() (interface{}, error)
}
type pullrequests interface {
Create(opt PullRequestsOptions) (interface{}, error)
Update(opt PullRequestsOptions) (interface{}, error)
List(opt PullRequestsOptions) (interface{}, error)
Get(opt PullRequestsOptions) (interface{}, error)
Activities(opt PullRequestsOptions) (interface{}, error)
Activity(opt PullRequestsOptions) (interface{}, error)
Commits(opt PullRequestsOptions) (interface{}, error)
Patch(opt PullRequestsOptions) (interface{}, error)
Diff(opt PullRequestsOptions) (interface{}, error)
Merge(opt PullRequestsOptions) (interface{}, error)
Decline(opt PullRequestsOptions) (interface{}, error)
}
type repository interface {
Get(opt RepositoryOptions) (*Repository, error)
Create(opt RepositoryOptions) (*Repository, error)
Delete(opt RepositoryOptions) (interface{}, error)
ListWatchers(opt RepositoryOptions) (interface{}, error)
ListForks(opt RepositoryOptions) (interface{}, error)
UpdatePipelineConfig(opt RepositoryPipelineOptions) (*Pipeline, error)
AddPipelineVariable(opt RepositoryPipelineVariableOptions) (*PipelineVariable, error)
AddPipelineKeyPair(opt RepositoryPipelineKeyPairOptions) (*PipelineKeyPair, error)
}
type repositories interface {
ListForAccount(opt RepositoriesOptions) (interface{}, error)
ListForTeam(opt RepositoriesOptions) (interface{}, error)
ListPublic() (interface{}, error)
}
type commits interface {
GetCommits(opt CommitsOptions) (interface{}, error)
GetCommit(opt CommitsOptions) (interface{}, error)
GetCommitComments(opt CommitsOptions) (interface{}, error)
GetCommitComment(opt CommitsOptions) (interface{}, error)
GetCommitStatus(opt CommitsOptions) (interface{}, error)
GiveApprove(opt CommitsOptions) (interface{}, error)
RemoveApprove(opt CommitsOptions) (interface{}, error)
}
type branchrestrictions interface {
Gets(opt BranchRestrictionsOptions) (interface{}, error)
Get(opt BranchRestrictionsOptions) (interface{}, error)
Create(opt BranchRestrictionsOptions) (interface{}, error)
Update(opt BranchRestrictionsOptions) (interface{}, error)
Delete(opt BranchRestrictionsOptions) (interface{}, error)
}
type diff interface {
GetDiff(opt DiffOptions) (interface{}, error)
GetPatch(opt DiffOptions) (interface{}, error)
}
type webhooks interface {
Gets(opt WebhooksOptions) (interface{}, error)
Get(opt WebhooksOptions) (interface{}, error)
Create(opt WebhooksOptions) (interface{}, error)
Update(opt WebhooksOptions) (interface{}, error)
Delete(opt WebhooksOptions) (interface{}, error)
}
type teams interface {
List(role string) (interface{}, error) // [WIP?] role=[admin|contributor|member]
Profile(teamname string) (interface{}, error)
Members(teamname string) (interface{}, error)
Followers(teamname string) (interface{}, error)
Following(teamname string) (interface{}, error)
Repositories(teamname string) (interface{}, error)
}
type RepositoriesOptions struct {
Owner string `json:"owner"`
Team string `json:"team"`
Role string `json:"role"` // role=[owner|admin|contributor|member]
}
type RepositoryOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Scm string `json:"scm"`
// Name string `json:"name"`
IsPrivate string `json:"is_private"`
Description string `json:"description"`
ForkPolicy string `json:"fork_policy"`
Language string `json:"language"`
HasIssues string `json:"has_issues"`
HasWiki string `json:"has_wiki"`
Project string `json:"project"`
}
type PullRequestsOptions struct {
ID string `json:"id"`
CommentID string `json:"comment_id"`
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Title string `json:"title"`
Description string `json:"description"`
CloseSourceBranch bool `json:"close_source_branch"`
SourceBranch string `json:"source_branch"`
SourceRepository string `json:"source_repository"`
DestinationBranch string `json:"destination_branch"`
DestinationCommit string `json:"destination_repository"`
Message string `json:"message"`
Reviewers []string `json:"reviewers"`
}
type CommitsOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Revision string `json:"revision"`
Branchortag string `json:"branchortag"`
Include string `json:"include"`
Exclude string `json:"exclude"`
CommentID string `json:"comment_id"`
}
type BranchRestrictionsOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
ID string `json:"id"`
Groups map[string]string `json:"groups"`
Pattern string `json:"pattern"`
Users []string `json:"users"`
Kind string `json:"kind"`
FullSlug string `json:"full_slug"`
Name string `json:"name"`
Value interface{} `json:"value"`
}
type DiffOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Spec string `json:"spec"`
}
type WebhooksOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Uuid string `json:"uuid"`
Description string `json:"description"`
Url string `json:"url"`
Active bool `json:"active"`
Events []string `json:"events"` // EX) {'repo:push','issue:created',..} REF) https://goo.gl/VTj93b
}
type RepositoryPipelineOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Enabled bool `json:"has_pipelines"`
}
type RepositoryPipelineVariableOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Uuid string `json:"uuid"`
Key string `json:"key"`
Value string `json:"value"`
Secured bool `json:"secured"`
}
type RepositoryPipelineKeyPairOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
PrivateKey string `json:"private_key"`
PublicKey string `json:"public_key"`
}