Method: OCI::KeyManagement::KmsManagementClientCompositeOperations#enable_key_and_wait_for_state

Defined in:
lib/oci/key_management/kms_management_client_composite_operations.rb

#enable_key_and_wait_for_state(key_id, wait_for_states = [], base_operation_opts = {}, waiter_opts = {}) ⇒ OCI::Response

Calls OCI::KeyManagement::KmsManagementClient#enable_key and then waits for the Models::Key acted upon to enter the given state(s).

Parameters:

  • key_id (String)

    The OCID of the key.

  • wait_for_states (Array<String>) (defaults to: [])

    An array of states to wait on. These should be valid values for Models::Key#lifecycle_state

  • base_operation_opts (Hash) (defaults to: {})

    Any optional arguments accepted by OCI::KeyManagement::KmsManagementClient#enable_key

  • waiter_opts (Hash) (defaults to: {})

    Optional arguments for the waiter. Keys should be symbols, and the following keys are supported:

    • max_interval_seconds: The maximum interval between queries, in seconds.

    • max_wait_seconds The maximum time to wait, in seconds

Returns:



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/oci/key_management/kms_management_client_composite_operations.rb', line 155

def enable_key_and_wait_for_state(key_id, wait_for_states = [], base_operation_opts = {}, waiter_opts = {})
  operation_result = @service_client.enable_key(key_id, base_operation_opts)

  return operation_result if wait_for_states.empty?

  lowered_wait_for_states = wait_for_states.map(&:downcase)
  wait_for_resource_id = operation_result.data.id

  begin
    waiter_result = @service_client.get_key(wait_for_resource_id).wait_until(
      eval_proc: ->(response) { response.data.respond_to?(:lifecycle_state) && lowered_wait_for_states.include?(response.data.lifecycle_state.downcase) },
      max_interval_seconds: waiter_opts.key?(:max_interval_seconds) ? waiter_opts[:max_interval_seconds] : 30,
      max_wait_seconds: waiter_opts.key?(:max_wait_seconds) ? waiter_opts[:max_wait_seconds] : 1200
    )
    result_to_return = waiter_result

    return result_to_return
  rescue StandardError
    raise OCI::Errors::CompositeOperationError.new(partial_results: [operation_result])
  end
end