Class: Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb

Overview

Client for the DatabaseAdmin service.

Cloud Spanner Database Admin API

The Cloud Spanner Database Admin API can be used to:

  • create, drop, and list databases
  • update the schema of pre-existing databases
  • create, delete, copy and list backups for a database
  • restore a database from an existing backup

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#backup_path, #crypto_key_path, #crypto_key_version_path, #database_path, #instance_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new DatabaseAdmin client object.

Examples:


# Create a client using the default configuration
client = ::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the DatabaseAdmin client.

Yield Parameters:



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 214

def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/spanner/admin/database/v1/spanner_database_admin_services_pb"

  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint.nil? ||
                           (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
                           !@config.endpoint.split(".").first.include?("-"))
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end
  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @operations_client = Operations.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @config.endpoint
    config.universe_domain = @config.universe_domain
  end

  @database_admin_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Stub,
    credentials: credentials,
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors,
    channel_pool_config: @config.channel_pool
  )
end

Instance Attribute Details

#operations_client::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Operations (readonly)

Get the associated client for long-running operations.



266
267
268
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 266

def operations_client
  @operations_client
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the DatabaseAdmin Client class.

See Configuration for a description of the configuration fields.

Examples:


# Modify the configuration for all DatabaseAdmin clients
::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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
160
161
162
163
164
165
166
167
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 70

def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "Spanner", "Admin", "Database", "V1"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.rpcs.list_databases.timeout = 3600.0
    default_config.rpcs.list_databases.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.create_database.timeout = 3600.0

    default_config.rpcs.get_database.timeout = 3600.0
    default_config.rpcs.get_database.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.update_database.timeout = 3600.0
    default_config.rpcs.update_database.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.update_database_ddl.timeout = 3600.0
    default_config.rpcs.update_database_ddl.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.drop_database.timeout = 3600.0
    default_config.rpcs.drop_database.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.get_database_ddl.timeout = 3600.0
    default_config.rpcs.get_database_ddl.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.set_iam_policy.timeout = 30.0

    default_config.rpcs.get_iam_policy.timeout = 30.0
    default_config.rpcs.get_iam_policy.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.test_iam_permissions.timeout = 30.0

    default_config.rpcs.create_backup.timeout = 3600.0

    default_config.rpcs.copy_backup.timeout = 3600.0

    default_config.rpcs.get_backup.timeout = 3600.0
    default_config.rpcs.get_backup.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.update_backup.timeout = 3600.0
    default_config.rpcs.update_backup.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.delete_backup.timeout = 3600.0
    default_config.rpcs.delete_backup.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.list_backups.timeout = 3600.0
    default_config.rpcs.list_backups.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.restore_database.timeout = 3600.0

    default_config.rpcs.list_database_operations.timeout = 3600.0
    default_config.rpcs.list_database_operations.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.list_backup_operations.timeout = 3600.0
    default_config.rpcs.list_backup_operations.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.list_database_roles.timeout = 3600.0
    default_config.rpcs.list_database_roles.retry_policy = {
      initial_delay: 1.0, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#configure {|config| ... } ⇒ Client::Configuration

Configure the DatabaseAdmin 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 configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



184
185
186
187
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 184

def configure
  yield @config if block_given?
  @config
end

#copy_backup(request, options = nil) ⇒ ::Gapic::Operation #copy_backup(parent: nil, backup_id: nil, source_backup: nil, expire_time: nil, encryption_config: nil) ⇒ ::Gapic::Operation

Starts copying a Cloud Spanner Backup. The returned backup long-running operation will have a name of the format projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id> and can be used to track copying of the backup. The operation is associated with the destination backup. The metadata field type is CopyBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the copying and delete the destination backup. Concurrent CopyBackup requests can run on the same source backup.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::V1::CopyBackupRequest.new

# Call the copy_backup method.
result = client.copy_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

Overloads:

  • #copy_backup(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to copy_backup via a request object, either of type CopyBackupRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::V1::CopyBackupRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #copy_backup(parent: nil, backup_id: nil, source_backup: nil, expire_time: nil, encryption_config: nil) ⇒ ::Gapic::Operation

    Pass arguments to copy_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) (defaults to: nil)

      Required. The name of the destination instance that will contain the backup copy. Values are of the form: projects/<project>/instances/<instance>.

    • backup_id (::String) (defaults to: nil)

      Required. The id of the backup copy. The backup_id appended to parent forms the full backup_uri of the form projects/<project>/instances/<instance>/backups/<backup>.

    • source_backup (::String) (defaults to: nil)

      Required. The source backup to be copied. The source backup needs to be in READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the form: projects/<project>/instances/<instance>/backups/<backup>.

    • expire_time (::Google::Protobuf::Timestamp, ::Hash) (defaults to: nil)

      Required. The expiration time of the backup in microsecond granularity. The expiration time must be at least 6 hours and at most 366 days from the create_time of the source backup. Once the expire_time has passed, the backup is eligible to be automatically deleted by Cloud Spanner to free the resources used by the backup.

    • encryption_config (::Google::Cloud::Spanner::Admin::Database::V1::CopyBackupEncryptionConfig, ::Hash) (defaults to: nil)

      Optional. The encryption configuration used to encrypt the backup. If this field is not specified, the backup will use the same encryption configuration as the source backup by default, namely encryption_type = USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION.

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.



1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 1557

def copy_backup request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::CopyBackupRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.copy_backup..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.copy_backup.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.copy_backup.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :copy_backup, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#create_backup(request, options = nil) ⇒ ::Gapic::Operation #create_backup(parent: nil, backup_id: nil, backup: nil, encryption_config: nil) ⇒ ::Gapic::Operation

Starts creating a new Cloud Spanner Backup. The returned backup long-running operation will have a name of the format projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id> and can be used to track creation of the backup. The metadata field type is CreateBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the creation and delete the backup. There can be only one pending backup creation per database. Backup creation of different databases can run concurrently.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::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

Overloads:

  • #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::Spanner::Admin::Database::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #create_backup(parent: nil, backup_id: nil, backup: nil, encryption_config: 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) (defaults to: nil)

      Required. The name of the instance in which the backup will be created. This must be the same instance that contains the database the backup will be created from. The backup will be stored in the location(s) specified in the instance configuration of this instance. Values are of the form projects/<project>/instances/<instance>.

    • backup_id (::String) (defaults to: nil)

      Required. The id of the backup to be created. The backup_id appended to parent forms the full backup name of the form projects/<project>/instances/<instance>/backups/<backup_id>.

    • backup (::Google::Cloud::Spanner::Admin::Database::V1::Backup, ::Hash) (defaults to: nil)

      Required. The backup to create.

    • encryption_config (::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupEncryptionConfig, ::Hash) (defaults to: nil)

      Optional. The encryption configuration used to encrypt the backup. If this field is not specified, the backup will use the same encryption configuration as the database by default, namely encryption_type = USE_DATABASE_ENCRYPTION.

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.



1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 1427

def create_backup request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_backup..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.create_backup.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_backup.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :create_backup, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#create_database(request, options = nil) ⇒ ::Gapic::Operation #create_database(parent: nil, create_statement: nil, extra_statements: nil, encryption_config: nil, database_dialect: nil, proto_descriptors: nil) ⇒ ::Gapic::Operation

Creates a new Cloud Spanner database and starts to prepare it for serving. The returned long-running operation will have a name of the format <database_name>/operations/<operation_id> and can be used to track preparation of the database. The metadata field type is CreateDatabaseMetadata. The response field type is Database, if successful.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::V1::CreateDatabaseRequest.new

# Call the create_database method.
result = client.create_database 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

Overloads:

  • #create_database(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to create_database via a request object, either of type CreateDatabaseRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::V1::CreateDatabaseRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #create_database(parent: nil, create_statement: nil, extra_statements: nil, encryption_config: nil, database_dialect: nil, proto_descriptors: nil) ⇒ ::Gapic::Operation

    Pass arguments to create_database 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) (defaults to: nil)

      Required. The name of the instance that will serve the new database. Values are of the form projects/<project>/instances/<instance>.

    • create_statement (::String) (defaults to: nil)

      Required. A CREATE DATABASE statement, which specifies the ID of the new database. The database ID must conform to the regular expression [a-z][a-z0-9_\-]*[a-z0-9] and be between 2 and 30 characters in length. If the database ID is a reserved word or if it contains a hyphen, the database ID must be enclosed in backticks (`).

    • extra_statements (::Array<::String>) (defaults to: nil)

      Optional. A list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.

    • encryption_config (::Google::Cloud::Spanner::Admin::Database::V1::EncryptionConfig, ::Hash) (defaults to: nil)

      Optional. The encryption configuration for the database. If this field is not specified, Cloud Spanner will encrypt/decrypt all data at rest using Google default encryption.

    • database_dialect (::Google::Cloud::Spanner::Admin::Database::V1::DatabaseDialect) (defaults to: nil)

      Optional. The dialect of the Cloud Spanner Database.

    • proto_descriptors (::String) (defaults to: nil)

      Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements in 'extra_statements' above. Contains a protobuf-serialized google.protobuf.FileDescriptorSet. To generate it, install and run protoc with --include_imports and --descriptor_set_out. For example, to generate for moon/shot/app.proto, run

      $protoc  --proto_path=/app_path --proto_path=/lib_path \
               --include_imports \
               --descriptor_set_out=descriptors.data \
               moon/shot/app.proto
      

      For more details, see protobuffer self description.

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.



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
495
496
497
498
499
500
501
502
503
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 462

def create_database request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::CreateDatabaseRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_database..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.create_database.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_database.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :create_database, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_backup(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_backup(name: nil) ⇒ ::Google::Protobuf::Empty

Deletes a pending or completed Backup.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

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

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

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #delete_backup(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_backup via a request object, either of type Google::Cloud::Spanner::Admin::Database::V1::DeleteBackupRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #delete_backup(name: nil) ⇒ ::Google::Protobuf::Empty

    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) (defaults to: nil)

      Required. Name of the backup to delete. Values are of the form projects/<project>/instances/<instance>/backups/<backup>.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 1832

def delete_backup request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::DeleteBackupRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_backup..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_backup.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_backup.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :delete_backup, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#drop_database(request, options = nil) ⇒ ::Google::Protobuf::Empty #drop_database(database: nil) ⇒ ::Google::Protobuf::Empty

Drops (aka deletes) a Cloud Spanner database. Completed backups for the database will be retained according to their expire_time. Note: Cloud Spanner might continue to accept requests for a few seconds after the database has been deleted.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::V1::DropDatabaseRequest.new

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

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #drop_database(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to drop_database via a request object, either of type Google::Cloud::Spanner::Admin::Database::V1::DropDatabaseRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::V1::DropDatabaseRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #drop_database(database: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to drop_database 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:

    • database (::String) (defaults to: nil)

      Required. The database to be dropped.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



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
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 914

def drop_database request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::DropDatabaseRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.drop_database..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.database
    header_params["database"] = request.database
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.drop_database.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.drop_database.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :drop_database, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_backup(request, options = nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::Backup #get_backup(name: nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::Backup

Gets metadata on a pending or completed Backup.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

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

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

# The returned object is of type Google::Cloud::Spanner::Admin::Database::V1::Backup.
p result

Overloads:

  • #get_backup(request, options = nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::Backup

    Pass arguments to get_backup via a request object, either of type GetBackupRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_backup(name: nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::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).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Name of the backup. Values are of the form projects/<project>/instances/<instance>/backups/<backup>.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 1647

def get_backup request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::GetBackupRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_backup..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_backup.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_backup.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :get_backup, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_database(request, options = nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::Database #get_database(name: nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::Database

Gets the state of a Cloud Spanner database.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseRequest.new

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

# The returned object is of type Google::Cloud::Spanner::Admin::Database::V1::Database.
p result

Overloads:

  • #get_database(request, options = nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::Database

    Pass arguments to get_database via a request object, either of type GetDatabaseRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_database(name: nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::Database

    Pass arguments to get_database 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) (defaults to: nil)

      Required. The name of the requested database. Values are of the form projects/<project>/instances/<instance>/databases/<database>.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 550

def get_database request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_database..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_database.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_database.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :get_database, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_database_ddl(request, options = nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlResponse #get_database_ddl(database: nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlResponse

Returns the schema of a Cloud Spanner database as a list of formatted DDL statements. This method does not show pending schema updates, those may be queried using the Operations API.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlRequest.new

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

# The returned object is of type Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlResponse.
p result

Overloads:

  • #get_database_ddl(request, options = nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlResponse

    Pass arguments to get_database_ddl via a request object, either of type GetDatabaseDdlRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_database_ddl(database: nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlResponse

    Pass arguments to get_database_ddl 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:

    • database (::String) (defaults to: nil)

      Required. The database whose schema we wish to get. Values are of the form projects/<project>/instances/<instance>/databases/<database>

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 1004

def get_database_ddl request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_database_ddl..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.database
    header_params["database"] = request.database
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_database_ddl.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_database_ddl.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :get_database_ddl, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_iam_policy(request, options = nil) ⇒ ::Google::Iam::V1::Policy #get_iam_policy(resource: nil, options: nil) ⇒ ::Google::Iam::V1::Policy

Gets the access control policy for a database or backup resource. Returns an empty policy if a database or backup exists but does not have a policy set.

Authorization requires spanner.databases.getIamPolicy permission on resource. For backups, authorization requires spanner.backups.getIamPolicy permission on resource.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Iam::V1::GetIamPolicyRequest.new

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

# The returned object is of type Google::Iam::V1::Policy.
p result

Overloads:

  • #get_iam_policy(request, options = nil) ⇒ ::Google::Iam::V1::Policy

    Pass arguments to get_iam_policy via a request object, either of type Iam::V1::GetIamPolicyRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Iam::V1::GetIamPolicyRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_iam_policy(resource: nil, options: nil) ⇒ ::Google::Iam::V1::Policy

    Pass arguments to get_iam_policy 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:

    • resource (::String) (defaults to: nil)

      REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

    • options (::Google::Iam::V1::GetPolicyOptions, ::Hash) (defaults to: nil)

      OPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 1205

def get_iam_policy request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::GetIamPolicyRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_iam_policy..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.resource
    header_params["resource"] = request.resource
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_iam_policy.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_iam_policy.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :get_iam_policy, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_backup_operations(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Gapic::Operation> #list_backup_operations(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Gapic::Operation>

Lists the backup long-running operations in the given instance. A backup operation has a name of the form projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>. The long-running operation metadata field type metadata.type_url describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations. Operations returned are ordered by operation.metadata.value.progress.start_time in descending order starting from the most recently started operation.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::V1::ListBackupOperationsRequest.new

# Call the list_backup_operations method.
result = client.list_backup_operations 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::Longrunning::Operation.
  p item
end

Overloads:

  • #list_backup_operations(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Gapic::Operation>

    Pass arguments to list_backup_operations via a request object, either of type ListBackupOperationsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::V1::ListBackupOperationsRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_backup_operations(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Gapic::Operation>

    Pass arguments to list_backup_operations 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) (defaults to: nil)

      Required. The instance of the backup operations. Values are of the form projects/<project>/instances/<instance>.

    • filter (::String) (defaults to: nil)

      An expression that filters the list of returned backup operations.

      A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

      The following fields in the operation are eligible for filtering:

      • name - The name of the long-running operation
      • done - False if the operation is in progress, else true.
      • metadata.@type - the type of metadata. For example, the type string for CreateBackupMetadata is type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata.
      • metadata.<field_name> - any field in metadata.value. metadata.@type must be specified first if filtering on metadata fields.
      • error - Error associated with the long-running operation.
      • response.@type - the type of response.
      • response.<field_name> - any field in response.value.

      You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic, but you can specify AND, OR, and NOT logic explicitly.

      Here are a few examples:

      • done:true - The operation is complete.
      • (metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND \ metadata.database:prod - Returns operations where:
        • The operation's metadata type is CreateBackupMetadata.
        • The source database name of backup contains the string "prod".
      • (metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND \ (metadata.name:howl) AND \ (metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND \ (error:*) - Returns operations where:
        • The operation's metadata type is CreateBackupMetadata.
        • The backup name contains the string "howl".
        • The operation started before 2018-03-28T14:50:00Z.
        • The operation resulted in an error.
      • (metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND \ (metadata.source_backup:test) AND \ (metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND \ (error:*) - Returns operations where:
        • The operation's metadata type is CopyBackupMetadata.
        • The source backup name contains the string "test".
        • The operation started before 2022-01-18T14:50:00Z.
        • The operation resulted in an error.
      • ((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND \ (metadata.database:test_db)) OR \ ((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND \ (metadata.source_backup:test_bkp)) AND \ (error:*) - Returns operations where:
        • The operation's metadata matches either of criteria:
          • The operation's metadata type is CreateBackupMetadata AND the source database name of the backup contains the string "test_db"
          • The operation's metadata type is CopyBackupMetadata AND the source backup name contains the string "test_bkp"
        • The operation resulted in an error.
    • page_size (::Integer) (defaults to: nil)

      Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

    • page_token (::String) (defaults to: nil)

      If non-empty, page_token should contain a next_page_token from a previous ListBackupOperationsResponse to the same parent and with the same filter.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::PagedEnumerable<::Gapic::Operation>)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::PagedEnumerable<::Gapic::Operation>)

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 2437

def list_backup_operations request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::ListBackupOperationsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_backup_operations..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_backup_operations.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_backup_operations.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :list_backup_operations, request, options: options do |response, operation|
    wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client }
    response = ::Gapic::PagedEnumerable.new @database_admin_stub, :list_backup_operations, request, response, operation, options, format_resource: wrap_lro_operation
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_backups(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Backup> #list_backups(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Backup>

Lists completed and pending backups. Backups returned are ordered by create_time in descending order, starting from the most recent create_time.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::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::Spanner::Admin::Database::V1::Backup.
  p item
end

Overloads:

  • #list_backups(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Backup>

    Pass arguments to list_backups via a request object, either of type ListBackupsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_backups(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::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) (defaults to: nil)

      Required. The instance to list backups from. Values are of the form projects/<project>/instances/<instance>.

    • filter (::String) (defaults to: nil)

      An expression that filters the list of returned backups.

      A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

      The following fields in the Backup are eligible for filtering:

      • name
      • database
      • state
      • create_time (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
      • expire_time (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
      • version_time (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
      • size_bytes

      You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic, but you can specify AND, OR, and NOT logic explicitly.

      Here are a few examples:

      • name:Howl - The backup's name contains the string "howl".
      • database:prod - The database's name contains the string "prod".
      • state:CREATING - The backup is pending creation.
      • state:READY - The backup is fully created and ready for use.
      • (name:howl) AND (create_time < \"2018-03-28T14:50:00Z\") - The backup name contains the string "howl" and create_time of the backup is before 2018-03-28T14:50:00Z.
      • expire_time < \"2018-03-28T14:50:00Z\" - The backup expire_time is before 2018-03-28T14:50:00Z.
      • size_bytes > 10000000000 - The backup's size is greater than 10GB
    • page_size (::Integer) (defaults to: nil)

      Number of backups to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

    • page_token (::String) (defaults to: nil)

      If non-empty, page_token should contain a next_page_token from a previous ListBackupsResponse to the same parent and with the same filter.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 1972

def list_backups request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::ListBackupsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_backups..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_backups.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_backups.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :list_backups, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @database_admin_stub, :list_backups, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_database_operations(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Gapic::Operation> #list_database_operations(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Gapic::Operation>

Lists database longrunning-operations. A database operation has a name of the form projects/<project>/instances/<instance>/databases/<database>/operations/<operation>. The long-running operation metadata field type metadata.type_url describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseOperationsRequest.new

# Call the list_database_operations method.
result = client.list_database_operations 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::Longrunning::Operation.
  p item
end

Overloads:

  • #list_database_operations(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Gapic::Operation>

    Pass arguments to list_database_operations via a request object, either of type ListDatabaseOperationsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseOperationsRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_database_operations(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Gapic::Operation>

    Pass arguments to list_database_operations 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) (defaults to: nil)

      Required. The instance of the database operations. Values are of the form projects/<project>/instances/<instance>.

    • filter (::String) (defaults to: nil)

      An expression that filters the list of returned operations.

      A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

      The following fields in the Operation are eligible for filtering:

      • name - The name of the long-running operation
      • done - False if the operation is in progress, else true.
      • metadata.@type - the type of metadata. For example, the type string for RestoreDatabaseMetadata is type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata.
      • metadata.<field_name> - any field in metadata.value. metadata.@type must be specified first, if filtering on metadata fields.
      • error - Error associated with the long-running operation.
      • response.@type - the type of response.
      • response.<field_name> - any field in response.value.

      You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic. However, you can specify AND, OR, and NOT logic explicitly.

      Here are a few examples:

      • done:true - The operation is complete.
      • (metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND \ (metadata.source_type:BACKUP) AND \ (metadata.backup_info.backup:backup_howl) AND \ (metadata.name:restored_howl) AND \ (metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND \ (error:*) - Return operations where:
        • The operation's metadata type is RestoreDatabaseMetadata.
        • The database is restored from a backup.
        • The backup name contains "backup_howl".
        • The restored database's name contains "restored_howl".
        • The operation started before 2018-03-28T14:50:00Z.
        • The operation resulted in an error.
    • page_size (::Integer) (defaults to: nil)

      Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

    • page_token (::String) (defaults to: nil)

      If non-empty, page_token should contain a next_page_token from a previous ListDatabaseOperationsResponse to the same parent and with the same filter.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • response (::Gapic::PagedEnumerable<::Gapic::Operation>)
  • operation (::GRPC::ActiveCall::Operation)

Returns:

  • (::Gapic::PagedEnumerable<::Gapic::Operation>)

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 2255

def list_database_operations request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseOperationsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_database_operations..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_database_operations.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_database_operations.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :list_database_operations, request, options: options do |response, operation|
    wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client }
    response = ::Gapic::PagedEnumerable.new @database_admin_stub, :list_database_operations, request, response, operation, options, format_resource: wrap_lro_operation
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_database_roles(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::DatabaseRole> #list_database_roles(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::DatabaseRole>

Lists Cloud Spanner database roles.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseRolesRequest.new

# Call the list_database_roles method.
result = client.list_database_roles 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::Spanner::Admin::Database::V1::DatabaseRole.
  p item
end

Overloads:

  • #list_database_roles(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::DatabaseRole>

    Pass arguments to list_database_roles via a request object, either of type ListDatabaseRolesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseRolesRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_database_roles(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::DatabaseRole>

    Pass arguments to list_database_roles 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) (defaults to: nil)

      Required. The database whose roles should be listed. Values are of the form projects/<project>/instances/<instance>/databases/<database>.

    • page_size (::Integer) (defaults to: nil)

      Number of database roles to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

    • page_token (::String) (defaults to: nil)

      If non-empty, page_token should contain a next_page_token from a previous ListDatabaseRolesResponse.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 2539

def list_database_roles request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseRolesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_database_roles..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_database_roles.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_database_roles.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :list_database_roles, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @database_admin_stub, :list_database_roles, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_databases(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Database> #list_databases(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Database>

Lists Cloud Spanner databases.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::V1::ListDatabasesRequest.new

# Call the list_databases method.
result = client.list_databases 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::Spanner::Admin::Database::V1::Database.
  p item
end

Overloads:

  • #list_databases(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Database>

    Pass arguments to list_databases via a request object, either of type ListDatabasesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::V1::ListDatabasesRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_databases(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Database>

    Pass arguments to list_databases 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) (defaults to: nil)

      Required. The instance whose databases should be listed. Values are of the form projects/<project>/instances/<instance>.

    • page_size (::Integer) (defaults to: nil)

      Number of databases to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

    • page_token (::String) (defaults to: nil)

      If non-empty, page_token should contain a next_page_token from a previous ListDatabasesResponse.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



327
328
329
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
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 327

def list_databases request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::ListDatabasesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_databases..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_databases.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_databases.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :list_databases, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @database_admin_stub, :list_databases, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#restore_database(request, options = nil) ⇒ ::Gapic::Operation #restore_database(parent: nil, database_id: nil, backup: nil, encryption_config: nil) ⇒ ::Gapic::Operation

Create a new database by restoring from a completed backup. The new database must be in the same project and in an instance with the same instance configuration as the instance containing the backup. The returned database [long-running operation][google.longrunning.Operation] has a name of the format projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>, and can be used to track the progress of the operation, and to cancel it. The metadata field type is RestoreDatabaseMetadata. The response type is Database, if successful. Cancelling the returned operation will stop the restore and delete the database. There can be only one database being restored into an instance at a time. Once the restore operation completes, a new restore operation can be initiated, without waiting for the optimize operation associated with the first restore to complete.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseRequest.new

# Call the restore_database method.
result = client.restore_database 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

Overloads:

  • #restore_database(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to restore_database via a request object, either of type RestoreDatabaseRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #restore_database(parent: nil, database_id: nil, backup: nil, encryption_config: nil) ⇒ ::Gapic::Operation

    Pass arguments to restore_database 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) (defaults to: nil)

      Required. The name of the instance in which to create the restored database. This instance must be in the same project and have the same instance configuration as the instance containing the source backup. Values are of the form projects/<project>/instances/<instance>.

    • database_id (::String) (defaults to: nil)

      Required. The id of the database to create and restore to. This database must not already exist. The database_id appended to parent forms the full database name of the form projects/<project>/instances/<instance>/databases/<database_id>.

    • backup (::String) (defaults to: nil)

      Name of the backup from which to restore. Values are of the form projects/<project>/instances/<instance>/backups/<backup>.

    • encryption_config (::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseEncryptionConfig, ::Hash) (defaults to: nil)

      Optional. An encryption configuration describing the encryption type and key resources in Cloud KMS used to encrypt/decrypt the database to restore to. If this field is not specified, the restored database will use the same encryption configuration as the backup by default, namely encryption_type = USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION.

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.



2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 2101

def restore_database request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.restore_database..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.restore_database.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.restore_database.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :restore_database, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_iam_policy(request, options = nil) ⇒ ::Google::Iam::V1::Policy #set_iam_policy(resource: nil, policy: nil, update_mask: nil) ⇒ ::Google::Iam::V1::Policy

Sets the access control policy on a database or backup resource. Replaces any existing policy.

Authorization requires spanner.databases.setIamPolicy permission on resource. For backups, authorization requires spanner.backups.setIamPolicy permission on resource.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Iam::V1::SetIamPolicyRequest.new

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

# The returned object is of type Google::Iam::V1::Policy.
p result

Overloads:

  • #set_iam_policy(request, options = nil) ⇒ ::Google::Iam::V1::Policy

    Pass arguments to set_iam_policy via a request object, either of type Iam::V1::SetIamPolicyRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Iam::V1::SetIamPolicyRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #set_iam_policy(resource: nil, policy: nil, update_mask: nil) ⇒ ::Google::Iam::V1::Policy

    Pass arguments to set_iam_policy 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:

    • resource (::String) (defaults to: nil)

      REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

    • policy (::Google::Iam::V1::Policy, ::Hash) (defaults to: nil)

      REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used:

      paths: "bindings, etag"

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 1108

def set_iam_policy request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::SetIamPolicyRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.set_iam_policy..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.resource
    header_params["resource"] = request.resource
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.set_iam_policy.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.set_iam_policy.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :set_iam_policy, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#test_iam_permissions(request, options = nil) ⇒ ::Google::Iam::V1::TestIamPermissionsResponse #test_iam_permissions(resource: nil, permissions: nil) ⇒ ::Google::Iam::V1::TestIamPermissionsResponse

Returns permissions that the caller has on the specified database or backup resource.

Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has spanner.databases.list permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has spanner.backups.list permission on the containing instance.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Iam::V1::TestIamPermissionsRequest.new

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

# The returned object is of type Google::Iam::V1::TestIamPermissionsResponse.
p result

Overloads:

  • #test_iam_permissions(request, options = nil) ⇒ ::Google::Iam::V1::TestIamPermissionsResponse

    Pass arguments to test_iam_permissions via a request object, either of type Iam::V1::TestIamPermissionsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Iam::V1::TestIamPermissionsRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #test_iam_permissions(resource: nil, permissions: nil) ⇒ ::Google::Iam::V1::TestIamPermissionsResponse

    Pass arguments to test_iam_permissions 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:

    • resource (::String) (defaults to: nil)

      REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

    • permissions (::Array<::String>) (defaults to: nil)

      The set of permissions to check for the resource. Permissions with wildcards (such as '' or 'storage.') are not allowed. For more information see IAM Overview.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 1306

def test_iam_permissions request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::TestIamPermissionsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.test_iam_permissions..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.resource
    header_params["resource"] = request.resource
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.test_iam_permissions.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.test_iam_permissions.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :test_iam_permissions, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


194
195
196
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 194

def universe_domain
  @database_admin_stub.universe_domain
end

#update_backup(request, options = nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::Backup #update_backup(backup: nil, update_mask: nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::Backup

Updates a pending or completed Backup.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

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

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

# The returned object is of type Google::Cloud::Spanner::Admin::Database::V1::Backup.
p result

Overloads:

  • #update_backup(request, options = nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::Backup

    Pass arguments to update_backup via a request object, either of type UpdateBackupRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #update_backup(backup: nil, update_mask: nil) ⇒ ::Google::Cloud::Spanner::Admin::Database::V1::Backup

    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:

    • backup (::Google::Cloud::Spanner::Admin::Database::V1::Backup, ::Hash) (defaults to: nil)

      Required. The backup to update. backup.name, and the fields to be updated as specified by update_mask are required. Other fields are ignored. Update is only supported for the following fields:

      • backup.expire_time.
    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      Required. A mask specifying which fields (e.g. expire_time) in the Backup resource should be updated. This mask is relative to the Backup resource, not to the request message. The field mask must always be specified; this prevents any future fields from being erased accidentally by clients that do not know about them.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 1743

def update_backup request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::UpdateBackupRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_backup..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.backup&.name
    header_params["backup.name"] = request.backup.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_backup.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_backup.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :update_backup, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_database(request, options = nil) ⇒ ::Gapic::Operation #update_database(database: nil, update_mask: nil) ⇒ ::Gapic::Operation

Updates a Cloud Spanner database. The returned long-running operation can be used to track the progress of updating the database. If the named database does not exist, returns NOT_FOUND.

While the operation is pending:

  • The database's reconciling field is set to true.
  • Cancelling the operation is best-effort. If the cancellation succeeds, the operation metadata's cancel_time is set, the updates are reverted, and the operation terminates with a CANCELLED status.
  • New UpdateDatabase requests will return a FAILED_PRECONDITION error until the pending operation is done (returns successfully or with error).
  • Reading the database via the API continues to give the pre-request values.

Upon completion of the returned operation:

  • The new values are in effect and readable via the API.
  • The database's reconciling field becomes false.

The returned long-running operation will have a name of the format projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id> and can be used to track the database modification. The metadata field type is UpdateDatabaseMetadata. The response field type is Database, if successful.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseRequest.new

# Call the update_database method.
result = client.update_database 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

Overloads:

  • #update_database(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to update_database via a request object, either of type UpdateDatabaseRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #update_database(database: nil, update_mask: nil) ⇒ ::Gapic::Operation

    Pass arguments to update_database 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:

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.



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
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 683

def update_database request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_database..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.database&.name
    header_params["database.name"] = request.database.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_database.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_database.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :update_database, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_database_ddl(request, options = nil) ⇒ ::Gapic::Operation #update_database_ddl(database: nil, statements: nil, operation_id: nil, proto_descriptors: nil) ⇒ ::Gapic::Operation

Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns, indexes, etc. The returned long-running operation will have a name of the format <database_name>/operations/<operation_id> and can be used to track execution of the schema change(s). The metadata field type is UpdateDatabaseDdlMetadata. The operation has no response.

Examples:

Basic example

require "google/cloud/spanner/admin/database/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest.new

# Call the update_database_ddl method.
result = client.update_database_ddl 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

Overloads:

  • #update_database_ddl(request, options = nil) ⇒ ::Gapic::Operation

    Pass arguments to update_database_ddl via a request object, either of type UpdateDatabaseDdlRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #update_database_ddl(database: nil, statements: nil, operation_id: nil, proto_descriptors: nil) ⇒ ::Gapic::Operation

    Pass arguments to update_database_ddl 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:

    • database (::String) (defaults to: nil)

      Required. The database to update.

    • statements (::Array<::String>) (defaults to: nil)

      Required. DDL statements to be applied to the database.

    • operation_id (::String) (defaults to: nil)

      If empty, the new update request is assigned an automatically-generated operation ID. Otherwise, operation_id is used to construct the name of the resulting Operation.

      Specifying an explicit operation ID simplifies determining whether the statements were executed in the event that the UpdateDatabaseDdl call is replayed, or the return value is otherwise lost: the database and operation_id fields can be combined to form the name of the resulting longrunning.Operation: <database>/operations/<operation_id>.

      operation_id should be unique within the database, and must be a valid identifier: [a-z][a-z0-9_]*. Note that automatically-generated operation IDs always begin with an underscore. If the named operation already exists, UpdateDatabaseDdl returns ALREADY_EXISTS.

    • proto_descriptors (::String) (defaults to: nil)

      Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements. Contains a protobuf-serialized google.protobuf.FileDescriptorSet. To generate it, install and run protoc with --include_imports and --descriptor_set_out. For example, to generate for moon/shot/app.proto, run

      $protoc  --proto_path=/app_path --proto_path=/lib_path \
               --include_imports \
               --descriptor_set_out=descriptors.data \
               moon/shot/app.proto
      

      For more details, see protobuffer self description.

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.



823
824
825
826
827
828
829
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
# File 'lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb', line 823

def update_database_ddl request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_database_ddl..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.database
    header_params["database"] = request.database
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_database_ddl.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_database_ddl.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @database_admin_stub.call_rpc :update_database_ddl, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end