0

I have a piece of Python code like this:

  oci_config = oci.config.from_file("config_file","profile_name")
  identity = oci.identity.IdentityClient(oci_config)
  user = identity.get_user(oci_config["user"]).data

The user object returned has an attribute "compartment_id" but it has a value of tenancy OCID "ocid1.tenancy.oc1..aaaaaaaa...." which is obviously wrong. I am hoping that I can get compartment ID of user for calling other APIs. Now I have to store it configuration file instead.

My SDK version is 2.18 on Python 3.8.3.

Does any one know where to file a bug report like this? Thanks

Eddie Ho
  • 113
  • 1
  • 7

1 Answers1

2

Compartments can be nested under other compartments, and the root compartment is the same as the tenancy. So the root compartment and the tenancy have the same ID.

If you are getting the tenancy ID back in the compartment_id field for a resource, it means the resource is in the root compartment.

You can see the same documented here. As you can see in the image at this link, the tenancy is referred to also as the "root compartment".

Joe
  • 2,500
  • 1
  • 14
  • 12
  • Thanks for your explanation. I am looking for a way to find my account's default compartment such that I can use it for other API calls and I don't want to store it from my client configuration somewhere. E.g. list object storage buckets in a region belong to my account's compartment. Looks like I have to explore other APIs. – Eddie Ho Jul 18 '20 at 02:12
  • I think the Object Storage service has APIs specifically for setting / getting the default compartment which Object Storage buckets will be assigned to - see https://docs.cloud.oracle.com/en-us/iaas/api/#/en/objectstorage/20160918/Namespace/GetNamespaceMetadata and https://docs.cloud.oracle.com/en-us/iaas/api/#/en/objectstorage/20160918/Namespace/UpdateNamespaceMetadata for more info – Joe Jul 20 '20 at 18:02