google-cloud-spanner-admin-instance-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +203 -0
  5. data/README.md +75 -0
  6. data/lib/google-cloud-spanner-admin-instance-v1.rb +21 -0
  7. data/lib/google/cloud/spanner/admin/instance/v1.rb +39 -0
  8. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin.rb +74 -0
  9. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin/client.rb +1291 -0
  10. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin/credentials.rb +56 -0
  11. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin/operations.rb +574 -0
  12. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin/paths.rb +85 -0
  13. data/lib/google/cloud/spanner/admin/instance/v1/version.rb +32 -0
  14. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +128 -0
  15. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +182 -0
  16. data/proto_docs/README.md +4 -0
  17. data/proto_docs/google/api/field_behavior.rb +59 -0
  18. data/proto_docs/google/api/resource.rb +247 -0
  19. data/proto_docs/google/iam/v1/iam_policy.rb +80 -0
  20. data/proto_docs/google/iam/v1/options.rb +40 -0
  21. data/proto_docs/google/iam/v1/policy.rb +248 -0
  22. data/proto_docs/google/longrunning/operations.rb +150 -0
  23. data/proto_docs/google/protobuf/any.rb +138 -0
  24. data/proto_docs/google/protobuf/empty.rb +36 -0
  25. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  26. data/proto_docs/google/protobuf/timestamp.rb +120 -0
  27. data/proto_docs/google/rpc/status.rb +46 -0
  28. data/proto_docs/google/spanner/admin/instance/v1/spanner_instance_admin.rb +391 -0
  29. data/proto_docs/google/type/expr.rb +52 -0
  30. metadata +231 -0
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ # This gem does not autoload during Bundler.require. To load this gem,
20
+ # issue explicit require statements for the packages desired, e.g.:
21
+ # require "google/cloud/spanner/admin/instance/v1"
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/spanner/admin/instance/v1/instance_admin"
20
+ require "google/cloud/spanner/admin/instance/v1/version"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Spanner
25
+ module Admin
26
+ module Instance
27
+ ##
28
+ # To load this package, including all its services, and instantiate a client:
29
+ #
30
+ # require "google/cloud/spanner/admin/instance/v1"
31
+ # client = ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client.new
32
+ #
33
+ module V1
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/spanner/admin/instance/v1/version"
24
+
25
+ require "google/cloud/spanner/admin/instance/v1/instance_admin/credentials"
26
+ require "google/cloud/spanner/admin/instance/v1/instance_admin/paths"
27
+ require "google/cloud/spanner/admin/instance/v1/instance_admin/operations"
28
+ require "google/cloud/spanner/admin/instance/v1/instance_admin/client"
29
+
30
+ module Google
31
+ module Cloud
32
+ module Spanner
33
+ module Admin
34
+ module Instance
35
+ module V1
36
+ ##
37
+ # Cloud Spanner Instance Admin API
38
+ #
39
+ # The Cloud Spanner Instance Admin API can be used to create, delete,
40
+ # modify and list instances. Instances are dedicated Cloud Spanner serving
41
+ # and storage resources to be used by Cloud Spanner databases.
42
+ #
43
+ # Each instance has a "configuration", which dictates where the
44
+ # serving resources for the Cloud Spanner instance are located (e.g.,
45
+ # US-central, Europe). Configurations are created by Google based on
46
+ # resource availability.
47
+ #
48
+ # Cloud Spanner billing is based on the instances that exist and their
49
+ # sizes. After an instance exists, there are no additional
50
+ # per-database or per-operation charges for use of the instance
51
+ # (though there may be additional network bandwidth charges).
52
+ # Instances offer isolation: problems with databases in one instance
53
+ # will not affect other instances. However, within an instance
54
+ # databases can affect each other. For example, if one database in an
55
+ # instance receives a lot of requests and consumes most of the
56
+ # instance resources, fewer resources are available for other
57
+ # databases in that instance, and their performance may suffer.
58
+ #
59
+ # To load this service and instantiate a client:
60
+ #
61
+ # require "google/cloud/spanner/admin/instance/v1/instance_admin"
62
+ # client = ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client.new
63
+ #
64
+ module InstanceAdmin
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ helper_path = ::File.join __dir__, "instance_admin", "helpers.rb"
74
+ require "google/cloud/spanner/admin/instance/v1/instance_admin/helpers" if ::File.file? helper_path
@@ -0,0 +1,1291 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/spanner/admin/instance/v1/spanner_instance_admin_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Spanner
25
+ module Admin
26
+ module Instance
27
+ module V1
28
+ module InstanceAdmin
29
+ ##
30
+ # Client for the InstanceAdmin service.
31
+ #
32
+ # Cloud Spanner Instance Admin API
33
+ #
34
+ # The Cloud Spanner Instance Admin API can be used to create, delete,
35
+ # modify and list instances. Instances are dedicated Cloud Spanner serving
36
+ # and storage resources to be used by Cloud Spanner databases.
37
+ #
38
+ # Each instance has a "configuration", which dictates where the
39
+ # serving resources for the Cloud Spanner instance are located (e.g.,
40
+ # US-central, Europe). Configurations are created by Google based on
41
+ # resource availability.
42
+ #
43
+ # Cloud Spanner billing is based on the instances that exist and their
44
+ # sizes. After an instance exists, there are no additional
45
+ # per-database or per-operation charges for use of the instance
46
+ # (though there may be additional network bandwidth charges).
47
+ # Instances offer isolation: problems with databases in one instance
48
+ # will not affect other instances. However, within an instance
49
+ # databases can affect each other. For example, if one database in an
50
+ # instance receives a lot of requests and consumes most of the
51
+ # instance resources, fewer resources are available for other
52
+ # databases in that instance, and their performance may suffer.
53
+ #
54
+ class Client
55
+ include Paths
56
+
57
+ # @private
58
+ attr_reader :instance_admin_stub
59
+
60
+ ##
61
+ # Configure the InstanceAdmin Client class.
62
+ #
63
+ # See {::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client::Configuration}
64
+ # for a description of the configuration fields.
65
+ #
66
+ # ## Example
67
+ #
68
+ # To modify the configuration for all InstanceAdmin clients:
69
+ #
70
+ # ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client.configure do |config|
71
+ # config.timeout = 10.0
72
+ # end
73
+ #
74
+ # @yield [config] Configure the Client client.
75
+ # @yieldparam config [Client::Configuration]
76
+ #
77
+ # @return [Client::Configuration]
78
+ #
79
+ def self.configure
80
+ @configure ||= begin
81
+ namespace = ["Google", "Cloud", "Spanner", "Admin", "Instance", "V1"]
82
+ parent_config = while namespace.any?
83
+ parent_name = namespace.join "::"
84
+ parent_const = const_get parent_name
85
+ break parent_const.configure if parent_const&.respond_to? :configure
86
+ namespace.pop
87
+ end
88
+ default_config = Client::Configuration.new parent_config
89
+
90
+ default_config.rpcs.list_instance_configs.timeout = 3600.0
91
+ default_config.rpcs.list_instance_configs.retry_policy = {
92
+ initial_delay: 1.0,
93
+ max_delay: 32.0,
94
+ multiplier: 1.3,
95
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
96
+ }
97
+
98
+ default_config.rpcs.get_instance_config.timeout = 3600.0
99
+ default_config.rpcs.get_instance_config.retry_policy = {
100
+ initial_delay: 1.0,
101
+ max_delay: 32.0,
102
+ multiplier: 1.3,
103
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
104
+ }
105
+
106
+ default_config.rpcs.list_instances.timeout = 3600.0
107
+ default_config.rpcs.list_instances.retry_policy = {
108
+ initial_delay: 1.0,
109
+ max_delay: 32.0,
110
+ multiplier: 1.3,
111
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
112
+ }
113
+
114
+ default_config.rpcs.get_instance.timeout = 3600.0
115
+ default_config.rpcs.get_instance.retry_policy = {
116
+ initial_delay: 1.0,
117
+ max_delay: 32.0,
118
+ multiplier: 1.3,
119
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
120
+ }
121
+
122
+ default_config.rpcs.create_instance.timeout = 3600.0
123
+
124
+ default_config.rpcs.update_instance.timeout = 3600.0
125
+
126
+ default_config.rpcs.delete_instance.timeout = 3600.0
127
+ default_config.rpcs.delete_instance.retry_policy = {
128
+ initial_delay: 1.0,
129
+ max_delay: 32.0,
130
+ multiplier: 1.3,
131
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
132
+ }
133
+
134
+ default_config.rpcs.set_iam_policy.timeout = 30.0
135
+
136
+ default_config.rpcs.get_iam_policy.timeout = 30.0
137
+ default_config.rpcs.get_iam_policy.retry_policy = {
138
+ initial_delay: 1.0,
139
+ max_delay: 32.0,
140
+ multiplier: 1.3,
141
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
142
+ }
143
+
144
+ default_config.rpcs.test_iam_permissions.timeout = 30.0
145
+
146
+ default_config
147
+ end
148
+ yield @configure if block_given?
149
+ @configure
150
+ end
151
+
152
+ ##
153
+ # Configure the InstanceAdmin Client instance.
154
+ #
155
+ # The configuration is set to the derived mode, meaning that values can be changed,
156
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
157
+ # should be made on {Client.configure}.
158
+ #
159
+ # See {::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client::Configuration}
160
+ # for a description of the configuration fields.
161
+ #
162
+ # @yield [config] Configure the Client client.
163
+ # @yieldparam config [Client::Configuration]
164
+ #
165
+ # @return [Client::Configuration]
166
+ #
167
+ def configure
168
+ yield @config if block_given?
169
+ @config
170
+ end
171
+
172
+ ##
173
+ # Create a new InstanceAdmin client object.
174
+ #
175
+ # ## Examples
176
+ #
177
+ # To create a new InstanceAdmin client with the default
178
+ # configuration:
179
+ #
180
+ # client = ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client.new
181
+ #
182
+ # To create a new InstanceAdmin client with a custom
183
+ # configuration:
184
+ #
185
+ # client = ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client.new do |config|
186
+ # config.timeout = 10.0
187
+ # end
188
+ #
189
+ # @yield [config] Configure the InstanceAdmin client.
190
+ # @yieldparam config [Client::Configuration]
191
+ #
192
+ def initialize
193
+ # These require statements are intentionally placed here to initialize
194
+ # the gRPC module only when it's required.
195
+ # See https://github.com/googleapis/toolkit/issues/446
196
+ require "gapic/grpc"
197
+ require "google/spanner/admin/instance/v1/spanner_instance_admin_services_pb"
198
+
199
+ # Create the configuration object
200
+ @config = Configuration.new Client.configure
201
+
202
+ # Yield the configuration if needed
203
+ yield @config if block_given?
204
+
205
+ # Create credentials
206
+ credentials = @config.credentials
207
+ credentials ||= Credentials.default scope: @config.scope
208
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
209
+ credentials = Credentials.new credentials, scope: @config.scope
210
+ end
211
+ @quota_project_id = @config.quota_project
212
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
213
+
214
+ @operations_client = Operations.new do |config|
215
+ config.credentials = credentials
216
+ config.endpoint = @config.endpoint
217
+ end
218
+
219
+ @instance_admin_stub = ::Gapic::ServiceStub.new(
220
+ ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Stub,
221
+ credentials: credentials,
222
+ endpoint: @config.endpoint,
223
+ channel_args: @config.channel_args,
224
+ interceptors: @config.interceptors
225
+ )
226
+ end
227
+
228
+ ##
229
+ # Get the associated client for long-running operations.
230
+ #
231
+ # @return [::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Operations]
232
+ #
233
+ attr_reader :operations_client
234
+
235
+ # Service calls
236
+
237
+ ##
238
+ # Lists the supported instance configurations for a given project.
239
+ #
240
+ # @overload list_instance_configs(request, options = nil)
241
+ # Pass arguments to `list_instance_configs` via a request object, either of type
242
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::ListInstanceConfigsRequest} or an equivalent Hash.
243
+ #
244
+ # @param request [::Google::Cloud::Spanner::Admin::Instance::V1::ListInstanceConfigsRequest, ::Hash]
245
+ # A request object representing the call parameters. Required. To specify no
246
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
247
+ # @param options [::Gapic::CallOptions, ::Hash]
248
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
249
+ #
250
+ # @overload list_instance_configs(parent: nil, page_size: nil, page_token: nil)
251
+ # Pass arguments to `list_instance_configs` via keyword arguments. Note that at
252
+ # least one keyword argument is required. To specify no parameters, or to keep all
253
+ # the default parameter values, pass an empty Hash as a request object (see above).
254
+ #
255
+ # @param parent [::String]
256
+ # Required. The name of the project for which a list of supported instance
257
+ # configurations is requested. Values are of the form
258
+ # `projects/<project>`.
259
+ # @param page_size [::Integer]
260
+ # Number of instance configurations to be returned in the response. If 0 or
261
+ # less, defaults to the server's maximum allowed page size.
262
+ # @param page_token [::String]
263
+ # If non-empty, `page_token` should contain a
264
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::ListInstanceConfigsResponse#next_page_token next_page_token}
265
+ # from a previous {::Google::Cloud::Spanner::Admin::Instance::V1::ListInstanceConfigsResponse ListInstanceConfigsResponse}.
266
+ #
267
+ # @yield [response, operation] Access the result along with the RPC operation
268
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig>]
269
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
270
+ #
271
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig>]
272
+ #
273
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
274
+ #
275
+ def list_instance_configs request, options = nil
276
+ raise ::ArgumentError, "request must be provided" if request.nil?
277
+
278
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Instance::V1::ListInstanceConfigsRequest
279
+
280
+ # Converts hash and nil to an options object
281
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
282
+
283
+ # Customize the options with defaults
284
+ metadata = @config.rpcs.list_instance_configs.metadata.to_h
285
+
286
+ # Set x-goog-api-client and x-goog-user-project headers
287
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
288
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
289
+ gapic_version: ::Google::Cloud::Spanner::Admin::Instance::V1::VERSION
290
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
291
+
292
+ header_params = {
293
+ "parent" => request.parent
294
+ }
295
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
296
+ metadata[:"x-goog-request-params"] ||= request_params_header
297
+
298
+ options.apply_defaults timeout: @config.rpcs.list_instance_configs.timeout,
299
+ metadata: metadata,
300
+ retry_policy: @config.rpcs.list_instance_configs.retry_policy
301
+ options.apply_defaults metadata: @config.metadata,
302
+ retry_policy: @config.retry_policy
303
+
304
+ @instance_admin_stub.call_rpc :list_instance_configs, request, options: options do |response, operation|
305
+ response = ::Gapic::PagedEnumerable.new @instance_admin_stub, :list_instance_configs, request, response, operation, options
306
+ yield response, operation if block_given?
307
+ return response
308
+ end
309
+ rescue ::GRPC::BadStatus => e
310
+ raise ::Google::Cloud::Error.from_error(e)
311
+ end
312
+
313
+ ##
314
+ # Gets information about a particular instance configuration.
315
+ #
316
+ # @overload get_instance_config(request, options = nil)
317
+ # Pass arguments to `get_instance_config` via a request object, either of type
318
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::GetInstanceConfigRequest} or an equivalent Hash.
319
+ #
320
+ # @param request [::Google::Cloud::Spanner::Admin::Instance::V1::GetInstanceConfigRequest, ::Hash]
321
+ # A request object representing the call parameters. Required. To specify no
322
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
323
+ # @param options [::Gapic::CallOptions, ::Hash]
324
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
325
+ #
326
+ # @overload get_instance_config(name: nil)
327
+ # Pass arguments to `get_instance_config` via keyword arguments. Note that at
328
+ # least one keyword argument is required. To specify no parameters, or to keep all
329
+ # the default parameter values, pass an empty Hash as a request object (see above).
330
+ #
331
+ # @param name [::String]
332
+ # Required. The name of the requested instance configuration. Values are of
333
+ # the form `projects/<project>/instanceConfigs/<config>`.
334
+ #
335
+ # @yield [response, operation] Access the result along with the RPC operation
336
+ # @yieldparam response [::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig]
337
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
338
+ #
339
+ # @return [::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig]
340
+ #
341
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
342
+ #
343
+ def get_instance_config request, options = nil
344
+ raise ::ArgumentError, "request must be provided" if request.nil?
345
+
346
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Instance::V1::GetInstanceConfigRequest
347
+
348
+ # Converts hash and nil to an options object
349
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
350
+
351
+ # Customize the options with defaults
352
+ metadata = @config.rpcs.get_instance_config.metadata.to_h
353
+
354
+ # Set x-goog-api-client and x-goog-user-project headers
355
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
356
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
357
+ gapic_version: ::Google::Cloud::Spanner::Admin::Instance::V1::VERSION
358
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
359
+
360
+ header_params = {
361
+ "name" => request.name
362
+ }
363
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
364
+ metadata[:"x-goog-request-params"] ||= request_params_header
365
+
366
+ options.apply_defaults timeout: @config.rpcs.get_instance_config.timeout,
367
+ metadata: metadata,
368
+ retry_policy: @config.rpcs.get_instance_config.retry_policy
369
+ options.apply_defaults metadata: @config.metadata,
370
+ retry_policy: @config.retry_policy
371
+
372
+ @instance_admin_stub.call_rpc :get_instance_config, request, options: options do |response, operation|
373
+ yield response, operation if block_given?
374
+ return response
375
+ end
376
+ rescue ::GRPC::BadStatus => e
377
+ raise ::Google::Cloud::Error.from_error(e)
378
+ end
379
+
380
+ ##
381
+ # Lists all instances in the given project.
382
+ #
383
+ # @overload list_instances(request, options = nil)
384
+ # Pass arguments to `list_instances` via a request object, either of type
385
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::ListInstancesRequest} or an equivalent Hash.
386
+ #
387
+ # @param request [::Google::Cloud::Spanner::Admin::Instance::V1::ListInstancesRequest, ::Hash]
388
+ # A request object representing the call parameters. Required. To specify no
389
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
390
+ # @param options [::Gapic::CallOptions, ::Hash]
391
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
392
+ #
393
+ # @overload list_instances(parent: nil, page_size: nil, page_token: nil, filter: nil)
394
+ # Pass arguments to `list_instances` via keyword arguments. Note that at
395
+ # least one keyword argument is required. To specify no parameters, or to keep all
396
+ # the default parameter values, pass an empty Hash as a request object (see above).
397
+ #
398
+ # @param parent [::String]
399
+ # Required. The name of the project for which a list of instances is
400
+ # requested. Values are of the form `projects/<project>`.
401
+ # @param page_size [::Integer]
402
+ # Number of instances to be returned in the response. If 0 or less, defaults
403
+ # to the server's maximum allowed page size.
404
+ # @param page_token [::String]
405
+ # If non-empty, `page_token` should contain a
406
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::ListInstancesResponse#next_page_token next_page_token} from a
407
+ # previous {::Google::Cloud::Spanner::Admin::Instance::V1::ListInstancesResponse ListInstancesResponse}.
408
+ # @param filter [::String]
409
+ # An expression for filtering the results of the request. Filter rules are
410
+ # case insensitive. The fields eligible for filtering are:
411
+ #
412
+ # * `name`
413
+ # * `display_name`
414
+ # * `labels.key` where key is the name of a label
415
+ #
416
+ # Some examples of using filters are:
417
+ #
418
+ # * `name:*` --> The instance has a name.
419
+ # * `name:Howl` --> The instance's name contains the string "howl".
420
+ # * `name:HOWL` --> Equivalent to above.
421
+ # * `NAME:howl` --> Equivalent to above.
422
+ # * `labels.env:*` --> The instance has the label "env".
423
+ # * `labels.env:dev` --> The instance has the label "env" and the value of
424
+ # the label contains the string "dev".
425
+ # * `name:howl labels.env:dev` --> The instance's name contains "howl" and
426
+ # it has the label "env" with its value
427
+ # containing "dev".
428
+ #
429
+ # @yield [response, operation] Access the result along with the RPC operation
430
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Instance::V1::Instance>]
431
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
432
+ #
433
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Instance::V1::Instance>]
434
+ #
435
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
436
+ #
437
+ def list_instances request, options = nil
438
+ raise ::ArgumentError, "request must be provided" if request.nil?
439
+
440
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Instance::V1::ListInstancesRequest
441
+
442
+ # Converts hash and nil to an options object
443
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
444
+
445
+ # Customize the options with defaults
446
+ metadata = @config.rpcs.list_instances.metadata.to_h
447
+
448
+ # Set x-goog-api-client and x-goog-user-project headers
449
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
450
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
451
+ gapic_version: ::Google::Cloud::Spanner::Admin::Instance::V1::VERSION
452
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
453
+
454
+ header_params = {
455
+ "parent" => request.parent
456
+ }
457
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
458
+ metadata[:"x-goog-request-params"] ||= request_params_header
459
+
460
+ options.apply_defaults timeout: @config.rpcs.list_instances.timeout,
461
+ metadata: metadata,
462
+ retry_policy: @config.rpcs.list_instances.retry_policy
463
+ options.apply_defaults metadata: @config.metadata,
464
+ retry_policy: @config.retry_policy
465
+
466
+ @instance_admin_stub.call_rpc :list_instances, request, options: options do |response, operation|
467
+ response = ::Gapic::PagedEnumerable.new @instance_admin_stub, :list_instances, request, response, operation, options
468
+ yield response, operation if block_given?
469
+ return response
470
+ end
471
+ rescue ::GRPC::BadStatus => e
472
+ raise ::Google::Cloud::Error.from_error(e)
473
+ end
474
+
475
+ ##
476
+ # Gets information about a particular instance.
477
+ #
478
+ # @overload get_instance(request, options = nil)
479
+ # Pass arguments to `get_instance` via a request object, either of type
480
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::GetInstanceRequest} or an equivalent Hash.
481
+ #
482
+ # @param request [::Google::Cloud::Spanner::Admin::Instance::V1::GetInstanceRequest, ::Hash]
483
+ # A request object representing the call parameters. Required. To specify no
484
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
485
+ # @param options [::Gapic::CallOptions, ::Hash]
486
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
487
+ #
488
+ # @overload get_instance(name: nil, field_mask: nil)
489
+ # Pass arguments to `get_instance` via keyword arguments. Note that at
490
+ # least one keyword argument is required. To specify no parameters, or to keep all
491
+ # the default parameter values, pass an empty Hash as a request object (see above).
492
+ #
493
+ # @param name [::String]
494
+ # Required. The name of the requested instance. Values are of the form
495
+ # `projects/<project>/instances/<instance>`.
496
+ # @param field_mask [::Google::Protobuf::FieldMask, ::Hash]
497
+ # If field_mask is present, specifies the subset of {::Google::Cloud::Spanner::Admin::Instance::V1::Instance Instance} fields that
498
+ # should be returned.
499
+ # If absent, all {::Google::Cloud::Spanner::Admin::Instance::V1::Instance Instance} fields are returned.
500
+ #
501
+ # @yield [response, operation] Access the result along with the RPC operation
502
+ # @yieldparam response [::Google::Cloud::Spanner::Admin::Instance::V1::Instance]
503
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
504
+ #
505
+ # @return [::Google::Cloud::Spanner::Admin::Instance::V1::Instance]
506
+ #
507
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
508
+ #
509
+ def get_instance request, options = nil
510
+ raise ::ArgumentError, "request must be provided" if request.nil?
511
+
512
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Instance::V1::GetInstanceRequest
513
+
514
+ # Converts hash and nil to an options object
515
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
516
+
517
+ # Customize the options with defaults
518
+ metadata = @config.rpcs.get_instance.metadata.to_h
519
+
520
+ # Set x-goog-api-client and x-goog-user-project headers
521
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
522
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
523
+ gapic_version: ::Google::Cloud::Spanner::Admin::Instance::V1::VERSION
524
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
525
+
526
+ header_params = {
527
+ "name" => request.name
528
+ }
529
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
530
+ metadata[:"x-goog-request-params"] ||= request_params_header
531
+
532
+ options.apply_defaults timeout: @config.rpcs.get_instance.timeout,
533
+ metadata: metadata,
534
+ retry_policy: @config.rpcs.get_instance.retry_policy
535
+ options.apply_defaults metadata: @config.metadata,
536
+ retry_policy: @config.retry_policy
537
+
538
+ @instance_admin_stub.call_rpc :get_instance, request, options: options do |response, operation|
539
+ yield response, operation if block_given?
540
+ return response
541
+ end
542
+ rescue ::GRPC::BadStatus => e
543
+ raise ::Google::Cloud::Error.from_error(e)
544
+ end
545
+
546
+ ##
547
+ # Creates an instance and begins preparing it to begin serving. The
548
+ # returned {::Google::Longrunning::Operation long-running operation}
549
+ # can be used to track the progress of preparing the new
550
+ # instance. The instance name is assigned by the caller. If the
551
+ # named instance already exists, `CreateInstance` returns
552
+ # `ALREADY_EXISTS`.
553
+ #
554
+ # Immediately upon completion of this request:
555
+ #
556
+ # * The instance is readable via the API, with all requested attributes
557
+ # but no allocated resources. Its state is `CREATING`.
558
+ #
559
+ # Until completion of the returned operation:
560
+ #
561
+ # * Cancelling the operation renders the instance immediately unreadable
562
+ # via the API.
563
+ # * The instance can be deleted.
564
+ # * All other attempts to modify the instance are rejected.
565
+ #
566
+ # Upon completion of the returned operation:
567
+ #
568
+ # * Billing for all successfully-allocated resources begins (some types
569
+ # may have lower than the requested levels).
570
+ # * Databases can be created in the instance.
571
+ # * The instance's allocated resource levels are readable via the API.
572
+ # * The instance's state becomes `READY`.
573
+ #
574
+ # The returned {::Google::Longrunning::Operation long-running operation} will
575
+ # have a name of the format `<instance_name>/operations/<operation_id>` and
576
+ # can be used to track creation of the instance. The
577
+ # {::Google::Longrunning::Operation#metadata metadata} field type is
578
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::CreateInstanceMetadata CreateInstanceMetadata}.
579
+ # The {::Google::Longrunning::Operation#response response} field type is
580
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::Instance Instance}, if successful.
581
+ #
582
+ # @overload create_instance(request, options = nil)
583
+ # Pass arguments to `create_instance` via a request object, either of type
584
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::CreateInstanceRequest} or an equivalent Hash.
585
+ #
586
+ # @param request [::Google::Cloud::Spanner::Admin::Instance::V1::CreateInstanceRequest, ::Hash]
587
+ # A request object representing the call parameters. Required. To specify no
588
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
589
+ # @param options [::Gapic::CallOptions, ::Hash]
590
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
591
+ #
592
+ # @overload create_instance(parent: nil, instance_id: nil, instance: nil)
593
+ # Pass arguments to `create_instance` via keyword arguments. Note that at
594
+ # least one keyword argument is required. To specify no parameters, or to keep all
595
+ # the default parameter values, pass an empty Hash as a request object (see above).
596
+ #
597
+ # @param parent [::String]
598
+ # Required. The name of the project in which to create the instance. Values
599
+ # are of the form `projects/<project>`.
600
+ # @param instance_id [::String]
601
+ # Required. The ID of the instance to create. Valid identifiers are of the
602
+ # form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in
603
+ # length.
604
+ # @param instance [::Google::Cloud::Spanner::Admin::Instance::V1::Instance, ::Hash]
605
+ # Required. The instance to create. The name may be omitted, but if
606
+ # specified must be `<parent>/instances/<instance_id>`.
607
+ #
608
+ # @yield [response, operation] Access the result along with the RPC operation
609
+ # @yieldparam response [::Gapic::Operation]
610
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
611
+ #
612
+ # @return [::Gapic::Operation]
613
+ #
614
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
615
+ #
616
+ def create_instance request, options = nil
617
+ raise ::ArgumentError, "request must be provided" if request.nil?
618
+
619
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Instance::V1::CreateInstanceRequest
620
+
621
+ # Converts hash and nil to an options object
622
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
623
+
624
+ # Customize the options with defaults
625
+ metadata = @config.rpcs.create_instance.metadata.to_h
626
+
627
+ # Set x-goog-api-client and x-goog-user-project headers
628
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
629
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
630
+ gapic_version: ::Google::Cloud::Spanner::Admin::Instance::V1::VERSION
631
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
632
+
633
+ header_params = {
634
+ "parent" => request.parent
635
+ }
636
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
637
+ metadata[:"x-goog-request-params"] ||= request_params_header
638
+
639
+ options.apply_defaults timeout: @config.rpcs.create_instance.timeout,
640
+ metadata: metadata,
641
+ retry_policy: @config.rpcs.create_instance.retry_policy
642
+ options.apply_defaults metadata: @config.metadata,
643
+ retry_policy: @config.retry_policy
644
+
645
+ @instance_admin_stub.call_rpc :create_instance, request, options: options do |response, operation|
646
+ response = ::Gapic::Operation.new response, @operations_client, options: options
647
+ yield response, operation if block_given?
648
+ return response
649
+ end
650
+ rescue ::GRPC::BadStatus => e
651
+ raise ::Google::Cloud::Error.from_error(e)
652
+ end
653
+
654
+ ##
655
+ # Updates an instance, and begins allocating or releasing resources
656
+ # as requested. The returned [long-running
657
+ # operation][google.longrunning.Operation] can be used to track the
658
+ # progress of updating the instance. If the named instance does not
659
+ # exist, returns `NOT_FOUND`.
660
+ #
661
+ # Immediately upon completion of this request:
662
+ #
663
+ # * For resource types for which a decrease in the instance's allocation
664
+ # has been requested, billing is based on the newly-requested level.
665
+ #
666
+ # Until completion of the returned operation:
667
+ #
668
+ # * Cancelling the operation sets its metadata's
669
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::UpdateInstanceMetadata#cancel_time cancel_time}, and begins
670
+ # restoring resources to their pre-request values. The operation
671
+ # is guaranteed to succeed at undoing all resource changes,
672
+ # after which point it terminates with a `CANCELLED` status.
673
+ # * All other attempts to modify the instance are rejected.
674
+ # * Reading the instance via the API continues to give the pre-request
675
+ # resource levels.
676
+ #
677
+ # Upon completion of the returned operation:
678
+ #
679
+ # * Billing begins for all successfully-allocated resources (some types
680
+ # may have lower than the requested levels).
681
+ # * All newly-reserved resources are available for serving the instance's
682
+ # tables.
683
+ # * The instance's new resource levels are readable via the API.
684
+ #
685
+ # The returned {::Google::Longrunning::Operation long-running operation} will
686
+ # have a name of the format `<instance_name>/operations/<operation_id>` and
687
+ # can be used to track the instance modification. The
688
+ # {::Google::Longrunning::Operation#metadata metadata} field type is
689
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::UpdateInstanceMetadata UpdateInstanceMetadata}.
690
+ # The {::Google::Longrunning::Operation#response response} field type is
691
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::Instance Instance}, if successful.
692
+ #
693
+ # Authorization requires `spanner.instances.update` permission on
694
+ # resource {::Google::Cloud::Spanner::Admin::Instance::V1::Instance#name name}.
695
+ #
696
+ # @overload update_instance(request, options = nil)
697
+ # Pass arguments to `update_instance` via a request object, either of type
698
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::UpdateInstanceRequest} or an equivalent Hash.
699
+ #
700
+ # @param request [::Google::Cloud::Spanner::Admin::Instance::V1::UpdateInstanceRequest, ::Hash]
701
+ # A request object representing the call parameters. Required. To specify no
702
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
703
+ # @param options [::Gapic::CallOptions, ::Hash]
704
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
705
+ #
706
+ # @overload update_instance(instance: nil, field_mask: nil)
707
+ # Pass arguments to `update_instance` via keyword arguments. Note that at
708
+ # least one keyword argument is required. To specify no parameters, or to keep all
709
+ # the default parameter values, pass an empty Hash as a request object (see above).
710
+ #
711
+ # @param instance [::Google::Cloud::Spanner::Admin::Instance::V1::Instance, ::Hash]
712
+ # Required. The instance to update, which must always include the instance
713
+ # name. Otherwise, only fields mentioned in {::Google::Cloud::Spanner::Admin::Instance::V1::UpdateInstanceRequest#field_mask field_mask} need be included.
714
+ # @param field_mask [::Google::Protobuf::FieldMask, ::Hash]
715
+ # Required. A mask specifying which fields in {::Google::Cloud::Spanner::Admin::Instance::V1::Instance Instance} should be updated.
716
+ # The field mask must always be specified; this prevents any future fields in
717
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::Instance Instance} from being erased accidentally by clients that do not know
718
+ # about them.
719
+ #
720
+ # @yield [response, operation] Access the result along with the RPC operation
721
+ # @yieldparam response [::Gapic::Operation]
722
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
723
+ #
724
+ # @return [::Gapic::Operation]
725
+ #
726
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
727
+ #
728
+ def update_instance request, options = nil
729
+ raise ::ArgumentError, "request must be provided" if request.nil?
730
+
731
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Instance::V1::UpdateInstanceRequest
732
+
733
+ # Converts hash and nil to an options object
734
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
735
+
736
+ # Customize the options with defaults
737
+ metadata = @config.rpcs.update_instance.metadata.to_h
738
+
739
+ # Set x-goog-api-client and x-goog-user-project headers
740
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
741
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
742
+ gapic_version: ::Google::Cloud::Spanner::Admin::Instance::V1::VERSION
743
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
744
+
745
+ header_params = {
746
+ "instance.name" => request.instance.name
747
+ }
748
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
749
+ metadata[:"x-goog-request-params"] ||= request_params_header
750
+
751
+ options.apply_defaults timeout: @config.rpcs.update_instance.timeout,
752
+ metadata: metadata,
753
+ retry_policy: @config.rpcs.update_instance.retry_policy
754
+ options.apply_defaults metadata: @config.metadata,
755
+ retry_policy: @config.retry_policy
756
+
757
+ @instance_admin_stub.call_rpc :update_instance, request, options: options do |response, operation|
758
+ response = ::Gapic::Operation.new response, @operations_client, options: options
759
+ yield response, operation if block_given?
760
+ return response
761
+ end
762
+ rescue ::GRPC::BadStatus => e
763
+ raise ::Google::Cloud::Error.from_error(e)
764
+ end
765
+
766
+ ##
767
+ # Deletes an instance.
768
+ #
769
+ # Immediately upon completion of the request:
770
+ #
771
+ # * Billing ceases for all of the instance's reserved resources.
772
+ #
773
+ # Soon afterward:
774
+ #
775
+ # * The instance and *all of its databases* immediately and
776
+ # irrevocably disappear from the API. All data in the databases
777
+ # is permanently deleted.
778
+ #
779
+ # @overload delete_instance(request, options = nil)
780
+ # Pass arguments to `delete_instance` via a request object, either of type
781
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::DeleteInstanceRequest} or an equivalent Hash.
782
+ #
783
+ # @param request [::Google::Cloud::Spanner::Admin::Instance::V1::DeleteInstanceRequest, ::Hash]
784
+ # A request object representing the call parameters. Required. To specify no
785
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
786
+ # @param options [::Gapic::CallOptions, ::Hash]
787
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
788
+ #
789
+ # @overload delete_instance(name: nil)
790
+ # Pass arguments to `delete_instance` via keyword arguments. Note that at
791
+ # least one keyword argument is required. To specify no parameters, or to keep all
792
+ # the default parameter values, pass an empty Hash as a request object (see above).
793
+ #
794
+ # @param name [::String]
795
+ # Required. The name of the instance to be deleted. Values are of the form
796
+ # `projects/<project>/instances/<instance>`
797
+ #
798
+ # @yield [response, operation] Access the result along with the RPC operation
799
+ # @yieldparam response [::Google::Protobuf::Empty]
800
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
801
+ #
802
+ # @return [::Google::Protobuf::Empty]
803
+ #
804
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
805
+ #
806
+ def delete_instance request, options = nil
807
+ raise ::ArgumentError, "request must be provided" if request.nil?
808
+
809
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Instance::V1::DeleteInstanceRequest
810
+
811
+ # Converts hash and nil to an options object
812
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
813
+
814
+ # Customize the options with defaults
815
+ metadata = @config.rpcs.delete_instance.metadata.to_h
816
+
817
+ # Set x-goog-api-client and x-goog-user-project headers
818
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
819
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
820
+ gapic_version: ::Google::Cloud::Spanner::Admin::Instance::V1::VERSION
821
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
822
+
823
+ header_params = {
824
+ "name" => request.name
825
+ }
826
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
827
+ metadata[:"x-goog-request-params"] ||= request_params_header
828
+
829
+ options.apply_defaults timeout: @config.rpcs.delete_instance.timeout,
830
+ metadata: metadata,
831
+ retry_policy: @config.rpcs.delete_instance.retry_policy
832
+ options.apply_defaults metadata: @config.metadata,
833
+ retry_policy: @config.retry_policy
834
+
835
+ @instance_admin_stub.call_rpc :delete_instance, request, options: options do |response, operation|
836
+ yield response, operation if block_given?
837
+ return response
838
+ end
839
+ rescue ::GRPC::BadStatus => e
840
+ raise ::Google::Cloud::Error.from_error(e)
841
+ end
842
+
843
+ ##
844
+ # Sets the access control policy on an instance resource. Replaces any
845
+ # existing policy.
846
+ #
847
+ # Authorization requires `spanner.instances.setIamPolicy` on
848
+ # {::Google::Iam::V1::SetIamPolicyRequest#resource resource}.
849
+ #
850
+ # @overload set_iam_policy(request, options = nil)
851
+ # Pass arguments to `set_iam_policy` via a request object, either of type
852
+ # {::Google::Iam::V1::SetIamPolicyRequest} or an equivalent Hash.
853
+ #
854
+ # @param request [::Google::Iam::V1::SetIamPolicyRequest, ::Hash]
855
+ # A request object representing the call parameters. Required. To specify no
856
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
857
+ # @param options [::Gapic::CallOptions, ::Hash]
858
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
859
+ #
860
+ # @overload set_iam_policy(resource: nil, policy: nil)
861
+ # Pass arguments to `set_iam_policy` via keyword arguments. Note that at
862
+ # least one keyword argument is required. To specify no parameters, or to keep all
863
+ # the default parameter values, pass an empty Hash as a request object (see above).
864
+ #
865
+ # @param resource [::String]
866
+ # REQUIRED: The resource for which the policy is being specified.
867
+ # See the operation documentation for the appropriate value for this field.
868
+ # @param policy [::Google::Iam::V1::Policy, ::Hash]
869
+ # REQUIRED: The complete policy to be applied to the `resource`. The size of
870
+ # the policy is limited to a few 10s of KB. An empty policy is a
871
+ # valid policy but certain Cloud Platform services (such as Projects)
872
+ # might reject them.
873
+ #
874
+ # @yield [response, operation] Access the result along with the RPC operation
875
+ # @yieldparam response [::Google::Iam::V1::Policy]
876
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
877
+ #
878
+ # @return [::Google::Iam::V1::Policy]
879
+ #
880
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
881
+ #
882
+ def set_iam_policy request, options = nil
883
+ raise ::ArgumentError, "request must be provided" if request.nil?
884
+
885
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::SetIamPolicyRequest
886
+
887
+ # Converts hash and nil to an options object
888
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
889
+
890
+ # Customize the options with defaults
891
+ metadata = @config.rpcs.set_iam_policy.metadata.to_h
892
+
893
+ # Set x-goog-api-client and x-goog-user-project headers
894
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
895
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
896
+ gapic_version: ::Google::Cloud::Spanner::Admin::Instance::V1::VERSION
897
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
898
+
899
+ header_params = {
900
+ "resource" => request.resource
901
+ }
902
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
903
+ metadata[:"x-goog-request-params"] ||= request_params_header
904
+
905
+ options.apply_defaults timeout: @config.rpcs.set_iam_policy.timeout,
906
+ metadata: metadata,
907
+ retry_policy: @config.rpcs.set_iam_policy.retry_policy
908
+ options.apply_defaults metadata: @config.metadata,
909
+ retry_policy: @config.retry_policy
910
+
911
+ @instance_admin_stub.call_rpc :set_iam_policy, request, options: options do |response, operation|
912
+ yield response, operation if block_given?
913
+ return response
914
+ end
915
+ rescue ::GRPC::BadStatus => e
916
+ raise ::Google::Cloud::Error.from_error(e)
917
+ end
918
+
919
+ ##
920
+ # Gets the access control policy for an instance resource. Returns an empty
921
+ # policy if an instance exists but does not have a policy set.
922
+ #
923
+ # Authorization requires `spanner.instances.getIamPolicy` on
924
+ # {::Google::Iam::V1::GetIamPolicyRequest#resource resource}.
925
+ #
926
+ # @overload get_iam_policy(request, options = nil)
927
+ # Pass arguments to `get_iam_policy` via a request object, either of type
928
+ # {::Google::Iam::V1::GetIamPolicyRequest} or an equivalent Hash.
929
+ #
930
+ # @param request [::Google::Iam::V1::GetIamPolicyRequest, ::Hash]
931
+ # A request object representing the call parameters. Required. To specify no
932
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
933
+ # @param options [::Gapic::CallOptions, ::Hash]
934
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
935
+ #
936
+ # @overload get_iam_policy(resource: nil, options: nil)
937
+ # Pass arguments to `get_iam_policy` via keyword arguments. Note that at
938
+ # least one keyword argument is required. To specify no parameters, or to keep all
939
+ # the default parameter values, pass an empty Hash as a request object (see above).
940
+ #
941
+ # @param resource [::String]
942
+ # REQUIRED: The resource for which the policy is being requested.
943
+ # See the operation documentation for the appropriate value for this field.
944
+ # @param options [::Google::Iam::V1::GetPolicyOptions, ::Hash]
945
+ # OPTIONAL: A `GetPolicyOptions` object for specifying options to
946
+ # `GetIamPolicy`. This field is only used by Cloud IAM.
947
+ #
948
+ # @yield [response, operation] Access the result along with the RPC operation
949
+ # @yieldparam response [::Google::Iam::V1::Policy]
950
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
951
+ #
952
+ # @return [::Google::Iam::V1::Policy]
953
+ #
954
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
955
+ #
956
+ def get_iam_policy request, options = nil
957
+ raise ::ArgumentError, "request must be provided" if request.nil?
958
+
959
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::GetIamPolicyRequest
960
+
961
+ # Converts hash and nil to an options object
962
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
963
+
964
+ # Customize the options with defaults
965
+ metadata = @config.rpcs.get_iam_policy.metadata.to_h
966
+
967
+ # Set x-goog-api-client and x-goog-user-project headers
968
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
969
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
970
+ gapic_version: ::Google::Cloud::Spanner::Admin::Instance::V1::VERSION
971
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
972
+
973
+ header_params = {
974
+ "resource" => request.resource
975
+ }
976
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
977
+ metadata[:"x-goog-request-params"] ||= request_params_header
978
+
979
+ options.apply_defaults timeout: @config.rpcs.get_iam_policy.timeout,
980
+ metadata: metadata,
981
+ retry_policy: @config.rpcs.get_iam_policy.retry_policy
982
+ options.apply_defaults metadata: @config.metadata,
983
+ retry_policy: @config.retry_policy
984
+
985
+ @instance_admin_stub.call_rpc :get_iam_policy, request, options: options do |response, operation|
986
+ yield response, operation if block_given?
987
+ return response
988
+ end
989
+ rescue ::GRPC::BadStatus => e
990
+ raise ::Google::Cloud::Error.from_error(e)
991
+ end
992
+
993
+ ##
994
+ # Returns permissions that the caller has on the specified instance resource.
995
+ #
996
+ # Attempting this RPC on a non-existent Cloud Spanner instance resource will
997
+ # result in a NOT_FOUND error if the user has `spanner.instances.list`
998
+ # permission on the containing Google Cloud Project. Otherwise returns an
999
+ # empty set of permissions.
1000
+ #
1001
+ # @overload test_iam_permissions(request, options = nil)
1002
+ # Pass arguments to `test_iam_permissions` via a request object, either of type
1003
+ # {::Google::Iam::V1::TestIamPermissionsRequest} or an equivalent Hash.
1004
+ #
1005
+ # @param request [::Google::Iam::V1::TestIamPermissionsRequest, ::Hash]
1006
+ # A request object representing the call parameters. Required. To specify no
1007
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1008
+ # @param options [::Gapic::CallOptions, ::Hash]
1009
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1010
+ #
1011
+ # @overload test_iam_permissions(resource: nil, permissions: nil)
1012
+ # Pass arguments to `test_iam_permissions` via keyword arguments. Note that at
1013
+ # least one keyword argument is required. To specify no parameters, or to keep all
1014
+ # the default parameter values, pass an empty Hash as a request object (see above).
1015
+ #
1016
+ # @param resource [::String]
1017
+ # REQUIRED: The resource for which the policy detail is being requested.
1018
+ # See the operation documentation for the appropriate value for this field.
1019
+ # @param permissions [::Array<::String>]
1020
+ # The set of permissions to check for the `resource`. Permissions with
1021
+ # wildcards (such as '*' or 'storage.*') are not allowed. For more
1022
+ # information see
1023
+ # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1024
+ #
1025
+ # @yield [response, operation] Access the result along with the RPC operation
1026
+ # @yieldparam response [::Google::Iam::V1::TestIamPermissionsResponse]
1027
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1028
+ #
1029
+ # @return [::Google::Iam::V1::TestIamPermissionsResponse]
1030
+ #
1031
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1032
+ #
1033
+ def test_iam_permissions request, options = nil
1034
+ raise ::ArgumentError, "request must be provided" if request.nil?
1035
+
1036
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::TestIamPermissionsRequest
1037
+
1038
+ # Converts hash and nil to an options object
1039
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1040
+
1041
+ # Customize the options with defaults
1042
+ metadata = @config.rpcs.test_iam_permissions.metadata.to_h
1043
+
1044
+ # Set x-goog-api-client and x-goog-user-project headers
1045
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1046
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1047
+ gapic_version: ::Google::Cloud::Spanner::Admin::Instance::V1::VERSION
1048
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1049
+
1050
+ header_params = {
1051
+ "resource" => request.resource
1052
+ }
1053
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1054
+ metadata[:"x-goog-request-params"] ||= request_params_header
1055
+
1056
+ options.apply_defaults timeout: @config.rpcs.test_iam_permissions.timeout,
1057
+ metadata: metadata,
1058
+ retry_policy: @config.rpcs.test_iam_permissions.retry_policy
1059
+ options.apply_defaults metadata: @config.metadata,
1060
+ retry_policy: @config.retry_policy
1061
+
1062
+ @instance_admin_stub.call_rpc :test_iam_permissions, request, options: options do |response, operation|
1063
+ yield response, operation if block_given?
1064
+ return response
1065
+ end
1066
+ rescue ::GRPC::BadStatus => e
1067
+ raise ::Google::Cloud::Error.from_error(e)
1068
+ end
1069
+
1070
+ ##
1071
+ # Configuration class for the InstanceAdmin API.
1072
+ #
1073
+ # This class represents the configuration for InstanceAdmin,
1074
+ # providing control over timeouts, retry behavior, logging, transport
1075
+ # parameters, and other low-level controls. Certain parameters can also be
1076
+ # applied individually to specific RPCs. See
1077
+ # {::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client::Configuration::Rpcs}
1078
+ # for a list of RPCs that can be configured independently.
1079
+ #
1080
+ # Configuration can be applied globally to all clients, or to a single client
1081
+ # on construction.
1082
+ #
1083
+ # # Examples
1084
+ #
1085
+ # To modify the global config, setting the timeout for list_instance_configs
1086
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
1087
+ #
1088
+ # ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client.configure do |config|
1089
+ # config.timeout = 10.0
1090
+ # config.rpcs.list_instance_configs.timeout = 20.0
1091
+ # end
1092
+ #
1093
+ # To apply the above configuration only to a new client:
1094
+ #
1095
+ # client = ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client.new do |config|
1096
+ # config.timeout = 10.0
1097
+ # config.rpcs.list_instance_configs.timeout = 20.0
1098
+ # end
1099
+ #
1100
+ # @!attribute [rw] endpoint
1101
+ # The hostname or hostname:port of the service endpoint.
1102
+ # Defaults to `"spanner.googleapis.com"`.
1103
+ # @return [::String]
1104
+ # @!attribute [rw] credentials
1105
+ # Credentials to send with calls. You may provide any of the following types:
1106
+ # * (`String`) The path to a service account key file in JSON format
1107
+ # * (`Hash`) A service account key as a Hash
1108
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1109
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
1110
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1111
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
1112
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
1113
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
1114
+ # * (`nil`) indicating no credentials
1115
+ # @return [::Object]
1116
+ # @!attribute [rw] scope
1117
+ # The OAuth scopes
1118
+ # @return [::Array<::String>]
1119
+ # @!attribute [rw] lib_name
1120
+ # The library name as recorded in instrumentation and logging
1121
+ # @return [::String]
1122
+ # @!attribute [rw] lib_version
1123
+ # The library version as recorded in instrumentation and logging
1124
+ # @return [::String]
1125
+ # @!attribute [rw] channel_args
1126
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
1127
+ # `GRPC::Core::Channel` object is provided as the credential.
1128
+ # @return [::Hash]
1129
+ # @!attribute [rw] interceptors
1130
+ # An array of interceptors that are run before calls are executed.
1131
+ # @return [::Array<::GRPC::ClientInterceptor>]
1132
+ # @!attribute [rw] timeout
1133
+ # The call timeout in seconds.
1134
+ # @return [::Numeric]
1135
+ # @!attribute [rw] metadata
1136
+ # Additional gRPC headers to be sent with the call.
1137
+ # @return [::Hash{::Symbol=>::String}]
1138
+ # @!attribute [rw] retry_policy
1139
+ # The retry policy. The value is a hash with the following keys:
1140
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1141
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1142
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1143
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1144
+ # trigger a retry.
1145
+ # @return [::Hash]
1146
+ # @!attribute [rw] quota_project
1147
+ # A separate project against which to charge quota.
1148
+ # @return [::String]
1149
+ #
1150
+ class Configuration
1151
+ extend ::Gapic::Config
1152
+
1153
+ config_attr :endpoint, "spanner.googleapis.com", ::String
1154
+ config_attr :credentials, nil do |value|
1155
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1156
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
1157
+ allowed.any? { |klass| klass === value }
1158
+ end
1159
+ config_attr :scope, nil, ::String, ::Array, nil
1160
+ config_attr :lib_name, nil, ::String, nil
1161
+ config_attr :lib_version, nil, ::String, nil
1162
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
1163
+ config_attr :interceptors, nil, ::Array, nil
1164
+ config_attr :timeout, nil, ::Numeric, nil
1165
+ config_attr :metadata, nil, ::Hash, nil
1166
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1167
+ config_attr :quota_project, nil, ::String, nil
1168
+
1169
+ # @private
1170
+ def initialize parent_config = nil
1171
+ @parent_config = parent_config unless parent_config.nil?
1172
+
1173
+ yield self if block_given?
1174
+ end
1175
+
1176
+ ##
1177
+ # Configurations for individual RPCs
1178
+ # @return [Rpcs]
1179
+ #
1180
+ def rpcs
1181
+ @rpcs ||= begin
1182
+ parent_rpcs = nil
1183
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
1184
+ Rpcs.new parent_rpcs
1185
+ end
1186
+ end
1187
+
1188
+ ##
1189
+ # Configuration RPC class for the InstanceAdmin API.
1190
+ #
1191
+ # Includes fields providing the configuration for each RPC in this service.
1192
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1193
+ # the following configuration fields:
1194
+ #
1195
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
1196
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1197
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1198
+ # include the following keys:
1199
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1200
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1201
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1202
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1203
+ # trigger a retry.
1204
+ #
1205
+ class Rpcs
1206
+ ##
1207
+ # RPC-specific configuration for `list_instance_configs`
1208
+ # @return [::Gapic::Config::Method]
1209
+ #
1210
+ attr_reader :list_instance_configs
1211
+ ##
1212
+ # RPC-specific configuration for `get_instance_config`
1213
+ # @return [::Gapic::Config::Method]
1214
+ #
1215
+ attr_reader :get_instance_config
1216
+ ##
1217
+ # RPC-specific configuration for `list_instances`
1218
+ # @return [::Gapic::Config::Method]
1219
+ #
1220
+ attr_reader :list_instances
1221
+ ##
1222
+ # RPC-specific configuration for `get_instance`
1223
+ # @return [::Gapic::Config::Method]
1224
+ #
1225
+ attr_reader :get_instance
1226
+ ##
1227
+ # RPC-specific configuration for `create_instance`
1228
+ # @return [::Gapic::Config::Method]
1229
+ #
1230
+ attr_reader :create_instance
1231
+ ##
1232
+ # RPC-specific configuration for `update_instance`
1233
+ # @return [::Gapic::Config::Method]
1234
+ #
1235
+ attr_reader :update_instance
1236
+ ##
1237
+ # RPC-specific configuration for `delete_instance`
1238
+ # @return [::Gapic::Config::Method]
1239
+ #
1240
+ attr_reader :delete_instance
1241
+ ##
1242
+ # RPC-specific configuration for `set_iam_policy`
1243
+ # @return [::Gapic::Config::Method]
1244
+ #
1245
+ attr_reader :set_iam_policy
1246
+ ##
1247
+ # RPC-specific configuration for `get_iam_policy`
1248
+ # @return [::Gapic::Config::Method]
1249
+ #
1250
+ attr_reader :get_iam_policy
1251
+ ##
1252
+ # RPC-specific configuration for `test_iam_permissions`
1253
+ # @return [::Gapic::Config::Method]
1254
+ #
1255
+ attr_reader :test_iam_permissions
1256
+
1257
+ # @private
1258
+ def initialize parent_rpcs = nil
1259
+ list_instance_configs_config = parent_rpcs&.list_instance_configs if parent_rpcs&.respond_to? :list_instance_configs
1260
+ @list_instance_configs = ::Gapic::Config::Method.new list_instance_configs_config
1261
+ get_instance_config_config = parent_rpcs&.get_instance_config if parent_rpcs&.respond_to? :get_instance_config
1262
+ @get_instance_config = ::Gapic::Config::Method.new get_instance_config_config
1263
+ list_instances_config = parent_rpcs&.list_instances if parent_rpcs&.respond_to? :list_instances
1264
+ @list_instances = ::Gapic::Config::Method.new list_instances_config
1265
+ get_instance_config = parent_rpcs&.get_instance if parent_rpcs&.respond_to? :get_instance
1266
+ @get_instance = ::Gapic::Config::Method.new get_instance_config
1267
+ create_instance_config = parent_rpcs&.create_instance if parent_rpcs&.respond_to? :create_instance
1268
+ @create_instance = ::Gapic::Config::Method.new create_instance_config
1269
+ update_instance_config = parent_rpcs&.update_instance if parent_rpcs&.respond_to? :update_instance
1270
+ @update_instance = ::Gapic::Config::Method.new update_instance_config
1271
+ delete_instance_config = parent_rpcs&.delete_instance if parent_rpcs&.respond_to? :delete_instance
1272
+ @delete_instance = ::Gapic::Config::Method.new delete_instance_config
1273
+ set_iam_policy_config = parent_rpcs&.set_iam_policy if parent_rpcs&.respond_to? :set_iam_policy
1274
+ @set_iam_policy = ::Gapic::Config::Method.new set_iam_policy_config
1275
+ get_iam_policy_config = parent_rpcs&.get_iam_policy if parent_rpcs&.respond_to? :get_iam_policy
1276
+ @get_iam_policy = ::Gapic::Config::Method.new get_iam_policy_config
1277
+ test_iam_permissions_config = parent_rpcs&.test_iam_permissions if parent_rpcs&.respond_to? :test_iam_permissions
1278
+ @test_iam_permissions = ::Gapic::Config::Method.new test_iam_permissions_config
1279
+
1280
+ yield self if block_given?
1281
+ end
1282
+ end
1283
+ end
1284
+ end
1285
+ end
1286
+ end
1287
+ end
1288
+ end
1289
+ end
1290
+ end
1291
+ end