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,244 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
from requests import HTTPError
|
|
4
|
+
from .repos import Repositories
|
|
5
|
+
from ..base import BitbucketServerBase
|
|
6
|
+
from ..common.permissions import Groups, Users
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Projects(BitbucketServerBase):
|
|
10
|
+
def __init__(self, url, *args, **kwargs):
|
|
11
|
+
super(Projects, self).__init__(url, *args, **kwargs)
|
|
12
|
+
|
|
13
|
+
def __get_object(self, data):
|
|
14
|
+
return Project(data, **self._new_session_args)
|
|
15
|
+
|
|
16
|
+
def create(self, name, key, description, avatar=None):
|
|
17
|
+
"""
|
|
18
|
+
Creates a new project with the given values.
|
|
19
|
+
|
|
20
|
+
Note that the avatar has to be embedded as either a data-url or a URL to an external image as shown in
|
|
21
|
+
the examples below:
|
|
22
|
+
|
|
23
|
+
w.projects.create( "Mars Project", "MARS", "Software for colonizing Mars.",
|
|
24
|
+
avatar="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/..."
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
w.projects.create( "Mars Project", "MARS", "Software for colonizing Mars.",
|
|
28
|
+
avatar="http://i.imgur.com/72tRx4w.gif"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
:param name: string: The name of the project.
|
|
32
|
+
:param key: string: The key of the project.
|
|
33
|
+
:param description: string: The description of the project.
|
|
34
|
+
:param avatar: string: The avatar of the project.
|
|
35
|
+
|
|
36
|
+
:return: The created project object
|
|
37
|
+
|
|
38
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp148
|
|
39
|
+
"""
|
|
40
|
+
data = {"name": name, "key": key, "description": description}
|
|
41
|
+
if avatar:
|
|
42
|
+
data["avatar"] = avatar
|
|
43
|
+
return self.__get_object(self.post(None, data=data))
|
|
44
|
+
|
|
45
|
+
def each(self, name=None, permission=None):
|
|
46
|
+
"""
|
|
47
|
+
Get all projects matching the criteria.
|
|
48
|
+
|
|
49
|
+
:param name: string: Name to filter by.
|
|
50
|
+
:param permission: string: Permission to filter by.
|
|
51
|
+
|
|
52
|
+
:return: A generator for the project objects
|
|
53
|
+
|
|
54
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp149
|
|
55
|
+
"""
|
|
56
|
+
params = {}
|
|
57
|
+
if name is not None:
|
|
58
|
+
params["name"] = name
|
|
59
|
+
if permission is not None:
|
|
60
|
+
params["permission"] = permission
|
|
61
|
+
for project in self._get_paged(None, params=params):
|
|
62
|
+
yield self.__get_object(project)
|
|
63
|
+
|
|
64
|
+
return
|
|
65
|
+
|
|
66
|
+
def get(self, project, by="key"):
|
|
67
|
+
"""
|
|
68
|
+
Returns the requested project
|
|
69
|
+
|
|
70
|
+
:param project: string: The requested project.
|
|
71
|
+
:param by: string (default is "key"): How to interpret project, can be 'key' or 'name'.
|
|
72
|
+
|
|
73
|
+
:return: The requested Project object
|
|
74
|
+
|
|
75
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp153
|
|
76
|
+
"""
|
|
77
|
+
if by == "key":
|
|
78
|
+
return self.__get_object(super(Projects, self).get(project))
|
|
79
|
+
elif by == "name":
|
|
80
|
+
for p in self.each(name=project):
|
|
81
|
+
if p.name == project:
|
|
82
|
+
return p
|
|
83
|
+
else:
|
|
84
|
+
ValueError("Unknown value '{}' for argument [by], expected 'key' or 'name'".format(by))
|
|
85
|
+
|
|
86
|
+
raise Exception("Unknown project {} '{}'".format(by, project))
|
|
87
|
+
|
|
88
|
+
def exists(self, project, by="key"):
|
|
89
|
+
"""
|
|
90
|
+
Check if project exist.
|
|
91
|
+
|
|
92
|
+
:param project: string: The requested project.
|
|
93
|
+
:param by: string (default is "key"): How to interpret project, can be 'key' or 'name'.
|
|
94
|
+
|
|
95
|
+
:return: True if the project exists
|
|
96
|
+
"""
|
|
97
|
+
exists = False
|
|
98
|
+
try:
|
|
99
|
+
self.get(project, by)
|
|
100
|
+
exists = True
|
|
101
|
+
except HTTPError as e:
|
|
102
|
+
if e.response.status_code in (401, 404):
|
|
103
|
+
pass
|
|
104
|
+
except Exception as e:
|
|
105
|
+
if not str(e) == "Unknown project {} '{}'".format(by, project):
|
|
106
|
+
raise e
|
|
107
|
+
return exists
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class Project(BitbucketServerBase):
|
|
111
|
+
def __init__(self, data, *args, **kwargs):
|
|
112
|
+
super(Project, self).__init__(None, *args, data=data, **kwargs)
|
|
113
|
+
self.__groups = Groups(
|
|
114
|
+
self._sub_url("permissions/groups"),
|
|
115
|
+
"PROJECT",
|
|
116
|
+
**self._new_session_args
|
|
117
|
+
) # fmt: skip
|
|
118
|
+
self.__users = Users(
|
|
119
|
+
self._sub_url("permissions/users"),
|
|
120
|
+
"PROJECT",
|
|
121
|
+
**self._new_session_args
|
|
122
|
+
) # fmt: skip
|
|
123
|
+
self.__repos = Repositories(self._sub_url("repos"), **self._new_session_args)
|
|
124
|
+
|
|
125
|
+
def delete(self):
|
|
126
|
+
"""
|
|
127
|
+
Delete the project.
|
|
128
|
+
|
|
129
|
+
:return: The response on success
|
|
130
|
+
|
|
131
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp151
|
|
132
|
+
"""
|
|
133
|
+
return super(Project, self).delete(None)
|
|
134
|
+
|
|
135
|
+
def update(self, **kwargs):
|
|
136
|
+
"""
|
|
137
|
+
Update the project properties. Fields not present in the request body are ignored.
|
|
138
|
+
|
|
139
|
+
:param kwargs: dict: The data to update.
|
|
140
|
+
|
|
141
|
+
:return: The updated project
|
|
142
|
+
|
|
143
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp152
|
|
144
|
+
"""
|
|
145
|
+
return self._update_data(self.put(None, data=kwargs))
|
|
146
|
+
|
|
147
|
+
@property
|
|
148
|
+
def id(self):
|
|
149
|
+
"""The project identifier"""
|
|
150
|
+
return self.get_data("id")
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def type(self):
|
|
154
|
+
"""The project type"""
|
|
155
|
+
return self.get_data("type")
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def name(self):
|
|
159
|
+
"""The project name"""
|
|
160
|
+
return self.get_data("name")
|
|
161
|
+
|
|
162
|
+
@name.setter
|
|
163
|
+
def name(self, name):
|
|
164
|
+
"""Setter for the project name"""
|
|
165
|
+
return self.update(name=name)
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
def key(self):
|
|
169
|
+
"""The project key"""
|
|
170
|
+
return self.get_data("key")
|
|
171
|
+
|
|
172
|
+
@key.setter
|
|
173
|
+
def key(self, key):
|
|
174
|
+
"""Setter for the project key"""
|
|
175
|
+
return self.update(key=key)
|
|
176
|
+
|
|
177
|
+
@property
|
|
178
|
+
def description(self):
|
|
179
|
+
"""The project description"""
|
|
180
|
+
return self.get_data("description")
|
|
181
|
+
|
|
182
|
+
@description.setter
|
|
183
|
+
def description(self, description):
|
|
184
|
+
"""Setter for the project description"""
|
|
185
|
+
return self.update(description=description)
|
|
186
|
+
|
|
187
|
+
@property
|
|
188
|
+
def public(self):
|
|
189
|
+
"""The project public flag"""
|
|
190
|
+
return self.get_data("public")
|
|
191
|
+
|
|
192
|
+
@public.setter
|
|
193
|
+
def public(self, public):
|
|
194
|
+
"""Setter for the project public flag"""
|
|
195
|
+
return self.update(public=public)
|
|
196
|
+
|
|
197
|
+
def get_avatar(self, s=0):
|
|
198
|
+
"""
|
|
199
|
+
Get the avatar.
|
|
200
|
+
|
|
201
|
+
:param s: int (default 0): The desired size of the image. The server will return
|
|
202
|
+
an image as close as possible to the specified size.
|
|
203
|
+
|
|
204
|
+
:return: The response on success
|
|
205
|
+
|
|
206
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp155
|
|
207
|
+
"""
|
|
208
|
+
return self.get("avatar.png", params={"s": s})
|
|
209
|
+
|
|
210
|
+
def set_avatar(self, avatar):
|
|
211
|
+
"""
|
|
212
|
+
Set the avatar.
|
|
213
|
+
|
|
214
|
+
:param avatar: See function create for examples.
|
|
215
|
+
|
|
216
|
+
:return: The response on success
|
|
217
|
+
|
|
218
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp156
|
|
219
|
+
"""
|
|
220
|
+
return self.post("avatar.png", data={"avatar": avatar})
|
|
221
|
+
|
|
222
|
+
@property
|
|
223
|
+
def groups(self):
|
|
224
|
+
"""
|
|
225
|
+
Property to access the project groups
|
|
226
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp158
|
|
227
|
+
"""
|
|
228
|
+
return self.__groups
|
|
229
|
+
|
|
230
|
+
@property
|
|
231
|
+
def users(self):
|
|
232
|
+
"""
|
|
233
|
+
Property to access the project groups
|
|
234
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp164
|
|
235
|
+
"""
|
|
236
|
+
return self.__users
|
|
237
|
+
|
|
238
|
+
@property
|
|
239
|
+
def repos(self):
|
|
240
|
+
"""
|
|
241
|
+
Property to access the repositories
|
|
242
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp173
|
|
243
|
+
"""
|
|
244
|
+
return self.__repos
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
from requests import HTTPError
|
|
4
|
+
from ...base import BitbucketServerBase
|
|
5
|
+
from ...common.permissions import Groups, Users
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Repositories(BitbucketServerBase):
|
|
9
|
+
def __init__(self, url, *args, **kwargs):
|
|
10
|
+
super(Repositories, self).__init__(url, *args, **kwargs)
|
|
11
|
+
|
|
12
|
+
def __get_object(self, data):
|
|
13
|
+
return Repository(data, **self._new_session_args)
|
|
14
|
+
|
|
15
|
+
def create(self, name):
|
|
16
|
+
"""
|
|
17
|
+
Creates a new repository with the given name.
|
|
18
|
+
|
|
19
|
+
See https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp174
|
|
20
|
+
|
|
21
|
+
:param name: string: The name of the project.
|
|
22
|
+
|
|
23
|
+
:return: The created project object
|
|
24
|
+
"""
|
|
25
|
+
return self.__get_object(self.post(None, data={"name": name}))
|
|
26
|
+
|
|
27
|
+
def each(self):
|
|
28
|
+
"""
|
|
29
|
+
Get all repositories.
|
|
30
|
+
|
|
31
|
+
See https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp175
|
|
32
|
+
|
|
33
|
+
:return: A generator for the Repository objects
|
|
34
|
+
"""
|
|
35
|
+
for repository in self._get_paged(None):
|
|
36
|
+
yield self.__get_object(repository)
|
|
37
|
+
|
|
38
|
+
def get(self, repository, by="slug"):
|
|
39
|
+
"""
|
|
40
|
+
Returns the requested repository.
|
|
41
|
+
|
|
42
|
+
:param repository: string: The requested repository.
|
|
43
|
+
:param by: string (default is "slug"): How to interpret project, can be 'slug' or 'name'.
|
|
44
|
+
|
|
45
|
+
:return: The requested Repository object
|
|
46
|
+
"""
|
|
47
|
+
if by == "slug":
|
|
48
|
+
return self.__get_object(super(Repositories, self).get(repository))
|
|
49
|
+
elif by == "name":
|
|
50
|
+
for r in self.each():
|
|
51
|
+
print(r.name)
|
|
52
|
+
if r.name == repository:
|
|
53
|
+
return r
|
|
54
|
+
else:
|
|
55
|
+
ValueError("Unknown value '{}' for argument [by], expected 'slug' or 'name'".format(by))
|
|
56
|
+
|
|
57
|
+
raise Exception("Unknown repository {} '{}'".format(by, repository))
|
|
58
|
+
|
|
59
|
+
def exists(self, repository, by="slug"):
|
|
60
|
+
"""
|
|
61
|
+
Check if repository exist.
|
|
62
|
+
|
|
63
|
+
:param repository: string: The requested repository.
|
|
64
|
+
:param by: string (default is "slug"): How to interpret repository, can be 'slug' or 'name'.
|
|
65
|
+
|
|
66
|
+
:return: True if the repository exists
|
|
67
|
+
"""
|
|
68
|
+
exists = False
|
|
69
|
+
try:
|
|
70
|
+
self.get(repository, by)
|
|
71
|
+
exists = True
|
|
72
|
+
except HTTPError as e:
|
|
73
|
+
if e.response.status_code in (401, 404):
|
|
74
|
+
pass
|
|
75
|
+
except Exception as e:
|
|
76
|
+
if not str(e) == "Unknown project {} '{}'".format(by, repository):
|
|
77
|
+
raise e
|
|
78
|
+
return exists
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class Repository(BitbucketServerBase):
|
|
82
|
+
def __init__(self, data, *args, **kwargs):
|
|
83
|
+
super(Repository, self).__init__(None, *args, data=data, **kwargs)
|
|
84
|
+
self.__groups = Groups(
|
|
85
|
+
self._sub_url("permissions/groups"),
|
|
86
|
+
"REPO",
|
|
87
|
+
**self._new_session_args
|
|
88
|
+
) # fmt: skip
|
|
89
|
+
self.__users = Users(
|
|
90
|
+
self._sub_url("permissions/users"),
|
|
91
|
+
"REPO",
|
|
92
|
+
**self._new_session_args
|
|
93
|
+
) # fmt: skip
|
|
94
|
+
|
|
95
|
+
def __get_object(self, data):
|
|
96
|
+
return Repository(data, **self._new_session_args)
|
|
97
|
+
|
|
98
|
+
def update(self, **kwargs):
|
|
99
|
+
"""
|
|
100
|
+
Update the repository properties. Fields not present in the request body are ignored.
|
|
101
|
+
|
|
102
|
+
:param kwargs: dict: The data to update.
|
|
103
|
+
|
|
104
|
+
:return: The updated repository
|
|
105
|
+
|
|
106
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp180
|
|
107
|
+
"""
|
|
108
|
+
return self._update_data(self.put(None, data=kwargs))
|
|
109
|
+
|
|
110
|
+
def delete(self):
|
|
111
|
+
"""
|
|
112
|
+
Delete the repostory.
|
|
113
|
+
|
|
114
|
+
:return: The response on success
|
|
115
|
+
|
|
116
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp177
|
|
117
|
+
"""
|
|
118
|
+
return super(Repository, self).delete(None)
|
|
119
|
+
|
|
120
|
+
@property
|
|
121
|
+
def id(self):
|
|
122
|
+
"""The repository identifier"""
|
|
123
|
+
return self.get_data("id")
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
def name(self):
|
|
127
|
+
"""The repository name"""
|
|
128
|
+
return self.get_data("name")
|
|
129
|
+
|
|
130
|
+
@name.setter
|
|
131
|
+
def name(self, name):
|
|
132
|
+
"""Setter for the repository name"""
|
|
133
|
+
return self.update(name=name)
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def slug(self):
|
|
137
|
+
"""The repository slug"""
|
|
138
|
+
return self.get_data("slug")
|
|
139
|
+
|
|
140
|
+
@property
|
|
141
|
+
def description(self):
|
|
142
|
+
"""The repository description"""
|
|
143
|
+
return self.get_data("description")
|
|
144
|
+
|
|
145
|
+
@description.setter
|
|
146
|
+
def description(self, description):
|
|
147
|
+
"""Setter for the repository description"""
|
|
148
|
+
return self.update(description=description)
|
|
149
|
+
|
|
150
|
+
@property
|
|
151
|
+
def public(self):
|
|
152
|
+
"""The repository public flag"""
|
|
153
|
+
return self.get_data("public")
|
|
154
|
+
|
|
155
|
+
@public.setter
|
|
156
|
+
def public(self, public):
|
|
157
|
+
"""Setter for the repository public flag"""
|
|
158
|
+
return self.update(public=public)
|
|
159
|
+
|
|
160
|
+
@property
|
|
161
|
+
def forkable(self):
|
|
162
|
+
"""The repository forkable flag"""
|
|
163
|
+
return self.get_data("forkable")
|
|
164
|
+
|
|
165
|
+
@forkable.setter
|
|
166
|
+
def forkable(self, forkable):
|
|
167
|
+
"""Setter for the repository forkable flag"""
|
|
168
|
+
return self.update(forkable=forkable)
|
|
169
|
+
|
|
170
|
+
def contributing(self, at=None, markup=None):
|
|
171
|
+
"""
|
|
172
|
+
Get the contributing guidelines.
|
|
173
|
+
|
|
174
|
+
:param at: string: Optional, the commit to get the contributing guideline from.
|
|
175
|
+
:param markup: boolean: Optional, If set to true, the rendered content is returned as HTML.
|
|
176
|
+
|
|
177
|
+
:return: The text content of the contributing guidlines.
|
|
178
|
+
|
|
179
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp183
|
|
180
|
+
"""
|
|
181
|
+
params = {}
|
|
182
|
+
if at is not None:
|
|
183
|
+
params["at"] = at
|
|
184
|
+
if markup is True:
|
|
185
|
+
params["markup"] = markup
|
|
186
|
+
|
|
187
|
+
return self.get("contributing", params=params)
|
|
188
|
+
|
|
189
|
+
def license(self, at=None, markup=None):
|
|
190
|
+
"""
|
|
191
|
+
Get the license file.
|
|
192
|
+
|
|
193
|
+
:param at: string: Optional, the commit to get the license file from.
|
|
194
|
+
:param markup: boolean: Optional, If set to true, the rendered content is returned as HTML.
|
|
195
|
+
|
|
196
|
+
:return: The text content of the license file.
|
|
197
|
+
|
|
198
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp191
|
|
199
|
+
"""
|
|
200
|
+
params = {}
|
|
201
|
+
if at is not None:
|
|
202
|
+
params["at"] = at
|
|
203
|
+
if markup is True:
|
|
204
|
+
params["markup"] = markup
|
|
205
|
+
|
|
206
|
+
return self.get("license", params=params)
|
|
207
|
+
|
|
208
|
+
def readme(self, at=None, markup=None):
|
|
209
|
+
"""
|
|
210
|
+
Get the readme file.
|
|
211
|
+
|
|
212
|
+
:param at: string: Optional, the commit to get the readme file from.
|
|
213
|
+
:param markup: boolean: Optional, If set to true, the rendered content is returned as HTML.
|
|
214
|
+
|
|
215
|
+
:return: The text content of the readme file.
|
|
216
|
+
|
|
217
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp194
|
|
218
|
+
"""
|
|
219
|
+
params = {}
|
|
220
|
+
if at is not None:
|
|
221
|
+
params["at"] = at
|
|
222
|
+
if markup is True:
|
|
223
|
+
params["markup"] = markup
|
|
224
|
+
|
|
225
|
+
return self.get("readme", params=params)
|
|
226
|
+
|
|
227
|
+
@property
|
|
228
|
+
def default_branch(self):
|
|
229
|
+
"""
|
|
230
|
+
Get the default branch.
|
|
231
|
+
|
|
232
|
+
:return: The default branch (displayId without refs/heads/).
|
|
233
|
+
|
|
234
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp185
|
|
235
|
+
"""
|
|
236
|
+
return self.get("default-branch")["displayId"]
|
|
237
|
+
|
|
238
|
+
@default_branch.setter
|
|
239
|
+
def default_branch(self, branch):
|
|
240
|
+
"""
|
|
241
|
+
Set the default branch.
|
|
242
|
+
|
|
243
|
+
:param id: string: The default branch to set (without refs/heads/).
|
|
244
|
+
|
|
245
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp186
|
|
246
|
+
"""
|
|
247
|
+
self.put("default-branch", data={"id": "refs/heads/{}".format(branch)})
|
|
248
|
+
|
|
249
|
+
def forks(self):
|
|
250
|
+
"""
|
|
251
|
+
Get all forks.
|
|
252
|
+
|
|
253
|
+
:return: A generator object for the forks.
|
|
254
|
+
|
|
255
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp188
|
|
256
|
+
"""
|
|
257
|
+
for fork in self._get_paged("forks"):
|
|
258
|
+
yield fork
|
|
259
|
+
|
|
260
|
+
def related(self):
|
|
261
|
+
"""
|
|
262
|
+
Get all related repositories.
|
|
263
|
+
|
|
264
|
+
:return: A generator for the related repository objects
|
|
265
|
+
|
|
266
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp195
|
|
267
|
+
"""
|
|
268
|
+
for repository in self._get_paged("related"):
|
|
269
|
+
yield self.__get_object(repository)
|
|
270
|
+
|
|
271
|
+
@property
|
|
272
|
+
def groups(self):
|
|
273
|
+
"""
|
|
274
|
+
Property to access the project groups:
|
|
275
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp279
|
|
276
|
+
"""
|
|
277
|
+
return self.__groups
|
|
278
|
+
|
|
279
|
+
@property
|
|
280
|
+
def users(self):
|
|
281
|
+
"""
|
|
282
|
+
Property to access the project groups
|
|
283
|
+
API docs: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp285
|
|
284
|
+
"""
|
|
285
|
+
return self.__users
|
|
286
|
+
|
|
287
|
+
def download_archive(
|
|
288
|
+
self,
|
|
289
|
+
dest_fd,
|
|
290
|
+
at=None,
|
|
291
|
+
filename=None,
|
|
292
|
+
format=None,
|
|
293
|
+
path=None,
|
|
294
|
+
prefix=None,
|
|
295
|
+
chunk_size=128,
|
|
296
|
+
):
|
|
297
|
+
"""
|
|
298
|
+
Downloads a repository archive.
|
|
299
|
+
Note that the data is written to the specified file-like object,
|
|
300
|
+
rather than simply being returned.
|
|
301
|
+
For further information visit:
|
|
302
|
+
https://docs.atlassian.com/bitbucket-server/rest/7.13.0/bitbucket-rest.html#idp199
|
|
303
|
+
:param dest_fd: a file-like object to which the archive will be written
|
|
304
|
+
:param at: string: Optional, the commit to download an archive of; if not supplied, an archive of the default branch is downloaded
|
|
305
|
+
:param filename: string: Optional, a filename to include the "Content-Disposition" header
|
|
306
|
+
:param format: string: Optional, the format to stream the archive in; must be one of: zip, tar, tar.gz or tgz.
|
|
307
|
+
If not specified, then the archive will be in zip format.
|
|
308
|
+
:param path: string: Optional, path to include in the streamed archive
|
|
309
|
+
:param prefix: string: Optional, a prefix to apply to all entries in the streamed archive;
|
|
310
|
+
if the supplied prefix does not end with a trailing /, one will be added automatically
|
|
311
|
+
:param chunk_size: int: Optional, download chunk size. Defeault is 128
|
|
312
|
+
"""
|
|
313
|
+
params = {}
|
|
314
|
+
if at is not None:
|
|
315
|
+
params["at"] = at
|
|
316
|
+
if filename is not None:
|
|
317
|
+
params["filename"] = filename
|
|
318
|
+
if format is not None:
|
|
319
|
+
params["format"] = format
|
|
320
|
+
if path is not None:
|
|
321
|
+
params["path"] = path
|
|
322
|
+
if prefix is not None:
|
|
323
|
+
params["prefix"] = prefix
|
|
324
|
+
headers = {"Accept": "*/*"}
|
|
325
|
+
response = self.get("archive", params=params, headers=headers, advanced_mode=True)
|
|
326
|
+
for chunk in response.iter_content(chunk_size=chunk_size):
|
|
327
|
+
dest_fd.write(chunk)
|
atlassian/cloud_admin.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
from .rest_client import AtlassianRestAPI
|
|
5
|
+
|
|
6
|
+
log = logging.getLogger(__name__)
|
|
7
|
+
|
|
8
|
+
ADMIN_URL = "https://api.atlassian.com"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CloudAdminOrgs(AtlassianRestAPI):
|
|
12
|
+
def __init__(self, admin_api_key, *args, **kwargs):
|
|
13
|
+
kwargs["token"] = admin_api_key
|
|
14
|
+
kwargs["api_root"] = "admin"
|
|
15
|
+
kwargs["api_version"] = "v1"
|
|
16
|
+
super(CloudAdminOrgs, self).__init__(url=ADMIN_URL, *args, **kwargs)
|
|
17
|
+
|
|
18
|
+
def get_organizations(self):
|
|
19
|
+
url = self.resource_url("orgs")
|
|
20
|
+
return self.get(url)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CloudAdminUsers(AtlassianRestAPI):
|
|
24
|
+
def __init__(self, admin_api_key, *args, **kwargs):
|
|
25
|
+
kwargs["token"] = admin_api_key
|
|
26
|
+
kwargs["api_root"] = "users"
|
|
27
|
+
kwargs["api_version"] = None
|
|
28
|
+
super(CloudAdminUsers, self).__init__(ADMIN_URL, *args, **kwargs)
|
|
29
|
+
|
|
30
|
+
def get_profile(self, account_id):
|
|
31
|
+
url = self.resource_url("{}/manage/profile".format(account_id))
|
|
32
|
+
return self.get(url)
|