oracle-cloud-infrastructureoci-java-sdk

What is the REST API for listing all the compartments in Oracle Cloud Infrastructure?


I need to fetch all the instances (authorized) in the tenancy. In Oracle Cloud documentation, I have seen fetching the instances by compartment ID(ListInstances API). So in order to fetch all instances, I need all the compartments.

Any inputs? Or Is there a way of fetching all instances irrespective of compartments?


Solution

  • You want ListCompartments, under the IAM section of the docs, here https://docs.cloud.oracle.com/iaas/api/#/en/identity/20160918/Compartment/ListCompartments

    You need to give it the parent compartment, which would be the root compartment for the first-level compartments.