Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CloudPak-Outcomes
GitHub Repository: CloudPak-Outcomes/Outcomes-Projects
Path: blob/main/L4assets/DSandMLOpsAssets/CLIandSDK/packages/cpdalllibs/commonlib/assets.py
1928 views
1
import requests
2
from cpdalllibs.commonlib.constants import *
3
4
def getAssetTypes(headersAPI, type, guid, url=None) :
5
"""Get asset types in project using a project id
6
type is: catalog_id, project_id, space_id, or bss_account_id
7
"""
8
if url is None :
9
url = WATSON_DATA_ENDPOINT
10
if url[-1] != "/" :
11
url = url + "/"
12
endpoint = url + 'v2/asset_types?{}={}'.format(type, guid)
13
resp = requests.get(endpoint, headers=headersAPI)
14
return(resp)
15
16
def getEnvironments(headersAPI, type, guid, url=None) :
17
"""Get environments in project using a project id
18
type is: catalog_id, project_id, space_id, or bss_account_id
19
"""
20
if url is None :
21
url = WATSON_DATA_ENDPOINT
22
if url[-1] != "/" :
23
url = url + "/"
24
endpoint = url + 'v2/environments?{}={}'.format(type, guid)
25
resp = requests.get(endpoint, headers=headersAPI)
26
return(resp)
27
28
def getContainer(headersAPI, type, guid, url=None) :
29
"""Get environments in project using a project id
30
type is: catalog_id, project_id, space_id, or bss_account_id
31
"""
32
if url is None :
33
url = WATSON_DATA_ENDPOINT
34
if url[-1] != "/" :
35
url = url + "/"
36
endpoint = url + 'v2/asset_containers/configurations?{}={}'.format(type, guid)
37
resp = requests.get(endpoint, headers=headersAPI)
38
return(resp)
39
40
def deleteProjectAsset(headersAPI, assetid, projectid, url) :
41
"""Mark an asset for deletion"""
42
if url is None :
43
url = WATSON_DATA_ENDPOINT
44
if url[-1] != "/" :
45
url = url + "/"
46
endpoint = url + 'v2/assets/{}?project_id={}'.format(assetid, projectid)
47
resp = requests.get(endpoint, headers=headersAPI)
48
return(resp)
49