Path: blob/main/L4assets/DSandMLOpsAssets/CLIandSDK/packages/cpdalllibs/commonlib/assets.py
1928 views
import requests1from cpdalllibs.commonlib.constants import *23def getAssetTypes(headersAPI, type, guid, url=None) :4"""Get asset types in project using a project id5type is: catalog_id, project_id, space_id, or bss_account_id6"""7if url is None :8url = WATSON_DATA_ENDPOINT9if url[-1] != "/" :10url = url + "/"11endpoint = url + 'v2/asset_types?{}={}'.format(type, guid)12resp = requests.get(endpoint, headers=headersAPI)13return(resp)1415def getEnvironments(headersAPI, type, guid, url=None) :16"""Get environments in project using a project id17type is: catalog_id, project_id, space_id, or bss_account_id18"""19if url is None :20url = WATSON_DATA_ENDPOINT21if url[-1] != "/" :22url = url + "/"23endpoint = url + 'v2/environments?{}={}'.format(type, guid)24resp = requests.get(endpoint, headers=headersAPI)25return(resp)2627def getContainer(headersAPI, type, guid, url=None) :28"""Get environments in project using a project id29type is: catalog_id, project_id, space_id, or bss_account_id30"""31if url is None :32url = WATSON_DATA_ENDPOINT33if url[-1] != "/" :34url = url + "/"35endpoint = url + 'v2/asset_containers/configurations?{}={}'.format(type, guid)36resp = requests.get(endpoint, headers=headersAPI)37return(resp)3839def deleteProjectAsset(headersAPI, assetid, projectid, url) :40"""Mark an asset for deletion"""41if url is None :42url = WATSON_DATA_ENDPOINT43if url[-1] != "/" :44url = url + "/"45endpoint = url + 'v2/assets/{}?project_id={}'.format(assetid, projectid)46resp = requests.get(endpoint, headers=headersAPI)47return(resp)4849