google-cloud-redis-cluster-v1 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +149 -0
  4. data/LICENSE.md +201 -0
  5. data/README.md +144 -0
  6. data/lib/google/cloud/redis/cluster/v1/bindings_override.rb +104 -0
  7. data/lib/google/cloud/redis/cluster/v1/cloud_redis_cluster/client.rb +918 -0
  8. data/lib/google/cloud/redis/cluster/v1/cloud_redis_cluster/credentials.rb +49 -0
  9. data/lib/google/cloud/redis/cluster/v1/cloud_redis_cluster/operations.rb +781 -0
  10. data/lib/google/cloud/redis/cluster/v1/cloud_redis_cluster/paths.rb +71 -0
  11. data/lib/google/cloud/redis/cluster/v1/cloud_redis_cluster/rest/client.rb +861 -0
  12. data/lib/google/cloud/redis/cluster/v1/cloud_redis_cluster/rest/operations.rb +871 -0
  13. data/lib/google/cloud/redis/cluster/v1/cloud_redis_cluster/rest/service_stub.rb +347 -0
  14. data/lib/google/cloud/redis/cluster/v1/cloud_redis_cluster/rest.rb +76 -0
  15. data/lib/google/cloud/redis/cluster/v1/cloud_redis_cluster.rb +78 -0
  16. data/lib/google/cloud/redis/cluster/v1/cloud_redis_cluster_pb.rb +71 -0
  17. data/lib/google/cloud/redis/cluster/v1/cloud_redis_cluster_services_pb.rb +95 -0
  18. data/lib/google/cloud/redis/cluster/v1/rest.rb +40 -0
  19. data/lib/google/cloud/redis/cluster/v1/version.rb +30 -0
  20. data/lib/google/cloud/redis/cluster/v1.rb +47 -0
  21. data/lib/google-cloud-redis-cluster-v1.rb +21 -0
  22. data/proto_docs/README.md +4 -0
  23. data/proto_docs/google/api/client.rb +381 -0
  24. data/proto_docs/google/api/field_behavior.rb +85 -0
  25. data/proto_docs/google/api/launch_stage.rb +71 -0
  26. data/proto_docs/google/api/resource.rb +222 -0
  27. data/proto_docs/google/cloud/redis/cluster/v1/cloud_redis_cluster.rb +353 -0
  28. data/proto_docs/google/longrunning/operations.rb +164 -0
  29. data/proto_docs/google/protobuf/any.rb +144 -0
  30. data/proto_docs/google/protobuf/duration.rb +98 -0
  31. data/proto_docs/google/protobuf/empty.rb +34 -0
  32. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  33. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  34. data/proto_docs/google/rpc/status.rb +48 -0
  35. metadata +244 -0
@@ -0,0 +1,781 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/operation"
20
+ require "google/longrunning/operations_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Redis
25
+ module Cluster
26
+ module V1
27
+ module CloudRedisCluster
28
+ # Service that implements Longrunning Operations API.
29
+ class Operations
30
+ # @private
31
+ attr_reader :operations_stub
32
+
33
+ ##
34
+ # Configuration for the CloudRedisCluster Operations API.
35
+ #
36
+ # @yield [config] Configure the Operations client.
37
+ # @yieldparam config [Operations::Configuration]
38
+ #
39
+ # @return [Operations::Configuration]
40
+ #
41
+ def self.configure
42
+ @configure ||= Operations::Configuration.new
43
+ yield @configure if block_given?
44
+ @configure
45
+ end
46
+
47
+ ##
48
+ # Configure the CloudRedisCluster Operations instance.
49
+ #
50
+ # The configuration is set to the derived mode, meaning that values can be changed,
51
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
52
+ # should be made on {Operations.configure}.
53
+ #
54
+ # @yield [config] Configure the Operations client.
55
+ # @yieldparam config [Operations::Configuration]
56
+ #
57
+ # @return [Operations::Configuration]
58
+ #
59
+ def configure
60
+ yield @config if block_given?
61
+ @config
62
+ end
63
+
64
+ ##
65
+ # Create a new Operations client object.
66
+ #
67
+ # @yield [config] Configure the Client client.
68
+ # @yieldparam config [Operations::Configuration]
69
+ #
70
+ def initialize
71
+ # These require statements are intentionally placed here to initialize
72
+ # the gRPC module only when it's required.
73
+ # See https://github.com/googleapis/toolkit/issues/446
74
+ require "gapic/grpc"
75
+ require "google/longrunning/operations_services_pb"
76
+
77
+ # Create the configuration object
78
+ @config = Configuration.new Operations.configure
79
+
80
+ # Yield the configuration if needed
81
+ yield @config if block_given?
82
+
83
+ # Create credentials
84
+ credentials = @config.credentials
85
+ credentials ||= Credentials.default scope: @config.scope
86
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
87
+ credentials = Credentials.new credentials, scope: @config.scope
88
+ end
89
+ @quota_project_id = @config.quota_project
90
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
91
+
92
+ @operations_stub = ::Gapic::ServiceStub.new(
93
+ ::Google::Longrunning::Operations::Stub,
94
+ credentials: credentials,
95
+ endpoint: @config.endpoint,
96
+ channel_args: @config.channel_args,
97
+ interceptors: @config.interceptors,
98
+ channel_pool_config: @config.channel_pool
99
+ )
100
+
101
+ # Used by an LRO wrapper for some methods of this service
102
+ @operations_client = self
103
+ end
104
+
105
+ # Service calls
106
+
107
+ ##
108
+ # Lists operations that match the specified filter in the request. If the
109
+ # server doesn't support this method, it returns `UNIMPLEMENTED`.
110
+ #
111
+ # NOTE: the `name` binding allows API services to override the binding
112
+ # to use different resource name schemes, such as `users/*/operations`. To
113
+ # override the binding, API services can add a binding such as
114
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
115
+ # For backwards compatibility, the default name includes the operations
116
+ # collection id, however overriding users must ensure the name binding
117
+ # is the parent resource, without the operations collection id.
118
+ #
119
+ # @overload list_operations(request, options = nil)
120
+ # Pass arguments to `list_operations` via a request object, either of type
121
+ # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
122
+ #
123
+ # @param request [::Google::Longrunning::ListOperationsRequest, ::Hash]
124
+ # A request object representing the call parameters. Required. To specify no
125
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
126
+ # @param options [::Gapic::CallOptions, ::Hash]
127
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
128
+ #
129
+ # @overload list_operations(name: nil, filter: nil, page_size: nil, page_token: nil)
130
+ # Pass arguments to `list_operations` via keyword arguments. Note that at
131
+ # least one keyword argument is required. To specify no parameters, or to keep all
132
+ # the default parameter values, pass an empty Hash as a request object (see above).
133
+ #
134
+ # @param name [::String]
135
+ # The name of the operation's parent resource.
136
+ # @param filter [::String]
137
+ # The standard list filter.
138
+ # @param page_size [::Integer]
139
+ # The standard list page size.
140
+ # @param page_token [::String]
141
+ # The standard list page token.
142
+ #
143
+ # @yield [response, operation] Access the result along with the RPC operation
144
+ # @yieldparam response [::Gapic::PagedEnumerable<::Gapic::Operation>]
145
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
146
+ #
147
+ # @return [::Gapic::PagedEnumerable<::Gapic::Operation>]
148
+ #
149
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
150
+ #
151
+ # @example Basic example
152
+ # require "google/longrunning"
153
+ #
154
+ # # Create a client object. The client can be reused for multiple calls.
155
+ # client = Google::Longrunning::Operations::Client.new
156
+ #
157
+ # # Create a request. To set request fields, pass in keyword arguments.
158
+ # request = Google::Longrunning::ListOperationsRequest.new
159
+ #
160
+ # # Call the list_operations method.
161
+ # result = client.list_operations request
162
+ #
163
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
164
+ # # over elements, and API calls will be issued to fetch pages as needed.
165
+ # result.each do |item|
166
+ # # Each element is of type ::Google::Longrunning::Operation.
167
+ # p item
168
+ # end
169
+ #
170
+ def list_operations request, options = nil
171
+ raise ::ArgumentError, "request must be provided" if request.nil?
172
+
173
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::ListOperationsRequest
174
+
175
+ # Converts hash and nil to an options object
176
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
177
+
178
+ # Customize the options with defaults
179
+ metadata = @config.rpcs.list_operations.metadata.to_h
180
+
181
+ # Set x-goog-api-client and x-goog-user-project headers
182
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
183
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
184
+ gapic_version: ::Google::Cloud::Redis::Cluster::V1::VERSION
185
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
186
+
187
+ header_params = {}
188
+ if request.name
189
+ header_params["name"] = request.name
190
+ end
191
+
192
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
193
+ metadata[:"x-goog-request-params"] ||= request_params_header
194
+
195
+ options.apply_defaults timeout: @config.rpcs.list_operations.timeout,
196
+ metadata: metadata,
197
+ retry_policy: @config.rpcs.list_operations.retry_policy
198
+
199
+ options.apply_defaults timeout: @config.timeout,
200
+ metadata: @config.metadata,
201
+ retry_policy: @config.retry_policy
202
+
203
+ @operations_stub.call_rpc :list_operations, request, options: options do |response, operation|
204
+ wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client }
205
+ response = ::Gapic::PagedEnumerable.new @operations_stub, :list_operations, request, response, operation, options, format_resource: wrap_lro_operation
206
+ yield response, operation if block_given?
207
+ return response
208
+ end
209
+ rescue ::GRPC::BadStatus => e
210
+ raise ::Google::Cloud::Error.from_error(e)
211
+ end
212
+
213
+ ##
214
+ # Gets the latest state of a long-running operation. Clients can use this
215
+ # method to poll the operation result at intervals as recommended by the API
216
+ # service.
217
+ #
218
+ # @overload get_operation(request, options = nil)
219
+ # Pass arguments to `get_operation` via a request object, either of type
220
+ # {::Google::Longrunning::GetOperationRequest} or an equivalent Hash.
221
+ #
222
+ # @param request [::Google::Longrunning::GetOperationRequest, ::Hash]
223
+ # A request object representing the call parameters. Required. To specify no
224
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
225
+ # @param options [::Gapic::CallOptions, ::Hash]
226
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
227
+ #
228
+ # @overload get_operation(name: nil)
229
+ # Pass arguments to `get_operation` via keyword arguments. Note that at
230
+ # least one keyword argument is required. To specify no parameters, or to keep all
231
+ # the default parameter values, pass an empty Hash as a request object (see above).
232
+ #
233
+ # @param name [::String]
234
+ # The name of the operation resource.
235
+ #
236
+ # @yield [response, operation] Access the result along with the RPC operation
237
+ # @yieldparam response [::Gapic::Operation]
238
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
239
+ #
240
+ # @return [::Gapic::Operation]
241
+ #
242
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
243
+ #
244
+ # @example Basic example
245
+ # require "google/longrunning"
246
+ #
247
+ # # Create a client object. The client can be reused for multiple calls.
248
+ # client = Google::Longrunning::Operations::Client.new
249
+ #
250
+ # # Create a request. To set request fields, pass in keyword arguments.
251
+ # request = Google::Longrunning::GetOperationRequest.new
252
+ #
253
+ # # Call the get_operation method.
254
+ # result = client.get_operation request
255
+ #
256
+ # # The returned object is of type Gapic::Operation. You can use it to
257
+ # # check the status of an operation, cancel it, or wait for results.
258
+ # # Here is how to wait for a response.
259
+ # result.wait_until_done! timeout: 60
260
+ # if result.response?
261
+ # p result.response
262
+ # else
263
+ # puts "No response received."
264
+ # end
265
+ #
266
+ def get_operation request, options = nil
267
+ raise ::ArgumentError, "request must be provided" if request.nil?
268
+
269
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::GetOperationRequest
270
+
271
+ # Converts hash and nil to an options object
272
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
273
+
274
+ # Customize the options with defaults
275
+ metadata = @config.rpcs.get_operation.metadata.to_h
276
+
277
+ # Set x-goog-api-client and x-goog-user-project headers
278
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
279
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
280
+ gapic_version: ::Google::Cloud::Redis::Cluster::V1::VERSION
281
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
282
+
283
+ header_params = {}
284
+ if request.name
285
+ header_params["name"] = request.name
286
+ end
287
+
288
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
289
+ metadata[:"x-goog-request-params"] ||= request_params_header
290
+
291
+ options.apply_defaults timeout: @config.rpcs.get_operation.timeout,
292
+ metadata: metadata,
293
+ retry_policy: @config.rpcs.get_operation.retry_policy
294
+
295
+ options.apply_defaults timeout: @config.timeout,
296
+ metadata: @config.metadata,
297
+ retry_policy: @config.retry_policy
298
+
299
+ @operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
300
+ response = ::Gapic::Operation.new response, @operations_client, options: options
301
+ yield response, operation if block_given?
302
+ return response
303
+ end
304
+ rescue ::GRPC::BadStatus => e
305
+ raise ::Google::Cloud::Error.from_error(e)
306
+ end
307
+
308
+ ##
309
+ # Deletes a long-running operation. This method indicates that the client is
310
+ # no longer interested in the operation result. It does not cancel the
311
+ # operation. If the server doesn't support this method, it returns
312
+ # `google.rpc.Code.UNIMPLEMENTED`.
313
+ #
314
+ # @overload delete_operation(request, options = nil)
315
+ # Pass arguments to `delete_operation` via a request object, either of type
316
+ # {::Google::Longrunning::DeleteOperationRequest} or an equivalent Hash.
317
+ #
318
+ # @param request [::Google::Longrunning::DeleteOperationRequest, ::Hash]
319
+ # A request object representing the call parameters. Required. To specify no
320
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
321
+ # @param options [::Gapic::CallOptions, ::Hash]
322
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
323
+ #
324
+ # @overload delete_operation(name: nil)
325
+ # Pass arguments to `delete_operation` via keyword arguments. Note that at
326
+ # least one keyword argument is required. To specify no parameters, or to keep all
327
+ # the default parameter values, pass an empty Hash as a request object (see above).
328
+ #
329
+ # @param name [::String]
330
+ # The name of the operation resource to be deleted.
331
+ #
332
+ # @yield [response, operation] Access the result along with the RPC operation
333
+ # @yieldparam response [::Google::Protobuf::Empty]
334
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
335
+ #
336
+ # @return [::Google::Protobuf::Empty]
337
+ #
338
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
339
+ #
340
+ # @example Basic example
341
+ # require "google/longrunning"
342
+ #
343
+ # # Create a client object. The client can be reused for multiple calls.
344
+ # client = Google::Longrunning::Operations::Client.new
345
+ #
346
+ # # Create a request. To set request fields, pass in keyword arguments.
347
+ # request = Google::Longrunning::DeleteOperationRequest.new
348
+ #
349
+ # # Call the delete_operation method.
350
+ # result = client.delete_operation request
351
+ #
352
+ # # The returned object is of type Google::Protobuf::Empty.
353
+ # p result
354
+ #
355
+ def delete_operation request, options = nil
356
+ raise ::ArgumentError, "request must be provided" if request.nil?
357
+
358
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::DeleteOperationRequest
359
+
360
+ # Converts hash and nil to an options object
361
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
362
+
363
+ # Customize the options with defaults
364
+ metadata = @config.rpcs.delete_operation.metadata.to_h
365
+
366
+ # Set x-goog-api-client and x-goog-user-project headers
367
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
368
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
369
+ gapic_version: ::Google::Cloud::Redis::Cluster::V1::VERSION
370
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
371
+
372
+ header_params = {}
373
+ if request.name
374
+ header_params["name"] = request.name
375
+ end
376
+
377
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
378
+ metadata[:"x-goog-request-params"] ||= request_params_header
379
+
380
+ options.apply_defaults timeout: @config.rpcs.delete_operation.timeout,
381
+ metadata: metadata,
382
+ retry_policy: @config.rpcs.delete_operation.retry_policy
383
+
384
+ options.apply_defaults timeout: @config.timeout,
385
+ metadata: @config.metadata,
386
+ retry_policy: @config.retry_policy
387
+
388
+ @operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
389
+ yield response, operation if block_given?
390
+ return response
391
+ end
392
+ rescue ::GRPC::BadStatus => e
393
+ raise ::Google::Cloud::Error.from_error(e)
394
+ end
395
+
396
+ ##
397
+ # Starts asynchronous cancellation on a long-running operation. The server
398
+ # makes a best effort to cancel the operation, but success is not
399
+ # guaranteed. If the server doesn't support this method, it returns
400
+ # `google.rpc.Code.UNIMPLEMENTED`. Clients can use
401
+ # Operations.GetOperation or
402
+ # other methods to check whether the cancellation succeeded or whether the
403
+ # operation completed despite cancellation. On successful cancellation,
404
+ # the operation is not deleted; instead, it becomes an operation with
405
+ # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
406
+ # corresponding to `Code.CANCELLED`.
407
+ #
408
+ # @overload cancel_operation(request, options = nil)
409
+ # Pass arguments to `cancel_operation` via a request object, either of type
410
+ # {::Google::Longrunning::CancelOperationRequest} or an equivalent Hash.
411
+ #
412
+ # @param request [::Google::Longrunning::CancelOperationRequest, ::Hash]
413
+ # A request object representing the call parameters. Required. To specify no
414
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
415
+ # @param options [::Gapic::CallOptions, ::Hash]
416
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
417
+ #
418
+ # @overload cancel_operation(name: nil)
419
+ # Pass arguments to `cancel_operation` via keyword arguments. Note that at
420
+ # least one keyword argument is required. To specify no parameters, or to keep all
421
+ # the default parameter values, pass an empty Hash as a request object (see above).
422
+ #
423
+ # @param name [::String]
424
+ # The name of the operation resource to be cancelled.
425
+ #
426
+ # @yield [response, operation] Access the result along with the RPC operation
427
+ # @yieldparam response [::Google::Protobuf::Empty]
428
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
429
+ #
430
+ # @return [::Google::Protobuf::Empty]
431
+ #
432
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
433
+ #
434
+ # @example Basic example
435
+ # require "google/longrunning"
436
+ #
437
+ # # Create a client object. The client can be reused for multiple calls.
438
+ # client = Google::Longrunning::Operations::Client.new
439
+ #
440
+ # # Create a request. To set request fields, pass in keyword arguments.
441
+ # request = Google::Longrunning::CancelOperationRequest.new
442
+ #
443
+ # # Call the cancel_operation method.
444
+ # result = client.cancel_operation request
445
+ #
446
+ # # The returned object is of type Google::Protobuf::Empty.
447
+ # p result
448
+ #
449
+ def cancel_operation request, options = nil
450
+ raise ::ArgumentError, "request must be provided" if request.nil?
451
+
452
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::CancelOperationRequest
453
+
454
+ # Converts hash and nil to an options object
455
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
456
+
457
+ # Customize the options with defaults
458
+ metadata = @config.rpcs.cancel_operation.metadata.to_h
459
+
460
+ # Set x-goog-api-client and x-goog-user-project headers
461
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
462
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
463
+ gapic_version: ::Google::Cloud::Redis::Cluster::V1::VERSION
464
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
465
+
466
+ header_params = {}
467
+ if request.name
468
+ header_params["name"] = request.name
469
+ end
470
+
471
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
472
+ metadata[:"x-goog-request-params"] ||= request_params_header
473
+
474
+ options.apply_defaults timeout: @config.rpcs.cancel_operation.timeout,
475
+ metadata: metadata,
476
+ retry_policy: @config.rpcs.cancel_operation.retry_policy
477
+
478
+ options.apply_defaults timeout: @config.timeout,
479
+ metadata: @config.metadata,
480
+ retry_policy: @config.retry_policy
481
+
482
+ @operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
483
+ yield response, operation if block_given?
484
+ return response
485
+ end
486
+ rescue ::GRPC::BadStatus => e
487
+ raise ::Google::Cloud::Error.from_error(e)
488
+ end
489
+
490
+ ##
491
+ # Waits until the specified long-running operation is done or reaches at most
492
+ # a specified timeout, returning the latest state. If the operation is
493
+ # already done, the latest state is immediately returned. If the timeout
494
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
495
+ # timeout is used. If the server does not support this method, it returns
496
+ # `google.rpc.Code.UNIMPLEMENTED`.
497
+ # Note that this method is on a best-effort basis. It may return the latest
498
+ # state before the specified timeout (including immediately), meaning even an
499
+ # immediate response is no guarantee that the operation is done.
500
+ #
501
+ # @overload wait_operation(request, options = nil)
502
+ # Pass arguments to `wait_operation` via a request object, either of type
503
+ # {::Google::Longrunning::WaitOperationRequest} or an equivalent Hash.
504
+ #
505
+ # @param request [::Google::Longrunning::WaitOperationRequest, ::Hash]
506
+ # A request object representing the call parameters. Required. To specify no
507
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
508
+ # @param options [::Gapic::CallOptions, ::Hash]
509
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
510
+ #
511
+ # @overload wait_operation(name: nil, timeout: nil)
512
+ # Pass arguments to `wait_operation` via keyword arguments. Note that at
513
+ # least one keyword argument is required. To specify no parameters, or to keep all
514
+ # the default parameter values, pass an empty Hash as a request object (see above).
515
+ #
516
+ # @param name [::String]
517
+ # The name of the operation resource to wait on.
518
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
519
+ # The maximum duration to wait before timing out. If left blank, the wait
520
+ # will be at most the time permitted by the underlying HTTP/RPC protocol.
521
+ # If RPC context deadline is also specified, the shorter one will be used.
522
+ #
523
+ # @yield [response, operation] Access the result along with the RPC operation
524
+ # @yieldparam response [::Gapic::Operation]
525
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
526
+ #
527
+ # @return [::Gapic::Operation]
528
+ #
529
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
530
+ #
531
+ # @example Basic example
532
+ # require "google/longrunning"
533
+ #
534
+ # # Create a client object. The client can be reused for multiple calls.
535
+ # client = Google::Longrunning::Operations::Client.new
536
+ #
537
+ # # Create a request. To set request fields, pass in keyword arguments.
538
+ # request = Google::Longrunning::WaitOperationRequest.new
539
+ #
540
+ # # Call the wait_operation method.
541
+ # result = client.wait_operation request
542
+ #
543
+ # # The returned object is of type Gapic::Operation. You can use it to
544
+ # # check the status of an operation, cancel it, or wait for results.
545
+ # # Here is how to wait for a response.
546
+ # result.wait_until_done! timeout: 60
547
+ # if result.response?
548
+ # p result.response
549
+ # else
550
+ # puts "No response received."
551
+ # end
552
+ #
553
+ def wait_operation request, options = nil
554
+ raise ::ArgumentError, "request must be provided" if request.nil?
555
+
556
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest
557
+
558
+ # Converts hash and nil to an options object
559
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
560
+
561
+ # Customize the options with defaults
562
+ metadata = @config.rpcs.wait_operation.metadata.to_h
563
+
564
+ # Set x-goog-api-client and x-goog-user-project headers
565
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
566
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
567
+ gapic_version: ::Google::Cloud::Redis::Cluster::V1::VERSION
568
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
569
+
570
+ options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
571
+ metadata: metadata,
572
+ retry_policy: @config.rpcs.wait_operation.retry_policy
573
+
574
+ options.apply_defaults timeout: @config.timeout,
575
+ metadata: @config.metadata,
576
+ retry_policy: @config.retry_policy
577
+
578
+ @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
579
+ response = ::Gapic::Operation.new response, @operations_client, options: options
580
+ yield response, operation if block_given?
581
+ return response
582
+ end
583
+ rescue ::GRPC::BadStatus => e
584
+ raise ::Google::Cloud::Error.from_error(e)
585
+ end
586
+
587
+ ##
588
+ # Configuration class for the Operations API.
589
+ #
590
+ # This class represents the configuration for Operations,
591
+ # providing control over timeouts, retry behavior, logging, transport
592
+ # parameters, and other low-level controls. Certain parameters can also be
593
+ # applied individually to specific RPCs. See
594
+ # {::Google::Longrunning::Operations::Client::Configuration::Rpcs}
595
+ # for a list of RPCs that can be configured independently.
596
+ #
597
+ # Configuration can be applied globally to all clients, or to a single client
598
+ # on construction.
599
+ #
600
+ # @example
601
+ #
602
+ # # Modify the global config, setting the timeout for
603
+ # # list_operations to 20 seconds,
604
+ # # and all remaining timeouts to 10 seconds.
605
+ # ::Google::Longrunning::Operations::Client.configure do |config|
606
+ # config.timeout = 10.0
607
+ # config.rpcs.list_operations.timeout = 20.0
608
+ # end
609
+ #
610
+ # # Apply the above configuration only to a new client.
611
+ # client = ::Google::Longrunning::Operations::Client.new do |config|
612
+ # config.timeout = 10.0
613
+ # config.rpcs.list_operations.timeout = 20.0
614
+ # end
615
+ #
616
+ # @!attribute [rw] endpoint
617
+ # The hostname or hostname:port of the service endpoint.
618
+ # Defaults to `"redis.googleapis.com"`.
619
+ # @return [::String]
620
+ # @!attribute [rw] credentials
621
+ # Credentials to send with calls. You may provide any of the following types:
622
+ # * (`String`) The path to a service account key file in JSON format
623
+ # * (`Hash`) A service account key as a Hash
624
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
625
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
626
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
627
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
628
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
629
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
630
+ # * (`nil`) indicating no credentials
631
+ # @return [::Object]
632
+ # @!attribute [rw] scope
633
+ # The OAuth scopes
634
+ # @return [::Array<::String>]
635
+ # @!attribute [rw] lib_name
636
+ # The library name as recorded in instrumentation and logging
637
+ # @return [::String]
638
+ # @!attribute [rw] lib_version
639
+ # The library version as recorded in instrumentation and logging
640
+ # @return [::String]
641
+ # @!attribute [rw] channel_args
642
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
643
+ # `GRPC::Core::Channel` object is provided as the credential.
644
+ # @return [::Hash]
645
+ # @!attribute [rw] interceptors
646
+ # An array of interceptors that are run before calls are executed.
647
+ # @return [::Array<::GRPC::ClientInterceptor>]
648
+ # @!attribute [rw] timeout
649
+ # The call timeout in seconds.
650
+ # @return [::Numeric]
651
+ # @!attribute [rw] metadata
652
+ # Additional gRPC headers to be sent with the call.
653
+ # @return [::Hash{::Symbol=>::String}]
654
+ # @!attribute [rw] retry_policy
655
+ # The retry policy. The value is a hash with the following keys:
656
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
657
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
658
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
659
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
660
+ # trigger a retry.
661
+ # @return [::Hash]
662
+ # @!attribute [rw] quota_project
663
+ # A separate project against which to charge quota.
664
+ # @return [::String]
665
+ #
666
+ class Configuration
667
+ extend ::Gapic::Config
668
+
669
+ DEFAULT_ENDPOINT = "redis.googleapis.com"
670
+
671
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
672
+ config_attr :credentials, nil do |value|
673
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
674
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
675
+ allowed.any? { |klass| klass === value }
676
+ end
677
+ config_attr :scope, nil, ::String, ::Array, nil
678
+ config_attr :lib_name, nil, ::String, nil
679
+ config_attr :lib_version, nil, ::String, nil
680
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
681
+ config_attr :interceptors, nil, ::Array, nil
682
+ config_attr :timeout, nil, ::Numeric, nil
683
+ config_attr :metadata, nil, ::Hash, nil
684
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
685
+ config_attr :quota_project, nil, ::String, nil
686
+
687
+ # @private
688
+ def initialize parent_config = nil
689
+ @parent_config = parent_config unless parent_config.nil?
690
+
691
+ yield self if block_given?
692
+ end
693
+
694
+ ##
695
+ # Configurations for individual RPCs
696
+ # @return [Rpcs]
697
+ #
698
+ def rpcs
699
+ @rpcs ||= begin
700
+ parent_rpcs = nil
701
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
702
+ Rpcs.new parent_rpcs
703
+ end
704
+ end
705
+
706
+ ##
707
+ # Configuration for the channel pool
708
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
709
+ #
710
+ def channel_pool
711
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
712
+ end
713
+
714
+ ##
715
+ # Configuration RPC class for the Operations API.
716
+ #
717
+ # Includes fields providing the configuration for each RPC in this service.
718
+ # Each configuration object is of type `Gapic::Config::Method` and includes
719
+ # the following configuration fields:
720
+ #
721
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
722
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
723
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
724
+ # include the following keys:
725
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
726
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
727
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
728
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
729
+ # trigger a retry.
730
+ #
731
+ class Rpcs
732
+ ##
733
+ # RPC-specific configuration for `list_operations`
734
+ # @return [::Gapic::Config::Method]
735
+ #
736
+ attr_reader :list_operations
737
+ ##
738
+ # RPC-specific configuration for `get_operation`
739
+ # @return [::Gapic::Config::Method]
740
+ #
741
+ attr_reader :get_operation
742
+ ##
743
+ # RPC-specific configuration for `delete_operation`
744
+ # @return [::Gapic::Config::Method]
745
+ #
746
+ attr_reader :delete_operation
747
+ ##
748
+ # RPC-specific configuration for `cancel_operation`
749
+ # @return [::Gapic::Config::Method]
750
+ #
751
+ attr_reader :cancel_operation
752
+ ##
753
+ # RPC-specific configuration for `wait_operation`
754
+ # @return [::Gapic::Config::Method]
755
+ #
756
+ attr_reader :wait_operation
757
+
758
+ # @private
759
+ def initialize parent_rpcs = nil
760
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
761
+ @list_operations = ::Gapic::Config::Method.new list_operations_config
762
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
763
+ @get_operation = ::Gapic::Config::Method.new get_operation_config
764
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
765
+ @delete_operation = ::Gapic::Config::Method.new delete_operation_config
766
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
767
+ @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
768
+ wait_operation_config = parent_rpcs.wait_operation if parent_rpcs.respond_to? :wait_operation
769
+ @wait_operation = ::Gapic::Config::Method.new wait_operation_config
770
+
771
+ yield self if block_given?
772
+ end
773
+ end
774
+ end
775
+ end
776
+ end
777
+ end
778
+ end
779
+ end
780
+ end
781
+ end