Skip to content

Commit 744d994

Browse files
committed
Assets: Added Assets Cloud class
1 parent a04b9b3 commit 744d994

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

atlassian/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from .confluence import Confluence
1010
from .crowd import Crowd
1111
from .insight import Insight
12-
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
1314
from .jira import Jira
1415
from .marketplace import MarketPlace
1516
from .portfolio import Portfolio
@@ -33,4 +34,5 @@
3334
"Xray",
3435
"Insight",
3536
"Assets",
37+
"AssetsCloud",
3638
]

atlassian/assets.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
import logging
33

44
from .rest_client import AtlassianRestAPI
5+
56
# from deprecated import deprecated
67

78
log = logging.getLogger(__name__)
89

910

10-
class Assets(AtlassianRestAPI):
11+
class AssetsCloud(AtlassianRestAPI):
1112
"""Assets for Jira API wrapper."""
1213

1314
# https://developer.atlassian.com/cloud/assets/rest
@@ -24,7 +25,7 @@ def __init__(self, *args, **kwargs):
2425
# If cloud is set to true, trigger private __cloud__init method
2526
if kwargs.get("cloud"):
2627
args, kwargs = self.__cloud_init(*args, **kwargs)
27-
super(Assets, self).__init__(*args, **kwargs)
28+
super(AssetsCloud, self).__init__(*args, **kwargs)
2829

2930
def __cloud_init(self, *args, **kwargs):
3031
"""
@@ -35,7 +36,7 @@ def __cloud_init(self, *args, **kwargs):
3536
"""
3637
# trigger a normal init and avoid looping
3738
del kwargs["cloud"]
38-
temp = Assets(*args, **kwargs)
39+
temp = AssetsCloud(*args, **kwargs)
3940
# retrieve cloud workspace id and generate the api_root
4041
kwargs["api_root"] = f"/jsm/assets/workspace/{temp.__get_workspace_id()}/v1/"
4142
# Assets cloud uses the atlassian base url, not custom instance urls
@@ -257,13 +258,7 @@ def reindex_current_node_assets(self):
257258
# Fetch Objects by AQL
258259
# Cloud-only. Server use navlist_aql()
259260
# 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):
267262
"""
268263
Resource dedicated to finding objects based on the Assets Query Language (AQL)
269264
@@ -275,14 +270,8 @@ def aql(
275270
"""
276271
if not self.cloud:
277272
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}
286275
url = self.url_joiner(self.api_root, "object/aql")
287276
return self.post(url, params=params, data=data)
288277

@@ -331,7 +320,7 @@ def navlist_aql(
331320
"includeAttributes": include_attributes,
332321
"includeAttributesDeep": include_attributes_deep,
333322
"includeTypeAttributes": include_type_attributes,
334-
"includeExtendedInfo": include_extended_info
323+
"includeExtendedInfo": include_extended_info,
335324
}
336325
if order_by_attribute_id:
337326
data["orderByAttributeId"] = order_by_attribute_id
@@ -634,4 +623,4 @@ def update_issue_assets_field(self, key, field_id, assets_keys, add=False):
634623
}
635624
}
636625
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)

atlassian/bitbucket/cloud/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
from .repositories import Repositories
55
from .workspaces import Workspaces
66

7+
78
class Cloud(BitbucketCloudBase):
9+
"""
10+
Bitbucket Cloud REST API wrapper
11+
"""
12+
813
def __init__(self, url="https://api.bitbucket.org/", *args, **kwargs):
914
kwargs["cloud"] = True
1015
kwargs["api_root"] = None

0 commit comments

Comments
 (0)