google-cloud-spanner 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +5 -5
  2. data/lib/google-cloud-spanner.rb +13 -10
  3. data/lib/google/cloud/spanner.rb +21 -18
  4. data/lib/google/cloud/spanner/admin/database.rb +111 -0
  5. data/lib/google/cloud/spanner/admin/database/credentials.rb +35 -0
  6. data/lib/google/cloud/spanner/admin/database/v1.rb +100 -3
  7. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +129 -138
  8. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +8 -8
  9. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +12 -2
  10. data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +22 -22
  11. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +33 -20
  12. data/lib/google/cloud/spanner/admin/database/v1/doc/overview.rb +57 -0
  13. data/lib/google/cloud/spanner/admin/instance.rb +127 -0
  14. data/lib/google/cloud/spanner/admin/instance/credentials.rb +35 -0
  15. data/lib/google/cloud/spanner/admin/instance/v1.rb +116 -3
  16. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +8 -8
  17. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +12 -2
  18. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +22 -22
  19. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +58 -43
  20. data/lib/google/cloud/spanner/admin/instance/v1/doc/overview.rb +57 -0
  21. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +180 -189
  22. data/lib/google/cloud/spanner/client.rb +3 -3
  23. data/lib/google/cloud/spanner/credentials.rb +33 -7
  24. data/lib/google/cloud/spanner/database.rb +3 -6
  25. data/lib/google/cloud/spanner/instance.rb +2 -4
  26. data/lib/google/cloud/spanner/instance/config.rb +2 -4
  27. data/lib/google/cloud/spanner/project.rb +6 -6
  28. data/lib/google/cloud/spanner/service.rb +5 -26
  29. data/lib/google/cloud/spanner/session.rb +4 -4
  30. data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +14 -1
  31. data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +26 -1
  32. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +3 -3
  33. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +12 -12
  34. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +9 -9
  35. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +33 -33
  36. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +99 -28
  37. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +41 -31
  38. data/lib/google/cloud/spanner/v1/doc/overview.rb +54 -0
  39. data/lib/google/cloud/spanner/v1/spanner_client.rb +277 -195
  40. data/lib/google/cloud/spanner/v1/spanner_client_config.json +5 -0
  41. data/lib/google/cloud/spanner/version.rb +1 -1
  42. data/lib/google/spanner/v1/spanner_pb.rb +16 -1
  43. data/lib/google/spanner/v1/spanner_services_pb.rb +2 -0
  44. metadata +16 -23
@@ -0,0 +1,57 @@
1
+ # Copyright 2017, Google Inc. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Cloud
17
+ module Spanner
18
+ module Admin
19
+ # rubocop:disable LineLength
20
+
21
+ ##
22
+ # # Ruby Client for Cloud Spanner Instance Admin API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
23
+ #
24
+ # [Cloud Spanner Instance Admin API][Product Documentation]:
25
+ #
26
+ # - [Product Documentation][]
27
+ #
28
+ # ## Quick Start
29
+ # In order to use this library, you first need to go through the following
30
+ # steps:
31
+ #
32
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
33
+ # 2. [Enable the Cloud Spanner Instance Admin API.](https://console.cloud.google.com/apis/api/spanner-admin-instance)
34
+ # 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
35
+ #
36
+ # ### Installation
37
+ # ```
38
+ # $ gem install google-cloud-spanner-admin-instance
39
+ # ```
40
+ #
41
+ # ### Next Steps
42
+ # - Read the [Cloud Spanner Instance Admin API Product documentation][Product Documentation]
43
+ # to learn more about the product and see How-to Guides.
44
+ # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
45
+ # to see the full list of Cloud APIs that we cover.
46
+ #
47
+ # [Product Documentation]: https://cloud.google.com/spanner-admin-instance
48
+ #
49
+ #
50
+ module Instance
51
+ module V1
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -30,6 +30,7 @@ require "google/gax/operation"
30
30
  require "google/longrunning/operations_client"
31
31
 
32
32
  require "google/spanner/admin/instance/v1/spanner_instance_admin_pb"
33
+ require "google/cloud/spanner/admin/instance/credentials"
33
34
 
34
35
  module Google
35
36
  module Cloud
@@ -141,50 +142,24 @@ module Google
141
142
  )
142
143
  end
143
144
 
144
- # Parses the project from a project resource.
145
- # @param project_name [String]
146
- # @return [String]
147
- def self.match_project_from_project_name project_name
148
- PROJECT_PATH_TEMPLATE.match(project_name)["project"]
149
- end
150
-
151
- # Parses the project from a instance_config resource.
152
- # @param instance_config_name [String]
153
- # @return [String]
154
- def self.match_project_from_instance_config_name instance_config_name
155
- INSTANCE_CONFIG_PATH_TEMPLATE.match(instance_config_name)["project"]
156
- end
157
-
158
- # Parses the instance_config from a instance_config resource.
159
- # @param instance_config_name [String]
160
- # @return [String]
161
- def self.match_instance_config_from_instance_config_name instance_config_name
162
- INSTANCE_CONFIG_PATH_TEMPLATE.match(instance_config_name)["instance_config"]
163
- end
164
-
165
- # Parses the project from a instance resource.
166
- # @param instance_name [String]
167
- # @return [String]
168
- def self.match_project_from_instance_name instance_name
169
- INSTANCE_PATH_TEMPLATE.match(instance_name)["project"]
170
- end
171
-
172
- # Parses the instance from a instance resource.
173
- # @param instance_name [String]
174
- # @return [String]
175
- def self.match_instance_from_instance_name instance_name
176
- INSTANCE_PATH_TEMPLATE.match(instance_name)["instance"]
177
- end
178
-
179
- # @param service_path [String]
180
- # The domain name of the API remote host.
181
- # @param port [Integer]
182
- # The port on which to connect to the remote host.
183
- # @param channel [Channel]
184
- # A Channel object through which to make calls.
185
- # @param chan_creds [Grpc::ChannelCredentials]
186
- # A ChannelCredentials for the setting up the RPC client.
187
- # @param client_config[Hash]
145
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
146
+ # Provides the means for authenticating requests made by the client. This parameter can
147
+ # be many types.
148
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
149
+ # authenticating requests made by this client.
150
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
151
+ # credentials for this client.
152
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
153
+ # credentials for this client.
154
+ # A `GRPC::Core::Channel` will be used to make calls through.
155
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
156
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
157
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
158
+ # metadata for requests, generally, to give OAuth credentials.
159
+ # @param scopes [Array<String>]
160
+ # The OAuth scopes for this service. This parameter is ignored if
161
+ # an updater_proc is supplied.
162
+ # @param client_config [Hash]
188
163
  # A Hash for call options for each method. See
189
164
  # Google::Gax#construct_settings for the structure of
190
165
  # this data. Falls back to the default config if not specified
@@ -196,11 +171,11 @@ module Google
196
171
  port: DEFAULT_SERVICE_PORT,
197
172
  channel: nil,
198
173
  chan_creds: nil,
174
+ updater_proc: nil,
175
+ credentials: nil,
199
176
  scopes: ALL_SCOPES,
200
177
  client_config: {},
201
178
  timeout: DEFAULT_TIMEOUT,
202
- app_name: nil,
203
- app_version: nil,
204
179
  lib_name: nil,
205
180
  lib_version: ""
206
181
  # These require statements are intentionally placed here to initialize
@@ -209,27 +184,48 @@ module Google
209
184
  require "google/gax/grpc"
210
185
  require "google/spanner/admin/instance/v1/spanner_instance_admin_services_pb"
211
186
 
187
+ if channel || chan_creds || updater_proc
188
+ warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
189
+ "on 2017/09/08"
190
+ credentials ||= channel
191
+ credentials ||= chan_creds
192
+ credentials ||= updater_proc
193
+ end
194
+ if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
195
+ warn "`service_path` and `port` parameters are deprecated and will be removed"
196
+ end
197
+
198
+ credentials ||= Google::Cloud::Spanner::Admin::Instance::Credentials.default
199
+
212
200
  @operations_client = Google::Longrunning::OperationsClient.new(
213
201
  service_path: service_path,
214
- port: port,
215
- channel: channel,
216
- chan_creds: chan_creds,
202
+ credentials: credentials,
217
203
  scopes: scopes,
218
204
  client_config: client_config,
219
205
  timeout: timeout,
220
- app_name: app_name,
221
- app_version: app_version,
222
206
  lib_name: lib_name,
223
207
  lib_version: lib_version,
224
208
  )
225
209
 
226
- if app_name || app_version
227
- warn "`app_name` and `app_version` are no longer being used in the request headers."
210
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
211
+ updater_proc = Google::Cloud::Spanner::Admin::Instance::Credentials.new(credentials).updater_proc
212
+ end
213
+ if credentials.is_a?(GRPC::Core::Channel)
214
+ channel = credentials
215
+ end
216
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
217
+ chan_creds = credentials
218
+ end
219
+ if credentials.is_a?(Proc)
220
+ updater_proc = credentials
221
+ end
222
+ if credentials.is_a?(Google::Auth::Credentials)
223
+ updater_proc = credentials.updater_proc
228
224
  end
229
225
 
230
226
  google_api_client = "gl-ruby/#{RUBY_VERSION}"
231
227
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
232
- google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
228
+ google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
233
229
  google_api_client << " grpc/#{GRPC::VERSION}"
234
230
  google_api_client.freeze
235
231
 
@@ -254,6 +250,7 @@ module Google
254
250
  port,
255
251
  chan_creds: chan_creds,
256
252
  channel: channel,
253
+ updater_proc: updater_proc,
257
254
  scopes: scopes,
258
255
  &Google::Spanner::Admin::Instance::V1::InstanceAdmin::Stub.method(:new)
259
256
  )
@@ -324,12 +321,10 @@ module Google
324
321
  # object.
325
322
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
326
323
  # @example
327
- # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
324
+ # require "google/cloud/spanner/admin/instance/v1"
328
325
  #
329
- # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
330
- #
331
- # instance_admin_client = InstanceAdminClient.new
332
- # formatted_parent = InstanceAdminClient.project_path("[PROJECT]")
326
+ # instance_admin_client = Google::Cloud::Spanner::Admin::Instance::V1.new
327
+ # formatted_parent = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.project_path("[PROJECT]")
333
328
  #
334
329
  # # Iterate over all results.
335
330
  # instance_admin_client.list_instance_configs(formatted_parent).each do |element|
@@ -348,10 +343,11 @@ module Google
348
343
  parent,
349
344
  page_size: nil,
350
345
  options: nil
351
- req = Google::Spanner::Admin::Instance::V1::ListInstanceConfigsRequest.new({
346
+ req = {
352
347
  parent: parent,
353
348
  page_size: page_size
354
- }.delete_if { |_, v| v.nil? })
349
+ }.delete_if { |_, v| v.nil? }
350
+ req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::ListInstanceConfigsRequest)
355
351
  @list_instance_configs.call(req, options)
356
352
  end
357
353
 
@@ -366,20 +362,19 @@ module Google
366
362
  # @return [Google::Spanner::Admin::Instance::V1::InstanceConfig]
367
363
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
368
364
  # @example
369
- # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
370
- #
371
- # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
365
+ # require "google/cloud/spanner/admin/instance/v1"
372
366
  #
373
- # instance_admin_client = InstanceAdminClient.new
374
- # formatted_name = InstanceAdminClient.instance_config_path("[PROJECT]", "[INSTANCE_CONFIG]")
367
+ # instance_admin_client = Google::Cloud::Spanner::Admin::Instance::V1.new
368
+ # formatted_name = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.instance_config_path("[PROJECT]", "[INSTANCE_CONFIG]")
375
369
  # response = instance_admin_client.get_instance_config(formatted_name)
376
370
 
377
371
  def get_instance_config \
378
372
  name,
379
373
  options: nil
380
- req = Google::Spanner::Admin::Instance::V1::GetInstanceConfigRequest.new({
374
+ req = {
381
375
  name: name
382
- }.delete_if { |_, v| v.nil? })
376
+ }.delete_if { |_, v| v.nil? }
377
+ req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::GetInstanceConfigRequest)
383
378
  @get_instance_config.call(req, options)
384
379
  end
385
380
 
@@ -398,22 +393,22 @@ module Google
398
393
  # An expression for filtering the results of the request. Filter rules are
399
394
  # case insensitive. The fields eligible for filtering are:
400
395
  #
401
- # * name
402
- # * display_name
403
- # * labels.key where key is the name of a label
404
- #
405
- # Some examples of using filters are:
406
- #
407
- # * name:* --> The instance has a name.
408
- # * name:Howl --> The instance's name contains the string "howl".
409
- # * name:HOWL --> Equivalent to above.
410
- # * NAME:howl --> Equivalent to above.
411
- # * labels.env:* --> The instance has the label "env".
412
- # * labels.env:dev --> The instance has the label "env" and the value of
413
- # the label contains the string "dev".
414
- # * name:howl labels.env:dev --> The instance's name contains "howl" and
415
- # it has the label "env" with its value
416
- # containing "dev".
396
+ # * +name+
397
+ # * +display_name+
398
+ # * +labels.key+ where key is the name of a label
399
+ #
400
+ # Some examples of using filters are:
401
+ #
402
+ # * +name:*+ --> The instance has a name.
403
+ # * +name:Howl+ --> The instance's name contains the string "howl".
404
+ # * +name:HOWL+ --> Equivalent to above.
405
+ # * +NAME:howl+ --> Equivalent to above.
406
+ # * +labels.env:*+ --> The instance has the label "env".
407
+ # * +labels.env:dev+ --> The instance has the label "env" and the value of
408
+ # the label contains the string "dev".
409
+ # * +name:howl labels.env:dev+ --> The instance's name contains "howl" and
410
+ # it has the label "env" with its value
411
+ # containing "dev".
417
412
  # @param options [Google::Gax::CallOptions]
418
413
  # Overrides the default settings for this call, e.g, timeout,
419
414
  # retries, etc.
@@ -424,12 +419,10 @@ module Google
424
419
  # object.
425
420
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
426
421
  # @example
427
- # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
422
+ # require "google/cloud/spanner/admin/instance/v1"
428
423
  #
429
- # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
430
- #
431
- # instance_admin_client = InstanceAdminClient.new
432
- # formatted_parent = InstanceAdminClient.project_path("[PROJECT]")
424
+ # instance_admin_client = Google::Cloud::Spanner::Admin::Instance::V1.new
425
+ # formatted_parent = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.project_path("[PROJECT]")
433
426
  #
434
427
  # # Iterate over all results.
435
428
  # instance_admin_client.list_instances(formatted_parent).each do |element|
@@ -449,11 +442,12 @@ module Google
449
442
  page_size: nil,
450
443
  filter: nil,
451
444
  options: nil
452
- req = Google::Spanner::Admin::Instance::V1::ListInstancesRequest.new({
445
+ req = {
453
446
  parent: parent,
454
447
  page_size: page_size,
455
448
  filter: filter
456
- }.delete_if { |_, v| v.nil? })
449
+ }.delete_if { |_, v| v.nil? }
450
+ req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::ListInstancesRequest)
457
451
  @list_instances.call(req, options)
458
452
  end
459
453
 
@@ -468,25 +462,24 @@ module Google
468
462
  # @return [Google::Spanner::Admin::Instance::V1::Instance]
469
463
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
470
464
  # @example
471
- # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
472
- #
473
- # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
465
+ # require "google/cloud/spanner/admin/instance/v1"
474
466
  #
475
- # instance_admin_client = InstanceAdminClient.new
476
- # formatted_name = InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
467
+ # instance_admin_client = Google::Cloud::Spanner::Admin::Instance::V1.new
468
+ # formatted_name = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
477
469
  # response = instance_admin_client.get_instance(formatted_name)
478
470
 
479
471
  def get_instance \
480
472
  name,
481
473
  options: nil
482
- req = Google::Spanner::Admin::Instance::V1::GetInstanceRequest.new({
474
+ req = {
483
475
  name: name
484
- }.delete_if { |_, v| v.nil? })
476
+ }.delete_if { |_, v| v.nil? }
477
+ req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::GetInstanceRequest)
485
478
  @get_instance.call(req, options)
486
479
  end
487
480
 
488
481
  # Creates an instance and begins preparing it to begin serving. The
489
- # returned Long-running operation
482
+ # returned {Google::Longrunning::Operation long-running operation}
490
483
  # can be used to track the progress of preparing the new
491
484
  # instance. The instance name is assigned by the caller. If the
492
485
  # named instance already exists, +CreateInstance+ returns
@@ -494,17 +487,17 @@ module Google
494
487
  #
495
488
  # Immediately upon completion of this request:
496
489
  #
497
- # * The instance is readable via the API, with all requested attributes
498
- # but no allocated resources. Its state is +CREATING+.
490
+ # * The instance is readable via the API, with all requested attributes
491
+ # but no allocated resources. Its state is +CREATING+.
499
492
  #
500
493
  # Until completion of the returned operation:
501
494
  #
502
- # * Cancelling the operation renders the instance immediately unreadable
503
- # via the API.
495
+ # * Cancelling the operation renders the instance immediately unreadable
496
+ # via the API.
504
497
  # * The instance can be deleted.
505
498
  # * All other attempts to modify the instance are rejected.
506
499
  #
507
- # Upon completion of the returned operation:
500
+ # Upon completion of the returned operation:
508
501
  #
509
502
  # * Billing for all successfully-allocated resources begins (some types
510
503
  # may have lower than the requested levels).
@@ -512,13 +505,13 @@ module Google
512
505
  # * The instance's allocated resource levels are readable via the API.
513
506
  # * The instance's state becomes +READY+.
514
507
  #
515
- # The returned Long-running operation will
516
- # have a name of the format +<instance_name>/operations/<operation_id>+ and
517
- # can be used to track creation of the instance. The
518
- # Metadata field type is
519
- # CreateInstanceMetadata.
520
- # The Response field type is
521
- # Instance, if successful.
508
+ # The returned {Google::Longrunning::Operation long-running operation} will
509
+ # have a name of the format +<instance_name>/operations/<operation_id>+ and
510
+ # can be used to track creation of the instance. The
511
+ # {Google::Longrunning::Operation#metadata metadata} field type is
512
+ # {Google::Spanner::Admin::Instance::V1::CreateInstanceMetadata CreateInstanceMetadata}.
513
+ # The {Google::Longrunning::Operation#response response} field type is
514
+ # {Google::Spanner::Admin::Instance::V1::Instance Instance}, if successful.
522
515
  #
523
516
  # @param parent [String]
524
517
  # Required. The name of the project in which to create the instance. Values
@@ -527,24 +520,23 @@ module Google
527
520
  # Required. The ID of the instance to create. Valid identifiers are of the
528
521
  # form +[a-z][-a-z0-9]*[a-z0-9]+ and must be between 6 and 30 characters in
529
522
  # length.
530
- # @param instance [Google::Spanner::Admin::Instance::V1::Instance]
523
+ # @param instance [Google::Spanner::Admin::Instance::V1::Instance | Hash]
531
524
  # Required. The instance to create. The name may be omitted, but if
532
525
  # specified must be +<parent>/instances/<instance_id>+.
526
+ # A hash of the same form as `Google::Spanner::Admin::Instance::V1::Instance`
527
+ # can also be provided.
533
528
  # @param options [Google::Gax::CallOptions]
534
529
  # Overrides the default settings for this call, e.g, timeout,
535
530
  # retries, etc.
536
531
  # @return [Google::Gax::Operation]
537
532
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
538
533
  # @example
539
- # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
534
+ # require "google/cloud/spanner/admin/instance/v1"
540
535
  #
541
- # Instance = Google::Spanner::Admin::Instance::V1::Instance
542
- # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
543
- #
544
- # instance_admin_client = InstanceAdminClient.new
545
- # formatted_parent = InstanceAdminClient.project_path("[PROJECT]")
536
+ # instance_admin_client = Google::Cloud::Spanner::Admin::Instance::V1.new
537
+ # formatted_parent = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.project_path("[PROJECT]")
546
538
  # instance_id = ''
547
- # instance = Instance.new
539
+ # instance = {}
548
540
  #
549
541
  # # Register a callback during the method call.
550
542
  # operation = instance_admin_client.create_instance(formatted_parent, instance_id, instance) do |op|
@@ -578,11 +570,12 @@ module Google
578
570
  instance_id,
579
571
  instance,
580
572
  options: nil
581
- req = Google::Spanner::Admin::Instance::V1::CreateInstanceRequest.new({
573
+ req = {
582
574
  parent: parent,
583
575
  instance_id: instance_id,
584
576
  instance: instance
585
- }.delete_if { |_, v| v.nil? })
577
+ }.delete_if { |_, v| v.nil? }
578
+ req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::CreateInstanceRequest)
586
579
  operation = Google::Gax::Operation.new(
587
580
  @create_instance.call(req, options),
588
581
  @operations_client,
@@ -595,28 +588,28 @@ module Google
595
588
  end
596
589
 
597
590
  # Updates an instance, and begins allocating or releasing resources
598
- # as requested. The returned Long-running
599
- # operation can be used to track the
591
+ # as requested. The returned [long-running
592
+ # operation][google.longrunning.Operation] can be used to track the
600
593
  # progress of updating the instance. If the named instance does not
601
594
  # exist, returns +NOT_FOUND+.
602
595
  #
603
596
  # Immediately upon completion of this request:
604
597
  #
605
- # * For resource types for which a decrease in the instance's allocation
606
- # has been requested, billing is based on the newly-requested level.
598
+ # * For resource types for which a decrease in the instance's allocation
599
+ # has been requested, billing is based on the newly-requested level.
607
600
  #
608
601
  # Until completion of the returned operation:
609
602
  #
610
- # * Cancelling the operation sets its metadata's
611
- # Cancel_time, and begins
612
- # restoring resources to their pre-request values. The operation
613
- # is guaranteed to succeed at undoing all resource changes,
614
- # after which point it terminates with a +CANCELLED+ status.
603
+ # * Cancelling the operation sets its metadata's
604
+ # {Google::Spanner::Admin::Instance::V1::UpdateInstanceMetadata#cancel_time cancel_time}, and begins
605
+ # restoring resources to their pre-request values. The operation
606
+ # is guaranteed to succeed at undoing all resource changes,
607
+ # after which point it terminates with a +CANCELLED+ status.
615
608
  # * All other attempts to modify the instance are rejected.
616
609
  # * Reading the instance via the API continues to give the pre-request
617
610
  # resource levels.
618
611
  #
619
- # Upon completion of the returned operation:
612
+ # Upon completion of the returned operation:
620
613
  #
621
614
  # * Billing begins for all successfully-allocated resources (some types
622
615
  # may have lower than the requested levels).
@@ -624,40 +617,40 @@ module Google
624
617
  # tables.
625
618
  # * The instance's new resource levels are readable via the API.
626
619
  #
627
- # The returned Long-running operation will
628
- # have a name of the format +<instance_name>/operations/<operation_id>+ and
629
- # can be used to track the instance modification. The
630
- # Metadata field type is
631
- # UpdateInstanceMetadata.
632
- # The Response field type is
633
- # Instance, if successful.
620
+ # The returned {Google::Longrunning::Operation long-running operation} will
621
+ # have a name of the format +<instance_name>/operations/<operation_id>+ and
622
+ # can be used to track the instance modification. The
623
+ # {Google::Longrunning::Operation#metadata metadata} field type is
624
+ # {Google::Spanner::Admin::Instance::V1::UpdateInstanceMetadata UpdateInstanceMetadata}.
625
+ # The {Google::Longrunning::Operation#response response} field type is
626
+ # {Google::Spanner::Admin::Instance::V1::Instance Instance}, if successful.
634
627
  #
635
628
  # Authorization requires +spanner.instances.update+ permission on
636
- # resource Name.
629
+ # resource {Google::Spanner::Admin::Instance::V1::Instance#name name}.
637
630
  #
638
- # @param instance [Google::Spanner::Admin::Instance::V1::Instance]
631
+ # @param instance [Google::Spanner::Admin::Instance::V1::Instance | Hash]
639
632
  # Required. The instance to update, which must always include the instance
640
633
  # name. Otherwise, only fields mentioned in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] need be included.
641
- # @param field_mask [Google::Protobuf::FieldMask]
634
+ # A hash of the same form as `Google::Spanner::Admin::Instance::V1::Instance`
635
+ # can also be provided.
636
+ # @param field_mask [Google::Protobuf::FieldMask | Hash]
642
637
  # Required. A mask specifying which fields in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.instance] should be updated.
643
638
  # The field mask must always be specified; this prevents any future fields in
644
639
  # [][google.spanner.admin.instance.v1.Instance] from being erased accidentally by clients that do not know
645
640
  # about them.
641
+ # A hash of the same form as `Google::Protobuf::FieldMask`
642
+ # can also be provided.
646
643
  # @param options [Google::Gax::CallOptions]
647
644
  # Overrides the default settings for this call, e.g, timeout,
648
645
  # retries, etc.
649
646
  # @return [Google::Gax::Operation]
650
647
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
651
648
  # @example
652
- # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
653
- #
654
- # FieldMask = Google::Protobuf::FieldMask
655
- # Instance = Google::Spanner::Admin::Instance::V1::Instance
656
- # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
649
+ # require "google/cloud/spanner/admin/instance/v1"
657
650
  #
658
- # instance_admin_client = InstanceAdminClient.new
659
- # instance = Instance.new
660
- # field_mask = FieldMask.new
651
+ # instance_admin_client = Google::Cloud::Spanner::Admin::Instance::V1.new
652
+ # instance = {}
653
+ # field_mask = {}
661
654
  #
662
655
  # # Register a callback during the method call.
663
656
  # operation = instance_admin_client.update_instance(instance, field_mask) do |op|
@@ -690,10 +683,11 @@ module Google
690
683
  instance,
691
684
  field_mask,
692
685
  options: nil
693
- req = Google::Spanner::Admin::Instance::V1::UpdateInstanceRequest.new({
686
+ req = {
694
687
  instance: instance,
695
688
  field_mask: field_mask
696
- }.delete_if { |_, v| v.nil? })
689
+ }.delete_if { |_, v| v.nil? }
690
+ req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::UpdateInstanceRequest)
697
691
  operation = Google::Gax::Operation.new(
698
692
  @update_instance.call(req, options),
699
693
  @operations_client,
@@ -709,13 +703,13 @@ module Google
709
703
  #
710
704
  # Immediately upon completion of the request:
711
705
  #
712
- # * Billing ceases for all of the instance's reserved resources.
706
+ # * Billing ceases for all of the instance's reserved resources.
713
707
  #
714
708
  # Soon afterward:
715
709
  #
716
- # * The instance and *all of its databases* immediately and
717
- # irrevocably disappear from the API. All data in the databases
718
- # is permanently deleted.
710
+ # * The instance and *all of its databases* immediately and
711
+ # irrevocably disappear from the API. All data in the databases
712
+ # is permanently deleted.
719
713
  #
720
714
  # @param name [String]
721
715
  # Required. The name of the instance to be deleted. Values are of the form
@@ -725,20 +719,19 @@ module Google
725
719
  # retries, etc.
726
720
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
727
721
  # @example
728
- # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
722
+ # require "google/cloud/spanner/admin/instance/v1"
729
723
  #
730
- # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
731
- #
732
- # instance_admin_client = InstanceAdminClient.new
733
- # formatted_name = InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
724
+ # instance_admin_client = Google::Cloud::Spanner::Admin::Instance::V1.new
725
+ # formatted_name = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
734
726
  # instance_admin_client.delete_instance(formatted_name)
735
727
 
736
728
  def delete_instance \
737
729
  name,
738
730
  options: nil
739
- req = Google::Spanner::Admin::Instance::V1::DeleteInstanceRequest.new({
731
+ req = {
740
732
  name: name
741
- }.delete_if { |_, v| v.nil? })
733
+ }.delete_if { |_, v| v.nil? }
734
+ req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::DeleteInstanceRequest)
742
735
  @delete_instance.call(req, options)
743
736
  nil
744
737
  end
@@ -747,41 +740,41 @@ module Google
747
740
  # existing policy.
748
741
  #
749
742
  # Authorization requires +spanner.instances.setIamPolicy+ on
750
- # Resource.
743
+ # {Google::Iam::V1::SetIamPolicyRequest#resource resource}.
751
744
  #
752
745
  # @param resource [String]
753
746
  # REQUIRED: The resource for which the policy is being specified.
754
747
  # +resource+ is usually specified as a path. For example, a Project
755
748
  # resource is specified as +projects/{project}+.
756
- # @param policy [Google::Iam::V1::Policy]
749
+ # @param policy [Google::Iam::V1::Policy | Hash]
757
750
  # REQUIRED: The complete policy to be applied to the +resource+. The size of
758
751
  # the policy is limited to a few 10s of KB. An empty policy is a
759
752
  # valid policy but certain Cloud Platform services (such as Projects)
760
753
  # might reject them.
754
+ # A hash of the same form as `Google::Iam::V1::Policy`
755
+ # can also be provided.
761
756
  # @param options [Google::Gax::CallOptions]
762
757
  # Overrides the default settings for this call, e.g, timeout,
763
758
  # retries, etc.
764
759
  # @return [Google::Iam::V1::Policy]
765
760
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
766
761
  # @example
767
- # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
768
- #
769
- # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
770
- # Policy = Google::Iam::V1::Policy
762
+ # require "google/cloud/spanner/admin/instance/v1"
771
763
  #
772
- # instance_admin_client = InstanceAdminClient.new
773
- # formatted_resource = InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
774
- # policy = Policy.new
764
+ # instance_admin_client = Google::Cloud::Spanner::Admin::Instance::V1.new
765
+ # formatted_resource = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
766
+ # policy = {}
775
767
  # response = instance_admin_client.set_iam_policy(formatted_resource, policy)
776
768
 
777
769
  def set_iam_policy \
778
770
  resource,
779
771
  policy,
780
772
  options: nil
781
- req = Google::Iam::V1::SetIamPolicyRequest.new({
773
+ req = {
782
774
  resource: resource,
783
775
  policy: policy
784
- }.delete_if { |_, v| v.nil? })
776
+ }.delete_if { |_, v| v.nil? }
777
+ req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
785
778
  @set_iam_policy.call(req, options)
786
779
  end
787
780
 
@@ -789,7 +782,7 @@ module Google
789
782
  # policy if an instance exists but does not have a policy set.
790
783
  #
791
784
  # Authorization requires +spanner.instances.getIamPolicy+ on
792
- # Resource.
785
+ # {Google::Iam::V1::GetIamPolicyRequest#resource resource}.
793
786
  #
794
787
  # @param resource [String]
795
788
  # REQUIRED: The resource for which the policy is being requested.
@@ -801,20 +794,19 @@ module Google
801
794
  # @return [Google::Iam::V1::Policy]
802
795
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
803
796
  # @example
804
- # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
797
+ # require "google/cloud/spanner/admin/instance/v1"
805
798
  #
806
- # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
807
- #
808
- # instance_admin_client = InstanceAdminClient.new
809
- # formatted_resource = InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
799
+ # instance_admin_client = Google::Cloud::Spanner::Admin::Instance::V1.new
800
+ # formatted_resource = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
810
801
  # response = instance_admin_client.get_iam_policy(formatted_resource)
811
802
 
812
803
  def get_iam_policy \
813
804
  resource,
814
805
  options: nil
815
- req = Google::Iam::V1::GetIamPolicyRequest.new({
806
+ req = {
816
807
  resource: resource
817
- }.delete_if { |_, v| v.nil? })
808
+ }.delete_if { |_, v| v.nil? }
809
+ req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
818
810
  @get_iam_policy.call(req, options)
819
811
  end
820
812
 
@@ -833,19 +825,17 @@ module Google
833
825
  # The set of permissions to check for the +resource+. Permissions with
834
826
  # wildcards (such as '*' or 'storage.*') are not allowed. For more
835
827
  # information see
836
- # {IAM Overview}[https://cloud.google.com/iam/docs/overview#permissions].
828
+ # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
837
829
  # @param options [Google::Gax::CallOptions]
838
830
  # Overrides the default settings for this call, e.g, timeout,
839
831
  # retries, etc.
840
832
  # @return [Google::Iam::V1::TestIamPermissionsResponse]
841
833
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
842
834
  # @example
843
- # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
844
- #
845
- # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
835
+ # require "google/cloud/spanner/admin/instance/v1"
846
836
  #
847
- # instance_admin_client = InstanceAdminClient.new
848
- # formatted_resource = InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
837
+ # instance_admin_client = Google::Cloud::Spanner::Admin::Instance::V1.new
838
+ # formatted_resource = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
849
839
  # permissions = []
850
840
  # response = instance_admin_client.test_iam_permissions(formatted_resource, permissions)
851
841
 
@@ -853,10 +843,11 @@ module Google
853
843
  resource,
854
844
  permissions,
855
845
  options: nil
856
- req = Google::Iam::V1::TestIamPermissionsRequest.new({
846
+ req = {
857
847
  resource: resource,
858
848
  permissions: permissions
859
- }.delete_if { |_, v| v.nil? })
849
+ }.delete_if { |_, v| v.nil? }
850
+ req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
860
851
  @test_iam_permissions.call(req, options)
861
852
  end
862
853
  end