class OCI::KeyManagement::KmsManagementClient

API for managing and performing operations with keys and vaults. (For the API for managing secrets, see the Vault Service Secret Management API. For the API for retrieving secrets, see the Vault Service Secret Retrieval API.)

Attributes

api_client[R]

Client used to make HTTP requests. @return [OCI::ApiClient]

endpoint[R]

Fully qualified endpoint URL @return [String]

retry_config[R]

The default retry configuration to apply to all operations in this service client. This can be overridden on a per-operation basis. The default retry configuration value is `nil`, which means that an operation will not perform any retries @return [OCI::Retry::RetryConfig]

Public Class Methods

new(config: nil, endpoint: nil, signer: nil, proxy_settings: nil, retry_config: nil) click to toggle source

Creates a new KmsManagementClient. Notes:

If a config is not specified, then the global OCI.config will be used.

This client is not thread-safe

@param [Config] config A Config object. @param [String] endpoint The fully qualified endpoint URL @param [OCI::BaseSigner] signer A signer implementation which can be used by this client. If this is not provided then

a signer will be constructed via the provided config. One use case of this parameter is instance principals authentication,
so that the instance principals signer can be provided to the client

@param [OCI::ApiClientProxySettings] proxy_settings If your environment requires you to use a proxy server for outgoing HTTP requests

the details for the proxy can be provided in this parameter

@param [OCI::Retry::RetryConfig] retry_config The retry configuration for this service client. This represents the default retry configuration to

apply across all operations. This can be overridden on a per-operation basis. The default retry configuration value is `nil`, which means that an operation
will not perform any retries
# File lib/oci/key_management/kms_management_client.rb, line 44
def initialize(config: nil, endpoint: nil, signer: nil, proxy_settings: nil, retry_config: nil)
  raise 'A fully qualified endpoint URL must be defined' unless endpoint

  @endpoint = endpoint + '/'

  # If the signer is an InstancePrincipalsSecurityTokenSigner or SecurityTokenSigner and no config was supplied (they are self-sufficient signers)
  # then create a dummy config to pass to the ApiClient constructor. If customers wish to create a client which uses instance principals
  # and has config (either populated programmatically or loaded from a file), they must construct that config themselves and then
  # pass it to this constructor.
  #
  # If there is no signer (or the signer is not an instance principals signer) and no config was supplied, this is not valid
  # so try and load the config from the default file.
  config = OCI::Config.validate_and_build_config_with_signer(config, signer)

  signer = OCI::Signer.config_file_auth_builder(config) if signer.nil?

  @api_client = OCI::ApiClient.new(config, signer, proxy_settings: proxy_settings)
  @retry_config = retry_config
  logger.info "KmsManagementClient endpoint set to '#{@endpoint}'." if logger
end

Public Instance Methods

backup_key(key_id, opts = {}) click to toggle source

Backs up an encrypted file that contains all key versions and metadata of the specified key so that you can restore the key later. The file also contains the metadata of the vault that the key belonged to.

@param [String] key_id The OCID of the key. @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] :if_match For optimistic concurrency control. In the PUT or DELETE call for a

resource, set the `if-match` parameter to the value of the etag from a
previous GET or POST response for that resource. The resource will be
updated or deleted only if the etag you provide matches the resource's
current etag value.

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@option opts [OCI::KeyManagement::Models::BackupKeyDetails] :backup_key_details BackupKeyDetails @return [Response] A Response object with data of type {OCI::KeyManagement::Models::Key Key} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/backup_key.rb.html) to see an example of how to use backup_key API.

# File lib/oci/key_management/kms_management_client.rb, line 103
def backup_key(key_id, opts = {})
  logger.debug 'Calling operation KmsManagementClient#backup_key.' if logger

  raise "Missing the required parameter 'key_id' when calling backup_key." if key_id.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)

  path = '/20180608/keys/{keyId}/actions/backup'.sub('{keyId}', key_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'if-match'] = opts[:if_match] if opts[:if_match]
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = @api_client.object_to_http_body(opts[:backup_key_details])

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#backup_key') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::Key'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
cancel_key_deletion(key_id, opts = {}) click to toggle source

Cancels the scheduled deletion of the specified key. Canceling a scheduled deletion restores the key's lifecycle state to what it was before its scheduled deletion.

As a provisioning operation, this call is subject to a Key Management limit that applies to the total number of requests across all provisioning write operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of provisioning write operations exceeds 10 requests per second for a given tenancy.

@param [String] key_id The OCID of the key. @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] :if_match For optimistic concurrency control. In the PUT or DELETE call for a

resource, set the `if-match` parameter to the value of the etag from a
previous GET or POST response for that resource. The resource will be
updated or deleted only if the etag you provide matches the resource's
current etag value.

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::Key Key} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/cancel_key_deletion.rb.html) to see an example of how to use cancel_key_deletion API.

# File lib/oci/key_management/kms_management_client.rb, line 184
def cancel_key_deletion(key_id, opts = {})
  logger.debug 'Calling operation KmsManagementClient#cancel_key_deletion.' if logger

  raise "Missing the required parameter 'key_id' when calling cancel_key_deletion." if key_id.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)

  path = '/20180608/keys/{keyId}/actions/cancelDeletion'.sub('{keyId}', key_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'if-match'] = opts[:if_match] if opts[:if_match]
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#cancel_key_deletion') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::Key'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
cancel_key_version_deletion(key_id, key_version_id, opts = {}) click to toggle source

Cancels the scheduled deletion of the specified key version. Canceling a scheduled deletion restores the key version to its lifecycle state from before its scheduled deletion.

As a provisioning operation, this call is subject to a Key Management limit that applies to the total number of requests across all provisioning write operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of provisioning write operations exceeds 10 requests per second for a given tenancy.

@param [String] key_id The OCID of the key. @param [String] key_version_id The OCID of the key version. @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] :if_match For optimistic concurrency control. In the PUT or DELETE call for a

resource, set the `if-match` parameter to the value of the etag from a
previous GET or POST response for that resource. The resource will be
updated or deleted only if the etag you provide matches the resource's
current etag value.

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::KeyVersion KeyVersion} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/cancel_key_version_deletion.rb.html) to see an example of how to use cancel_key_version_deletion API.

# File lib/oci/key_management/kms_management_client.rb, line 266
def cancel_key_version_deletion(key_id, key_version_id, opts = {})
  logger.debug 'Calling operation KmsManagementClient#cancel_key_version_deletion.' if logger

  raise "Missing the required parameter 'key_id' when calling cancel_key_version_deletion." if key_id.nil?
  raise "Missing the required parameter 'key_version_id' when calling cancel_key_version_deletion." if key_version_id.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)
  raise "Parameter value for 'key_version_id' must not be blank" if OCI::Internal::Util.blank_string?(key_version_id)

  path = '/20180608/keys/{keyId}/keyVersions/{keyVersionId}/actions/cancelDeletion'.sub('{keyId}', key_id.to_s).sub('{keyVersionId}', key_version_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'if-match'] = opts[:if_match] if opts[:if_match]
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#cancel_key_version_deletion') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::KeyVersion'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
change_key_compartment(key_id, change_key_compartment_details, opts = {}) click to toggle source

Moves a key into a different compartment within the same tenancy. For information about moving resources between compartments, see [Moving Resources to a Different Compartment](docs.cloud.oracle.com/iaas/Content/Identity/Tasks/managingcompartments.htm#moveRes).

When provided, if-match is checked against the ETag values of the key.

As a provisioning operation, this call is subject to a Key Management limit that applies to the total number of requests across all provisioning write operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of provisioning write operations exceeds 10 requests per second for a given tenancy.

@param [String] key_id The OCID of the key. @param [OCI::KeyManagement::Models::ChangeKeyCompartmentDetails] change_key_compartment_details @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] :if_match For optimistic concurrency control. In the PUT or DELETE call for a

resource, set the `if-match` parameter to the value of the etag from a
previous GET or POST response for that resource. The resource will be
updated or deleted only if the etag you provide matches the resource's
current etag value.

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@return [Response] A Response object with data of type nil @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/change_key_compartment.rb.html) to see an example of how to use change_key_compartment API.

# File lib/oci/key_management/kms_management_client.rb, line 351
def change_key_compartment(key_id, change_key_compartment_details, opts = {})
  logger.debug 'Calling operation KmsManagementClient#change_key_compartment.' if logger

  raise "Missing the required parameter 'key_id' when calling change_key_compartment." if key_id.nil?
  raise "Missing the required parameter 'change_key_compartment_details' when calling change_key_compartment." if change_key_compartment_details.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)

  path = '/20180608/keys/{keyId}/actions/changeCompartment'.sub('{keyId}', key_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'if-match'] = opts[:if_match] if opts[:if_match]
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = @api_client.object_to_http_body(change_key_compartment_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#change_key_compartment') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body
    )
  end
  # rubocop:enable Metrics/BlockLength
end
create_key(create_key_details, opts = {}) click to toggle source

Creates a new master encryption key.

As a management operation, this call is subject to a Key Management limit that applies to the total number of requests across all management write operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of management write operations exceeds 10 requests per second for a given tenancy.

@param [OCI::KeyManagement::Models::CreateKeyDetails] create_key_details CreateKeyDetails @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] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::Key Key} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/create_key.rb.html) to see an example of how to use create_key API.

# File lib/oci/key_management/kms_management_client.rb, line 424
def create_key(create_key_details, opts = {})
  logger.debug 'Calling operation KmsManagementClient#create_key.' if logger

  raise "Missing the required parameter 'create_key_details' when calling create_key." if create_key_details.nil?

  path = '/20180608/keys'
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = @api_client.object_to_http_body(create_key_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#create_key') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::Key'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
create_key_version(key_id, opts = {}) click to toggle source

Generates a new [KeyVersion](docs.cloud.oracle.com/api/#/en/key/latest/KeyVersion/) resource that provides new cryptographic material for a master encryption key. The key must be in an `ENABLED` state to be rotated.

As a management operation, this call is subject to a Key Management limit that applies to the total number of requests across all management write operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of management write operations exceeds 10 requests per second for a given tenancy.

@param [String] key_id The OCID of the key. @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] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::KeyVersion KeyVersion} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/create_key_version.rb.html) to see an example of how to use create_key_version API.

# File lib/oci/key_management/kms_management_client.rb, line 496
def create_key_version(key_id, opts = {})
  logger.debug 'Calling operation KmsManagementClient#create_key_version.' if logger

  raise "Missing the required parameter 'key_id' when calling create_key_version." if key_id.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)

  path = '/20180608/keys/{keyId}/keyVersions'.sub('{keyId}', key_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#create_key_version') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::KeyVersion'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
disable_key(key_id, opts = {}) click to toggle source

Disables a master encryption key so it can no longer be used for encryption, decryption, or generating new data encryption keys.

As a management operation, this call is subject to a Key Management limit that applies to the total number of requests across all management write operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of management write operations exceeds 10 requests per second for a given tenancy.

@param [String] key_id The OCID of the key. @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] :if_match For optimistic concurrency control. In the PUT or DELETE call for a

resource, set the `if-match` parameter to the value of the etag from a
previous GET or POST response for that resource. The resource will be
updated or deleted only if the etag you provide matches the resource's
current etag value.

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::Key Key} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/disable_key.rb.html) to see an example of how to use disable_key API.

# File lib/oci/key_management/kms_management_client.rb, line 575
def disable_key(key_id, opts = {})
  logger.debug 'Calling operation KmsManagementClient#disable_key.' if logger

  raise "Missing the required parameter 'key_id' when calling disable_key." if key_id.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)

  path = '/20180608/keys/{keyId}/actions/disable'.sub('{keyId}', key_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'if-match'] = opts[:if_match] if opts[:if_match]
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#disable_key') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::Key'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
enable_key(key_id, opts = {}) click to toggle source

Enables a master encryption key so it can be used for encryption, decryption, or generating new data encryption keys.

As a management operation, this call is subject to a Key Management limit that applies to the total number of requests across all management write operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of management write operations exceeds 10 requests per second for a given tenancy.

@param [String] key_id The OCID of the key. @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] :if_match For optimistic concurrency control. In the PUT or DELETE call for a

resource, set the `if-match` parameter to the value of the etag from a
previous GET or POST response for that resource. The resource will be
updated or deleted only if the etag you provide matches the resource's
current etag value.

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::Key Key} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/enable_key.rb.html) to see an example of how to use enable_key API.

# File lib/oci/key_management/kms_management_client.rb, line 655
def enable_key(key_id, opts = {})
  logger.debug 'Calling operation KmsManagementClient#enable_key.' if logger

  raise "Missing the required parameter 'key_id' when calling enable_key." if key_id.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)

  path = '/20180608/keys/{keyId}/actions/enable'.sub('{keyId}', key_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'if-match'] = opts[:if_match] if opts[:if_match]
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#enable_key') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::Key'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
get_key(key_id, opts = {}) click to toggle source

Gets information about the specified master encryption key.

As a management operation, this call is subject to a Key Management limit that applies to the total number of requests across all management read operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of management read operations exceeds 10 requests per second for a given tenancy.

@param [String] key_id The OCID of the key. @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] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::Key Key} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/get_key.rb.html) to see an example of how to use get_key API.

# File lib/oci/key_management/kms_management_client.rb, line 721
def get_key(key_id, opts = {})
  logger.debug 'Calling operation KmsManagementClient#get_key.' if logger

  raise "Missing the required parameter 'key_id' when calling get_key." if key_id.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)

  path = '/20180608/keys/{keyId}'.sub('{keyId}', key_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  # rubocop:enable Style/NegatedIf

  post_body = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#get_key') 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: 'OCI::KeyManagement::Models::Key'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
get_key_version(key_id, key_version_id, opts = {}) click to toggle source

Gets information about the specified key version.

As a management operation, this call is subject to a Key Management limit that applies to the total number of requests across all management read operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of management read operations exceeds 10 requests per second for a given tenancy.

@param [String] key_id The OCID of the key. @param [String] key_version_id The OCID of the key version. @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] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::KeyVersion KeyVersion} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/get_key_version.rb.html) to see an example of how to use get_key_version API.

# File lib/oci/key_management/kms_management_client.rb, line 785
def get_key_version(key_id, key_version_id, opts = {})
  logger.debug 'Calling operation KmsManagementClient#get_key_version.' if logger

  raise "Missing the required parameter 'key_id' when calling get_key_version." if key_id.nil?
  raise "Missing the required parameter 'key_version_id' when calling get_key_version." if key_version_id.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)
  raise "Parameter value for 'key_version_id' must not be blank" if OCI::Internal::Util.blank_string?(key_version_id)

  path = '/20180608/keys/{keyId}/keyVersions/{keyVersionId}'.sub('{keyId}', key_id.to_s).sub('{keyVersionId}', key_version_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  # rubocop:enable Style/NegatedIf

  post_body = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#get_key_version') 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: 'OCI::KeyManagement::Models::KeyVersion'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
get_replication_status(replication_id, opts = {}) click to toggle source

When a vault has a replica, each operation on the vault or its resources, such as keys, is replicated and has an associated replicationId. Replication status provides details about whether the operation associated with the given replicationId has been successfully applied across replicas.

@param [String] replication_id replicationId associated with an operation on a resource

@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] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::ReplicationStatusDetails ReplicationStatusDetails} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/get_replication_status.rb.html) to see an example of how to use get_replication_status API.

# File lib/oci/key_management/kms_management_client.rb, line 849
def get_replication_status(replication_id, opts = {})
  logger.debug 'Calling operation KmsManagementClient#get_replication_status.' if logger

  raise "Missing the required parameter 'replication_id' when calling get_replication_status." if replication_id.nil?
  raise "Parameter value for 'replication_id' must not be blank" if OCI::Internal::Util.blank_string?(replication_id)

  path = '/20180608/replicaOperations/{replicationId}/status'.sub('{replicationId}', replication_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  # rubocop:enable Style/NegatedIf

  post_body = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#get_replication_status') 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: 'OCI::KeyManagement::Models::ReplicationStatusDetails'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
get_wrapping_key(opts = {}) click to toggle source

Gets details about the public RSA wrapping key associated with the vault in the endpoint. Each vault has an RSA key-pair that wraps and unwraps AES key material for import into Key Management.

@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] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::WrappingKey WrappingKey} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/get_wrapping_key.rb.html) to see an example of how to use get_wrapping_key API.

# File lib/oci/key_management/kms_management_client.rb, line 907
def get_wrapping_key(opts = {})
  logger.debug 'Calling operation KmsManagementClient#get_wrapping_key.' if logger


  path = '/20180608/wrappingKeys'
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  # rubocop:enable Style/NegatedIf

  post_body = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#get_wrapping_key') 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: 'OCI::KeyManagement::Models::WrappingKey'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
import_key(import_key_details, opts = {}) click to toggle source

Imports AES key material to create a new key with. The key material must be base64-encoded and wrapped by the vault's public RSA wrapping key before you can import it. Key Management supports AES symmetric keys that are exactly 16, 24, or 32 bytes. Furthermore, the key length must match what you specify at the time of import.

@param [OCI::KeyManagement::Models::ImportKeyDetails] import_key_details ImportKeyDetails @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] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::Key Key} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/import_key.rb.html) to see an example of how to use import_key API.

# File lib/oci/key_management/kms_management_client.rb, line 972
def import_key(import_key_details, opts = {})
  logger.debug 'Calling operation KmsManagementClient#import_key.' if logger

  raise "Missing the required parameter 'import_key_details' when calling import_key." if import_key_details.nil?

  path = '/20180608/keys/import'
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = @api_client.object_to_http_body(import_key_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#import_key') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::Key'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
import_key_version(key_id, import_key_version_details, opts = {}) click to toggle source

Imports AES key material to create a new key version with, and then rotates the key to begin using the new key version. The key material must be base64-encoded and wrapped by the vault's public RSA wrapping key before you can import it. Key Management supports AES symmetric keys that are exactly 16, 24, or 32 bytes. Furthermore, the key length must match the length of the specified key and what you specify as the length at the time of import.

@param [String] key_id The OCID of the key. @param [OCI::KeyManagement::Models::ImportKeyVersionDetails] import_key_version_details ImportKeyVersionDetails @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] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::KeyVersion KeyVersion} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/import_key_version.rb.html) to see an example of how to use import_key_version API.

# File lib/oci/key_management/kms_management_client.rb, line 1043
def import_key_version(key_id, import_key_version_details, opts = {})
  logger.debug 'Calling operation KmsManagementClient#import_key_version.' if logger

  raise "Missing the required parameter 'key_id' when calling import_key_version." if key_id.nil?
  raise "Missing the required parameter 'import_key_version_details' when calling import_key_version." if import_key_version_details.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)

  path = '/20180608/keys/{keyId}/keyVersions/import'.sub('{keyId}', key_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = @api_client.object_to_http_body(import_key_version_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#import_key_version') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::KeyVersion'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
list_key_versions(key_id, opts = {}) click to toggle source

Lists all [KeyVersion](docs.cloud.oracle.com/api/#/en/key/latest/KeyVersion/) resources for the specified master encryption key.

As a management operation, this call is subject to a Key Management limit that applies to the total number of requests across all management read operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of management read operations exceeds 10 requests per second for a given tenancy.

@param [String] key_id The OCID of the key. @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 [Integer] :limit The maximum number of items to return in a paginated "List" call.

@option opts [String] :page The value of the `opc-next-page` response header

from the previous \"List\" call.

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :sort_by The field to sort by. You can specify only one sort order. The default

order for `TIMECREATED` is descending. The default order for `DISPLAYNAME`
is ascending.

Allowed values are: TIMECREATED, DISPLAYNAME

@option opts [String] :sort_order The sort order to use, either ascending (`ASC`) or descending (`DESC`).

Allowed values are: ASC, DESC

@return [Response] A Response object with data of type Array<{OCI::KeyManagement::Models::KeyVersionSummary KeyVersionSummary}> @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/list_key_versions.rb.html) to see an example of how to use list_key_versions API.

# File lib/oci/key_management/kms_management_client.rb, line 1123
def list_key_versions(key_id, opts = {})
  logger.debug 'Calling operation KmsManagementClient#list_key_versions.' if logger

  raise "Missing the required parameter 'key_id' when calling list_key_versions." if key_id.nil?

  if opts[:sort_by] && !%w[TIMECREATED DISPLAYNAME].include?(opts[:sort_by])
    raise 'Invalid value for "sort_by", must be one of TIMECREATED, DISPLAYNAME.'
  end

  if opts[:sort_order] && !%w[ASC DESC].include?(opts[:sort_order])
    raise 'Invalid value for "sort_order", must be one of ASC, DESC.'
  end
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)

  path = '/20180608/keys/{keyId}/keyVersions'.sub('{keyId}', key_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}
  query_params[:limit] = opts[:limit] if opts[:limit]
  query_params[:page] = opts[:page] if opts[:page]
  query_params[:sortBy] = opts[:sort_by] if opts[:sort_by]
  query_params[:sortOrder] = opts[:sort_order] if opts[:sort_order]

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  # rubocop:enable Style/NegatedIf

  post_body = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#list_key_versions') 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::KeyManagement::Models::KeyVersionSummary>'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
list_keys(compartment_id, opts = {}) click to toggle source

Lists the master encryption keys in the specified vault and compartment.

As a management operation, this call is subject to a Key Management limit that applies to the total number of requests across all management read operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of management read operations exceeds 10 requests per second for a given tenancy.

@param [String] compartment_id The OCID of the 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 [Integer] :limit The maximum number of items to return in a paginated "List" call.

@option opts [String] :page The value of the `opc-next-page` response header

from the previous \"List\" call.

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :sort_by The field to sort by. You can specify only one sort order. The default

order for `TIMECREATED` is descending. The default order for `DISPLAYNAME`
is ascending.

Allowed values are: TIMECREATED, DISPLAYNAME

@option opts [String] :sort_order The sort order to use, either ascending (`ASC`) or descending (`DESC`).

Allowed values are: ASC, DESC

@option opts [String] :protection_mode A key's protection mode indicates how the key persists and where cryptographic operations that use the key are performed. A

protection mode of `HSM` means that the key persists on a hardware security module (HSM) and all cryptographic operations are
performed inside the HSM. A protection mode of `SOFTWARE` means that the key persists on the server, protected by the vault's
RSA wrapping key which persists on the HSM. All cryptographic operations that use a key with a protection mode of
`SOFTWARE` are performed on the server.
 (default to HSM)
Allowed values are: HSM, SOFTWARE

@option opts [String] :algorithm The algorithm used by a key's key versions to encrypt or decrypt data. Currently, support includes AES, RSA, and ECDSA algorithms.

Allowed values are: AES, RSA, ECDSA

@option opts [Integer] :length The length of the key in bytes, expressed as an integer. Supported values include 16, 24, or 32.

@option opts [String] :curve_id The curve ID of the keys. (This pertains only to ECDSA keys.)

Allowed values are: NIST_P256, NIST_P384, NIST_P521

@return [Response] A Response object with data of type Array<{OCI::KeyManagement::Models::KeySummary KeySummary}> @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/list_keys.rb.html) to see an example of how to use list_keys API.

# File lib/oci/key_management/kms_management_client.rb, line 1226
def list_keys(compartment_id, opts = {})
  logger.debug 'Calling operation KmsManagementClient#list_keys.' if logger

  raise "Missing the required parameter 'compartment_id' when calling list_keys." if compartment_id.nil?

  if opts[:sort_by] && !%w[TIMECREATED DISPLAYNAME].include?(opts[:sort_by])
    raise 'Invalid value for "sort_by", must be one of TIMECREATED, DISPLAYNAME.'
  end

  if opts[:sort_order] && !%w[ASC DESC].include?(opts[:sort_order])
    raise 'Invalid value for "sort_order", must be one of ASC, DESC.'
  end

  if opts[:protection_mode] && !%w[HSM SOFTWARE].include?(opts[:protection_mode])
    raise 'Invalid value for "protection_mode", must be one of HSM, SOFTWARE.'
  end

  if opts[:algorithm] && !%w[AES RSA ECDSA].include?(opts[:algorithm])
    raise 'Invalid value for "algorithm", must be one of AES, RSA, ECDSA.'
  end

  if opts[:curve_id] && !%w[NIST_P256 NIST_P384 NIST_P521].include?(opts[:curve_id])
    raise 'Invalid value for "curve_id", must be one of NIST_P256, NIST_P384, NIST_P521.'
  end

  path = '/20180608/keys'
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}
  query_params[:compartmentId] = compartment_id
  query_params[:limit] = opts[:limit] if opts[:limit]
  query_params[:page] = opts[:page] if opts[:page]
  query_params[:sortBy] = opts[:sort_by] if opts[:sort_by]
  query_params[:sortOrder] = opts[:sort_order] if opts[:sort_order]
  query_params[:protectionMode] = opts[:protection_mode] if opts[:protection_mode]
  query_params[:algorithm] = opts[:algorithm] if opts[:algorithm]
  query_params[:length] = opts[:length] if opts[:length]
  query_params[:curveId] = opts[:curve_id] if opts[:curve_id]

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  # rubocop:enable Style/NegatedIf

  post_body = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#list_keys') 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::KeyManagement::Models::KeySummary>'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
logger() click to toggle source

@return [Logger] The logger for this client. May be nil.

# File lib/oci/key_management/kms_management_client.rb, line 67
def logger
  @api_client.config.logger
end
restore_key_from_file(restore_key_from_file_details, opts = {}) click to toggle source

Restores the specified key to the specified vault, based on information in the backup file provided. If the vault doesn't exist, the operation returns a response with a 404 HTTP status error code. You need to first restore the vault associated with the key.

@param [String, IO] restore_key_from_file_details The encrypted backup file to upload to restore the key. @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 [Integer] :content_length The content length of the body. @option opts [String] :if_match For optimistic concurrency control. In the PUT or DELETE call for a

resource, set the `if-match` parameter to the value of the etag from a
previous GET or POST response for that resource. The resource will be
updated or deleted only if the etag you provide matches the resource's
current etag value.

@option opts [String] :content_md5 The base64-encoded MD5 hash value of the body, as described in [RFC 2616](tools.ietf.org/rfc/rfc2616), section 14.15.

If the Content-MD5 header is present, Key Management performs an integrity check on the body of the HTTP request by computing the MD5
hash for the body and comparing it to the MD5 hash supplied in the header. If the two hashes don't match, the object is rejected and
a response with 400 Unmatched Content MD5 error is returned, along with the message: \"The computed MD5 of the request body (ACTUAL_MD5)
does not match the Content-MD5 header (HEADER_MD5).\"

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::Key Key} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/restore_key_from_file.rb.html) to see an example of how to use restore_key_from_file API.

# File lib/oci/key_management/kms_management_client.rb, line 1334
def restore_key_from_file(restore_key_from_file_details, opts = {})
  logger.debug 'Calling operation KmsManagementClient#restore_key_from_file.' if logger

  raise "Missing the required parameter 'restore_key_from_file_details' when calling restore_key_from_file." if restore_key_from_file_details.nil?

  path = '/20180608/keys/actions/restoreFromFile'
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-length'] = opts[:content_length] if opts[:content_length]
  header_params[:'if-match'] = opts[:if_match] if opts[:if_match]
  header_params[:'content-md5'] = opts[:content_md5] if opts[:content_md5]
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'content-type'] ||= 'application/octet-stream'
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = @api_client.object_to_http_body(restore_key_from_file_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#restore_key_from_file') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::Key'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
restore_key_from_object_store(opts = {}) click to toggle source

Restores the specified key to the specified vault from an Oracle Cloud Infrastructure Object Storage location. If the vault doesn't exist, the operation returns a response with a 404 HTTP status error code. You need to first restore the vault associated with the key.

@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] :if_match For optimistic concurrency control. In the PUT or DELETE call for a

resource, set the `if-match` parameter to the value of the etag from a
previous GET or POST response for that resource. The resource will be
updated or deleted only if the etag you provide matches the resource's
current etag value.

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@option opts [OCI::KeyManagement::Models::RestoreKeyFromObjectStoreDetails] :restore_key_from_object_store_details Location to restore the backup from @return [Response] A Response object with data of type {OCI::KeyManagement::Models::Key Key} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/restore_key_from_object_store.rb.html) to see an example of how to use restore_key_from_object_store API.

# File lib/oci/key_management/kms_management_client.rb, line 1411
def restore_key_from_object_store(opts = {})
  logger.debug 'Calling operation KmsManagementClient#restore_key_from_object_store.' if logger


  path = '/20180608/keys/actions/restoreFromObjectStore'
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'if-match'] = opts[:if_match] if opts[:if_match]
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = @api_client.object_to_http_body(opts[:restore_key_from_object_store_details])

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#restore_key_from_object_store') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::Key'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
schedule_key_deletion(key_id, schedule_key_deletion_details, opts = {}) click to toggle source

Schedules the deletion of the specified key. This sets the lifecycle state of the key to `PENDING_DELETION` and then deletes it after the specified retention period ends.

As a provisioning operation, this call is subject to a Key Management limit that applies to the total number of requests across all provisioning write operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of provisioning write operations exceeds 10 requests per second for a given tenancy.

@param [String] key_id The OCID of the key. @param [OCI::KeyManagement::Models::ScheduleKeyDeletionDetails] schedule_key_deletion_details ScheduleKeyDeletionDetails @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] :if_match For optimistic concurrency control. In the PUT or DELETE call for a

resource, set the `if-match` parameter to the value of the etag from a
previous GET or POST response for that resource. The resource will be
updated or deleted only if the etag you provide matches the resource's
current etag value.

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::Key Key} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/schedule_key_deletion.rb.html) to see an example of how to use schedule_key_deletion API.

# File lib/oci/key_management/kms_management_client.rb, line 1490
def schedule_key_deletion(key_id, schedule_key_deletion_details, opts = {})
  logger.debug 'Calling operation KmsManagementClient#schedule_key_deletion.' if logger

  raise "Missing the required parameter 'key_id' when calling schedule_key_deletion." if key_id.nil?
  raise "Missing the required parameter 'schedule_key_deletion_details' when calling schedule_key_deletion." if schedule_key_deletion_details.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)

  path = '/20180608/keys/{keyId}/actions/scheduleDeletion'.sub('{keyId}', key_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'if-match'] = opts[:if_match] if opts[:if_match]
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = @api_client.object_to_http_body(schedule_key_deletion_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#schedule_key_deletion') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::Key'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
schedule_key_version_deletion(key_id, key_version_id, schedule_key_version_deletion_details, opts = {}) click to toggle source

Schedules the deletion of the specified key version. This sets the lifecycle state of the key version to `PENDING_DELETION` and then deletes it after the specified retention period ends.

As a provisioning operation, this call is subject to a Key Management limit that applies to the total number of requests across all provisioning write operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of provisioning write operations exceeds 10 requests per second for a given tenancy.

@param [String] key_id The OCID of the key. @param [String] key_version_id The OCID of the key version. @param [OCI::KeyManagement::Models::ScheduleKeyVersionDeletionDetails] schedule_key_version_deletion_details ScheduleKeyVersionDeletionDetails @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] :if_match For optimistic concurrency control. In the PUT or DELETE call for a

resource, set the `if-match` parameter to the value of the etag from a
previous GET or POST response for that resource. The resource will be
updated or deleted only if the etag you provide matches the resource's
current etag value.

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@option opts [String] :opc_retry_token A token that uniquely identifies a request so it can be retried in case

of a timeout or server error without risk of executing that same action
again. Retry tokens expire after 24 hours, but can be invalidated
before then due to conflicting operations (e.g., if a resource has been
deleted and purged from the system, then a retry of the original
creation request may be rejected).

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::KeyVersion KeyVersion} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/schedule_key_version_deletion.rb.html) to see an example of how to use schedule_key_version_deletion API.

# File lib/oci/key_management/kms_management_client.rb, line 1573
def schedule_key_version_deletion(key_id, key_version_id, schedule_key_version_deletion_details, opts = {})
  logger.debug 'Calling operation KmsManagementClient#schedule_key_version_deletion.' if logger

  raise "Missing the required parameter 'key_id' when calling schedule_key_version_deletion." if key_id.nil?
  raise "Missing the required parameter 'key_version_id' when calling schedule_key_version_deletion." if key_version_id.nil?
  raise "Missing the required parameter 'schedule_key_version_deletion_details' when calling schedule_key_version_deletion." if schedule_key_version_deletion_details.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)
  raise "Parameter value for 'key_version_id' must not be blank" if OCI::Internal::Util.blank_string?(key_version_id)

  path = '/20180608/keys/{keyId}/keyVersions/{keyVersionId}/actions/scheduleDeletion'.sub('{keyId}', key_id.to_s).sub('{keyVersionId}', key_version_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'if-match'] = opts[:if_match] if opts[:if_match]
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  header_params[:'opc-retry-token'] = opts[:opc_retry_token] if opts[:opc_retry_token]
  # rubocop:enable Style/NegatedIf
  header_params[:'opc-retry-token'] ||= OCI::Retry.generate_opc_retry_token

  post_body = @api_client.object_to_http_body(schedule_key_version_deletion_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#schedule_key_version_deletion') do
    @api_client.call_api(
      :POST,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::KeyVersion'
    )
  end
  # rubocop:enable Metrics/BlockLength
end
update_key(key_id, update_key_details, opts = {}) click to toggle source

Updates the properties of a master encryption key. Specifically, you can update the `displayName`, `freeformTags`, and `definedTags` properties. Furthermore, the key must be in an `ENABLED` or `CREATING` state to be updated.

As a management operation, this call is subject to a Key Management limit that applies to the total number of requests across all management write operations. Key Management might throttle this call to reject an otherwise valid request when the total rate of management write operations exceeds 10 requests per second for a given tenancy.

@param [String] key_id The OCID of the key. @param [OCI::KeyManagement::Models::UpdateKeyDetails] update_key_details UpdateKeyDetails @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] :if_match For optimistic concurrency control. In the PUT or DELETE call for a

resource, set the `if-match` parameter to the value of the etag from a
previous GET or POST response for that resource. The resource will be
updated or deleted only if the etag you provide matches the resource's
current etag value.

@option opts [String] :opc_request_id Unique identifier for the request. If provided, the returned request ID

will include this value. Otherwise, a random request ID will be
generated by the service.

@return [Response] A Response object with data of type {OCI::KeyManagement::Models::Key Key} @note Click [here](docs.cloud.oracle.com/en-us/iaas/tools/ruby-sdk-examples/latest/keymanagement/update_key.rb.html) to see an example of how to use update_key API.

# File lib/oci/key_management/kms_management_client.rb, line 1651
def update_key(key_id, update_key_details, opts = {})
  logger.debug 'Calling operation KmsManagementClient#update_key.' if logger

  raise "Missing the required parameter 'key_id' when calling update_key." if key_id.nil?
  raise "Missing the required parameter 'update_key_details' when calling update_key." if update_key_details.nil?
  raise "Parameter value for 'key_id' must not be blank" if OCI::Internal::Util.blank_string?(key_id)

  path = '/20180608/keys/{keyId}'.sub('{keyId}', key_id.to_s)
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}

  # Header Params
  header_params = {}
  header_params[:accept] = 'application/json'
  header_params[:'content-type'] = 'application/json'
  header_params[:'if-match'] = opts[:if_match] if opts[:if_match]
  header_params[:'opc-request-id'] = opts[:opc_request_id] if opts[:opc_request_id]
  # rubocop:enable Style/NegatedIf

  post_body = @api_client.object_to_http_body(update_key_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'KmsManagementClient#update_key') do
    @api_client.call_api(
      :PUT,
      path,
      endpoint,
      header_params: header_params,
      query_params: query_params,
      operation_signing_strategy: operation_signing_strategy,
      body: post_body,
      return_type: 'OCI::KeyManagement::Models::Key'
    )
  end
  # rubocop:enable Metrics/BlockLength
end

Private Instance Methods

applicable_retry_config(opts = {}) click to toggle source

rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity rubocop:enable Style/IfUnlessModifier, Metrics/ParameterLists rubocop:enable Metrics/MethodLength, Layout/EmptyLines

# File lib/oci/key_management/kms_management_client.rb, line 1696
def applicable_retry_config(opts = {})
  return @retry_config unless opts.key?(:retry_config)

  opts[:retry_config]
end