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
atlassian/crowd.py
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
from jmespath import search
|
|
5
|
+
|
|
6
|
+
from .rest_client import AtlassianRestAPI
|
|
7
|
+
|
|
8
|
+
log = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Crowd(AtlassianRestAPI):
|
|
12
|
+
"""Crowd API wrapper.
|
|
13
|
+
Important to note that you will have to use an application credentials,
|
|
14
|
+
not user credentials, in order to access Crowd APIs"""
|
|
15
|
+
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
url,
|
|
19
|
+
username,
|
|
20
|
+
password,
|
|
21
|
+
timeout=60,
|
|
22
|
+
api_root="rest",
|
|
23
|
+
api_version="latest",
|
|
24
|
+
):
|
|
25
|
+
super(Crowd, self).__init__(url, username, password, timeout, api_root, api_version)
|
|
26
|
+
|
|
27
|
+
def _crowd_api_url(self, api, resource):
|
|
28
|
+
return "/{api_root}/{api}/{version}/{resource}".format(
|
|
29
|
+
api_root=self.api_root,
|
|
30
|
+
api=api,
|
|
31
|
+
version=self.api_version,
|
|
32
|
+
resource=resource,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
def _user_change_status(self, username, active):
|
|
36
|
+
"""
|
|
37
|
+
Change user status.
|
|
38
|
+
:param username: str - username
|
|
39
|
+
:param active: bool - True/False
|
|
40
|
+
:return:
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
user = self.user(username)
|
|
44
|
+
|
|
45
|
+
user_object = {
|
|
46
|
+
"name": username,
|
|
47
|
+
"active": active,
|
|
48
|
+
"display-name": user.get("display-name"),
|
|
49
|
+
"first-name": user.get("first-name"),
|
|
50
|
+
"last-name": user.get("last-name"),
|
|
51
|
+
"email": user.get("email"),
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
params = {"username": username}
|
|
55
|
+
|
|
56
|
+
return self.put(
|
|
57
|
+
self._crowd_api_url("usermanagement", "user"),
|
|
58
|
+
params=params,
|
|
59
|
+
data=user_object,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
def user(self, username):
|
|
63
|
+
"""
|
|
64
|
+
Get user information
|
|
65
|
+
:param username:
|
|
66
|
+
:return:
|
|
67
|
+
"""
|
|
68
|
+
params = {"username": username}
|
|
69
|
+
return self.get(self._crowd_api_url("usermanagement", "user"), params=params)
|
|
70
|
+
|
|
71
|
+
def user_activate(self, username):
|
|
72
|
+
"""
|
|
73
|
+
Activate user
|
|
74
|
+
:param username: str - username
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
return self._user_change_status(username, True)
|
|
78
|
+
|
|
79
|
+
def user_create(
|
|
80
|
+
self,
|
|
81
|
+
username,
|
|
82
|
+
active,
|
|
83
|
+
first_name,
|
|
84
|
+
last_name,
|
|
85
|
+
display_name,
|
|
86
|
+
email,
|
|
87
|
+
password,
|
|
88
|
+
):
|
|
89
|
+
"""
|
|
90
|
+
Create new user method
|
|
91
|
+
:param active: bool:
|
|
92
|
+
:param username: string: username
|
|
93
|
+
:param active: bool:
|
|
94
|
+
:param first_name: string:
|
|
95
|
+
:param last_name: string:
|
|
96
|
+
:param display_name: string:
|
|
97
|
+
:param email: string:
|
|
98
|
+
:param password: string:
|
|
99
|
+
:return:
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
user_object = {
|
|
103
|
+
"name": username,
|
|
104
|
+
"password": {"value": password},
|
|
105
|
+
"active": active,
|
|
106
|
+
"first-name": first_name,
|
|
107
|
+
"last-name": last_name,
|
|
108
|
+
"display-name": display_name,
|
|
109
|
+
"email": email,
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return self.post(self._crowd_api_url("usermanagement", "user"), data=user_object)
|
|
113
|
+
|
|
114
|
+
def user_deactivate(self, username):
|
|
115
|
+
"""
|
|
116
|
+
Deactivate user
|
|
117
|
+
|
|
118
|
+
:return:
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
return self._user_change_status(username, False)
|
|
122
|
+
|
|
123
|
+
def user_delete(self, username):
|
|
124
|
+
"""
|
|
125
|
+
Delete user
|
|
126
|
+
:param username: str - username
|
|
127
|
+
:return:
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
params = {"username": username}
|
|
131
|
+
|
|
132
|
+
return self.delete(self._crowd_api_url("usermanagement", "user"), params=params)
|
|
133
|
+
|
|
134
|
+
def user_groups(self, username, kind="direct"):
|
|
135
|
+
"""
|
|
136
|
+
Get user's all group info
|
|
137
|
+
:param username: str - username
|
|
138
|
+
:param kind: str - group type
|
|
139
|
+
:return: The specify user's group info
|
|
140
|
+
"""
|
|
141
|
+
path = self._crowd_api_url("usermanagement", "user/group/{kind}".format(kind=kind))
|
|
142
|
+
response = self.get(path, params={"username": username})
|
|
143
|
+
return search("groups[*].name", response)
|
|
144
|
+
|
|
145
|
+
def group_members(self, group, kind="direct", max_results=99999):
|
|
146
|
+
"""
|
|
147
|
+
Get group's all direct members
|
|
148
|
+
:param group: str - group name
|
|
149
|
+
:param kind: str - group type
|
|
150
|
+
:param max_results: int - maximum number of results
|
|
151
|
+
:return: The specify group's direct members info
|
|
152
|
+
"""
|
|
153
|
+
path = self._crowd_api_url("usermanagement", "group/user/{kind}".format(kind=kind))
|
|
154
|
+
params = {"groupname": group, "max-results": max_results}
|
|
155
|
+
response = self.get(path, params=params)
|
|
156
|
+
return search("users[*].name", response)
|
|
157
|
+
|
|
158
|
+
def is_user_in_group(self, username, group, kind="direct"):
|
|
159
|
+
"""
|
|
160
|
+
Check if the user is a member of the group
|
|
161
|
+
:param username: str - username
|
|
162
|
+
:param group: str - group name
|
|
163
|
+
:param kind: str - group type
|
|
164
|
+
:return: bool - Return `True` or `False`
|
|
165
|
+
"""
|
|
166
|
+
path = self._crowd_api_url("usermanagement", "group/user/{kind}".format(kind=kind))
|
|
167
|
+
params = {"username": username, "groupname": group}
|
|
168
|
+
response = self.get(path, params=params, advanced_mode=True)
|
|
169
|
+
return response.status_code == 200
|
|
170
|
+
|
|
171
|
+
def group_add_user(self, username, groupname):
|
|
172
|
+
"""
|
|
173
|
+
Add user to group
|
|
174
|
+
:return:
|
|
175
|
+
"""
|
|
176
|
+
|
|
177
|
+
data = {"name": groupname}
|
|
178
|
+
|
|
179
|
+
params = {"username": username}
|
|
180
|
+
|
|
181
|
+
return self.post(
|
|
182
|
+
self._crowd_api_url("usermanagement", "user/group/direct"),
|
|
183
|
+
params=params,
|
|
184
|
+
json=data,
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
def health_check(self):
|
|
188
|
+
"""
|
|
189
|
+
Get health status
|
|
190
|
+
https://confluence.atlassian.com/jirakb/how-to-retrieve-health-check-results-using-rest-api-867195158.html
|
|
191
|
+
:return:
|
|
192
|
+
"""
|
|
193
|
+
# check as Troubleshooting & Support Tools Plugin
|
|
194
|
+
response = self.get("rest/troubleshooting/1.0/check/")
|
|
195
|
+
if not response:
|
|
196
|
+
# check as support tools
|
|
197
|
+
response = self.get("rest/supportHealthCheck/1.0/check/")
|
|
198
|
+
return response
|
|
199
|
+
|
|
200
|
+
def get_plugins_info(self):
|
|
201
|
+
"""
|
|
202
|
+
Provide plugins info
|
|
203
|
+
:return a json of installed plugins
|
|
204
|
+
"""
|
|
205
|
+
url = "rest/plugins/1.0/"
|
|
206
|
+
return self.get(url, headers=self.no_check_headers, trailing=True)
|
|
207
|
+
|
|
208
|
+
def get_plugin_info(self, plugin_key):
|
|
209
|
+
"""
|
|
210
|
+
Provide plugin info
|
|
211
|
+
:return a json of installed plugins
|
|
212
|
+
"""
|
|
213
|
+
url = "rest/plugins/1.0/{plugin_key}-key".format(plugin_key=plugin_key)
|
|
214
|
+
return self.get(url, headers=self.no_check_headers, trailing=True)
|
|
215
|
+
|
|
216
|
+
def get_plugin_license_info(self, plugin_key):
|
|
217
|
+
"""
|
|
218
|
+
Provide plugin license info
|
|
219
|
+
:return a json specific License query
|
|
220
|
+
"""
|
|
221
|
+
url = "rest/plugins/1.0/{plugin_key}-key/license".format(plugin_key=plugin_key)
|
|
222
|
+
return self.get(url, headers=self.no_check_headers, trailing=True)
|
|
223
|
+
|
|
224
|
+
def upload_plugin(self, plugin_path):
|
|
225
|
+
"""
|
|
226
|
+
Provide plugin path for upload into Jira e.g. useful for auto deploy
|
|
227
|
+
:param plugin_path:
|
|
228
|
+
:return:
|
|
229
|
+
"""
|
|
230
|
+
files = {"plugin": open(plugin_path, "rb")}
|
|
231
|
+
upm_token = self.request(
|
|
232
|
+
method="GET",
|
|
233
|
+
path="rest/plugins/1.0/",
|
|
234
|
+
headers=self.no_check_headers,
|
|
235
|
+
trailing=True,
|
|
236
|
+
).headers["upm-token"]
|
|
237
|
+
url = "rest/plugins/1.0/?token={upm_token}".format(upm_token=upm_token)
|
|
238
|
+
return self.post(url, files=files, headers=self.no_check_headers)
|
|
239
|
+
|
|
240
|
+
def delete_plugin(self, plugin_key):
|
|
241
|
+
"""
|
|
242
|
+
Delete plugin
|
|
243
|
+
:param plugin_key:
|
|
244
|
+
:return:
|
|
245
|
+
"""
|
|
246
|
+
url = "rest/plugins/1.0/{}-key".format(plugin_key)
|
|
247
|
+
return self.delete(url)
|
|
248
|
+
|
|
249
|
+
def check_plugin_manager_status(self):
|
|
250
|
+
url = "rest/plugins/latest/safe-mode"
|
|
251
|
+
return self.request(method="GET", path=url, headers=self.safe_mode_headers)
|
|
252
|
+
|
|
253
|
+
def update_plugin_license(self, plugin_key, raw_license):
|
|
254
|
+
"""
|
|
255
|
+
Update license for plugin
|
|
256
|
+
:param plugin_key:
|
|
257
|
+
:param raw_license:
|
|
258
|
+
:return:
|
|
259
|
+
"""
|
|
260
|
+
app_headers = {
|
|
261
|
+
"X-Atlassian-Token": "nocheck",
|
|
262
|
+
"Content-Type": "application/vnd.atl.plugins+json",
|
|
263
|
+
}
|
|
264
|
+
url = "/plugins/1.0/{plugin_key}/license".format(plugin_key=plugin_key)
|
|
265
|
+
data = {"rawLicense": raw_license}
|
|
266
|
+
return self.put(url, data=data, headers=app_headers)
|
atlassian/errors.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ApiError(Exception):
|
|
5
|
+
def __init__(self, *args, **kwargs):
|
|
6
|
+
self.reason = kwargs.get("reason")
|
|
7
|
+
super(ApiError, self).__init__(*args)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ApiNotFoundError(ApiError):
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ApiPermissionError(ApiError):
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ApiValueError(ApiError):
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ApiConflictError(ApiError):
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ApiNotAcceptable(ApiError):
|
|
27
|
+
pass
|