ListCompartments
GET {{baseUrl}}/compartments/?compartmentId={{tenancy_ocid}}&limit=693&accessLevel=ANY&compartmentIdInSubtree=true&sortBy=NAME&sortOrder=ASC&lifecycleState=ACTIVE
Lists the compartments in a specified compartment. The members of the list returned depends on the values set for several parameters.
With the exception of the tenancy (root compartment), the ListCompartments operation
returns only the first-level child compartments in the parent compartment specified in
compartmentId
. The list does not include any subcompartments of the child
compartments (grandchildren).
The parameter accessLevel
specifies whether to return only those compartments for which the
requestor has INSPECT permissions on at least one resource directly
or indirectly (the resource can be in a subcompartment).
The parameter compartmentIdInSubtree
applies only when you perform ListCompartments on the
tenancy (root compartment). When set to true, the entire hierarchy of compartments can be returned.
To get a full list of all compartments and subcompartments in the tenancy (root compartment),
set the parameter compartmentIdInSubtree
to true and accessLevel
to ANY.
See Where to Get the Tenancy's OCID and User's OCID.
Request Params
Key | Datatype | Required | Description |
---|---|---|---|
compartmentId | string | (Required) The OCID of the compartment (remember that the tenancy is simply the root compartment). | |
page | string | The value of the opc-next-page response header from the previous "List" call. | |
limit | number | The maximum number of items to return in a paginated "List" call. | |
accessLevel | string | Valid values are ANY and ACCESSIBLE . Default is ANY . | |
Setting this to ACCESSIBLE returns only those compartments for which the | |||
user has INSPECT permissions directly or indirectly (permissions can be on a | |||
resource in a subcompartment). For the compartments on which the user indirectly has | |||
INSPECT permissions, a restricted set of fields is returned. |
When set to ANY
permissions are not checked.
|
| compartmentIdInSubtree
| boolean | | Default is false. Can only be set to true when performing
ListCompartments on the tenancy (root compartment).
When set to true, the hierarchy of compartments is traversed
and all compartments and subcompartments in the tenancy are
returned depending on the the setting of accessLevel
.
|
| name
| string | | A filter to only return resources that match the given name exactly.
|
| sortBy
| string | | The field to sort by. You can provide one sort order (sortOrder
). Default order for
TIMECREATED is descending. Default order for NAME is ascending. The NAME
sort order is case sensitive.
Note: In general, some "List" operations (for example, ListInstances
) let you
optionally filter by Availability Domain if the scope of the resource type is within a
single Availability Domain. If you call one of these "List" operations without specifying
an Availability Domain, the resources are grouped by Availability Domain, then sorted.
|
| sortOrder
| string | | The sort order to use, either ascending (ASC
) or descending (DESC
). The NAME sort order
is case sensitive.
|
| lifecycleState
| string | | A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.
|
HEADERS
Key | Datatype | Required | Description |
---|---|---|---|
Date | string | (Required) Current Date | |
Authorization | string | (Required) Signature Authentication on Authorization header |
RESPONSES
status: OK
[{"id":"velit","compartmentId":"consec","name":"eu enim","description":"commodo anim mollit non irure","timeCreated":"1992-06-05T21:13:09.740Z","lifecycleState":"INACTIVE","definedTags":{},"freeformTags":{},"inactiveStatus":1849236,"isAccessible":true},{"id":"Lorem aliquip consectetur ea","compartmentId":"voluptate reprehenderit est","name":"et adipisicing est sed","description":"eu","timeCreated":"1974-09-22T10:56:03.798Z","lifecycleState":"DELETING","definedTags":{},"freeformTags":{},"inactiveStatus":-36185321,"isAccessible":true}]