atlassian-python-api 3.41.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atlassian/VERSION +1 -0
- atlassian/__init__.py +32 -0
- atlassian/bamboo.py +1343 -0
- atlassian/bitbucket/__init__.py +3572 -0
- atlassian/bitbucket/base.py +198 -0
- atlassian/bitbucket/cloud/__init__.py +24 -0
- atlassian/bitbucket/cloud/base.py +123 -0
- atlassian/bitbucket/cloud/common/__init__.py +1 -0
- atlassian/bitbucket/cloud/common/builds.py +85 -0
- atlassian/bitbucket/cloud/common/comments.py +50 -0
- atlassian/bitbucket/cloud/common/users.py +79 -0
- atlassian/bitbucket/cloud/repositories/__init__.py +437 -0
- atlassian/bitbucket/cloud/repositories/branchRestrictions.py +175 -0
- atlassian/bitbucket/cloud/repositories/commits.py +188 -0
- atlassian/bitbucket/cloud/repositories/defaultReviewers.py +94 -0
- atlassian/bitbucket/cloud/repositories/deploymentEnvironments.py +264 -0
- atlassian/bitbucket/cloud/repositories/diffstat.py +92 -0
- atlassian/bitbucket/cloud/repositories/groupPermissions.py +81 -0
- atlassian/bitbucket/cloud/repositories/hooks.py +117 -0
- atlassian/bitbucket/cloud/repositories/issues.py +164 -0
- atlassian/bitbucket/cloud/repositories/pipelines.py +274 -0
- atlassian/bitbucket/cloud/repositories/pullRequests.py +483 -0
- atlassian/bitbucket/cloud/repositories/refs.py +136 -0
- atlassian/bitbucket/cloud/repositories/repositoryVariables.py +146 -0
- atlassian/bitbucket/cloud/workspaces/__init__.py +146 -0
- atlassian/bitbucket/cloud/workspaces/members.py +62 -0
- atlassian/bitbucket/cloud/workspaces/permissions.py +125 -0
- atlassian/bitbucket/cloud/workspaces/projects.py +215 -0
- atlassian/bitbucket/server/__init__.py +46 -0
- atlassian/bitbucket/server/base.py +63 -0
- atlassian/bitbucket/server/common/__init__.py +1 -0
- atlassian/bitbucket/server/common/permissions.py +220 -0
- atlassian/bitbucket/server/globalPermissions.py +198 -0
- atlassian/bitbucket/server/projects/__init__.py +244 -0
- atlassian/bitbucket/server/projects/repos/__init__.py +327 -0
- atlassian/cloud_admin.py +32 -0
- atlassian/confluence.py +3336 -0
- atlassian/crowd.py +266 -0
- atlassian/errors.py +27 -0
- atlassian/insight.py +678 -0
- atlassian/jira.py +5324 -0
- atlassian/marketplace.py +84 -0
- atlassian/portfolio.py +108 -0
- atlassian/request_utils.py +39 -0
- atlassian/rest_client.py +558 -0
- atlassian/service_desk.py +911 -0
- atlassian/statuspage.py +3133 -0
- atlassian/utils.py +327 -0
- atlassian/xray.py +632 -0
- atlassian_python_api-3.41.13.dist-info/LICENSE +201 -0
- atlassian_python_api-3.41.13.dist-info/METADATA +261 -0
- atlassian_python_api-3.41.13.dist-info/RECORD +54 -0
- atlassian_python_api-3.41.13.dist-info/WHEEL +5 -0
- atlassian_python_api-3.41.13.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
from requests import HTTPError
|
|
4
|
+
from ..base import BitbucketCloudBase
|
|
5
|
+
from .issues import Issues
|
|
6
|
+
from .branchRestrictions import BranchRestrictions
|
|
7
|
+
from .commits import Commits
|
|
8
|
+
from .hooks import Hooks
|
|
9
|
+
from .defaultReviewers import DefaultReviewers
|
|
10
|
+
from .deploymentEnvironments import DeploymentEnvironments
|
|
11
|
+
from .groupPermissions import GroupPermissions
|
|
12
|
+
from .pipelines import Pipelines
|
|
13
|
+
from .pullRequests import PullRequests
|
|
14
|
+
from .refs import Branches, Tags
|
|
15
|
+
from .repositoryVariables import RepositoryVariables
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class RepositoriesBase(BitbucketCloudBase):
|
|
19
|
+
def __init__(self, url, *args, **kwargs):
|
|
20
|
+
super(RepositoriesBase, self).__init__(url, *args, **kwargs)
|
|
21
|
+
|
|
22
|
+
def _get_object(self, data):
|
|
23
|
+
return Repository(data, **self._new_session_args)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Repositories(RepositoriesBase):
|
|
27
|
+
def __init__(self, url, *args, **kwargs):
|
|
28
|
+
super(Repositories, self).__init__(url, *args, **kwargs)
|
|
29
|
+
|
|
30
|
+
def each(self, after=None, role=None, q=None, sort=None):
|
|
31
|
+
"""
|
|
32
|
+
Get all repositories matching the criteria.
|
|
33
|
+
|
|
34
|
+
The result can be narrowed down based on the authenticated user"s role.
|
|
35
|
+
E.g. with ?role=contributor, only those repositories that the authenticated user has write access to
|
|
36
|
+
are returned (this includes any repo the user is an admin on, as that implies write access).
|
|
37
|
+
|
|
38
|
+
:param after: string: Filter the results to include only repositories created on or after this ISO-8601
|
|
39
|
+
timestamp. Example: YYYY-MM-DDTHH:mm:ss.sssZ
|
|
40
|
+
:param role: string: Filters the workspaces based on the authenticated user"s role on each workspace.
|
|
41
|
+
* member: returns a list of all the workspaces which the caller is a member of
|
|
42
|
+
at least one workspace group or repository
|
|
43
|
+
* collaborator: returns a list of workspaces which the caller has write access
|
|
44
|
+
to at least one repository in the workspace
|
|
45
|
+
* owner: returns a list of workspaces which the caller has administrator access
|
|
46
|
+
:param q: string: Query string to narrow down the response. role parameter must also be specified.
|
|
47
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
48
|
+
:param sort: string: Name of a response property to sort results.
|
|
49
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
50
|
+
|
|
51
|
+
:return: A generator for the repository objects
|
|
52
|
+
|
|
53
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories#get
|
|
54
|
+
"""
|
|
55
|
+
if q is not None and role is None:
|
|
56
|
+
raise ValueError("Argument [q] requires argument [role].")
|
|
57
|
+
|
|
58
|
+
params = {}
|
|
59
|
+
if after is not None:
|
|
60
|
+
params["after"] = after
|
|
61
|
+
if role is not None:
|
|
62
|
+
params["role"] = role
|
|
63
|
+
if q is not None:
|
|
64
|
+
params["q"] = q
|
|
65
|
+
if sort is not None:
|
|
66
|
+
params["sort"] = sort
|
|
67
|
+
for repository in self._get_paged(None, params):
|
|
68
|
+
yield self._get_object(repository)
|
|
69
|
+
|
|
70
|
+
def get(self, workspace, repo_slug):
|
|
71
|
+
"""
|
|
72
|
+
Returns the requested repository.
|
|
73
|
+
|
|
74
|
+
Since this method accesses the repository endpoint
|
|
75
|
+
directly it is usable if you do not have permission
|
|
76
|
+
to access the workspace endpoint.
|
|
77
|
+
|
|
78
|
+
:param workspace: string: The workspace of the repository
|
|
79
|
+
:param repo_slug: string: The requested repository.
|
|
80
|
+
|
|
81
|
+
:return: The requested Repository object
|
|
82
|
+
|
|
83
|
+
API docs:
|
|
84
|
+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-get
|
|
85
|
+
"""
|
|
86
|
+
return self._get_object(super(Repositories, self).get("{}/{}".format(workspace, repo_slug)))
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class WorkspaceRepositories(RepositoriesBase):
|
|
90
|
+
ALLOW_FORKS = "allow_forks"
|
|
91
|
+
NO_PUBLIC_FORKS = "no_public_forks"
|
|
92
|
+
NO_FORKS = "no_forks"
|
|
93
|
+
FORK_POLICIES = [
|
|
94
|
+
ALLOW_FORKS,
|
|
95
|
+
NO_PUBLIC_FORKS,
|
|
96
|
+
NO_FORKS,
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
def __init__(self, url, *args, **kwargs):
|
|
100
|
+
super(WorkspaceRepositories, self).__init__(url, *args, **kwargs)
|
|
101
|
+
|
|
102
|
+
def create(self, repo_slug, project_key=None, is_private=None, fork_policy=None):
|
|
103
|
+
"""
|
|
104
|
+
Creates a new repository with the given repo_slug.
|
|
105
|
+
|
|
106
|
+
:param repo_slug: string: The repo_slug of the project.
|
|
107
|
+
:param project_key: string: The key of the project. If the project is not provided, the repository
|
|
108
|
+
is automatically assigned to the oldest project in the workspace.
|
|
109
|
+
:param is_private: boolean: Set to false if the repository shall be public.
|
|
110
|
+
:param fork_policy: string: The fork policy (one of WorkspaceRepositories.ALLOW_FORKS,
|
|
111
|
+
WorkspaceRepositories.NO_PUBLIC_FORKS, WorkspaceRepositories.NO_FORKS).
|
|
112
|
+
|
|
113
|
+
:return: The created project object
|
|
114
|
+
|
|
115
|
+
API docs:
|
|
116
|
+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D#post
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
data = {"scm": "git"}
|
|
120
|
+
if project_key is not None:
|
|
121
|
+
data["project"] = {"key": project_key}
|
|
122
|
+
if is_private is not None:
|
|
123
|
+
data["is_private"] = is_private
|
|
124
|
+
if fork_policy is not None:
|
|
125
|
+
if fork_policy not in self.FORK_POLICIES:
|
|
126
|
+
raise ValueError("fork_policy must be one of {}".format(self.FORK_POLICIES))
|
|
127
|
+
data["fork_policy"] = fork_policy
|
|
128
|
+
return self._get_object(self.post(repo_slug, data=data))
|
|
129
|
+
|
|
130
|
+
def each(self, role=None, q=None, sort=None):
|
|
131
|
+
"""
|
|
132
|
+
Get all repositories in the workspace matching the criteria.
|
|
133
|
+
|
|
134
|
+
:param role: string: Filters the workspaces based on the authenticated user's role on each workspace.
|
|
135
|
+
* member: returns a list of all the workspaces which the caller is a member of
|
|
136
|
+
at least one workspace group or repository
|
|
137
|
+
* collaborator: returns a list of workspaces which the caller has write access
|
|
138
|
+
to at least one repository in the workspace
|
|
139
|
+
* owner: returns a list of workspaces which the caller has administrator access
|
|
140
|
+
:param q: string: Query string to narrow down the response. role parameter must also be specified.
|
|
141
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
142
|
+
:param sort: string: Name of a response property to sort results.
|
|
143
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
144
|
+
|
|
145
|
+
:return: A generator for the workspace objects
|
|
146
|
+
|
|
147
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D#get
|
|
148
|
+
"""
|
|
149
|
+
params = {}
|
|
150
|
+
if role is not None:
|
|
151
|
+
params["role"] = role
|
|
152
|
+
if q is not None:
|
|
153
|
+
params["q"] = q
|
|
154
|
+
if sort is not None:
|
|
155
|
+
params["sort"] = sort
|
|
156
|
+
for repository in self._get_paged(None, params):
|
|
157
|
+
yield self._get_object(repository)
|
|
158
|
+
|
|
159
|
+
def get(self, repository, by="slug"):
|
|
160
|
+
"""
|
|
161
|
+
Returns the requested repository
|
|
162
|
+
|
|
163
|
+
:param repository: string: The requested repository.
|
|
164
|
+
:param by: string: How to interprate repository, can be 'slug' or 'name'.
|
|
165
|
+
|
|
166
|
+
:return: The requested Repository object
|
|
167
|
+
|
|
168
|
+
API docs:
|
|
169
|
+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D#get
|
|
170
|
+
"""
|
|
171
|
+
if by == "slug":
|
|
172
|
+
return self._get_object(super(WorkspaceRepositories, self).get(repository))
|
|
173
|
+
elif by == "name":
|
|
174
|
+
for r in self.each():
|
|
175
|
+
if r.name == repository:
|
|
176
|
+
return r
|
|
177
|
+
else:
|
|
178
|
+
ValueError("Unknown value '{}' for argument [by], expected 'key' or 'name'".format(by))
|
|
179
|
+
|
|
180
|
+
raise Exception("Unknown repository {} '{}'".format(by, repository))
|
|
181
|
+
|
|
182
|
+
def exists(self, repository, by="slug"):
|
|
183
|
+
"""
|
|
184
|
+
Check if repository exist.
|
|
185
|
+
|
|
186
|
+
:param repository: string: The requested repository.
|
|
187
|
+
:param by: string (default is "slug"): How to interpret repository, can be 'slug' or 'name'.
|
|
188
|
+
|
|
189
|
+
:return: True if the repository exists
|
|
190
|
+
|
|
191
|
+
API docs:
|
|
192
|
+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D#get
|
|
193
|
+
"""
|
|
194
|
+
exists = False
|
|
195
|
+
try:
|
|
196
|
+
self.get(repository, by)
|
|
197
|
+
exists = True
|
|
198
|
+
except HTTPError as e:
|
|
199
|
+
if e.response.status_code in (401, 404):
|
|
200
|
+
pass
|
|
201
|
+
except Exception as e:
|
|
202
|
+
if not str(e) == "Unknown project {} '{}'".format(by, repository):
|
|
203
|
+
raise e
|
|
204
|
+
return exists
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
class ProjectRepositories(RepositoriesBase):
|
|
208
|
+
def __init__(self, url, *args, **kwargs):
|
|
209
|
+
super(ProjectRepositories, self).__init__(url, *args, **kwargs)
|
|
210
|
+
|
|
211
|
+
def each(self, sort=None):
|
|
212
|
+
"""
|
|
213
|
+
Get all repositories in the project matching the criteria.
|
|
214
|
+
|
|
215
|
+
:param sort: string: Name of a response property to sort results.
|
|
216
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
217
|
+
|
|
218
|
+
:return: A generator for the repository objects
|
|
219
|
+
|
|
220
|
+
API docs:
|
|
221
|
+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces/%7Bworkspace%7D/projects/%7Bproject_key%7D#get
|
|
222
|
+
"""
|
|
223
|
+
params = {}
|
|
224
|
+
if sort is not None:
|
|
225
|
+
params["sort"] = sort
|
|
226
|
+
for repository in self._get_paged(None, params):
|
|
227
|
+
yield self._get_object(repository)
|
|
228
|
+
|
|
229
|
+
def get(self, repository, by="slug"):
|
|
230
|
+
"""
|
|
231
|
+
Returns the requested repository
|
|
232
|
+
|
|
233
|
+
:param repository: string: The requested repository.
|
|
234
|
+
:param by: string: How to interprate repository, can be 'slug' or 'name'.
|
|
235
|
+
|
|
236
|
+
:return: The requested Repository object
|
|
237
|
+
|
|
238
|
+
API docs:
|
|
239
|
+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces/%7Bworkspace%7D/projects/%7Bproject_key%7D#get
|
|
240
|
+
"""
|
|
241
|
+
if by not in ("slug", "name"):
|
|
242
|
+
ValueError("Unknown value '{}' for argument [by], expected 'slug' or 'name'".format(by))
|
|
243
|
+
|
|
244
|
+
for r in self.each():
|
|
245
|
+
if ((by == "slug") and (r.slug == repository)) or ((by == "name") and (r.name == repository)):
|
|
246
|
+
return r
|
|
247
|
+
|
|
248
|
+
raise Exception("Unknown repository {} '{}'".format(by, repository))
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
class Repository(BitbucketCloudBase):
|
|
252
|
+
def __init__(self, data, *args, **kwargs):
|
|
253
|
+
super(Repository, self).__init__(None, *args, data=data, expected_type="repository", **kwargs)
|
|
254
|
+
self.__branch_restrictions = BranchRestrictions(
|
|
255
|
+
"{}/branch-restrictions".format(self.url), **self._new_session_args
|
|
256
|
+
)
|
|
257
|
+
self.__branches = Branches("{}/refs/branches".format(self.url), **self._new_session_args)
|
|
258
|
+
self.__commits = Commits(
|
|
259
|
+
"{}/commits".format(self.url),
|
|
260
|
+
data={"links": {"commit": {"href": "{}/commit".format(self.url)}}},
|
|
261
|
+
**self._new_session_args
|
|
262
|
+
) # fmt: skip
|
|
263
|
+
self.__hooks = Hooks(
|
|
264
|
+
"{}/hooks".format(self.url),
|
|
265
|
+
data={"links": {"hooks": {"href": "{}/hooks".format(self.url)}}},
|
|
266
|
+
**self._new_session_args,
|
|
267
|
+
)
|
|
268
|
+
self.__default_reviewers = DefaultReviewers("{}/default-reviewers".format(self.url), **self._new_session_args)
|
|
269
|
+
self.__deployment_environments = DeploymentEnvironments(
|
|
270
|
+
"{}/environments".format(self.url), **self._new_session_args
|
|
271
|
+
)
|
|
272
|
+
self.__group_permissions = GroupPermissions(
|
|
273
|
+
"{}/permissions-config/groups".format(self.url), **self._new_session_args
|
|
274
|
+
)
|
|
275
|
+
self.__issues = Issues("{}/issues".format(self.url), **self._new_session_args)
|
|
276
|
+
self.__pipelines = Pipelines("{}/pipelines".format(self.url), **self._new_session_args)
|
|
277
|
+
self.__pullrequests = PullRequests("{}/pullrequests".format(self.url), **self._new_session_args)
|
|
278
|
+
self.__repository_variables = RepositoryVariables(
|
|
279
|
+
"{}/pipelines_config/variables".format(self.url), **self._new_session_args
|
|
280
|
+
)
|
|
281
|
+
self.__tags = Tags("{}/refs/tags".format(self.url), **self._new_session_args)
|
|
282
|
+
|
|
283
|
+
def update(self, **kwargs):
|
|
284
|
+
"""
|
|
285
|
+
Update the repository properties. Fields not present in the request body are ignored.
|
|
286
|
+
|
|
287
|
+
:param kwargs: dict: The data to update.
|
|
288
|
+
|
|
289
|
+
:return: The updated repository
|
|
290
|
+
|
|
291
|
+
API docs:
|
|
292
|
+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D#put
|
|
293
|
+
"""
|
|
294
|
+
return self._update_data(self.put(None, data=kwargs))
|
|
295
|
+
|
|
296
|
+
def delete(self, redirect_to=None):
|
|
297
|
+
"""
|
|
298
|
+
Delete the repostory.
|
|
299
|
+
|
|
300
|
+
:param redirect_to: string (default is None): If a repository has been moved to a new location, use this
|
|
301
|
+
parameter to show users a friendly message in the Bitbucket UI
|
|
302
|
+
that the repository has moved to a new location. However, a GET
|
|
303
|
+
to this endpoint will still return a 404.
|
|
304
|
+
|
|
305
|
+
:return: The response on success
|
|
306
|
+
|
|
307
|
+
API docs:
|
|
308
|
+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D#delete
|
|
309
|
+
"""
|
|
310
|
+
params = {}
|
|
311
|
+
if redirect_to is not None:
|
|
312
|
+
params["redirect_to"] = redirect_to
|
|
313
|
+
return super(Repository, self).delete(None, params=params)
|
|
314
|
+
|
|
315
|
+
@property
|
|
316
|
+
def name(self):
|
|
317
|
+
"""The repository name"""
|
|
318
|
+
return self.get_data("name")
|
|
319
|
+
|
|
320
|
+
@name.setter
|
|
321
|
+
def name(self, name):
|
|
322
|
+
"""Setter for the repository name"""
|
|
323
|
+
return self.update(name=name)
|
|
324
|
+
|
|
325
|
+
@property
|
|
326
|
+
def slug(self):
|
|
327
|
+
"""The repository slug"""
|
|
328
|
+
return self.get_data("slug")
|
|
329
|
+
|
|
330
|
+
@property
|
|
331
|
+
def description(self):
|
|
332
|
+
"""The repository description"""
|
|
333
|
+
return self.get_data("description")
|
|
334
|
+
|
|
335
|
+
@description.setter
|
|
336
|
+
def description(self, description):
|
|
337
|
+
"""Setter for the repository description"""
|
|
338
|
+
return self.update(description=description)
|
|
339
|
+
|
|
340
|
+
@property
|
|
341
|
+
def is_private(self):
|
|
342
|
+
"""The repository private flag"""
|
|
343
|
+
return self.get_data("is_private")
|
|
344
|
+
|
|
345
|
+
@is_private.setter
|
|
346
|
+
def is_private(self, is_private):
|
|
347
|
+
"""Setter for the repository private flag"""
|
|
348
|
+
return self.update(is_private=is_private)
|
|
349
|
+
|
|
350
|
+
@property
|
|
351
|
+
def fork_policy(self):
|
|
352
|
+
"""Getter for the repository fork policy"""
|
|
353
|
+
return self.get_data("fork_policy")
|
|
354
|
+
|
|
355
|
+
@property
|
|
356
|
+
def uuid(self):
|
|
357
|
+
"""The repository uuid"""
|
|
358
|
+
return self.get_data("uuid")
|
|
359
|
+
|
|
360
|
+
@property
|
|
361
|
+
def size(self):
|
|
362
|
+
"""The repository size"""
|
|
363
|
+
return self.get_data("size")
|
|
364
|
+
|
|
365
|
+
@property
|
|
366
|
+
def created_on(self):
|
|
367
|
+
"""The repository creation time"""
|
|
368
|
+
return self.get_data("created_on")
|
|
369
|
+
|
|
370
|
+
@property
|
|
371
|
+
def updated_on(self):
|
|
372
|
+
"""The repository last update time"""
|
|
373
|
+
return self.get_data("updated_on", "never updated")
|
|
374
|
+
|
|
375
|
+
def get_avatar(self):
|
|
376
|
+
"""The repository avatar"""
|
|
377
|
+
return self.get(self.get_link("avatar"), absolute=True)
|
|
378
|
+
|
|
379
|
+
@property
|
|
380
|
+
def branch_restrictions(self):
|
|
381
|
+
"""The repository branch restrictions"""
|
|
382
|
+
return self.__branch_restrictions
|
|
383
|
+
|
|
384
|
+
@property
|
|
385
|
+
def branches(self):
|
|
386
|
+
"""The repository branches."""
|
|
387
|
+
return self.__branches
|
|
388
|
+
|
|
389
|
+
@property
|
|
390
|
+
def commits(self):
|
|
391
|
+
"""The repository commits."""
|
|
392
|
+
return self.__commits
|
|
393
|
+
|
|
394
|
+
@property
|
|
395
|
+
def hooks(self):
|
|
396
|
+
"""The repository hooks."""
|
|
397
|
+
return self.__hooks
|
|
398
|
+
|
|
399
|
+
@property
|
|
400
|
+
def default_reviewers(self):
|
|
401
|
+
"""The repository default reviewers"""
|
|
402
|
+
return self.__default_reviewers
|
|
403
|
+
|
|
404
|
+
@property
|
|
405
|
+
def deployment_environments(self):
|
|
406
|
+
"""The repository deployment environments"""
|
|
407
|
+
return self.__deployment_environments
|
|
408
|
+
|
|
409
|
+
@property
|
|
410
|
+
def issues(self):
|
|
411
|
+
"""The repository issues"""
|
|
412
|
+
return self.__issues
|
|
413
|
+
|
|
414
|
+
@property
|
|
415
|
+
def group_permissions(self):
|
|
416
|
+
"""The repository group permissions"""
|
|
417
|
+
return self.__group_permissions
|
|
418
|
+
|
|
419
|
+
@property
|
|
420
|
+
def pipelines(self):
|
|
421
|
+
"""The repository pipelines"""
|
|
422
|
+
return self.__pipelines
|
|
423
|
+
|
|
424
|
+
@property
|
|
425
|
+
def pullrequests(self):
|
|
426
|
+
"""The repository pull requests"""
|
|
427
|
+
return self.__pullrequests
|
|
428
|
+
|
|
429
|
+
@property
|
|
430
|
+
def repository_variables(self):
|
|
431
|
+
"""The repository variables"""
|
|
432
|
+
return self.__repository_variables
|
|
433
|
+
|
|
434
|
+
@property
|
|
435
|
+
def tags(self):
|
|
436
|
+
"""The repository tags."""
|
|
437
|
+
return self.__tags
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
from ..base import BitbucketCloudBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BranchRestrictions(BitbucketCloudBase):
|
|
7
|
+
def __init__(self, url, *args, **kwargs):
|
|
8
|
+
super(BranchRestrictions, self).__init__(url, *args, **kwargs)
|
|
9
|
+
|
|
10
|
+
def __get_object(self, data):
|
|
11
|
+
return BranchRestriction(data, **self._new_session_args)
|
|
12
|
+
|
|
13
|
+
def create(
|
|
14
|
+
self,
|
|
15
|
+
kind,
|
|
16
|
+
branch_match_kind="glob",
|
|
17
|
+
branch_pattern="*",
|
|
18
|
+
branch_type=None,
|
|
19
|
+
users=None,
|
|
20
|
+
groups=None,
|
|
21
|
+
value=None,
|
|
22
|
+
):
|
|
23
|
+
"""
|
|
24
|
+
Add a new branch restriction.
|
|
25
|
+
|
|
26
|
+
:param value:
|
|
27
|
+
:param kind: string: One of require_tasks_to_be_completed, force, restrict_merges,
|
|
28
|
+
enforce_merge_checks, require_approvals_to_merge, delete,
|
|
29
|
+
require_all_dependencies_merged, push, require_passing_builds_to_merge,
|
|
30
|
+
reset_pullrequest_approvals_on_change, require_default_reviewer_approvals_to_merge
|
|
31
|
+
:param branch_match_kind: string: branching_model or glob, if branching_model use
|
|
32
|
+
param branch_type otherwise branch_pattern.
|
|
33
|
+
:param branch_pattern: string: A glob specifying the branch this restriction should
|
|
34
|
+
apply to (supports * as wildcard).
|
|
35
|
+
:param branch_type: string: The branch type specifies the branches this restriction
|
|
36
|
+
should apply to. One of: feature, bugfix, release, hotfix, development, production.
|
|
37
|
+
:param users: List: List of user objects that are excluded from the restriction.
|
|
38
|
+
Minimal: {"username": "<username>"}
|
|
39
|
+
:param groups: List: List of group objects that are excluded from the restriction.
|
|
40
|
+
Minimal: {"owner": {"username": "<teamname>"}, "slug": "<groupslug>"}
|
|
41
|
+
|
|
42
|
+
:return: The created BranchRestriction object
|
|
43
|
+
|
|
44
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions#post
|
|
45
|
+
"""
|
|
46
|
+
if branch_match_kind == "branching_model":
|
|
47
|
+
branch_pattern = ""
|
|
48
|
+
|
|
49
|
+
data = {
|
|
50
|
+
"kind": kind,
|
|
51
|
+
"branch_match_kind": branch_match_kind,
|
|
52
|
+
"pattern": branch_pattern,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if branch_match_kind == "branching_model":
|
|
56
|
+
data["branch_type"] = branch_type
|
|
57
|
+
|
|
58
|
+
if users is not None:
|
|
59
|
+
data["users"] = users
|
|
60
|
+
|
|
61
|
+
if groups is not None:
|
|
62
|
+
data["groups"] = groups
|
|
63
|
+
|
|
64
|
+
if value is not None:
|
|
65
|
+
data["value"] = value
|
|
66
|
+
|
|
67
|
+
return self.__get_object(self.post(None, data=data))
|
|
68
|
+
|
|
69
|
+
def each(self, kind=None, pattern=None, q=None, sort=None):
|
|
70
|
+
"""
|
|
71
|
+
Returns the list of branch restrictions in this repository.
|
|
72
|
+
|
|
73
|
+
:param kind: string: Branch restrictions of this type
|
|
74
|
+
:param pattern: string: Branch restrictions applied to branches of this pattern
|
|
75
|
+
:param q: string: Query string to narrow down the response.
|
|
76
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
77
|
+
:param sort: string: Name of a response property to sort results.
|
|
78
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
79
|
+
|
|
80
|
+
:return: A generator for the BranchRestriction objects
|
|
81
|
+
|
|
82
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions#get
|
|
83
|
+
"""
|
|
84
|
+
params = {}
|
|
85
|
+
if kind is not None:
|
|
86
|
+
params["kind"] = kind
|
|
87
|
+
if pattern is not None:
|
|
88
|
+
params["pattern"] = pattern
|
|
89
|
+
if sort is not None:
|
|
90
|
+
params["sort"] = sort
|
|
91
|
+
if q is not None:
|
|
92
|
+
params["q"] = q
|
|
93
|
+
for branch_restriction in self._get_paged(None, params=params):
|
|
94
|
+
yield self.__get_object(branch_restriction)
|
|
95
|
+
|
|
96
|
+
return
|
|
97
|
+
|
|
98
|
+
def get(self, id):
|
|
99
|
+
"""
|
|
100
|
+
Returns the branch restriction with the ID in this repository.
|
|
101
|
+
|
|
102
|
+
:param id: string: The requested issue ID
|
|
103
|
+
|
|
104
|
+
:return: The requested BranchRestriction objects
|
|
105
|
+
|
|
106
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#get
|
|
107
|
+
"""
|
|
108
|
+
return self.__get_object(super(BranchRestrictions, self).get(id))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class BranchRestriction(BitbucketCloudBase):
|
|
112
|
+
def __init__(self, data, *args, **kwargs):
|
|
113
|
+
super(BranchRestriction, self).__init__(None, *args, data=data, expected_type="branchrestriction", **kwargs)
|
|
114
|
+
|
|
115
|
+
def update(self, **kwargs):
|
|
116
|
+
"""
|
|
117
|
+
Update the branch restriction properties. Fields not present in the request body are ignored.
|
|
118
|
+
|
|
119
|
+
:param kwargs: dict: The data to update.
|
|
120
|
+
|
|
121
|
+
:return: The updated branch restriction
|
|
122
|
+
|
|
123
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#put
|
|
124
|
+
"""
|
|
125
|
+
return self._update_data(self.put(None, data=kwargs))
|
|
126
|
+
|
|
127
|
+
def delete(self):
|
|
128
|
+
"""
|
|
129
|
+
Delete the branch restriction.
|
|
130
|
+
|
|
131
|
+
:return: The response on success
|
|
132
|
+
|
|
133
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#delete
|
|
134
|
+
"""
|
|
135
|
+
return super(BranchRestriction, self).delete(None)
|
|
136
|
+
|
|
137
|
+
@property
|
|
138
|
+
def id(self):
|
|
139
|
+
"""The branch restriction id"""
|
|
140
|
+
return str(self.get_data("id"))
|
|
141
|
+
|
|
142
|
+
@property
|
|
143
|
+
def kind(self):
|
|
144
|
+
"""The branch restriction kind"""
|
|
145
|
+
return self.get_data("kind")
|
|
146
|
+
|
|
147
|
+
@property
|
|
148
|
+
def branch_match_kind(self):
|
|
149
|
+
"""The branch restriction match kind"""
|
|
150
|
+
return self.get_data("branch_match_kind")
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def branch_type(self):
|
|
154
|
+
"""The branch restriction type"""
|
|
155
|
+
return self.get_data("branch_type")
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def pattern(self):
|
|
159
|
+
"""The branch restriction pattern"""
|
|
160
|
+
return self.get_data("pattern")
|
|
161
|
+
|
|
162
|
+
@property
|
|
163
|
+
def users(self):
|
|
164
|
+
"""The branch restriction users"""
|
|
165
|
+
return self.get_data("users")
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
def groups(self):
|
|
169
|
+
"""The branch restriction groups"""
|
|
170
|
+
return self.get_data("groups")
|
|
171
|
+
|
|
172
|
+
@property
|
|
173
|
+
def value(self):
|
|
174
|
+
"""The branch restriction value"""
|
|
175
|
+
return self.get_data("value")
|