atlassian-python-api 4.0.3__py3-none-any.whl → 4.0.5__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 -1
- atlassian/__init__.py +7 -1
- atlassian/assets.py +626 -0
- atlassian/bamboo.py +1 -0
- atlassian/bitbucket/__init__.py +5 -9
- atlassian/bitbucket/base.py +1 -1
- atlassian/bitbucket/cloud/__init__.py +5 -1
- atlassian/bitbucket/cloud/base.py +2 -2
- atlassian/bitbucket/cloud/common/users.py +48 -0
- atlassian/bitbucket/cloud/repositories/__init__.py +11 -3
- atlassian/bitbucket/cloud/repositories/deploymentEnvironments.py +1 -1
- atlassian/bitbucket/cloud/repositories/downloads.py +75 -0
- atlassian/cloud_admin.py +85 -0
- atlassian/{confluence.py → confluence/__init__.py} +250 -14
- atlassian/errors.py +9 -0
- atlassian/insight.py +1 -1
- atlassian/jira.py +107 -31
- atlassian/request_utils.py +3 -28
- atlassian/rest_client.py +16 -5
- {atlassian_python_api-4.0.3.dist-info → atlassian_python_api-4.0.5.dist-info}/METADATA +3 -4
- {atlassian_python_api-4.0.3.dist-info → atlassian_python_api-4.0.5.dist-info}/RECORD +24 -22
- {atlassian_python_api-4.0.3.dist-info → atlassian_python_api-4.0.5.dist-info}/WHEEL +1 -1
- {atlassian_python_api-4.0.3.dist-info → atlassian_python_api-4.0.5.dist-info}/licenses/LICENSE +0 -0
- {atlassian_python_api-4.0.3.dist-info → atlassian_python_api-4.0.5.dist-info}/top_level.txt +0 -0
atlassian/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.0.
|
|
1
|
+
4.0.5
|
atlassian/__init__.py
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Atlassian Python API
|
|
3
|
+
"""
|
|
4
|
+
|
|
1
5
|
from .bamboo import Bamboo
|
|
2
6
|
from .bitbucket import Bitbucket
|
|
3
7
|
from .bitbucket import Bitbucket as Stash
|
|
@@ -5,7 +9,8 @@ from .cloud_admin import CloudAdminOrgs, CloudAdminUsers
|
|
|
5
9
|
from .confluence import Confluence
|
|
6
10
|
from .crowd import Crowd
|
|
7
11
|
from .insight import Insight
|
|
8
|
-
from .insight import Insight as Assets
|
|
12
|
+
from .insight import Insight as Assets # used for Insight on-premise
|
|
13
|
+
from .assets import AssetsCloud # used for Insight Cloud
|
|
9
14
|
from .jira import Jira
|
|
10
15
|
from .marketplace import MarketPlace
|
|
11
16
|
from .portfolio import Portfolio
|
|
@@ -29,4 +34,5 @@ __all__ = [
|
|
|
29
34
|
"Xray",
|
|
30
35
|
"Insight",
|
|
31
36
|
"Assets",
|
|
37
|
+
"AssetsCloud",
|
|
32
38
|
]
|
atlassian/assets.py
ADDED
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
from .rest_client import AtlassianRestAPI
|
|
5
|
+
|
|
6
|
+
# from deprecated import deprecated
|
|
7
|
+
|
|
8
|
+
log = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class AssetsCloud(AtlassianRestAPI):
|
|
12
|
+
"""Assets for Jira API wrapper."""
|
|
13
|
+
|
|
14
|
+
# https://developer.atlassian.com/cloud/assets/rest
|
|
15
|
+
|
|
16
|
+
def __init__(self, *args, **kwargs):
|
|
17
|
+
"""
|
|
18
|
+
Initialize Assets()
|
|
19
|
+
|
|
20
|
+
:param args:
|
|
21
|
+
:param kwargs:
|
|
22
|
+
:return: Assets()
|
|
23
|
+
"""
|
|
24
|
+
kwargs["api_root"] = "rest/assets/1.0"
|
|
25
|
+
# If cloud is set to true, trigger private __cloud__init method
|
|
26
|
+
if kwargs.get("cloud"):
|
|
27
|
+
args, kwargs = self.__cloud_init(*args, **kwargs)
|
|
28
|
+
super(AssetsCloud, self).__init__(*args, **kwargs)
|
|
29
|
+
|
|
30
|
+
def __cloud_init(self, *args, **kwargs):
|
|
31
|
+
"""
|
|
32
|
+
Creates a Cloud specific version of Assets()
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
Assets(AtlassianRestAPI)
|
|
36
|
+
"""
|
|
37
|
+
# trigger a normal init and avoid looping
|
|
38
|
+
del kwargs["cloud"]
|
|
39
|
+
temp = AssetsCloud(*args, **kwargs)
|
|
40
|
+
# retrieve cloud workspace id and generate the api_root
|
|
41
|
+
kwargs["api_root"] = f"/jsm/assets/workspace/{temp.__get_workspace_id()}/v1/"
|
|
42
|
+
# Assets cloud uses the atlassian base url, not custom instance urls
|
|
43
|
+
kwargs["url"] = "https://api.atlassian.com"
|
|
44
|
+
# set cloud back to true and return
|
|
45
|
+
kwargs["cloud"] = True
|
|
46
|
+
# Assets cloud is particular about its headers.
|
|
47
|
+
self.default_headers = {"Accept": "application/json", "Content-Type": "application/json"}
|
|
48
|
+
return args, kwargs
|
|
49
|
+
|
|
50
|
+
def __get_workspace_id(self):
|
|
51
|
+
result = self.get(
|
|
52
|
+
"rest/servicedeskapi/assets/workspace",
|
|
53
|
+
headers=self.default_headers,
|
|
54
|
+
)
|
|
55
|
+
return result["values"][0]["workspaceId"]
|
|
56
|
+
|
|
57
|
+
def _get_assets_workspace_ids(self):
|
|
58
|
+
"""
|
|
59
|
+
Returns all Assets workspace Ids.
|
|
60
|
+
:return: List
|
|
61
|
+
"""
|
|
62
|
+
result = self.get(
|
|
63
|
+
"rest/servicedeskapi/assets/workspace",
|
|
64
|
+
headers=self.experimental_headers,
|
|
65
|
+
)
|
|
66
|
+
return [i["workspaceId"] for i in result["values"]]
|
|
67
|
+
|
|
68
|
+
def _get_assets_workspace_id(self):
|
|
69
|
+
"""
|
|
70
|
+
Returns the first Assets workspace ID.
|
|
71
|
+
:return: str
|
|
72
|
+
"""
|
|
73
|
+
return next(iter(self._get_assets_workspace_ids()))
|
|
74
|
+
|
|
75
|
+
# Attachments
|
|
76
|
+
def get_attachments_of_objects(self, object_id):
|
|
77
|
+
"""
|
|
78
|
+
Get Attachment info
|
|
79
|
+
Example output:
|
|
80
|
+
[
|
|
81
|
+
{
|
|
82
|
+
"id": 1,
|
|
83
|
+
"author": "admin",
|
|
84
|
+
"mimeType": "image/png",
|
|
85
|
+
"filename": "astronaut.png",
|
|
86
|
+
"filesize": "490 B",
|
|
87
|
+
"created": "2019-11-27T11:42:22.283Z",
|
|
88
|
+
"comment": "",
|
|
89
|
+
"commentOutput": "",
|
|
90
|
+
"url": "http://jira/rest/assets/1.0/attachments/1"
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
:param object_id Object ID
|
|
95
|
+
:return list of object
|
|
96
|
+
id: required(string)
|
|
97
|
+
author: (string)
|
|
98
|
+
mimeType: (string)
|
|
99
|
+
filename: required(string)
|
|
100
|
+
filesize: (string)
|
|
101
|
+
created: required(datetime)
|
|
102
|
+
comment: (string)
|
|
103
|
+
commentOutput: (string)
|
|
104
|
+
url: required(string)
|
|
105
|
+
"""
|
|
106
|
+
if self.cloud:
|
|
107
|
+
raise NotImplementedError
|
|
108
|
+
url = self.url_joiner(
|
|
109
|
+
self.api_root,
|
|
110
|
+
f"attachments/object/{object_id}",
|
|
111
|
+
)
|
|
112
|
+
return self.get(url)
|
|
113
|
+
|
|
114
|
+
def upload_attachment_to_object(self, object_id, filename):
|
|
115
|
+
"""
|
|
116
|
+
Add attachment to Object
|
|
117
|
+
:param object_id: int
|
|
118
|
+
:param filename: str, name, if file in current directory or full path to file
|
|
119
|
+
"""
|
|
120
|
+
if self.cloud:
|
|
121
|
+
raise NotImplementedError
|
|
122
|
+
log.info("Adding attachment...")
|
|
123
|
+
url = f"rest/assets/1.0/attachments/object/{object_id}"
|
|
124
|
+
with open(filename, "rb") as attachment:
|
|
125
|
+
files = {"file": attachment}
|
|
126
|
+
return self.post(url, headers=self.no_check_headers, files=files)
|
|
127
|
+
|
|
128
|
+
def delete_attachment(self, attachment_id):
|
|
129
|
+
"""
|
|
130
|
+
Add attachment to Object
|
|
131
|
+
:param attachment_id: int
|
|
132
|
+
"""
|
|
133
|
+
if self.cloud:
|
|
134
|
+
raise NotImplementedError
|
|
135
|
+
log.info("Deleting attachment...")
|
|
136
|
+
url = f"rest/assets/1.0/attachments/{attachment_id}"
|
|
137
|
+
return self.delete(url)
|
|
138
|
+
|
|
139
|
+
# Comments
|
|
140
|
+
# Handle comments on objets
|
|
141
|
+
def add_comment_to_object(self, comment, object_id, role):
|
|
142
|
+
"""
|
|
143
|
+
Add comment to Object
|
|
144
|
+
|
|
145
|
+
:param comment: str
|
|
146
|
+
:param object_id: int - Object ID
|
|
147
|
+
:param role: int - Role ID
|
|
148
|
+
0 Assets Users
|
|
149
|
+
1 Assets Managers
|
|
150
|
+
2 Assets Administrators
|
|
151
|
+
3 Assets Developers
|
|
152
|
+
:return:
|
|
153
|
+
{
|
|
154
|
+
"created": "2019-11-27T12:37:41.492Z",
|
|
155
|
+
"updated": "2019-11-27T12:37:41.492Z",
|
|
156
|
+
"id": 1,
|
|
157
|
+
"actor": {
|
|
158
|
+
"avatarUrl": "https://www.gravatar.com/avatar/64e1b8d34f425d19e1ee2ea7236d3028?d=mm&s=48",
|
|
159
|
+
"displayName": "admin",
|
|
160
|
+
"name": "admin",
|
|
161
|
+
"key": "admin",
|
|
162
|
+
"renderedLink": "<a href=\"/jira/secure/ViewProfile.jspa?name=admin\">admin</a>",
|
|
163
|
+
"isDeleted": false
|
|
164
|
+
},
|
|
165
|
+
"role": 0,
|
|
166
|
+
"comment": "A comment to be added",
|
|
167
|
+
"commentOutput": "A comment to be added",
|
|
168
|
+
"objectId": 1,
|
|
169
|
+
"canEdit": true,
|
|
170
|
+
"canDelete": true
|
|
171
|
+
}
|
|
172
|
+
"""
|
|
173
|
+
if self.cloud:
|
|
174
|
+
raise NotImplementedError
|
|
175
|
+
params = {"comment": comment, "objectId": object_id, "role": role}
|
|
176
|
+
url = "rest/assets/1.0/comment/create"
|
|
177
|
+
return self.post(url, params=params)
|
|
178
|
+
|
|
179
|
+
def get_comment_of_object(self, object_id):
|
|
180
|
+
"""
|
|
181
|
+
The object id to fetch comments from
|
|
182
|
+
|
|
183
|
+
:param object_id:
|
|
184
|
+
:return:
|
|
185
|
+
"""
|
|
186
|
+
if self.cloud:
|
|
187
|
+
raise NotImplementedError
|
|
188
|
+
url = f"rest/assets/1.0/comment/object/{object_id}"
|
|
189
|
+
return self.get(url)
|
|
190
|
+
|
|
191
|
+
# Icon
|
|
192
|
+
# Resources dedicated to load and find icons
|
|
193
|
+
def get_icon_by_id(self, icon_id):
|
|
194
|
+
"""
|
|
195
|
+
Load a single icon by id
|
|
196
|
+
|
|
197
|
+
:param icon_id:
|
|
198
|
+
:return:
|
|
199
|
+
{
|
|
200
|
+
"id": 1,
|
|
201
|
+
"name": "Delete",
|
|
202
|
+
"url16": "http://jira/rest/assets/1.0/icon/1/icon.png?size=16",
|
|
203
|
+
"url48": "http://jira/rest/assets/1.0/icon/1/icon.png?size=48"
|
|
204
|
+
}
|
|
205
|
+
"""
|
|
206
|
+
url = self.url_joiner(self.api_root, f"icon/{icon_id}")
|
|
207
|
+
return self.get(url)
|
|
208
|
+
|
|
209
|
+
def get_all_global_icons(self):
|
|
210
|
+
"""
|
|
211
|
+
All existing global icons
|
|
212
|
+
|
|
213
|
+
:return:
|
|
214
|
+
"""
|
|
215
|
+
url = self.url_joiner(self.api_root, "icon/global")
|
|
216
|
+
return self.get(url)
|
|
217
|
+
|
|
218
|
+
# Import
|
|
219
|
+
# Start configured imports. To see an ongoing import see the Progress resource
|
|
220
|
+
def start_import_configuration(self, import_id):
|
|
221
|
+
"""
|
|
222
|
+
The id of the import configuration that should be started
|
|
223
|
+
|
|
224
|
+
:param import_id:
|
|
225
|
+
:return:
|
|
226
|
+
"""
|
|
227
|
+
url = self.url_joiner(
|
|
228
|
+
self.api_root,
|
|
229
|
+
f"import/start/{import_id}",
|
|
230
|
+
)
|
|
231
|
+
return self.post(url)
|
|
232
|
+
|
|
233
|
+
# Index
|
|
234
|
+
# Handle the indexing of Assets
|
|
235
|
+
def reindex_assets(self):
|
|
236
|
+
"""
|
|
237
|
+
Should the reindex clean the index before doing the reindex
|
|
238
|
+
|
|
239
|
+
:return:
|
|
240
|
+
"""
|
|
241
|
+
if self.cloud:
|
|
242
|
+
raise NotImplementedError
|
|
243
|
+
url = self.url_joiner(self.api_root, "index/reindex/start")
|
|
244
|
+
return self.post(url)
|
|
245
|
+
|
|
246
|
+
def reindex_current_node_assets(self):
|
|
247
|
+
"""
|
|
248
|
+
Should the reindex clean the index before doing the reindex
|
|
249
|
+
|
|
250
|
+
:return:
|
|
251
|
+
"""
|
|
252
|
+
if self.cloud:
|
|
253
|
+
raise NotImplementedError
|
|
254
|
+
url = self.url_joiner(self.api_root, "index/reindex/currentnode")
|
|
255
|
+
return self.post(url)
|
|
256
|
+
|
|
257
|
+
# AQL
|
|
258
|
+
# Fetch Objects by AQL
|
|
259
|
+
# Cloud-only. Server use navlist_aql()
|
|
260
|
+
# https://developer.atlassian.com/cloud/assets/rest/api-group-object/#api-object-aql-post
|
|
261
|
+
def aql(self, query, start=0, max_results=25, include_attributes=True):
|
|
262
|
+
"""
|
|
263
|
+
Resource dedicated to finding objects based on the Assets Query Language (AQL)
|
|
264
|
+
|
|
265
|
+
:param query:
|
|
266
|
+
:param start:
|
|
267
|
+
:param max_results:
|
|
268
|
+
:param include_attributes:
|
|
269
|
+
:return:
|
|
270
|
+
"""
|
|
271
|
+
if not self.cloud:
|
|
272
|
+
raise NotImplementedError
|
|
273
|
+
params = {"startAt": start, "maxResults": max_results, "includeAttributes": include_attributes}
|
|
274
|
+
data = {"qlQuery": query}
|
|
275
|
+
url = self.url_joiner(self.api_root, "object/aql")
|
|
276
|
+
return self.post(url, params=params, data=data)
|
|
277
|
+
|
|
278
|
+
# Navlist AQL
|
|
279
|
+
# Retrieve a list of objects based on an AQL query
|
|
280
|
+
# Server-only. Cloud use aql()
|
|
281
|
+
# https://developer.atlassian.com/server/jira-servicedesk/rest/v1006/api-group-assets---object/#api-assets-1-0-object-navlist-aql-post
|
|
282
|
+
def navlist_aql(
|
|
283
|
+
self,
|
|
284
|
+
query,
|
|
285
|
+
object_schema_id,
|
|
286
|
+
page=1,
|
|
287
|
+
order_by_attribute_id=None,
|
|
288
|
+
order_asc=True,
|
|
289
|
+
result_per_page=25,
|
|
290
|
+
include_attributes=True,
|
|
291
|
+
include_attributes_deep=1,
|
|
292
|
+
include_type_attributes=False,
|
|
293
|
+
include_extended_info=False,
|
|
294
|
+
extended=None,
|
|
295
|
+
):
|
|
296
|
+
"""
|
|
297
|
+
Resource dedicated to finding objects based on the Insight Query Language (IQL)
|
|
298
|
+
|
|
299
|
+
:param query:
|
|
300
|
+
:param object_schema_id:
|
|
301
|
+
:param page:
|
|
302
|
+
:param order_by_attribute_id:
|
|
303
|
+
:param order_asc:
|
|
304
|
+
:param result_per_page:
|
|
305
|
+
:param include_attributes:
|
|
306
|
+
:param include_attributes_deep:
|
|
307
|
+
:param include_type_attributes:
|
|
308
|
+
:param include_extended_info:
|
|
309
|
+
:param extended:
|
|
310
|
+
:return:
|
|
311
|
+
"""
|
|
312
|
+
if self.cloud:
|
|
313
|
+
raise NotImplementedError
|
|
314
|
+
data = {
|
|
315
|
+
"qlQuery": query,
|
|
316
|
+
"objectSchemaId": object_schema_id,
|
|
317
|
+
"page": page,
|
|
318
|
+
"orderAsc": order_asc,
|
|
319
|
+
"resultPerPage": result_per_page,
|
|
320
|
+
"includeAttributes": include_attributes,
|
|
321
|
+
"includeAttributesDeep": include_attributes_deep,
|
|
322
|
+
"includeTypeAttributes": include_type_attributes,
|
|
323
|
+
"includeExtendedInfo": include_extended_info,
|
|
324
|
+
}
|
|
325
|
+
if order_by_attribute_id:
|
|
326
|
+
data["orderByAttributeId"] = order_by_attribute_id
|
|
327
|
+
if extended:
|
|
328
|
+
data["extended"] = extended
|
|
329
|
+
url = self.url_joiner(self.api_root, "object/navlist/aql")
|
|
330
|
+
return self.get(url, data=data)
|
|
331
|
+
|
|
332
|
+
# Object
|
|
333
|
+
def get_object(self, object_id):
|
|
334
|
+
"""
|
|
335
|
+
Load one object
|
|
336
|
+
|
|
337
|
+
:param object_id:
|
|
338
|
+
:return:
|
|
339
|
+
"""
|
|
340
|
+
url = self.url_joiner(self.api_root, f"object/{object_id}")
|
|
341
|
+
return self.get(url)
|
|
342
|
+
|
|
343
|
+
def update_object(
|
|
344
|
+
self,
|
|
345
|
+
object_id,
|
|
346
|
+
object_type_id,
|
|
347
|
+
attributes,
|
|
348
|
+
has_avatar=False,
|
|
349
|
+
avatar_uuid="",
|
|
350
|
+
):
|
|
351
|
+
"""
|
|
352
|
+
Update an existing object in Assets
|
|
353
|
+
|
|
354
|
+
:param object_id:
|
|
355
|
+
:param object_type_id:
|
|
356
|
+
:param attributes:
|
|
357
|
+
:param has_avatar:
|
|
358
|
+
:param avatar_uuid:
|
|
359
|
+
:return:
|
|
360
|
+
"""
|
|
361
|
+
body = {
|
|
362
|
+
"attributes": attributes,
|
|
363
|
+
"objectTypeId": object_type_id,
|
|
364
|
+
"avatarUUID": avatar_uuid,
|
|
365
|
+
"hasAvatar": has_avatar,
|
|
366
|
+
}
|
|
367
|
+
url = self.url_joiner(self.api_root, f"object/{object_id}")
|
|
368
|
+
return self.put(url, data=body)
|
|
369
|
+
|
|
370
|
+
def delete_object(self, object_id):
|
|
371
|
+
"""
|
|
372
|
+
Delete the referenced object
|
|
373
|
+
|
|
374
|
+
:param object_id:
|
|
375
|
+
:return:
|
|
376
|
+
"""
|
|
377
|
+
url = self.url_joiner(self.api_root, f"object/{object_id}")
|
|
378
|
+
return self.delete(url)
|
|
379
|
+
|
|
380
|
+
def get_object_attributes(self, object_id):
|
|
381
|
+
"""
|
|
382
|
+
List all attributes for the given object
|
|
383
|
+
|
|
384
|
+
:param object_id:
|
|
385
|
+
:return:
|
|
386
|
+
"""
|
|
387
|
+
url = self.url_joiner(self.api_root, f"object/{object_id}/attributes")
|
|
388
|
+
return self.get(url)
|
|
389
|
+
|
|
390
|
+
def get_object_history(self, object_id, asc=False, abbreviate=True):
|
|
391
|
+
"""
|
|
392
|
+
Retrieve the history entries for this object
|
|
393
|
+
|
|
394
|
+
:param object_id:
|
|
395
|
+
:param asc:
|
|
396
|
+
:param abbreviate:
|
|
397
|
+
:return:
|
|
398
|
+
"""
|
|
399
|
+
params = {"asc": asc, "abbreviate": abbreviate}
|
|
400
|
+
url = self.url_joiner(self.api_root, f"object/{object_id}/history")
|
|
401
|
+
return self.get(url, params=params)
|
|
402
|
+
|
|
403
|
+
def get_object_reference_info(self, object_id):
|
|
404
|
+
"""
|
|
405
|
+
Find all references for an object
|
|
406
|
+
|
|
407
|
+
:param object_id:
|
|
408
|
+
:return:
|
|
409
|
+
"""
|
|
410
|
+
url = self.url_joiner(self.api_root, f"object/{object_id}/referenceinfo")
|
|
411
|
+
return self.get(url)
|
|
412
|
+
|
|
413
|
+
def create_object(self, object_type_id, attributes, has_avatar=False, avatar_uuid=""):
|
|
414
|
+
"""
|
|
415
|
+
Create a new object in Assets
|
|
416
|
+
|
|
417
|
+
:param object_type_id:
|
|
418
|
+
:param attributes:
|
|
419
|
+
:param has_avatar:
|
|
420
|
+
:param avatar_uuid:
|
|
421
|
+
:return:
|
|
422
|
+
:return:
|
|
423
|
+
"""
|
|
424
|
+
data = {
|
|
425
|
+
"attributes": attributes,
|
|
426
|
+
"objectTypeId": object_type_id,
|
|
427
|
+
"avatarUUID": avatar_uuid,
|
|
428
|
+
"hasAvatar": has_avatar,
|
|
429
|
+
}
|
|
430
|
+
url = self.url_joiner(self.api_root, "object/create")
|
|
431
|
+
return self.post(url, data=data)
|
|
432
|
+
|
|
433
|
+
# Objectconnectedtickets
|
|
434
|
+
def get_object_connected_tickets(self, object_id):
|
|
435
|
+
"""
|
|
436
|
+
Relation between Jira issues and Assets objects
|
|
437
|
+
|
|
438
|
+
:param object_id:
|
|
439
|
+
:return:
|
|
440
|
+
"""
|
|
441
|
+
url = self.url_joiner(
|
|
442
|
+
self.api_root,
|
|
443
|
+
f"objectconnectedtickets/{object_id}/tickets",
|
|
444
|
+
)
|
|
445
|
+
return self.get(url)
|
|
446
|
+
|
|
447
|
+
def list_object_schema(self):
|
|
448
|
+
"""
|
|
449
|
+
Resource to find object schemas in Assets
|
|
450
|
+
:return:
|
|
451
|
+
{
|
|
452
|
+
"objectschemas": [
|
|
453
|
+
{
|
|
454
|
+
"id": 1,
|
|
455
|
+
"name": "Test",
|
|
456
|
+
"objectSchemaKey": "TEST",
|
|
457
|
+
"status": "Ok",
|
|
458
|
+
"created": "2019-11-26T08:05:46.894Z",
|
|
459
|
+
"updated": "2019-11-26T08:05:46.894Z",
|
|
460
|
+
"objectCount": 2,
|
|
461
|
+
"objectTypeCount": 3
|
|
462
|
+
}
|
|
463
|
+
]
|
|
464
|
+
}
|
|
465
|
+
"""
|
|
466
|
+
url = self.url_joiner(self.api_root, "objectschema/list")
|
|
467
|
+
return self.get(url)
|
|
468
|
+
|
|
469
|
+
def create_object_schema(self, object_schema_key, description):
|
|
470
|
+
raise NotImplementedError
|
|
471
|
+
|
|
472
|
+
def get_object_schema(self, schema_id):
|
|
473
|
+
"""
|
|
474
|
+
Find a schema by id
|
|
475
|
+
:param schema_id:
|
|
476
|
+
"""
|
|
477
|
+
url = self.url_joiner(self.api_root, f"objectschema/{schema_id}")
|
|
478
|
+
return self.get(url)
|
|
479
|
+
|
|
480
|
+
def update_object_schema(self, schema_id):
|
|
481
|
+
"""
|
|
482
|
+
Update an object schema
|
|
483
|
+
"""
|
|
484
|
+
raise NotImplementedError
|
|
485
|
+
|
|
486
|
+
def delete_object_schema(self, schema_id):
|
|
487
|
+
"""
|
|
488
|
+
Delete a schema
|
|
489
|
+
"""
|
|
490
|
+
raise NotImplementedError
|
|
491
|
+
|
|
492
|
+
def get_object_schema_attributes(self, schema_id):
|
|
493
|
+
"""
|
|
494
|
+
Find all object type attributes for this object schema
|
|
495
|
+
"""
|
|
496
|
+
raise NotImplementedError
|
|
497
|
+
|
|
498
|
+
def get_object_schema_object_types_flat(self, schema_id, query=None, exclude=None, includeObjectCounts=None):
|
|
499
|
+
"""
|
|
500
|
+
Find all object types for this object schema
|
|
501
|
+
https://developer.atlassian.com/cloud/assets/rest/api-group-objectschema/#api-objectschema-id-objecttypes-flat-get
|
|
502
|
+
Args:
|
|
503
|
+
schema_id (str): id of the object schema
|
|
504
|
+
query (bool, optional): Object Type Names to search for, defaults to None (Use API default)
|
|
505
|
+
exclude (str, optional): Exclude objects with this name, defaults to None (Use API default)
|
|
506
|
+
includeObjectCounts (bool, optional): Populate objectCount attribute for each object type, defaults to None (Use API default)
|
|
507
|
+
"""
|
|
508
|
+
kwargs = list(locals().items())
|
|
509
|
+
params = dict()
|
|
510
|
+
params.update({k: v for k, v in kwargs if v is not None and k not in ["self", "schema_id"]})
|
|
511
|
+
return self.get(
|
|
512
|
+
f"{self.api_root}/objectschema/{schema_id}/objecttypes/flat",
|
|
513
|
+
params=params,
|
|
514
|
+
)
|
|
515
|
+
|
|
516
|
+
def get_object_type_attributes(
|
|
517
|
+
self,
|
|
518
|
+
type_id,
|
|
519
|
+
only_value_editable=None,
|
|
520
|
+
order_by_name=None,
|
|
521
|
+
query=None,
|
|
522
|
+
include_values_exist=None,
|
|
523
|
+
exclude_parent_attributes=None,
|
|
524
|
+
include_children=None,
|
|
525
|
+
order_by_required=None,
|
|
526
|
+
):
|
|
527
|
+
"""
|
|
528
|
+
Find all attributes for this object type
|
|
529
|
+
https://developer.atlassian.com/cloud/assets/rest/api-group-objecttype/#api-objecttype-id-attributes-get
|
|
530
|
+
Args:
|
|
531
|
+
type_id (str): id of the object type
|
|
532
|
+
only_value_editable (bool, optional): only return editable values, defaults to None (Use API default)
|
|
533
|
+
order_by_name (bool, optional): values, defaults to None (Use API default)
|
|
534
|
+
query (str, optional): Not documented in API, defaults to None (Use API default)
|
|
535
|
+
include_values_exist (bool, optional): Include only where values exist, defaults to None (Use API default)
|
|
536
|
+
exclude_parent_attributes (bool, optional): Exclude parent attributes, defaults to None (Use API default)
|
|
537
|
+
include_children (bool, optional): include attributes from children, defaults to None (Use API default)
|
|
538
|
+
order_by_required (bool, optional): Order by required fields, defaults to None (Use API default)
|
|
539
|
+
"""
|
|
540
|
+
|
|
541
|
+
kwargs = list(locals().items())
|
|
542
|
+
params = dict()
|
|
543
|
+
params.update({k: v for k, v in kwargs if v is not None and k not in ["self", "type_id"]})
|
|
544
|
+
|
|
545
|
+
return self.get(
|
|
546
|
+
f"{self.api_root}/objecttype/{type_id}/attributes",
|
|
547
|
+
headers=self.experimental_headers,
|
|
548
|
+
params=params,
|
|
549
|
+
)
|
|
550
|
+
|
|
551
|
+
# Objecttype
|
|
552
|
+
# TODO: Post objecttype {id} position:
|
|
553
|
+
# https://developer.atlassian.com/cloud/assets/rest/api-group-objecttype/#api-objecttype-id-position-post
|
|
554
|
+
# TODO: Post objecttype create:
|
|
555
|
+
# https://developer.atlassian.com/cloud/assets/rest/api-group-objecttype/#api-objecttype-create-post
|
|
556
|
+
|
|
557
|
+
# Assets ObjectTypeAttribute API
|
|
558
|
+
# TODO: Post objecttypeattribute {objectTypeId}:
|
|
559
|
+
# https://developer.atlassian.com/cloud/assets/rest/api-group-objecttypeattribute/#api-objecttypeattribute-objecttypeid-post
|
|
560
|
+
# TODO: Put objecttypeattribute {objectTypeId} {id}:
|
|
561
|
+
# https://developer.atlassian.com/cloud/assets/rest/api-group-objecttypeattribute/#api-objecttypeattribute-objecttypeid-id-put
|
|
562
|
+
# TODO: Delete objecttypeattribute {id}:
|
|
563
|
+
# https://developer.atlassian.com/cloud/assets/rest/api-group-objecttypeattribute/#api-objecttypeattribute-id-delete
|
|
564
|
+
|
|
565
|
+
# Assets Progress API
|
|
566
|
+
# TODO: Get progress category imports {id}:
|
|
567
|
+
# https://developer.atlassian.com/cloud/assets/rest/api-group-progress/#api-progress-category-imports-id-get
|
|
568
|
+
def get_progress_of_reindex(self):
|
|
569
|
+
"""
|
|
570
|
+
Show ongoing assets processes
|
|
571
|
+
:return:
|
|
572
|
+
"""
|
|
573
|
+
if self.cloud:
|
|
574
|
+
raise NotImplementedError
|
|
575
|
+
# Yes, the Assets Server API still uses "insight-reindex" as a category (as of April 2025)
|
|
576
|
+
# https://developer.atlassian.com/server/jira-servicedesk/rest/v1006/api-group-assets---progress/#api-assets-1-0-progress-category-category-resourceid-get
|
|
577
|
+
url = self.url_joiner(self.api_root, "progress/category/insight-reindex/reindex")
|
|
578
|
+
return self.get(url)
|
|
579
|
+
|
|
580
|
+
def get_progress_of_import(self, import_id):
|
|
581
|
+
"""
|
|
582
|
+
Show ongoing assets processes
|
|
583
|
+
:type import_id: int: The id of the import source configuration
|
|
584
|
+
that the progress should be fetched for
|
|
585
|
+
:return:
|
|
586
|
+
"""
|
|
587
|
+
if self.cloud:
|
|
588
|
+
raise NotImplementedError
|
|
589
|
+
url = self.url_joiner(self.api_root, f"progress/category/imports/{import_id}")
|
|
590
|
+
return self.get(url)
|
|
591
|
+
|
|
592
|
+
# Assets Config API
|
|
593
|
+
# TODO: Get config statustype:
|
|
594
|
+
# https://developer.atlassian.com/cloud/assets/rest/api-group-config/#api-config-statustype-get
|
|
595
|
+
# TODO: Post config statustype:
|
|
596
|
+
# https://developer.atlassian.com/cloud/assets/rest/api-group-config/#api-config-statustype-post
|
|
597
|
+
# TODO: Get config statustype {id}:
|
|
598
|
+
# https://developer.atlassian.com/cloud/assets/rest/api-group-config/#api-config-statustype-id-get
|
|
599
|
+
# TODO: Put config statustype {id}:
|
|
600
|
+
# https://developer.atlassian.com/cloud/assets/rest/api-group-config/#api-config-statustype-id-put
|
|
601
|
+
# TODO: Delete config statustype {id}:
|
|
602
|
+
# https://developer.atlassian.com/cloud/assets/rest/api-group-config/#api-config-statustype-id-delete
|
|
603
|
+
|
|
604
|
+
# Update Issue with Assets Field
|
|
605
|
+
def update_issue_assets_field(self, key, field_id, assets_keys, add=False):
|
|
606
|
+
"""
|
|
607
|
+
Set the value of an Assets field.
|
|
608
|
+
Args:
|
|
609
|
+
key (str): Jira issue key, eg. SFT-446
|
|
610
|
+
field_id (str): The internal Jira name of the Assets field, e.g. customfield_10200
|
|
611
|
+
assets_keys (list): List of Assets objects to associate with the field. Limited
|
|
612
|
+
to 20 objects. If the field only takes a single object pass a single value list.
|
|
613
|
+
add (bool, optional): Add to the existing field rather than setting the field value.
|
|
614
|
+
Defaults to False.
|
|
615
|
+
Returns:
|
|
616
|
+
[type]: The assets object updated.
|
|
617
|
+
"""
|
|
618
|
+
base_url = self.resource_url("issue")
|
|
619
|
+
action = "add" if add else "set"
|
|
620
|
+
data = {
|
|
621
|
+
"update": {
|
|
622
|
+
field_id: [{action: [{"key": i} for i in assets_keys]}],
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
data = {"fields": {field_id: [{"key": i} for i in assets_keys]}}
|
|
626
|
+
return self.put(f"{base_url}/{key}", data=data)
|
atlassian/bamboo.py
CHANGED
atlassian/bitbucket/__init__.py
CHANGED
|
@@ -162,7 +162,6 @@ class Bitbucket(BitbucketBase):
|
|
|
162
162
|
params["filter"] = user_filter
|
|
163
163
|
return self._get_paged(url, params=params)
|
|
164
164
|
|
|
165
|
-
@property
|
|
166
165
|
def get_current_license(self):
|
|
167
166
|
"""
|
|
168
167
|
Retrieves details about the current license, as well as the current status of the system with
|
|
@@ -1578,14 +1577,7 @@ class Bitbucket(BitbucketBase):
|
|
|
1578
1577
|
return f"{self._url_repo(project_key, repository_slug)}/pull-requests"
|
|
1579
1578
|
|
|
1580
1579
|
def get_pull_requests(
|
|
1581
|
-
self,
|
|
1582
|
-
project_key,
|
|
1583
|
-
repository_slug,
|
|
1584
|
-
state="OPEN",
|
|
1585
|
-
order="newest",
|
|
1586
|
-
limit=100,
|
|
1587
|
-
start=0,
|
|
1588
|
-
at=None,
|
|
1580
|
+
self, project_key, repository_slug, state="OPEN", order="newest", limit=100, start=0, at=None, filter_text=None
|
|
1589
1581
|
):
|
|
1590
1582
|
"""
|
|
1591
1583
|
Get pull requests
|
|
@@ -1597,6 +1589,8 @@ class Bitbucket(BitbucketBase):
|
|
|
1597
1589
|
:param limit:
|
|
1598
1590
|
:param start:
|
|
1599
1591
|
:param at:
|
|
1592
|
+
:param filter_text: (optional) If specified, only pull requests where the title or description
|
|
1593
|
+
contains the supplied string will be returned.
|
|
1600
1594
|
:return:
|
|
1601
1595
|
"""
|
|
1602
1596
|
url = self._url_pull_requests(project_key, repository_slug)
|
|
@@ -1611,6 +1605,8 @@ class Bitbucket(BitbucketBase):
|
|
|
1611
1605
|
params["order"] = order
|
|
1612
1606
|
if at:
|
|
1613
1607
|
params["at"] = at
|
|
1608
|
+
if filter_text:
|
|
1609
|
+
params["filterText"] = filter_text
|
|
1614
1610
|
return self._get_paged(url, params=params)
|
|
1615
1611
|
|
|
1616
1612
|
def get_required_reviewers_for_pull_request(
|