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