google-cloud-spanner 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/lib/google-cloud-spanner.rb +5 -4
  3. data/lib/google/cloud/spanner.rb +2 -346
  4. data/lib/google/cloud/spanner/admin/database.rb +39 -3
  5. data/lib/google/cloud/spanner/admin/database/credentials.rb +5 -9
  6. data/lib/google/cloud/spanner/admin/database/v1.rb +69 -28
  7. data/lib/google/cloud/spanner/admin/database/v1/credentials.rb +46 -0
  8. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +111 -53
  9. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/iam_policy.rb +63 -0
  10. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +8 -19
  11. data/lib/google/cloud/spanner/admin/database/v1/doc/google/longrunning/operations.rb +93 -0
  12. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +15 -9
  13. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/empty.rb +29 -0
  14. data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +2 -1
  15. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +2 -12
  16. data/lib/google/cloud/spanner/admin/instance.rb +39 -3
  17. data/lib/google/cloud/spanner/admin/instance/credentials.rb +5 -9
  18. data/lib/google/cloud/spanner/admin/instance/v1.rb +69 -28
  19. data/lib/google/cloud/spanner/admin/instance/v1/credentials.rb +46 -0
  20. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/iam_policy.rb +63 -0
  21. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +8 -19
  22. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/longrunning/operations.rb +93 -0
  23. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +15 -9
  24. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/empty.rb +29 -0
  25. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +8 -1
  26. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +2 -1
  27. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +2 -12
  28. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +125 -58
  29. data/lib/google/cloud/spanner/database/job.rb +1 -0
  30. data/lib/google/cloud/spanner/instance/job.rb +1 -0
  31. data/lib/google/cloud/spanner/v1/credentials.rb +1 -0
  32. data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +1 -0
  33. data/lib/google/cloud/spanner/v1/doc/google/protobuf/empty.rb +1 -0
  34. data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +1 -0
  35. data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +9 -6
  36. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +1 -0
  37. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +1 -0
  38. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +1 -0
  39. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +1 -0
  40. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +1 -0
  41. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +1 -0
  42. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/type.rb +1 -0
  43. data/lib/google/cloud/spanner/v1/spanner_client.rb +28 -26
  44. data/lib/google/cloud/spanner/version.rb +1 -1
  45. data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +1 -1
  46. data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +3 -2
  47. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +1 -1
  48. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +3 -2
  49. data/lib/google/spanner/v1/keys_pb.rb +1 -0
  50. data/lib/google/spanner/v1/mutation_pb.rb +1 -0
  51. data/lib/google/spanner/v1/query_plan_pb.rb +1 -0
  52. data/lib/google/spanner/v1/result_set_pb.rb +1 -0
  53. data/lib/google/spanner/v1/spanner_pb.rb +1 -0
  54. data/lib/google/spanner/v1/spanner_services_pb.rb +1 -0
  55. data/lib/google/spanner/v1/transaction_pb.rb +1 -0
  56. data/lib/google/spanner/v1/type_pb.rb +1 -0
  57. metadata +14 -8
  58. data/lib/google/cloud/spanner/admin/database/v1/doc/overview.rb +0 -58
  59. data/lib/google/cloud/spanner/admin/instance/v1/doc/overview.rb +0 -58
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+
15
16
  require "googleauth"
16
17
 
17
18
  module Google
@@ -19,15 +20,10 @@ module Google
19
20
  module Spanner
20
21
  module Admin
21
22
  module Database
22
- class Credentials < Google::Auth::Credentials
23
- SCOPE = [
24
- "https://www.googleapis.com/auth/cloud-platform",
25
- "https://www.googleapis.com/auth/spanner.admin"
26
- ].freeze
27
- PATH_ENV_VARS = %w(SPANNER_ADMIN_DATABASE_KEYFILE GOOGLE_CLOUD_KEYFILE GCLOUD_KEYFILE)
28
- JSON_ENV_VARS = %w(SPANNER_ADMIN_DATABASE_KEYFILE_JSON GOOGLE_CLOUD_KEYFILE_JSON GCLOUD_KEYFILE_JSON)
29
- DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
30
- end
23
+ ##
24
+ # @deprecated Use version-specific credentials classes
25
+ #
26
+ Credentials = Google::Cloud::Spanner::Admin::Database::V1::Credentials
31
27
  end
32
28
  end
33
29
  end
@@ -1,4 +1,4 @@
1
- # Copyright 2017 Google LLC
1
+ # Copyright 2018 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -12,40 +12,72 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+
15
16
  require "google/cloud/spanner/admin/database/v1/database_admin_client"
17
+ require "google/spanner/admin/database/v1/spanner_database_admin_pb"
16
18
 
17
19
  module Google
18
20
  module Cloud
19
21
  module Spanner
20
22
  module Admin
21
- # rubocop:disable LineLength
22
-
23
- ##
24
- # # Ruby Client for Cloud Spanner Database Admin API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
25
- #
26
- # [Cloud Spanner Database Admin API][Product Documentation]:
27
- #
28
- # - [Product Documentation][]
29
- #
30
- # ## Quick Start
31
- # In order to use this library, you first need to go through the following
32
- # steps:
33
- #
34
- # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
35
- # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
36
- # 3. [Enable the Cloud Spanner Database Admin API.](https://console.cloud.google.com/apis/api/spanner-admin-database)
37
- # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
38
- #
39
- # ### Next Steps
40
- # - Read the [Cloud Spanner Database Admin API Product documentation][Product Documentation]
41
- # to learn more about the product and see How-to Guides.
42
- # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
43
- # to see the full list of Cloud APIs that we cover.
44
- #
45
- # [Product Documentation]: https://cloud.google.com/spanner-admin-database
46
- #
47
- #
48
23
  module Database
24
+ # rubocop:disable LineLength
25
+
26
+ ##
27
+ # # Ruby Client for Cloud Spanner Database Admin API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
28
+ #
29
+ # [Cloud Spanner Database Admin API][Product Documentation]:
30
+ #
31
+ # - [Product Documentation][]
32
+ #
33
+ # ## Quick Start
34
+ # In order to use this library, you first need to go through the following
35
+ # steps:
36
+ #
37
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
38
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
39
+ # 3. [Enable the Cloud Spanner Database Admin API.](https://console.cloud.google.com/apis/library/spanner.googleapis.com)
40
+ # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
41
+ #
42
+ # ### Installation
43
+ # ```
44
+ # $ gem install google-cloud-spanner
45
+ # ```
46
+ #
47
+ # ### Next Steps
48
+ # - Read the [Cloud Spanner Database Admin API Product documentation][Product Documentation]
49
+ # to learn more about the product and see How-to Guides.
50
+ # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
51
+ # to see the full list of Cloud APIs that we cover.
52
+ #
53
+ # [Product Documentation]: https://cloud.google.com/spanner
54
+ #
55
+ # ## Enabling Logging
56
+ #
57
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
58
+ # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
59
+ # or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
60
+ # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
61
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
62
+ #
63
+ # Configuring a Ruby stdlib logger:
64
+ #
65
+ # ```ruby
66
+ # require "logger"
67
+ #
68
+ # module MyLogger
69
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
70
+ # def logger
71
+ # LOGGER
72
+ # end
73
+ # end
74
+ #
75
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
76
+ # module GRPC
77
+ # extend MyLogger
78
+ # end
79
+ # ```
80
+ #
49
81
  module V1
50
82
  # rubocop:enable LineLength
51
83
 
@@ -80,11 +112,18 @@ module Google
80
112
  # or the specified config is missing data points.
81
113
  # @param timeout [Numeric]
82
114
  # The default timeout, in seconds, for calls made through this client.
115
+ # @param metadata [Hash]
116
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
117
+ # @param exception_transformer [Proc]
118
+ # An optional proc that intercepts any exceptions raised during an API call to inject
119
+ # custom error handling.
83
120
  def self.new \
84
121
  credentials: nil,
85
122
  scopes: nil,
86
123
  client_config: nil,
87
124
  timeout: nil,
125
+ metadata: nil,
126
+ exception_transformer: nil,
88
127
  lib_name: nil,
89
128
  lib_version: nil
90
129
  kwargs = {
@@ -92,6 +131,8 @@ module Google
92
131
  scopes: scopes,
93
132
  client_config: client_config,
94
133
  timeout: timeout,
134
+ metadata: metadata,
135
+ exception_transformer: exception_transformer,
95
136
  lib_name: lib_name,
96
137
  lib_version: lib_version
97
138
  }.select { |_, v| v != nil }
@@ -0,0 +1,46 @@
1
+ # Copyright 2018 Google LLC
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
+ # https://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
+
16
+ require "googleauth"
17
+
18
+ module Google
19
+ module Cloud
20
+ module Spanner
21
+ module Admin
22
+ module Database
23
+ module V1
24
+ class Credentials < Google::Auth::Credentials
25
+ SCOPE = [
26
+ "https://www.googleapis.com/auth/cloud-platform",
27
+ "https://www.googleapis.com/auth/spanner.admin"
28
+ ].freeze
29
+ PATH_ENV_VARS = %w(SPANNER_ADMIN_DATABASE_CREDENTIALS
30
+ SPANNER_ADMIN_DATABASE_KEYFILE
31
+ GOOGLE_CLOUD_CREDENTIALS
32
+ GOOGLE_CLOUD_KEYFILE
33
+ GCLOUD_KEYFILE)
34
+ JSON_ENV_VARS = %w(SPANNER_ADMIN_DATABASE_CREDENTIALS_JSON
35
+ SPANNER_ADMIN_DATABASE_KEYFILE_JSON
36
+ GOOGLE_CLOUD_CREDENTIALS_JSON
37
+ GOOGLE_CLOUD_KEYFILE_JSON
38
+ GCLOUD_KEYFILE_JSON)
39
+ DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,4 +1,4 @@
1
- # Copyright 2017 Google LLC
1
+ # Copyright 2018 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -18,9 +18,7 @@
18
18
  # and updates to that file get reflected here through a refresh process.
19
19
  # For the short term, the refresh process will only be runnable by Google
20
20
  # engineers.
21
- #
22
- # The only allowed edits are to method and file documentation. A 3-way
23
- # merge preserves those additions if the generated source changes.
21
+
24
22
 
25
23
  require "json"
26
24
  require "pathname"
@@ -30,7 +28,7 @@ require "google/gax/operation"
30
28
  require "google/longrunning/operations_client"
31
29
 
32
30
  require "google/spanner/admin/database/v1/spanner_database_admin_pb"
33
- require "google/cloud/spanner/admin/database/credentials"
31
+ require "google/cloud/spanner/admin/database/v1/credentials"
34
32
 
35
33
  module Google
36
34
  module Cloud
@@ -47,6 +45,7 @@ module Google
47
45
  # @!attribute [r] database_admin_stub
48
46
  # @return [Google::Spanner::Admin::Database::V1::DatabaseAdmin::Stub]
49
47
  class DatabaseAdminClient
48
+ # @private
50
49
  attr_reader :database_admin_stub
51
50
 
52
51
  # The default address of the service.
@@ -55,6 +54,9 @@ module Google
55
54
  # The default port of the service.
56
55
  DEFAULT_SERVICE_PORT = 443
57
56
 
57
+ # The default set of gRPC interceptors.
58
+ GRPC_INTERCEPTORS = []
59
+
58
60
  DEFAULT_TIMEOUT = 30
59
61
 
60
62
  PAGE_DESCRIPTORS = {
@@ -75,7 +77,8 @@ module Google
75
77
 
76
78
  # @private
77
79
  class OperationsClient < Google::Longrunning::OperationsClient
78
- SERVICE_ADDRESS = SERVICE_ADDRESS
80
+ self::SERVICE_ADDRESS = DatabaseAdminClient::SERVICE_ADDRESS
81
+ self::GRPC_INTERCEPTORS = DatabaseAdminClient::GRPC_INTERCEPTORS
79
82
  end
80
83
 
81
84
  INSTANCE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
@@ -138,11 +141,18 @@ module Google
138
141
  # or the specified config is missing data points.
139
142
  # @param timeout [Numeric]
140
143
  # The default timeout, in seconds, for calls made through this client.
144
+ # @param metadata [Hash]
145
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
146
+ # @param exception_transformer [Proc]
147
+ # An optional proc that intercepts any exceptions raised during an API call to inject
148
+ # custom error handling.
141
149
  def initialize \
142
150
  credentials: nil,
143
151
  scopes: ALL_SCOPES,
144
152
  client_config: {},
145
153
  timeout: DEFAULT_TIMEOUT,
154
+ metadata: nil,
155
+ exception_transformer: nil,
146
156
  lib_name: nil,
147
157
  lib_version: ""
148
158
  # These require statements are intentionally placed here to initialize
@@ -151,7 +161,7 @@ module Google
151
161
  require "google/gax/grpc"
152
162
  require "google/spanner/admin/database/v1/spanner_database_admin_services_pb"
153
163
 
154
- credentials ||= Google::Cloud::Spanner::Admin::Database::Credentials.default
164
+ credentials ||= Google::Cloud::Spanner::Admin::Database::V1::Credentials.default
155
165
 
156
166
  @operations_client = OperationsClient.new(
157
167
  credentials: credentials,
@@ -163,7 +173,7 @@ module Google
163
173
  )
164
174
 
165
175
  if credentials.is_a?(String) || credentials.is_a?(Hash)
166
- updater_proc = Google::Cloud::Spanner::Admin::Database::Credentials.new(credentials).updater_proc
176
+ updater_proc = Google::Cloud::Spanner::Admin::Database::V1::Credentials.new(credentials).updater_proc
167
177
  end
168
178
  if credentials.is_a?(GRPC::Core::Channel)
169
179
  channel = credentials
@@ -187,6 +197,7 @@ module Google
187
197
  google_api_client.freeze
188
198
 
189
199
  headers = { :"x-goog-api-client" => google_api_client }
200
+ headers.merge!(metadata) unless metadata.nil?
190
201
  client_config_file = Pathname.new(__dir__).join(
191
202
  "database_admin_client_config.json"
192
203
  )
@@ -199,13 +210,14 @@ module Google
199
210
  timeout,
200
211
  page_descriptors: PAGE_DESCRIPTORS,
201
212
  errors: Google::Gax::Grpc::API_ERRORS,
202
- kwargs: headers
213
+ metadata: headers
203
214
  )
204
215
  end
205
216
 
206
217
  # Allow overriding the service path/port in subclasses.
207
218
  service_path = self.class::SERVICE_ADDRESS
208
219
  port = self.class::DEFAULT_SERVICE_PORT
220
+ interceptors = self.class::GRPC_INTERCEPTORS
209
221
  @database_admin_stub = Google::Gax::Grpc.create_stub(
210
222
  service_path,
211
223
  port,
@@ -213,44 +225,54 @@ module Google
213
225
  channel: channel,
214
226
  updater_proc: updater_proc,
215
227
  scopes: scopes,
228
+ interceptors: interceptors,
216
229
  &Google::Spanner::Admin::Database::V1::DatabaseAdmin::Stub.method(:new)
217
230
  )
218
231
 
219
232
  @list_databases = Google::Gax.create_api_call(
220
233
  @database_admin_stub.method(:list_databases),
221
- defaults["list_databases"]
234
+ defaults["list_databases"],
235
+ exception_transformer: exception_transformer
222
236
  )
223
237
  @create_database = Google::Gax.create_api_call(
224
238
  @database_admin_stub.method(:create_database),
225
- defaults["create_database"]
239
+ defaults["create_database"],
240
+ exception_transformer: exception_transformer
226
241
  )
227
242
  @get_database = Google::Gax.create_api_call(
228
243
  @database_admin_stub.method(:get_database),
229
- defaults["get_database"]
244
+ defaults["get_database"],
245
+ exception_transformer: exception_transformer
230
246
  )
231
247
  @update_database_ddl = Google::Gax.create_api_call(
232
248
  @database_admin_stub.method(:update_database_ddl),
233
- defaults["update_database_ddl"]
249
+ defaults["update_database_ddl"],
250
+ exception_transformer: exception_transformer
234
251
  )
235
252
  @drop_database = Google::Gax.create_api_call(
236
253
  @database_admin_stub.method(:drop_database),
237
- defaults["drop_database"]
254
+ defaults["drop_database"],
255
+ exception_transformer: exception_transformer
238
256
  )
239
257
  @get_database_ddl = Google::Gax.create_api_call(
240
258
  @database_admin_stub.method(:get_database_ddl),
241
- defaults["get_database_ddl"]
259
+ defaults["get_database_ddl"],
260
+ exception_transformer: exception_transformer
242
261
  )
243
262
  @set_iam_policy = Google::Gax.create_api_call(
244
263
  @database_admin_stub.method(:set_iam_policy),
245
- defaults["set_iam_policy"]
264
+ defaults["set_iam_policy"],
265
+ exception_transformer: exception_transformer
246
266
  )
247
267
  @get_iam_policy = Google::Gax.create_api_call(
248
268
  @database_admin_stub.method(:get_iam_policy),
249
- defaults["get_iam_policy"]
269
+ defaults["get_iam_policy"],
270
+ exception_transformer: exception_transformer
250
271
  )
251
272
  @test_iam_permissions = Google::Gax.create_api_call(
252
273
  @database_admin_stub.method(:test_iam_permissions),
253
- defaults["test_iam_permissions"]
274
+ defaults["test_iam_permissions"],
275
+ exception_transformer: exception_transformer
254
276
  )
255
277
  end
256
278
 
@@ -270,6 +292,9 @@ module Google
270
292
  # @param options [Google::Gax::CallOptions]
271
293
  # Overrides the default settings for this call, e.g, timeout,
272
294
  # retries, etc.
295
+ # @yield [result, operation] Access the result along with the RPC operation
296
+ # @yieldparam result [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Database::V1::Database>]
297
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
273
298
  # @return [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Database::V1::Database>]
274
299
  # An enumerable of Google::Spanner::Admin::Database::V1::Database instances.
275
300
  # See Google::Gax::PagedEnumerable documentation for other
@@ -277,9 +302,9 @@ module Google
277
302
  # object.
278
303
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
279
304
  # @example
280
- # require "google/cloud/spanner/admin/database/v1"
305
+ # require "google/cloud/spanner/admin/database"
281
306
  #
282
- # database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
307
+ # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
283
308
  # formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
284
309
  #
285
310
  # # Iterate over all results.
@@ -298,13 +323,14 @@ module Google
298
323
  def list_databases \
299
324
  parent,
300
325
  page_size: nil,
301
- options: nil
326
+ options: nil,
327
+ &block
302
328
  req = {
303
329
  parent: parent,
304
330
  page_size: page_size
305
331
  }.delete_if { |_, v| v.nil? }
306
332
  req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::ListDatabasesRequest)
307
- @list_databases.call(req, options)
333
+ @list_databases.call(req, options, &block)
308
334
  end
309
335
 
310
336
  # Creates a new Cloud Spanner database and starts to prepare it for serving.
@@ -336,10 +362,12 @@ module Google
336
362
  # @return [Google::Gax::Operation]
337
363
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
338
364
  # @example
339
- # require "google/cloud/spanner/admin/database/v1"
365
+ # require "google/cloud/spanner/admin/database"
340
366
  #
341
- # database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
367
+ # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
342
368
  # formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
369
+ #
370
+ # # TODO: Initialize +create_statement+:
343
371
  # create_statement = ''
344
372
  #
345
373
  # # Register a callback during the method call.
@@ -399,23 +427,27 @@ module Google
399
427
  # @param options [Google::Gax::CallOptions]
400
428
  # Overrides the default settings for this call, e.g, timeout,
401
429
  # retries, etc.
430
+ # @yield [result, operation] Access the result along with the RPC operation
431
+ # @yieldparam result [Google::Spanner::Admin::Database::V1::Database]
432
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
402
433
  # @return [Google::Spanner::Admin::Database::V1::Database]
403
434
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
404
435
  # @example
405
- # require "google/cloud/spanner/admin/database/v1"
436
+ # require "google/cloud/spanner/admin/database"
406
437
  #
407
- # database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
438
+ # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
408
439
  # formatted_name = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
409
440
  # response = database_admin_client.get_database(formatted_name)
410
441
 
411
442
  def get_database \
412
443
  name,
413
- options: nil
444
+ options: nil,
445
+ &block
414
446
  req = {
415
447
  name: name
416
448
  }.delete_if { |_, v| v.nil? }
417
449
  req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::GetDatabaseRequest)
418
- @get_database.call(req, options)
450
+ @get_database.call(req, options, &block)
419
451
  end
420
452
 
421
453
  # Updates the schema of a Cloud Spanner database by
@@ -456,10 +488,12 @@ module Google
456
488
  # @return [Google::Gax::Operation]
457
489
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
458
490
  # @example
459
- # require "google/cloud/spanner/admin/database/v1"
491
+ # require "google/cloud/spanner/admin/database"
460
492
  #
461
- # database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
493
+ # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
462
494
  # formatted_database = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
495
+ #
496
+ # # TODO: Initialize +statements+:
463
497
  # statements = []
464
498
  #
465
499
  # # Register a callback during the method call.
@@ -518,22 +552,26 @@ module Google
518
552
  # @param options [Google::Gax::CallOptions]
519
553
  # Overrides the default settings for this call, e.g, timeout,
520
554
  # retries, etc.
555
+ # @yield [result, operation] Access the result along with the RPC operation
556
+ # @yieldparam result []
557
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
521
558
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
522
559
  # @example
523
- # require "google/cloud/spanner/admin/database/v1"
560
+ # require "google/cloud/spanner/admin/database"
524
561
  #
525
- # database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
562
+ # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
526
563
  # formatted_database = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
527
564
  # database_admin_client.drop_database(formatted_database)
528
565
 
529
566
  def drop_database \
530
567
  database,
531
- options: nil
568
+ options: nil,
569
+ &block
532
570
  req = {
533
571
  database: database
534
572
  }.delete_if { |_, v| v.nil? }
535
573
  req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::DropDatabaseRequest)
536
- @drop_database.call(req, options)
574
+ @drop_database.call(req, options, &block)
537
575
  nil
538
576
  end
539
577
 
@@ -546,23 +584,27 @@ module Google
546
584
  # @param options [Google::Gax::CallOptions]
547
585
  # Overrides the default settings for this call, e.g, timeout,
548
586
  # retries, etc.
587
+ # @yield [result, operation] Access the result along with the RPC operation
588
+ # @yieldparam result [Google::Spanner::Admin::Database::V1::GetDatabaseDdlResponse]
589
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
549
590
  # @return [Google::Spanner::Admin::Database::V1::GetDatabaseDdlResponse]
550
591
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
551
592
  # @example
552
- # require "google/cloud/spanner/admin/database/v1"
593
+ # require "google/cloud/spanner/admin/database"
553
594
  #
554
- # database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
595
+ # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
555
596
  # formatted_database = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
556
597
  # response = database_admin_client.get_database_ddl(formatted_database)
557
598
 
558
599
  def get_database_ddl \
559
600
  database,
560
- options: nil
601
+ options: nil,
602
+ &block
561
603
  req = {
562
604
  database: database
563
605
  }.delete_if { |_, v| v.nil? }
564
606
  req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::GetDatabaseDdlRequest)
565
- @get_database_ddl.call(req, options)
607
+ @get_database_ddl.call(req, options, &block)
566
608
  end
567
609
 
568
610
  # Sets the access control policy on a database resource. Replaces any
@@ -574,7 +616,7 @@ module Google
574
616
  # @param resource [String]
575
617
  # REQUIRED: The resource for which the policy is being specified.
576
618
  # +resource+ is usually specified as a path. For example, a Project
577
- # resource is specified as +projects/{project}+.
619
+ # resource is specified as +projects/\\{project}+.
578
620
  # @param policy [Google::Iam::V1::Policy | Hash]
579
621
  # REQUIRED: The complete policy to be applied to the +resource+. The size of
580
622
  # the policy is limited to a few 10s of KB. An empty policy is a
@@ -585,26 +627,32 @@ module Google
585
627
  # @param options [Google::Gax::CallOptions]
586
628
  # Overrides the default settings for this call, e.g, timeout,
587
629
  # retries, etc.
630
+ # @yield [result, operation] Access the result along with the RPC operation
631
+ # @yieldparam result [Google::Iam::V1::Policy]
632
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
588
633
  # @return [Google::Iam::V1::Policy]
589
634
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
590
635
  # @example
591
- # require "google/cloud/spanner/admin/database/v1"
636
+ # require "google/cloud/spanner/admin/database"
592
637
  #
593
- # database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
638
+ # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
594
639
  # formatted_resource = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
640
+ #
641
+ # # TODO: Initialize +policy+:
595
642
  # policy = {}
596
643
  # response = database_admin_client.set_iam_policy(formatted_resource, policy)
597
644
 
598
645
  def set_iam_policy \
599
646
  resource,
600
647
  policy,
601
- options: nil
648
+ options: nil,
649
+ &block
602
650
  req = {
603
651
  resource: resource,
604
652
  policy: policy
605
653
  }.delete_if { |_, v| v.nil? }
606
654
  req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
607
- @set_iam_policy.call(req, options)
655
+ @set_iam_policy.call(req, options, &block)
608
656
  end
609
657
 
610
658
  # Gets the access control policy for a database resource. Returns an empty
@@ -616,27 +664,31 @@ module Google
616
664
  # @param resource [String]
617
665
  # REQUIRED: The resource for which the policy is being requested.
618
666
  # +resource+ is usually specified as a path. For example, a Project
619
- # resource is specified as +projects/{project}+.
667
+ # resource is specified as +projects/\\{project}+.
620
668
  # @param options [Google::Gax::CallOptions]
621
669
  # Overrides the default settings for this call, e.g, timeout,
622
670
  # retries, etc.
671
+ # @yield [result, operation] Access the result along with the RPC operation
672
+ # @yieldparam result [Google::Iam::V1::Policy]
673
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
623
674
  # @return [Google::Iam::V1::Policy]
624
675
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
625
676
  # @example
626
- # require "google/cloud/spanner/admin/database/v1"
677
+ # require "google/cloud/spanner/admin/database"
627
678
  #
628
- # database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
679
+ # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
629
680
  # formatted_resource = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
630
681
  # response = database_admin_client.get_iam_policy(formatted_resource)
631
682
 
632
683
  def get_iam_policy \
633
684
  resource,
634
- options: nil
685
+ options: nil,
686
+ &block
635
687
  req = {
636
688
  resource: resource
637
689
  }.delete_if { |_, v| v.nil? }
638
690
  req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
639
- @get_iam_policy.call(req, options)
691
+ @get_iam_policy.call(req, options, &block)
640
692
  end
641
693
 
642
694
  # Returns permissions that the caller has on the specified database resource.
@@ -649,7 +701,7 @@ module Google
649
701
  # @param resource [String]
650
702
  # REQUIRED: The resource for which the policy detail is being requested.
651
703
  # +resource+ is usually specified as a path. For example, a Project
652
- # resource is specified as +projects/{project}+.
704
+ # resource is specified as +projects/\\{project}+.
653
705
  # @param permissions [Array<String>]
654
706
  # The set of permissions to check for the +resource+. Permissions with
655
707
  # wildcards (such as '*' or 'storage.*') are not allowed. For more
@@ -658,26 +710,32 @@ module Google
658
710
  # @param options [Google::Gax::CallOptions]
659
711
  # Overrides the default settings for this call, e.g, timeout,
660
712
  # retries, etc.
713
+ # @yield [result, operation] Access the result along with the RPC operation
714
+ # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
715
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
661
716
  # @return [Google::Iam::V1::TestIamPermissionsResponse]
662
717
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
663
718
  # @example
664
- # require "google/cloud/spanner/admin/database/v1"
719
+ # require "google/cloud/spanner/admin/database"
665
720
  #
666
- # database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
721
+ # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
667
722
  # formatted_resource = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
723
+ #
724
+ # # TODO: Initialize +permissions+:
668
725
  # permissions = []
669
726
  # response = database_admin_client.test_iam_permissions(formatted_resource, permissions)
670
727
 
671
728
  def test_iam_permissions \
672
729
  resource,
673
730
  permissions,
674
- options: nil
731
+ options: nil,
732
+ &block
675
733
  req = {
676
734
  resource: resource,
677
735
  permissions: permissions
678
736
  }.delete_if { |_, v| v.nil? }
679
737
  req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
680
- @test_iam_permissions.call(req, options)
738
+ @test_iam_permissions.call(req, options, &block)
681
739
  end
682
740
  end
683
741
  end