Class: OCI::Vault::VaultsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/vault/vaults_client.rb

Overview

Use the Secret Management API to manage secrets and secret versions. For more information, see Managing Secrets.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config: nil, region: nil, endpoint: nil, signer: nil, proxy_settings: nil, retry_config: nil) ⇒ VaultsClient

Creates a new VaultsClient. Notes: If a config is not specified, then the global OCI.config will be used.

This client is not thread-safe

Either a region or an endpoint must be specified. If an endpoint is specified, it will be used instead of the region. A region may be specified in the config or via or the region parameter. If specified in both, then the region parameter will be used.

Parameters:

  • config (Config) (defaults to: nil)

    A Config object.

  • region (String) (defaults to: nil)

    A region used to determine the service endpoint. This will usually correspond to a value in Regions::REGION_ENUM, but may be an arbitrary string.

  • endpoint (String) (defaults to: nil)

    The fully qualified endpoint URL

  • signer (OCI::BaseSigner) (defaults to: nil)

    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

  • proxy_settings (OCI::ApiClientProxySettings) (defaults to: nil)

    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

  • retry_config (OCI::Retry::RetryConfig) (defaults to: nil)

    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



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/oci/vault/vaults_client.rb', line 55

def initialize(config: nil, region: nil, endpoint: nil, signer: nil, proxy_settings: nil, retry_config: nil)
  # 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

  if endpoint
    @endpoint = endpoint + '/20180608'
  else
    region ||= config.region
    region ||= signer.region if signer.respond_to?(:region)
    self.region = region
  end
  logger.info "VaultsClient endpoint set to '#{@endpoint}'." if logger
end

Instance Attribute Details

#api_clientOCI::ApiClient (readonly)

Client used to make HTTP requests.

Returns:



15
16
17
# File 'lib/oci/vault/vaults_client.rb', line 15

def api_client
  @api_client
end

#endpointString (readonly)

Fully qualified endpoint URL

Returns:

  • (String)


19
20
21
# File 'lib/oci/vault/vaults_client.rb', line 19

def endpoint
  @endpoint
end

#regionString

The region, which will usually correspond to a value in Regions::REGION_ENUM.

Returns:

  • (String)


29
30
31
# File 'lib/oci/vault/vaults_client.rb', line 29

def region
  @region
end

#retry_configOCI::Retry::RetryConfig (readonly)

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



25
26
27
# File 'lib/oci/vault/vaults_client.rb', line 25

def retry_config
  @retry_config
end

Instance Method Details

#cancel_secret_deletion(secret_id, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use cancel_secret_deletion API.

Cancels the pending deletion of the specified secret. Canceling a scheduled deletion restores the secret's lifecycle state to what it was before you scheduled the secret for deletion.

Parameters:

  • secret_id (String)

    The OCID of the secret.

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

    the optional parameters

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :if_match (String)

    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.

  • :opc_request_id (String)

    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.

Returns:

  • (Response)

    A Response object with data of type nil



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/oci/vault/vaults_client.rb', line 123

def cancel_secret_deletion(secret_id, opts = {})
  logger.debug 'Calling operation VaultsClient#cancel_secret_deletion.' if logger

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

  path = '/secrets/{secretId}/actions/cancelDeletion'.sub('{secretId}', secret_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 = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'VaultsClient#cancel_secret_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
    )
  end
  # rubocop:enable Metrics/BlockLength
end

#cancel_secret_rotation(secret_id, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use cancel_secret_rotation API.

Cancels the ongoing secret rotation. The cancellation is contingent on how far the rotation process has progressed. Upon cancelling a rotation, all future rotations are also disabled.

Parameters:

  • secret_id (String)

    The OCID of the secret.

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

    the optional parameters

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :if_match (String)

    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.

  • :opc_request_id (String)

    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.

Returns:

  • (Response)

    A Response object with data of type nil



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/oci/vault/vaults_client.rb', line 189

def cancel_secret_rotation(secret_id, opts = {})
  logger.debug 'Calling operation VaultsClient#cancel_secret_rotation.' if logger

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

  path = '/secrets/{secretId}/actions/cancelRotation'.sub('{secretId}', secret_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 = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'VaultsClient#cancel_secret_rotation') 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

#cancel_secret_version_deletion(secret_id, secret_version_number, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use cancel_secret_version_deletion API.

Cancels the scheduled deletion of a secret version.

Parameters:

  • secret_id (String)

    The OCID of the secret.

  • secret_version_number (Integer)

    The version number of the secret.

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

    the optional parameters

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :if_match (String)

    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.

  • :opc_request_id (String)

    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.

Returns:

  • (Response)

    A Response object with data of type nil



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/oci/vault/vaults_client.rb', line 253

def cancel_secret_version_deletion(secret_id, secret_version_number, opts = {})
  logger.debug 'Calling operation VaultsClient#cancel_secret_version_deletion.' if logger

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

  path = '/secrets/{secretId}/version/{secretVersionNumber}/actions/cancelDeletion'.sub('{secretId}', secret_id.to_s).sub('{secretVersionNumber}', secret_version_number.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 = nil

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'VaultsClient#cancel_secret_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
    )
  end
  # rubocop:enable Metrics/BlockLength
end

#change_secret_compartment(secret_id, change_secret_compartment_details, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use change_secret_compartment API.

Moves a secret into a different compartment within the same tenancy. For information about moving resources between compartments, see Moving Resources to a Different Compartment.

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

Parameters:

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :if_match (String)

    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.

  • :opc_request_id (String)

    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.

  • :opc_retry_token (String)

    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).

Returns:

  • (Response)

    A Response object with data of type nil



330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/oci/vault/vaults_client.rb', line 330

def change_secret_compartment(secret_id, change_secret_compartment_details, opts = {})
  logger.debug 'Calling operation VaultsClient#change_secret_compartment.' if logger

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

  path = '/secrets/{secretId}/actions/changeCompartment'.sub('{secretId}', secret_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_secret_compartment_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'VaultsClient#change_secret_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_secret(create_secret_details, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use create_secret API.

Creates a new secret according to the details of the request.

This operation is not supported by the Oracle Cloud Infrastructure Terraform Provider.

Parameters:

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :opc_request_id (String)

    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.

  • :opc_retry_token (String)

    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).

Returns:



400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File 'lib/oci/vault/vaults_client.rb', line 400

def create_secret(create_secret_details, opts = {})
  logger.debug 'Calling operation VaultsClient#create_secret.' if logger

  raise "Missing the required parameter 'create_secret_details' when calling create_secret." if create_secret_details.nil?

  path = '/secrets'
  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_secret_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'VaultsClient#create_secret') 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::Vault::Models::Secret'
    )
  end
  # rubocop:enable Metrics/BlockLength
end

#get_secret(secret_id, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use get_secret API.

Gets information about the specified secret.

Parameters:

  • secret_id (String)

    The OCID of the secret.

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

    the optional parameters

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :opc_request_id (String)

    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.

Returns:



458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/oci/vault/vaults_client.rb', line 458

def get_secret(secret_id, opts = {})
  logger.debug 'Calling operation VaultsClient#get_secret.' if logger

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

  path = '/secrets/{secretId}'.sub('{secretId}', secret_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: 'VaultsClient#get_secret') 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::Vault::Models::Secret'
    )
  end
  # rubocop:enable Metrics/BlockLength
end

#get_secret_version(secret_id, secret_version_number, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use get_secret_version API.

Gets information about the specified version of a secret.

Parameters:

  • secret_id (String)

    The OCID of the secret.

  • secret_version_number (Integer)

    The version number of the secret.

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

    the optional parameters

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :opc_request_id (String)

    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.

Returns:



517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
# File 'lib/oci/vault/vaults_client.rb', line 517

def get_secret_version(secret_id, secret_version_number, opts = {})
  logger.debug 'Calling operation VaultsClient#get_secret_version.' if logger

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

  path = '/secrets/{secretId}/version/{secretVersionNumber}'.sub('{secretId}', secret_id.to_s).sub('{secretVersionNumber}', secret_version_number.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: 'VaultsClient#get_secret_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::Vault::Models::SecretVersion'
    )
  end
  # rubocop:enable Metrics/BlockLength
end

#list_secret_versions(secret_id, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use list_secret_versions API.

Lists all secret versions for the specified secret. Allowed values are: VERSION_NUMBER Allowed values are: ASC, DESC

Parameters:

  • secret_id (String)

    The OCID of the secret.

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

    the optional parameters

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :limit (Integer)

    The maximum number of items to return in a paginated "List" call.

  • :page (String)

    The value of the opc-next-page response header from the previous "List" call.

  • :opc_request_id (String)

    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.

  • :sort_by (String)

    The field to sort by. Only one sort order may be provided. Time created is default ordered as descending. Display name is default ordered as ascending. (default to VERSION_NUMBER)

  • :sort_order (String)

    The sort order to use, either ascending (ASC) or descending (DESC). (default to DESC)

Returns:



587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
# File 'lib/oci/vault/vaults_client.rb', line 587

def list_secret_versions(secret_id, opts = {})
  logger.debug 'Calling operation VaultsClient#list_secret_versions.' if logger

  raise "Missing the required parameter 'secret_id' when calling list_secret_versions." if secret_id.nil?

  if opts[:sort_by] && !%w[VERSION_NUMBER].include?(opts[:sort_by])
    raise 'Invalid value for "sort_by", must be one of VERSION_NUMBER.'
  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 'secret_id' must not be blank" if OCI::Internal::Util.blank_string?(secret_id)

  path = '/secrets/{secretId}/versions'.sub('{secretId}', secret_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: 'VaultsClient#list_secret_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::Vault::Models::SecretVersionSummary>'
    )
  end
  # rubocop:enable Metrics/BlockLength
end

#list_secrets(compartment_id, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use list_secrets API.

Lists all secrets in the specified vault and compartment. Allowed values are: ASC, DESC

Parameters:

  • compartment_id (String)

    The OCID of the compartment.

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

    the optional parameters

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :name (String)

    The secret name.

  • :limit (Integer)

    The maximum number of items to return in a paginated "List" call.

  • :page (String)

    The value of the opc-next-page response header from the previous "List" call.

  • :opc_request_id (String)

    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.

  • :sort_by (String)

    The field to sort by. You can specify only one sort order. The default order for TIMECREATED is descending. The default order for NAME is ascending. (default to NAME) Allowed values are: TIMECREATED, NAME

  • :sort_order (String)

    The sort order to use, either ascending (ASC) or descending (DESC). (default to DESC)

  • :vault_id (String)

    The OCID of the vault.

  • :lifecycle_state (String)

    A filter that returns only resources that match the specified lifecycle state. The state value is case-insensitive.

Returns:



672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
# File 'lib/oci/vault/vaults_client.rb', line 672

def list_secrets(compartment_id, opts = {})
  logger.debug 'Calling operation VaultsClient#list_secrets.' if logger

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

  if opts[:sort_by] && !%w[TIMECREATED NAME].include?(opts[:sort_by])
    raise 'Invalid value for "sort_by", must be one of TIMECREATED, NAME.'
  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[:lifecycle_state] && !OCI::Vault::Models::SecretSummary::LIFECYCLE_STATE_ENUM.include?(opts[:lifecycle_state])
    raise 'Invalid value for "lifecycle_state", must be one of the values in OCI::Vault::Models::SecretSummary::LIFECYCLE_STATE_ENUM.'
  end

  path = '/secrets'
  operation_signing_strategy = :standard

  # rubocop:disable Style/NegatedIf
  # Query Params
  query_params = {}
  query_params[:compartmentId] = compartment_id
  query_params[:name] = opts[:name] if opts[:name]
  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[:vaultId] = opts[:vault_id] if opts[:vault_id]
  query_params[:lifecycleState] = opts[:lifecycle_state] if opts[:lifecycle_state]

  # 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: 'VaultsClient#list_secrets') 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::Vault::Models::SecretSummary>'
    )
  end
  # rubocop:enable Metrics/BlockLength
end

#loggerLogger

Returns The logger for this client. May be nil.

Returns:

  • (Logger)

    The logger for this client. May be nil.



94
95
96
# File 'lib/oci/vault/vaults_client.rb', line 94

def logger
  @api_client.config.logger
end

#rotate_secret(secret_id, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use rotate_secret API.

API to force rotation of an existing secret in Vault and the specified target system; expects secret to have a valid Target System Details object

Parameters:

  • secret_id (String)

    The OCID of the secret.

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

    the optional parameters

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :if_match (String)

    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.

  • :opc_request_id (String)

    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.

  • :opc_retry_token (String)

    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).

Returns:

  • (Response)

    A Response object with data of type nil



762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
# File 'lib/oci/vault/vaults_client.rb', line 762

def rotate_secret(secret_id, opts = {})
  logger.debug 'Calling operation VaultsClient#rotate_secret.' if logger

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

  path = '/secrets/{secretId}/actions/rotate'.sub('{secretId}', secret_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: 'VaultsClient#rotate_secret') 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

#schedule_secret_deletion(secret_id, schedule_secret_deletion_details, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use schedule_secret_deletion API.

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

Parameters:

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :if_match (String)

    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.

  • :opc_request_id (String)

    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.

Returns:

  • (Response)

    A Response object with data of type nil



830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
# File 'lib/oci/vault/vaults_client.rb', line 830

def schedule_secret_deletion(secret_id, schedule_secret_deletion_details, opts = {})
  logger.debug 'Calling operation VaultsClient#schedule_secret_deletion.' if logger

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

  path = '/secrets/{secretId}/actions/scheduleDeletion'.sub('{secretId}', secret_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(schedule_secret_deletion_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'VaultsClient#schedule_secret_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
    )
  end
  # rubocop:enable Metrics/BlockLength
end

#schedule_secret_version_deletion(secret_id, secret_version_number, schedule_secret_version_deletion_details, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use schedule_secret_version_deletion API.

Schedules the deletion of the specified secret version. This deletes it after the specified retention period ends. You can only delete a secret version if the secret version rotation state is marked as DEPRECATED.

Parameters:

  • secret_id (String)

    The OCID of the secret.

  • secret_version_number (Integer)

    The version number of the secret.

  • schedule_secret_version_deletion_details (OCI::Vault::Models::ScheduleSecretVersionDeletionDetails)

    Request to delete a secret version.

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

    the optional parameters

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :if_match (String)

    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.

  • :opc_request_id (String)

    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.

Returns:

  • (Response)

    A Response object with data of type nil



899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
# File 'lib/oci/vault/vaults_client.rb', line 899

def schedule_secret_version_deletion(secret_id, secret_version_number, schedule_secret_version_deletion_details, opts = {})
  logger.debug 'Calling operation VaultsClient#schedule_secret_version_deletion.' if logger

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

  path = '/secrets/{secretId}/version/{secretVersionNumber}/actions/scheduleDeletion'.sub('{secretId}', secret_id.to_s).sub('{secretVersionNumber}', secret_version_number.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(schedule_secret_version_deletion_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'VaultsClient#schedule_secret_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
    )
  end
  # rubocop:enable Metrics/BlockLength
end

#update_secret(secret_id, update_secret_details, opts = {}) ⇒ Response

Note:

Click here to see an example of how to use update_secret API.

Updates the properties of a secret. Specifically, you can update the version number of the secret to make that version number the current version. You can also update a secret's description, its free-form or defined tags, rules and the secret contents. Updating the secret content automatically creates a new secret version. You cannot, however, update the current secret version number, secret contents, and secret rules at the same time. Furthermore, the secret must in an ACTIVE lifecycle state to be updated.

This operation is not supported by the Oracle Cloud Infrastructure Terraform Provider.

Parameters:

  • secret_id (String)

    The OCID of the secret.

  • update_secret_details (OCI::Vault::Models::UpdateSecretDetails)

    Request to update a secret.

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

    the optional parameters

Options Hash (opts):

  • :retry_config (OCI::Retry::RetryConfig)

    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

  • :if_match (String)

    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.

  • :opc_request_id (String)

    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.

Returns:



972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
# File 'lib/oci/vault/vaults_client.rb', line 972

def update_secret(secret_id, update_secret_details, opts = {})
  logger.debug 'Calling operation VaultsClient#update_secret.' if logger

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

  path = '/secrets/{secretId}'.sub('{secretId}', secret_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_secret_details)

  # rubocop:disable Metrics/BlockLength
  OCI::Retry.make_retrying_call(applicable_retry_config(opts), call_name: 'VaultsClient#update_secret') 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::Vault::Models::Secret'
    )
  end
  # rubocop:enable Metrics/BlockLength
end