lib/oci/identity/identity_client.rb
# 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](https://docs.cloud.oracle.com/Content/API/Concepts/apisigningkey.htm#five).
#
# @param [String] compartment_id The OCID of the compartment (remember that the tenancy is simply the root compartment).
#
# @param [Hash] opts the optional parameters
# @option opts [OCI::Retry::RetryConfig] :retry_config The retry configuration to apply to this operation. If no key is provided then the service-level
#   retry configuration defined by {#retry_config} will be used. If an explicit `nil` value is provided then the operation will not retry
# @option opts [String] :page The value of the `opc-next-page` response header from the previous \"List\" call.
#
# @option opts [Integer] :limit The maximum number of items to return in a paginated \"List\" call.
#
# @option opts [String] :access_level 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.
#
#   Allowed values are: ANY, ACCESSIBLE
# @option opts [BOOLEAN] :compartment_id_in_subtree 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`.
#
# @return [Response] A Response object with data of type Array<{OCI::Identity::Models::Compartment Compartment}>
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].
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 ] .
def list_compartments(compartment_id, opts = {})
      logger.debug 'Calling operation IdentityClient#list_compartments.' if logger
      raise "Missing the required parameter 'compartment_id' when calling list_compartments." if compartment_id.nil?
      if opts[:access_level] && !%w[ANY ACCESSIBLE].include?(opts[:access_level])
        raise 'Invalid value for "access_level", must be one of ANY, ACCESSIBLE.'
      end
      path = '/compartments/'
      operation_signing_strategy = :standard
      query_params = {}
      query_params[:compartmentId] = compartment_id
      query_params[:page] = opts[:page] if opts[:page]
      query_params[:limit] = opts[:limit] if opts[:limit]
      query_params[:accessLevel] = opts[:access_level] if opts[:access_level]
      query_params[:compartmentIdInSubtree] = opts[:compartment_id_in_subtree] if !opts[:compartment_id_in_subtree].nil?
      header_params = {}
      header_params[:accept] = 'application/json'
      header_params[:'content-type'] = 'application/json'
      post_body = nil
      OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'IdentityClient#list_compartments') do
        @api_client.call_api(
          :GET,
          path,
          endpoint,
          header_params: header_params,
          query_params: query_params,
          operation_signing_strategy: operation_signing_strategy,
          body: post_body,
          return_type: 'Array<OCI::Identity::Models::Compartment>'
        )
      end
    end
def list_compartments ( compartment_id , opts = { } ) logger . debug 'Calling operation IdentityClient#list_compartments.' if logger raise "Missing the required parameter 'compartment_id' when calling list_compartments." if compartment_id . nil? if opts [ :access_level ] && ! %w[ ANY ACCESSIBLE ] . include? ( opts [ :access_level ] ) raise 'Invalid value for "access_level", must be one of ANY, ACCESSIBLE.' end path = '/compartments/' operation_signing_strategy = :standard query_params = { } query_params [ :compartmentId ] = compartment_id query_params [ :page ] = opts [ :page ] if opts [ :page ] query_params [ :limit ] = opts [ :limit ] if opts [ :limit ] query_params [ :accessLevel ] = opts [ :access_level ] if opts [ :access_level ] query_params [ :compartmentIdInSubtree ] = opts [ :compartment_id_in_subtree ] if ! opts [ :compartment_id_in_subtree ] . nil? header_params = { } header_params [ :accept ] = 'application/json' header_params [ :' content-type ' ] = 'application/json' post_body = nil OCI :: Retry . make_retrying_call ( applicable_retry_config ( opts ) , call_name : 'IdentityClient#list_compartments' ) do @api_client . call_api ( :GET , path , endpoint , header_params : header_params , query_params : query_params , operation_signing_strategy : operation_signing_strategy , body : post_body , return_type : 'Array<OCI::Identity::Models::Compartment>' ) end end
Lists the compartments in a specified compartment.
Lists the compartments in a specified compartment .
# rubocop:disable Style/NegatedIf # Query Params # Header Params # rubocop:enable Style/NegatedIf # rubocop:disable Metrics/BlockLength # rubocop:enable Metrics/BlockLength
A Response object with data of type Array<{OCI::Identity::Models::Compartment Compartment}>
A Response object with data of type Array< { OCI :: Identity :: Models :: Compartment Compartment } >
Response
compartment_id
<not_specific>
opts
:compartment_id_in_subtree 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`.
: compartment_id_in_subtree 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 ` .
<not_specific>
opts the optional parameters
opts the optional parameters