【发布时间】:2021-05-20 07:44:03
【问题描述】:
这个函数给出了一个租户中的所有隔间直到它的结束点。这里myobject的类型是
'''
import oci
import hashlib
import uuid
import json
global finale_response,tenant_id,profile
profile="abc-profile"
tenant_id = "ocid1.tenancy.oc1.."
finale_response = []
config = oci.config.from_file(profile_name=profile)
def get_compartments(id):
identity_client = oci.identity.IdentityClient(config)
list_compartments_response = identity_client.list_compartments(compartment_id=id)
response = list_compartments_response.data
if response != []:
child_compartment_list = []
for i in range(len(response)):
compartmentId = response[i].id
myobject= response[i]
print(type(myobject))
finale_response.append({"profileName":profile,
"compartmentId":compartmentId,
"tenantId": tenant_id,
"comMetadata":myobject})
child_compartment_list.append(compartmentId)
for id in child_compartment_list:
get_compartments(id)
return finale_response
myList = get_compartments(tenant_id)
print(myList)
print(type(myList))
'''
【问题讨论】:
标签: python json types oracle-cloud-infrastructure json-serializable