google-cloud-spanner-admin-database-v1 0.1.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,3 +37,6 @@ module Google
37
37
  end
38
38
  end
39
39
  end
40
+
41
+ helper_path = ::File.join __dir__, "v1", "_helpers.rb"
42
+ require "google/cloud/spanner/admin/database/v1/_helpers" if ::File.file? helper_path
@@ -239,7 +239,13 @@ module Google
239
239
 
240
240
  # Create credentials
241
241
  credentials = @config.credentials
242
- credentials ||= Credentials.default scope: @config.scope
242
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
243
+ # but only if the default endpoint does not have a region prefix.
244
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
245
+ @config.endpoint == Client.configure.endpoint &&
246
+ !@config.endpoint.split(".").first.include?("-")
247
+ credentials ||= Credentials.default scope: @config.scope,
248
+ enable_self_signed_jwt: enable_self_signed_jwt
243
249
  if credentials.is_a?(String) || credentials.is_a?(Hash)
244
250
  credentials = Credentials.new credentials, scope: @config.scope
245
251
  end
@@ -295,8 +301,9 @@ module Google
295
301
  # defaults to the server's maximum allowed page size.
296
302
  # @param page_token [::String]
297
303
  # If non-empty, `page_token` should contain a
298
- # {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabasesResponse#next_page_token next_page_token} from a
299
- # previous {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabasesResponse ListDatabasesResponse}.
304
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabasesResponse#next_page_token next_page_token}
305
+ # from a previous
306
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabasesResponse ListDatabasesResponse}.
300
307
  #
301
308
  # @yield [response, operation] Access the result along with the RPC operation
302
309
  # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Database>]
@@ -350,8 +357,8 @@ module Google
350
357
  # have a name of the format `<database_name>/operations/<operation_id>` and
351
358
  # can be used to track preparation of the database. The
352
359
  # {::Google::Longrunning::Operation#metadata metadata} field type is
353
- # {::Google::Cloud::Spanner::Admin::Database::V1::CreateDatabaseMetadata CreateDatabaseMetadata}. The
354
- # {::Google::Longrunning::Operation#response response} field type is
360
+ # {::Google::Cloud::Spanner::Admin::Database::V1::CreateDatabaseMetadata CreateDatabaseMetadata}.
361
+ # The {::Google::Longrunning::Operation#response response} field type is
355
362
  # {::Google::Cloud::Spanner::Admin::Database::V1::Database Database}, if successful.
356
363
  #
357
364
  # @overload create_database(request, options = nil)
@@ -364,7 +371,7 @@ module Google
364
371
  # @param options [::Gapic::CallOptions, ::Hash]
365
372
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
366
373
  #
367
- # @overload create_database(parent: nil, create_statement: nil, extra_statements: nil)
374
+ # @overload create_database(parent: nil, create_statement: nil, extra_statements: nil, encryption_config: nil)
368
375
  # Pass arguments to `create_database` via keyword arguments. Note that at
369
376
  # least one keyword argument is required. To specify no parameters, or to keep all
370
377
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -383,6 +390,10 @@ module Google
383
390
  # database. Statements can create tables, indexes, etc. These
384
391
  # statements execute atomically with the creation of the database:
385
392
  # if there is an error in any statement, the database is not created.
393
+ # @param encryption_config [::Google::Cloud::Spanner::Admin::Database::V1::EncryptionConfig, ::Hash]
394
+ # Optional. The encryption configuration for the database. If this field is
395
+ # not specified, Cloud Spanner will encrypt/decrypt all data at rest using
396
+ # Google default encryption.
386
397
  #
387
398
  # @yield [response, operation] Access the result along with the RPC operation
388
399
  # @yieldparam response [::Gapic::Operation]
@@ -504,7 +515,8 @@ module Google
504
515
  # the format `<database_name>/operations/<operation_id>` and can be used to
505
516
  # track execution of the schema change(s). The
506
517
  # {::Google::Longrunning::Operation#metadata metadata} field type is
507
- # {::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseDdlMetadata UpdateDatabaseDdlMetadata}. The operation has no response.
518
+ # {::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseDdlMetadata UpdateDatabaseDdlMetadata}.
519
+ # The operation has no response.
508
520
  #
509
521
  # @overload update_database_ddl(request, options = nil)
510
522
  # Pass arguments to `update_database_ddl` via a request object, either of type
@@ -533,18 +545,20 @@ module Google
533
545
  #
534
546
  # Specifying an explicit operation ID simplifies determining
535
547
  # whether the statements were executed in the event that the
536
- # {::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client#update_database_ddl UpdateDatabaseDdl} call is replayed,
537
- # or the return value is otherwise lost: the {::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest#database database} and
538
- # `operation_id` fields can be combined to form the
548
+ # {::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client#update_database_ddl UpdateDatabaseDdl}
549
+ # call is replayed, or the return value is otherwise lost: the
550
+ # {::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest#database database}
551
+ # and `operation_id` fields can be combined to form the
539
552
  # {::Google::Longrunning::Operation#name name} of the resulting
540
- # {::Google::Longrunning::Operation longrunning.Operation}: `<database>/operations/<operation_id>`.
553
+ # {::Google::Longrunning::Operation longrunning.Operation}:
554
+ # `<database>/operations/<operation_id>`.
541
555
  #
542
556
  # `operation_id` should be unique within the database, and must be
543
557
  # a valid identifier: `[a-z][a-z0-9_]*`. Note that
544
558
  # automatically-generated operation IDs always begin with an
545
559
  # underscore. If the named operation already exists,
546
- # {::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client#update_database_ddl UpdateDatabaseDdl} returns
547
- # `ALREADY_EXISTS`.
560
+ # {::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client#update_database_ddl UpdateDatabaseDdl}
561
+ # returns `ALREADY_EXISTS`.
548
562
  #
549
563
  # @yield [response, operation] Access the result along with the RPC operation
550
564
  # @yieldparam response [::Gapic::Operation]
@@ -682,6 +696,8 @@ module Google
682
696
  #
683
697
  # @param database [::String]
684
698
  # Required. The database whose schema we wish to get.
699
+ # Values are of the form
700
+ # `projects/<project>/instances/<instance>/databases/<database>`
685
701
  #
686
702
  # @yield [response, operation] Access the result along with the RPC operation
687
703
  # @yieldparam response [::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlResponse]
@@ -971,12 +987,12 @@ module Google
971
987
  # `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>`
972
988
  # and can be used to track creation of the backup. The
973
989
  # {::Google::Longrunning::Operation#metadata metadata} field type is
974
- # {::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupMetadata CreateBackupMetadata}. The
975
- # {::Google::Longrunning::Operation#response response} field type is
976
- # {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup}, if successful. Cancelling the returned operation will stop the
977
- # creation and delete the backup.
978
- # There can be only one pending backup creation per database. Backup creation
979
- # of different databases can run concurrently.
990
+ # {::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupMetadata CreateBackupMetadata}.
991
+ # The {::Google::Longrunning::Operation#response response} field type is
992
+ # {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup}, if successful.
993
+ # Cancelling the returned operation will stop the creation and delete the
994
+ # backup. There can be only one pending backup creation per database. Backup
995
+ # creation of different databases can run concurrently.
980
996
  #
981
997
  # @overload create_backup(request, options = nil)
982
998
  # Pass arguments to `create_backup` via a request object, either of type
@@ -988,7 +1004,7 @@ module Google
988
1004
  # @param options [::Gapic::CallOptions, ::Hash]
989
1005
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
990
1006
  #
991
- # @overload create_backup(parent: nil, backup_id: nil, backup: nil)
1007
+ # @overload create_backup(parent: nil, backup_id: nil, backup: nil, encryption_config: nil)
992
1008
  # Pass arguments to `create_backup` via keyword arguments. Note that at
993
1009
  # least one keyword argument is required. To specify no parameters, or to keep all
994
1010
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -1006,6 +1022,12 @@ module Google
1006
1022
  # `projects/<project>/instances/<instance>/backups/<backup_id>`.
1007
1023
  # @param backup [::Google::Cloud::Spanner::Admin::Database::V1::Backup, ::Hash]
1008
1024
  # Required. The backup to create.
1025
+ # @param encryption_config [::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupEncryptionConfig, ::Hash]
1026
+ # Optional. The encryption configuration used to encrypt the backup. If this
1027
+ # field is not specified, the backup will use the same encryption
1028
+ # configuration as the database by default, namely
1029
+ # {::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupEncryptionConfig#encryption_type encryption_type}
1030
+ # = `USE_DATABASE_ENCRYPTION`.
1009
1031
  #
1010
1032
  # @yield [response, operation] Access the result along with the RPC operation
1011
1033
  # @yieldparam response [::Gapic::Operation]
@@ -1054,7 +1076,8 @@ module Google
1054
1076
  end
1055
1077
 
1056
1078
  ##
1057
- # Gets metadata on a pending or completed {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup}.
1079
+ # Gets metadata on a pending or completed
1080
+ # {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup}.
1058
1081
  #
1059
1082
  # @overload get_backup(request, options = nil)
1060
1083
  # Pass arguments to `get_backup` via a request object, either of type
@@ -1122,7 +1145,8 @@ module Google
1122
1145
  end
1123
1146
 
1124
1147
  ##
1125
- # Updates a pending or completed {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup}.
1148
+ # Updates a pending or completed
1149
+ # {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup}.
1126
1150
  #
1127
1151
  # @overload update_backup(request, options = nil)
1128
1152
  # Pass arguments to `update_backup` via a request object, either of type
@@ -1197,7 +1221,8 @@ module Google
1197
1221
  end
1198
1222
 
1199
1223
  ##
1200
- # Deletes a pending or completed {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup}.
1224
+ # Deletes a pending or completed
1225
+ # {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup}.
1201
1226
  #
1202
1227
  # @overload delete_backup(request, options = nil)
1203
1228
  # Pass arguments to `delete_backup` via a request object, either of type
@@ -1296,13 +1321,16 @@ module Google
1296
1321
  # must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
1297
1322
  # Colon `:` is the contains operator. Filter rules are not case sensitive.
1298
1323
  #
1299
- # The following fields in the {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup} are eligible for filtering:
1324
+ # The following fields in the
1325
+ # {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup} are eligible for
1326
+ # filtering:
1300
1327
  #
1301
1328
  # * `name`
1302
1329
  # * `database`
1303
1330
  # * `state`
1304
- # * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
1305
- # * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
1331
+ # * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
1332
+ # * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
1333
+ # * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
1306
1334
  # * `size_bytes`
1307
1335
  #
1308
1336
  # You can combine multiple expressions by enclosing each expression in
@@ -1327,9 +1355,10 @@ module Google
1327
1355
  # less, defaults to the server's maximum allowed page size.
1328
1356
  # @param page_token [::String]
1329
1357
  # If non-empty, `page_token` should contain a
1330
- # {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupsResponse#next_page_token next_page_token} from a
1331
- # previous {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupsResponse ListBackupsResponse} to the same `parent` and with the same
1332
- # `filter`.
1358
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupsResponse#next_page_token next_page_token}
1359
+ # from a previous
1360
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupsResponse ListBackupsResponse}
1361
+ # to the same `parent` and with the same `filter`.
1333
1362
  #
1334
1363
  # @yield [response, operation] Access the result along with the RPC operation
1335
1364
  # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Backup>]
@@ -1406,7 +1435,7 @@ module Google
1406
1435
  # @param options [::Gapic::CallOptions, ::Hash]
1407
1436
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1408
1437
  #
1409
- # @overload restore_database(parent: nil, database_id: nil, backup: nil)
1438
+ # @overload restore_database(parent: nil, database_id: nil, backup: nil, encryption_config: nil)
1410
1439
  # Pass arguments to `restore_database` via keyword arguments. Note that at
1411
1440
  # least one keyword argument is required. To specify no parameters, or to keep all
1412
1441
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -1425,6 +1454,13 @@ module Google
1425
1454
  # @param backup [::String]
1426
1455
  # Name of the backup from which to restore. Values are of the form
1427
1456
  # `projects/<project>/instances/<instance>/backups/<backup>`.
1457
+ # @param encryption_config [::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseEncryptionConfig, ::Hash]
1458
+ # Optional. An encryption configuration describing the encryption type and
1459
+ # key resources in Cloud KMS used to encrypt/decrypt the database to restore
1460
+ # to. If this field is not specified, the restored database will use the same
1461
+ # encryption configuration as the backup by default, namely
1462
+ # {::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseEncryptionConfig#encryption_type encryption_type}
1463
+ # = `USE_CONFIG_DEFAULT_OR_DATABASE_ENCRYPTION`.
1428
1464
  #
1429
1465
  # @yield [response, operation] Access the result along with the RPC operation
1430
1466
  # @yieldparam response [::Gapic::Operation]
@@ -1515,7 +1551,9 @@ module Google
1515
1551
  # * `name` - The name of the long-running operation
1516
1552
  # * `done` - False if the operation is in progress, else true.
1517
1553
  # * `metadata.@type` - the type of metadata. For example, the type string
1518
- # for {::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseMetadata RestoreDatabaseMetadata} is
1554
+ # for
1555
+ # {::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseMetadata RestoreDatabaseMetadata}
1556
+ # is
1519
1557
  # `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`.
1520
1558
  # * `metadata.<field_name>` - any field in metadata.value.
1521
1559
  # * `error` - Error associated with the long-running operation.
@@ -1529,13 +1567,14 @@ module Google
1529
1567
  # Here are a few examples:
1530
1568
  #
1531
1569
  # * `done:true` - The operation is complete.
1532
- # * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` <br/>
1533
- # `(metadata.source_type:BACKUP) AND` <br/>
1534
- # `(metadata.backup_info.backup:backup_howl) AND` <br/>
1535
- # `(metadata.name:restored_howl) AND` <br/>
1536
- # `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
1570
+ # * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \
1571
+ # `(metadata.source_type:BACKUP) AND` \
1572
+ # `(metadata.backup_info.backup:backup_howl) AND` \
1573
+ # `(metadata.name:restored_howl) AND` \
1574
+ # `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \
1537
1575
  # `(error:*)` - Return operations where:
1538
- # * The operation's metadata type is {::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseMetadata RestoreDatabaseMetadata}.
1576
+ # * The operation's metadata type is
1577
+ # {::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseMetadata RestoreDatabaseMetadata}.
1539
1578
  # * The database is restored from a backup.
1540
1579
  # * The backup name contains "backup_howl".
1541
1580
  # * The restored database's name contains "restored_howl".
@@ -1547,8 +1586,9 @@ module Google
1547
1586
  # @param page_token [::String]
1548
1587
  # If non-empty, `page_token` should contain a
1549
1588
  # {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseOperationsResponse#next_page_token next_page_token}
1550
- # from a previous {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseOperationsResponse ListDatabaseOperationsResponse} to the
1551
- # same `parent` and with the same `filter`.
1589
+ # from a previous
1590
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseOperationsResponse ListDatabaseOperationsResponse}
1591
+ # to the same `parent` and with the same `filter`.
1552
1592
  #
1553
1593
  # @yield [response, operation] Access the result along with the RPC operation
1554
1594
  # @yieldparam response [::Gapic::PagedEnumerable<::Gapic::Operation>]
@@ -1642,7 +1682,9 @@ module Google
1642
1682
  # * `name` - The name of the long-running operation
1643
1683
  # * `done` - False if the operation is in progress, else true.
1644
1684
  # * `metadata.@type` - the type of metadata. For example, the type string
1645
- # for {::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupMetadata CreateBackupMetadata} is
1685
+ # for
1686
+ # {::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupMetadata CreateBackupMetadata}
1687
+ # is
1646
1688
  # `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`.
1647
1689
  # * `metadata.<field_name>` - any field in metadata.value.
1648
1690
  # * `error` - Error associated with the long-running operation.
@@ -1658,11 +1700,12 @@ module Google
1658
1700
  # * `done:true` - The operation is complete.
1659
1701
  # * `metadata.database:prod` - The database the backup was taken from has
1660
1702
  # a name containing the string "prod".
1661
- # * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` <br/>
1662
- # `(metadata.name:howl) AND` <br/>
1663
- # `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
1703
+ # * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \
1704
+ # `(metadata.name:howl) AND` \
1705
+ # `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \
1664
1706
  # `(error:*)` - Returns operations where:
1665
- # * The operation's metadata type is {::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupMetadata CreateBackupMetadata}.
1707
+ # * The operation's metadata type is
1708
+ # {::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupMetadata CreateBackupMetadata}.
1666
1709
  # * The backup name contains the string "howl".
1667
1710
  # * The operation started before 2018-03-28T14:50:00Z.
1668
1711
  # * The operation resulted in an error.
@@ -1672,8 +1715,9 @@ module Google
1672
1715
  # @param page_token [::String]
1673
1716
  # If non-empty, `page_token` should contain a
1674
1717
  # {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupOperationsResponse#next_page_token next_page_token}
1675
- # from a previous {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupOperationsResponse ListBackupOperationsResponse} to the
1676
- # same `parent` and with the same `filter`.
1718
+ # from a previous
1719
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupOperationsResponse ListBackupOperationsResponse}
1720
+ # to the same `parent` and with the same `filter`.
1677
1721
  #
1678
1722
  # @yield [response, operation] Access the result along with the RPC operation
1679
1723
  # @yieldparam response [::Gapic::PagedEnumerable<::Gapic::Operation>]
@@ -1807,7 +1851,7 @@ module Google
1807
1851
 
1808
1852
  config_attr :endpoint, "spanner.googleapis.com", ::String
1809
1853
  config_attr :credentials, nil do |value|
1810
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1854
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1811
1855
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
1812
1856
  allowed.any? { |klass| klass === value }
1813
1857
  end
@@ -1847,7 +1891,7 @@ module Google
1847
1891
  # Each configuration object is of type `Gapic::Config::Method` and includes
1848
1892
  # the following configuration fields:
1849
1893
  #
1850
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
1894
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1851
1895
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1852
1896
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1853
1897
  # include the following keys:
@@ -105,8 +105,13 @@ module Google
105
105
  # Lists operations that match the specified filter in the request. If the
106
106
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
107
107
  #
108
- # NOTE: the `name` binding below allows API services to override the binding
109
- # to use different resource name schemes, such as `users/*/operations`.
108
+ # NOTE: the `name` binding allows API services to override the binding
109
+ # to use different resource name schemes, such as `users/*/operations`. To
110
+ # override the binding, API services can add a binding such as
111
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
112
+ # For backwards compatibility, the default name includes the operations
113
+ # collection id, however overriding users must ensure the name binding
114
+ # is the parent resource, without the operations collection id.
110
115
  #
111
116
  # @overload list_operations(request, options = nil)
112
117
  # Pass arguments to `list_operations` via a request object, either of type
@@ -124,7 +129,7 @@ module Google
124
129
  # the default parameter values, pass an empty Hash as a request object (see above).
125
130
  #
126
131
  # @param name [::String]
127
- # The name of the operation collection.
132
+ # The name of the operation's parent resource.
128
133
  # @param filter [::String]
129
134
  # The standard list filter.
130
135
  # @param page_size [::Integer]
@@ -392,6 +397,79 @@ module Google
392
397
  raise ::Google::Cloud::Error.from_error(e)
393
398
  end
394
399
 
400
+ ##
401
+ # Waits for the specified long-running operation until it is done or reaches
402
+ # at most a specified timeout, returning the latest state. If the operation
403
+ # is already done, the latest state is immediately returned. If the timeout
404
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
405
+ # timeout is used. If the server does not support this method, it returns
406
+ # `google.rpc.Code.UNIMPLEMENTED`.
407
+ # Note that this method is on a best-effort basis. It may return the latest
408
+ # state before the specified timeout (including immediately), meaning even an
409
+ # immediate response is no guarantee that the operation is done.
410
+ #
411
+ # @overload wait_operation(request, options = nil)
412
+ # Pass arguments to `wait_operation` via a request object, either of type
413
+ # {::Google::Longrunning::WaitOperationRequest} or an equivalent Hash.
414
+ #
415
+ # @param request [::Google::Longrunning::WaitOperationRequest, ::Hash]
416
+ # A request object representing the call parameters. Required. To specify no
417
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
418
+ # @param options [::Gapic::CallOptions, ::Hash]
419
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
420
+ #
421
+ # @overload wait_operation(name: nil, timeout: nil)
422
+ # Pass arguments to `wait_operation` via keyword arguments. Note that at
423
+ # least one keyword argument is required. To specify no parameters, or to keep all
424
+ # the default parameter values, pass an empty Hash as a request object (see above).
425
+ #
426
+ # @param name [::String]
427
+ # The name of the operation resource to wait on.
428
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
429
+ # The maximum duration to wait before timing out. If left blank, the wait
430
+ # will be at most the time permitted by the underlying HTTP/RPC protocol.
431
+ # If RPC context deadline is also specified, the shorter one will be used.
432
+ #
433
+ # @yield [response, operation] Access the result along with the RPC operation
434
+ # @yieldparam response [::Gapic::Operation]
435
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
436
+ #
437
+ # @return [::Gapic::Operation]
438
+ #
439
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
440
+ #
441
+ def wait_operation request, options = nil
442
+ raise ::ArgumentError, "request must be provided" if request.nil?
443
+
444
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest
445
+
446
+ # Converts hash and nil to an options object
447
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
448
+
449
+ # Customize the options with defaults
450
+ metadata = @config.rpcs.wait_operation.metadata.to_h
451
+
452
+ # Set x-goog-api-client and x-goog-user-project headers
453
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
454
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
455
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
456
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
457
+
458
+ options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
459
+ metadata: metadata,
460
+ retry_policy: @config.rpcs.wait_operation.retry_policy
461
+ options.apply_defaults metadata: @config.metadata,
462
+ retry_policy: @config.retry_policy
463
+
464
+ @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
465
+ response = ::Gapic::Operation.new response, @operations_client, options: options
466
+ yield response, operation if block_given?
467
+ return response
468
+ end
469
+ rescue ::GRPC::BadStatus => e
470
+ raise ::Google::Cloud::Error.from_error(e)
471
+ end
472
+
395
473
  ##
396
474
  # Configuration class for the Operations API.
397
475
  #
@@ -477,7 +555,7 @@ module Google
477
555
 
478
556
  config_attr :endpoint, "spanner.googleapis.com", ::String
479
557
  config_attr :credentials, nil do |value|
480
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
558
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
481
559
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
482
560
  allowed.any? { |klass| klass === value }
483
561
  end
@@ -517,7 +595,7 @@ module Google
517
595
  # Each configuration object is of type `Gapic::Config::Method` and includes
518
596
  # the following configuration fields:
519
597
  #
520
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
598
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
521
599
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
522
600
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
523
601
  # include the following keys:
@@ -548,6 +626,11 @@ module Google
548
626
  # @return [::Gapic::Config::Method]
549
627
  #
550
628
  attr_reader :cancel_operation
629
+ ##
630
+ # RPC-specific configuration for `wait_operation`
631
+ # @return [::Gapic::Config::Method]
632
+ #
633
+ attr_reader :wait_operation
551
634
 
552
635
  # @private
553
636
  def initialize parent_rpcs = nil
@@ -559,6 +642,8 @@ module Google
559
642
  @delete_operation = ::Gapic::Config::Method.new delete_operation_config
560
643
  cancel_operation_config = parent_rpcs&.cancel_operation if parent_rpcs&.respond_to? :cancel_operation
561
644
  @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
645
+ wait_operation_config = parent_rpcs&.wait_operation if parent_rpcs&.respond_to? :wait_operation
646
+ @wait_operation = ::Gapic::Config::Method.new wait_operation_config
562
647
 
563
648
  yield self if block_given?
564
649
  end