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/utils.py
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
import logging
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
log = logging.getLogger(__name__)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def is_email(element):
|
|
9
|
+
"""
|
|
10
|
+
>>> is_email('username@example.com')
|
|
11
|
+
True
|
|
12
|
+
>>> is_email('example.com')
|
|
13
|
+
False
|
|
14
|
+
>>> is_email('firstname.lastname@domain.co.uk')
|
|
15
|
+
True
|
|
16
|
+
"""
|
|
17
|
+
email_regex = r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$"
|
|
18
|
+
return re.match(email_regex, str(element))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def html_email(email, title=None):
|
|
22
|
+
"""
|
|
23
|
+
>>> html_email('username@example.com')
|
|
24
|
+
'<a href="mailto:username@example.com">username@example.com</a>'
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
if not title:
|
|
28
|
+
title = email
|
|
29
|
+
|
|
30
|
+
return '<a href="mailto:{email}">{title}</a>'.format(email=email, title=title)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def html_list(data):
|
|
34
|
+
"""
|
|
35
|
+
>>> html_list(['example.com', 'admin1@example.com', 'admin2@example.com'])
|
|
36
|
+
'<ul>
|
|
37
|
+
<li>example.com</li>
|
|
38
|
+
<li><a href="mailto:admin1@example.com">admin1@example.com</a></li>
|
|
39
|
+
<li><a href="mailto:admin2@example.com">admin2@example.com</a></li>
|
|
40
|
+
</ul>'
|
|
41
|
+
"""
|
|
42
|
+
html = "<ul>"
|
|
43
|
+
for item in data:
|
|
44
|
+
if isinstance(item, dict):
|
|
45
|
+
if item.get("email"):
|
|
46
|
+
item = html_email(item.get("email"), item.get("name", None))
|
|
47
|
+
elif item.get("name"):
|
|
48
|
+
item = item.get("name")
|
|
49
|
+
|
|
50
|
+
if is_email(item):
|
|
51
|
+
item = html_email(item, item)
|
|
52
|
+
html += "<li>{}</li>".format(item)
|
|
53
|
+
return html + "</ul>"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def html_table_header_row(data):
|
|
57
|
+
"""
|
|
58
|
+
>>> html_table_header_row(['administrators', 'key', 'leader', 'project'])
|
|
59
|
+
'\\n\\t<tr><th>Administrators</th><th>Key</th><th>Leader</th><th>Project</th></tr>'
|
|
60
|
+
>>> html_table_header_row(['key', 'project', 'leader', 'administrators'])
|
|
61
|
+
'\\n\\t<tr><th>Key</th><th>Project</th><th>Leader</th><th>Administrators</th></tr>'
|
|
62
|
+
"""
|
|
63
|
+
html = "\n\t<tr>"
|
|
64
|
+
for th in data:
|
|
65
|
+
title = th.replace("_", " ").title()
|
|
66
|
+
html += "<th>{}</th>".format(title)
|
|
67
|
+
return html + "</tr>"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def html_row_with_ordered_headers(data, col_headers, row_header=None):
|
|
71
|
+
"""
|
|
72
|
+
>>> headers = ['administrators', 'key', 'leader', 'project']
|
|
73
|
+
>>> data = {'key': 'DEMO', 'project': 'Demonstration',
|
|
74
|
+
'leader': 'leader@example.com',
|
|
75
|
+
'administrators': ['admin1@example.com', 'admin2@example.com']}
|
|
76
|
+
>>> html_row_with_ordered_headers(data, headers)
|
|
77
|
+
'\\n\\t<tr><td><ul>
|
|
78
|
+
<li><a href="mailto:admin1@example.com">admin1@example.com</a></li>
|
|
79
|
+
<li><a href="mailto:admin2@example.com">admin2@example.com</a></li>
|
|
80
|
+
</ul></td><td>DEMO</td><td>leader@example.com</td><td>Demonstration</td></tr>'
|
|
81
|
+
>>> headers = ['key', 'project', 'leader', 'administrators']
|
|
82
|
+
>>> html_row_with_ordered_headers(data, headers)
|
|
83
|
+
'\\n\\t<tr><td>DEMO</td><td>Demonstration</td>
|
|
84
|
+
<td>leader@example.com</td><td>
|
|
85
|
+
<ul>
|
|
86
|
+
<li><a href="mailto:admin1@example.com">admin1@example.com</a></li>
|
|
87
|
+
<li><a href="mailto:admin2@example.com">admin2@example.com</a></li>
|
|
88
|
+
</ul></td></tr>'
|
|
89
|
+
"""
|
|
90
|
+
html = "\n\t<tr>"
|
|
91
|
+
if row_header:
|
|
92
|
+
html += "<th>{}</th>".format(row_header.replace("_", " ").title())
|
|
93
|
+
for header in col_headers:
|
|
94
|
+
element = data[header]
|
|
95
|
+
if isinstance(element, list):
|
|
96
|
+
element = html_list(element)
|
|
97
|
+
|
|
98
|
+
if is_email(element):
|
|
99
|
+
element = html_email(element)
|
|
100
|
+
html += "<td>{}</td>".format(element)
|
|
101
|
+
return html + "</tr>"
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def html_table_from_dict(data, ordering):
|
|
105
|
+
"""
|
|
106
|
+
>>> ordering = ['administrators', 'key', 'leader', 'project']
|
|
107
|
+
>>> data = [ \
|
|
108
|
+
{'key': 'DEMO', 'project': 'Demo project', 'leader': 'lead@example.com', \
|
|
109
|
+
'administrators': ['admin@example.com', 'root@example.com']},]
|
|
110
|
+
>>> html_table_from_dict(data, ordering)
|
|
111
|
+
'<table>
|
|
112
|
+
<tbody>\\n
|
|
113
|
+
<tr>
|
|
114
|
+
<th>Administrators</th>
|
|
115
|
+
<th>Key</th>
|
|
116
|
+
<th>Leader</th>
|
|
117
|
+
<th>Project</th>
|
|
118
|
+
</tr>\\n
|
|
119
|
+
<tr>
|
|
120
|
+
<td>
|
|
121
|
+
<ul>
|
|
122
|
+
<li><a href="mailto:admin@example.com">admin@example.com</a></li>
|
|
123
|
+
<li><a href="mailto:root@example.com">root@example.com</a></li>
|
|
124
|
+
</ul>
|
|
125
|
+
</td>
|
|
126
|
+
<td>DEMO</td>
|
|
127
|
+
<td>lead@example.com</td>
|
|
128
|
+
<td>Demo project</td>
|
|
129
|
+
</tr>\\n
|
|
130
|
+
</tbody>
|
|
131
|
+
</table>'
|
|
132
|
+
>>> ordering = ['key', 'project', 'leader', 'administrators']
|
|
133
|
+
>>> html_table_from_dict(data, ordering)
|
|
134
|
+
'<table>
|
|
135
|
+
<tbody>\\n
|
|
136
|
+
<tr>
|
|
137
|
+
<th>Key</th>
|
|
138
|
+
<th>Project</th>
|
|
139
|
+
<th>Leader</th>
|
|
140
|
+
<th>Administrators</th>
|
|
141
|
+
</tr>\\n
|
|
142
|
+
<tr>
|
|
143
|
+
<td>DEMO</td>
|
|
144
|
+
<td>Demo project</td>
|
|
145
|
+
<td>lead@example.com</td>
|
|
146
|
+
<td>
|
|
147
|
+
<ul>
|
|
148
|
+
<li><a href="mailto:admin@example.com">admin@example.com</a></li>
|
|
149
|
+
<li><a href="mailto:root@example.com">root@example.com</a></li>
|
|
150
|
+
</ul>
|
|
151
|
+
</td>
|
|
152
|
+
</tr>\\n
|
|
153
|
+
</tbody>
|
|
154
|
+
</table>'
|
|
155
|
+
"""
|
|
156
|
+
html = "<table><tbody>"
|
|
157
|
+
html += html_table_header_row(ordering)
|
|
158
|
+
for row in data:
|
|
159
|
+
html += html_row_with_ordered_headers(row, ordering)
|
|
160
|
+
return html + "\n</tbody></table>"
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def html_table_from_nested_dict(data, ordering):
|
|
164
|
+
"""
|
|
165
|
+
>>> ordering = ['manager', 'admin', 'employee_count']
|
|
166
|
+
>>> data = {
|
|
167
|
+
'project_A': {'manager': 'John', 'admin': 'admin1@example.com', 'employee_count': '4'},
|
|
168
|
+
'project_B': {'manager': 'Jane', 'admin': 'admin2@example.com', 'employee_count': '7'}
|
|
169
|
+
}
|
|
170
|
+
>>> html_table_from_nested_dict(data, ordering)
|
|
171
|
+
<table>
|
|
172
|
+
<tbody>
|
|
173
|
+
<tr>
|
|
174
|
+
<th></th>
|
|
175
|
+
<th>Manager</th>
|
|
176
|
+
<th>Admin</th>
|
|
177
|
+
<th>Employee Count</th>
|
|
178
|
+
</tr>
|
|
179
|
+
<tr>
|
|
180
|
+
<th>Project A</th>
|
|
181
|
+
<td>John</td>
|
|
182
|
+
<td><a href="mailto:admin1@example.com">admin1@example.com</a></td>
|
|
183
|
+
<td>4</td>
|
|
184
|
+
</tr>
|
|
185
|
+
<tr>
|
|
186
|
+
<th>Project B</th>
|
|
187
|
+
<td>Jane</td>
|
|
188
|
+
<td><a href="mailto:admin2@example.com">admin2@example.com</a></td>
|
|
189
|
+
<td>7</td>
|
|
190
|
+
</tr>
|
|
191
|
+
</tbody>
|
|
192
|
+
</table>
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
html = "<table><tbody>"
|
|
196
|
+
# Add an empty first cell for the row header column
|
|
197
|
+
header_row = [""]
|
|
198
|
+
header_row.extend(ordering)
|
|
199
|
+
html += html_table_header_row(header_row)
|
|
200
|
+
|
|
201
|
+
for row_header, row in data.items():
|
|
202
|
+
html += html_row_with_ordered_headers(row, ordering, row_header)
|
|
203
|
+
|
|
204
|
+
return html + "\n</tbody></table>"
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def block_code_macro_confluence(code, lang=None):
|
|
208
|
+
"""
|
|
209
|
+
Wrap into code block macro
|
|
210
|
+
:param code:
|
|
211
|
+
:param lang:
|
|
212
|
+
:return:
|
|
213
|
+
"""
|
|
214
|
+
if not lang:
|
|
215
|
+
lang = ""
|
|
216
|
+
return (
|
|
217
|
+
"""\
|
|
218
|
+
<ac:structured-macro ac:name="code" ac:schema-version="1">
|
|
219
|
+
<ac:parameter ac:name="language">{lang}</ac:parameter>
|
|
220
|
+
<ac:plain-text-body><![CDATA[{code}]]></ac:plain-text-body>
|
|
221
|
+
</ac:structured-macro>
|
|
222
|
+
"""
|
|
223
|
+
).format(lang=lang, code=code)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def html_code__macro_confluence(text):
|
|
227
|
+
"""
|
|
228
|
+
Wrap into html macro
|
|
229
|
+
:param text:
|
|
230
|
+
:return:
|
|
231
|
+
"""
|
|
232
|
+
return (
|
|
233
|
+
"""\
|
|
234
|
+
<ac:structured-macro ac:name="html" ac:schema-version="1">
|
|
235
|
+
<ac:plain-text-body><![CDATA[{text}]]></ac:plain-text-body>
|
|
236
|
+
</ac:structured-macro>
|
|
237
|
+
"""
|
|
238
|
+
).format(text=text)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def noformat_code_macro_confluence(text, nopanel=None):
|
|
242
|
+
"""
|
|
243
|
+
Wrap into code block macro
|
|
244
|
+
:param text:
|
|
245
|
+
:param nopanel: (bool) True or False Removes the panel around the content.
|
|
246
|
+
:return:
|
|
247
|
+
"""
|
|
248
|
+
if not nopanel:
|
|
249
|
+
nopanel = False
|
|
250
|
+
return (
|
|
251
|
+
"""\
|
|
252
|
+
<ac:structured-macro ac:name="noformat" ac:schema-version="1">
|
|
253
|
+
<ac:parameter ac:name="nopanel">{nopanel}</ac:parameter>
|
|
254
|
+
<ac:plain-text-body><![CDATA[{text}]]></ac:plain-text-body>
|
|
255
|
+
</ac:structured-macro>
|
|
256
|
+
"""
|
|
257
|
+
).format(nopanel=nopanel, text=text)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def symbol_normalizer(text):
|
|
261
|
+
if not text:
|
|
262
|
+
return ""
|
|
263
|
+
result = text
|
|
264
|
+
result = result.replace("Ä", "Ä")
|
|
265
|
+
result = result.replace("ä", "ä")
|
|
266
|
+
result = result.replace("Ë", "Ë")
|
|
267
|
+
result = result.replace("ë", "ë")
|
|
268
|
+
result = result.replace("Ï", "Ï")
|
|
269
|
+
result = result.replace("ï", "ï")
|
|
270
|
+
result = result.replace("Ö", "Ö")
|
|
271
|
+
result = result.replace("ö", "ö")
|
|
272
|
+
result = result.replace("Ü", "Ü")
|
|
273
|
+
result = result.replace("ü", "ü")
|
|
274
|
+
result = result.replace("Á", "Á")
|
|
275
|
+
result = result.replace("á", "á")
|
|
276
|
+
result = result.replace("É", "É")
|
|
277
|
+
result = result.replace("é", "é")
|
|
278
|
+
result = result.replace("Í", "Í")
|
|
279
|
+
result = result.replace("í", "í")
|
|
280
|
+
result = result.replace("Ó", "Ó")
|
|
281
|
+
result = result.replace("ó", "ó")
|
|
282
|
+
result = result.replace("Ú", "Ú")
|
|
283
|
+
result = result.replace("ú", "ú")
|
|
284
|
+
result = result.replace("À", "À")
|
|
285
|
+
result = result.replace("à", "à")
|
|
286
|
+
result = result.replace("È", "È")
|
|
287
|
+
result = result.replace("è", "è")
|
|
288
|
+
result = result.replace("Ì", "Ì")
|
|
289
|
+
result = result.replace("ì", "ì")
|
|
290
|
+
result = result.replace("Ò", "Ò")
|
|
291
|
+
result = result.replace("ò", "ò")
|
|
292
|
+
result = result.replace("Ù", "Ù")
|
|
293
|
+
result = result.replace("ù", "ù")
|
|
294
|
+
result = result.replace("Â", "Â")
|
|
295
|
+
result = result.replace("â", "â")
|
|
296
|
+
result = result.replace("Ê", "Ê")
|
|
297
|
+
result = result.replace("ê", "ê")
|
|
298
|
+
result = result.replace("Î", "Î")
|
|
299
|
+
result = result.replace("î", "î")
|
|
300
|
+
result = result.replace("Ô", "Ô")
|
|
301
|
+
result = result.replace("ô", "ô")
|
|
302
|
+
result = result.replace("Û", "Û")
|
|
303
|
+
result = result.replace("û", "û")
|
|
304
|
+
result = result.replace("Å", "Å")
|
|
305
|
+
result = result.replace("å", "å")
|
|
306
|
+
result = result.replace("°", "°")
|
|
307
|
+
return result
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def parse_cookie_file(cookie_file):
|
|
311
|
+
"""
|
|
312
|
+
Parse a cookies.txt file (Netscape HTTP Cookie File)
|
|
313
|
+
return a dictionary of key value pairs
|
|
314
|
+
compatible with requests.
|
|
315
|
+
:param cookie_file: a cookie file
|
|
316
|
+
:return dict of cookies pairs
|
|
317
|
+
"""
|
|
318
|
+
cookies = {}
|
|
319
|
+
with open(cookie_file, "r") as fp:
|
|
320
|
+
for line in fp:
|
|
321
|
+
if not re.match(r"^(#|$)", line):
|
|
322
|
+
line_fields = line.strip().split("\t")
|
|
323
|
+
try:
|
|
324
|
+
cookies[line_fields[5]] = line_fields[6]
|
|
325
|
+
except IndexError as e:
|
|
326
|
+
log.error(e)
|
|
327
|
+
return cookies
|