Secret Manager V1 API - Class Google::Cloud::SecretManager::V1::SecretOperationsService::Client (v2.1.0)

Reference documentation and code samples for the Secret Manager V1 API class Google::Cloud::SecretManager::V1::SecretOperationsService::Client.

Client for the SecretOperationsService service.

Secret Operations Service

Manages backups of secrets. Implements a REST model with the following objects:

Note: SecretOperationsService is a regional service and must be called using regional endpoints (secretmanager.{location}.rep.googleapis.com).

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the SecretOperationsService Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all SecretOperationsService clients
::Google::Cloud::SecretManager::V1::SecretOperationsService::Client.configure do |config|
  config.timeout = 10.0
end

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the SecretOperationsService Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#create_backup

def create_backup(request, options = nil) -> ::Gapic::Operation
def create_backup(parent: nil, backup_id: nil, backup: nil) -> ::Gapic::Operation

Creates a new Backup in a given project and location.

Overloads
def create_backup(request, options = nil) -> ::Gapic::Operation
Pass arguments to create_backup via a request object, either of type CreateBackupRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::SecretManager::V1::CreateBackupRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def create_backup(parent: nil, backup_id: nil, backup: nil) -> ::Gapic::Operation
Pass arguments to create_backup via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. The resource name of the location where the Backup will be created, in the format projects/{project}/locations/{location}.
  • backup_id (::String) — Required. The ID to use for the backup, which will become the final component of the backup's resource name.
  • backup (::Google::Cloud::SecretManager::V1::Backup, ::Hash) — Required. The Backup resource to create.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/secret_manager/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::SecretManager::V1::SecretOperationsService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::SecretManager::V1::CreateBackupRequest.new

# Call the create_backup method.
result = client.create_backup request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#delete_backup

def delete_backup(request, options = nil) -> ::Gapic::Operation
def delete_backup(name: nil, etag: nil) -> ::Gapic::Operation

Deletes a single Backup.

Overloads
def delete_backup(request, options = nil) -> ::Gapic::Operation
Pass arguments to delete_backup via a request object, either of type DeleteBackupRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::SecretManager::V1::DeleteBackupRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def delete_backup(name: nil, etag: nil) -> ::Gapic::Operation
Pass arguments to delete_backup via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • name (::String) — Required. The resource name of the Backup to delete, in the format projects/{project}/locations/{location}/backups/{backup}.
  • etag (::String) — Optional. If set, the request will only succeed if it matches the etag of the currently stored Backup.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/secret_manager/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::SecretManager::V1::SecretOperationsService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::SecretManager::V1::DeleteBackupRequest.new

# Call the delete_backup method.
result = client.delete_backup request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#get_backup

def get_backup(request, options = nil) -> ::Google::Cloud::SecretManager::V1::Backup
def get_backup(name: nil) -> ::Google::Cloud::SecretManager::V1::Backup

Gets details of a single Backup.

Overloads
def get_backup(request, options = nil) -> ::Google::Cloud::SecretManager::V1::Backup
Pass arguments to get_backup via a request object, either of type GetBackupRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::SecretManager::V1::GetBackupRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_backup(name: nil) -> ::Google::Cloud::SecretManager::V1::Backup
Pass arguments to get_backup via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. The resource name of the Backup, in the format projects/{project}/locations/{location}/backups/{backup}.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/secret_manager/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::SecretManager::V1::SecretOperationsService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::SecretManager::V1::GetBackupRequest.new

# Call the get_backup method.
result = client.get_backup request

# The returned object is of type Google::Cloud::SecretManager::V1::Backup.
p result

#initialize

def initialize() { |config| ... } -> Client

Create a new SecretOperationsService client object.

Yields
  • (config) — Configure the SecretOperationsService client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::SecretManager::V1::SecretOperationsService::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::SecretManager::V1::SecretOperationsService::Client.new do |config|
  config.timeout = 10.0
end

#list_backups

def list_backups(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::SecretManager::V1::Backup>
def list_backups(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::SecretManager::V1::Backup>

Lists Backups in a given project and location.

Overloads
def list_backups(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::SecretManager::V1::Backup>
Pass arguments to list_backups via a request object, either of type ListBackupsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::SecretManager::V1::ListBackupsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_backups(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::SecretManager::V1::Backup>
Pass arguments to list_backups via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. The resource name of the location associated with the Backups, in the format projects/{project}/locations/{location}.
  • page_size (::Integer) — Optional. Maximum number of backups to return. The service may return fewer than this value. If unspecified, at most 50 backups will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
  • page_token (::String) — Optional. A token identifying a page of results the server should return.
  • filter (::String) — Optional. Filter expression to restrict the returned Backups.
  • order_by (::String) — Optional. Field specification for sorting the results in the response.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/secret_manager/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::SecretManager::V1::SecretOperationsService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::SecretManager::V1::ListBackupsRequest.new

# Call the list_backups method.
result = client.list_backups request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::SecretManager::V1::Backup.
  p item
end

#location_client

def location_client() -> Google::Cloud::Location::Locations::Client

Get the associated client for mix-in of the Locations.

Returns
  • (Google::Cloud::Location::Locations::Client)

#logger

def logger() -> Logger

The logger used for request/response debug logging.

Returns
  • (Logger)

#operations_client

def operations_client() -> ::Google::Cloud::SecretManager::V1::SecretOperationsService::Operations

Get the associated client for long-running operations.

#restore_backup

def restore_backup(request, options = nil) -> ::Gapic::Operation
def restore_backup(name: nil, destination_secret_parent: nil, destination_secret_id: nil, kms_key_name: nil) -> ::Gapic::Operation

Restores a Secret from the given Backup. This creates a new Secret resource. The LRO tracks the restoration process, and the result of the LRO is the newly created Secret.

Overloads
def restore_backup(request, options = nil) -> ::Gapic::Operation
Pass arguments to restore_backup via a request object, either of type RestoreBackupRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::SecretManager::V1::RestoreBackupRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def restore_backup(name: nil, destination_secret_parent: nil, destination_secret_id: nil, kms_key_name: nil) -> ::Gapic::Operation
Pass arguments to restore_backup via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • name (::String) — Required. The resource name of the Backup to restore from. Format: projects/{project}/locations/{location}/backups/{backup}
  • destination_secret_parent (::String) —

    Required. Parent of the new Secret to be created from this backup. Formats:

    • projects/{project}/locations/{location} (for regional secrets)
    • projects/{project} (for global secrets)
  • destination_secret_id (::String) — Required. ID of the new Secret to be created from this backup. This must be unique within the project.

    A secret ID is a string with a maximum length of 255 characters and can contain uppercase and lowercase letters, numerals, and the hyphen (-) and underscore (_) characters.

  • kms_key_name (::String) — Optional. The resource name of the Cloud KMS CryptoKey to be used to encrypt the Secret. Format: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/secret_manager/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::SecretManager::V1::SecretOperationsService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::SecretManager::V1::RestoreBackupRequest.new

# Call the restore_backup method.
result = client.restore_backup request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#universe_domain

def universe_domain() -> String

The effective universe domain

Returns
  • (String)

#update_backup

def update_backup(request, options = nil) -> ::Gapic::Operation
def update_backup(update_mask: nil, backup: nil) -> ::Gapic::Operation

Updates the parameters of a single Backup.

Overloads
def update_backup(request, options = nil) -> ::Gapic::Operation
Pass arguments to update_backup via a request object, either of type UpdateBackupRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::SecretManager::V1::UpdateBackupRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def update_backup(update_mask: nil, backup: nil) -> ::Gapic::Operation
Pass arguments to update_backup via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • update_mask (::Google::Protobuf::FieldMask, ::Hash) — Optional. Field mask is used to specify the fields to be overwritten in the Backup resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. If the user does not provide a mask then all fields present in the request will be overwritten.
  • backup (::Google::Cloud::SecretManager::V1::Backup, ::Hash) — Required. The Backup resource with updated fields.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/secret_manager/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::SecretManager::V1::SecretOperationsService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::SecretManager::V1::UpdateBackupRequest.new

# Call the update_backup method.
result = client.update_backup request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end