2
2
import logging
3
3
4
4
from .rest_client import AtlassianRestAPI
5
+
5
6
# from deprecated import deprecated
6
7
7
8
log = logging .getLogger (__name__ )
8
9
9
10
10
- class Assets (AtlassianRestAPI ):
11
+ class AssetsCloud (AtlassianRestAPI ):
11
12
"""Assets for Jira API wrapper."""
12
13
13
14
# https://developer.atlassian.com/cloud/assets/rest
@@ -24,7 +25,7 @@ def __init__(self, *args, **kwargs):
24
25
# If cloud is set to true, trigger private __cloud__init method
25
26
if kwargs .get ("cloud" ):
26
27
args , kwargs = self .__cloud_init (* args , ** kwargs )
27
- super (Assets , self ).__init__ (* args , ** kwargs )
28
+ super (AssetsCloud , self ).__init__ (* args , ** kwargs )
28
29
29
30
def __cloud_init (self , * args , ** kwargs ):
30
31
"""
@@ -35,7 +36,7 @@ def __cloud_init(self, *args, **kwargs):
35
36
"""
36
37
# trigger a normal init and avoid looping
37
38
del kwargs ["cloud" ]
38
- temp = Assets (* args , ** kwargs )
39
+ temp = AssetsCloud (* args , ** kwargs )
39
40
# retrieve cloud workspace id and generate the api_root
40
41
kwargs ["api_root" ] = f"/jsm/assets/workspace/{ temp .__get_workspace_id ()} /v1/"
41
42
# Assets cloud uses the atlassian base url, not custom instance urls
@@ -257,13 +258,7 @@ def reindex_current_node_assets(self):
257
258
# Fetch Objects by AQL
258
259
# Cloud-only. Server use navlist_aql()
259
260
# https://developer.atlassian.com/cloud/assets/rest/api-group-object/#api-object-aql-post
260
- def aql (
261
- self ,
262
- query ,
263
- start = 0 ,
264
- max_results = 25 ,
265
- include_attributes = True
266
- ):
261
+ def aql (self , query , start = 0 , max_results = 25 , include_attributes = True ):
267
262
"""
268
263
Resource dedicated to finding objects based on the Assets Query Language (AQL)
269
264
@@ -275,14 +270,8 @@ def aql(
275
270
"""
276
271
if not self .cloud :
277
272
raise NotImplementedError
278
- params = {
279
- "startAt" : start ,
280
- "maxResults" : max_results ,
281
- "includeAttributes" : include_attributes
282
- }
283
- data = {
284
- "qlQuery" : query
285
- }
273
+ params = {"startAt" : start , "maxResults" : max_results , "includeAttributes" : include_attributes }
274
+ data = {"qlQuery" : query }
286
275
url = self .url_joiner (self .api_root , "object/aql" )
287
276
return self .post (url , params = params , data = data )
288
277
@@ -331,7 +320,7 @@ def navlist_aql(
331
320
"includeAttributes" : include_attributes ,
332
321
"includeAttributesDeep" : include_attributes_deep ,
333
322
"includeTypeAttributes" : include_type_attributes ,
334
- "includeExtendedInfo" : include_extended_info
323
+ "includeExtendedInfo" : include_extended_info ,
335
324
}
336
325
if order_by_attribute_id :
337
326
data ["orderByAttributeId" ] = order_by_attribute_id
@@ -634,4 +623,4 @@ def update_issue_assets_field(self, key, field_id, assets_keys, add=False):
634
623
}
635
624
}
636
625
data = {"fields" : {field_id : [{"key" : i } for i in assets_keys ]}}
637
- return self .put (f"{ base_url } /{ key } " , data = data )
626
+ return self .put (f"{ base_url } /{ key } " , data = data )
0 commit comments