google-cloud-redis-cluster-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,918 @@
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 "google/cloud/errors"
20
+ require "google/cloud/redis/cluster/v1/cloud_redis_cluster_pb"
21
+ require "google/cloud/location"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Redis
26
+ module Cluster
27
+ module V1
28
+ module CloudRedisCluster
29
+ ##
30
+ # Client for the CloudRedisCluster service.
31
+ #
32
+ # Configures and manages Cloud Memorystore for Redis clusters
33
+ #
34
+ # Google Cloud Memorystore for Redis Cluster
35
+ #
36
+ # The `redis.googleapis.com` service implements the Google Cloud Memorystore
37
+ # for Redis API and defines the following resource model for managing Redis
38
+ # clusters:
39
+ # * The service works with a collection of cloud projects, named: `/projects/*`
40
+ # * Each project has a collection of available locations, named: `/locations/*`
41
+ # * Each location has a collection of Redis clusters, named: `/clusters/*`
42
+ # * As such, Redis clusters are resources of the form:
43
+ # `/projects/{project_id}/locations/{location_id}/clusters/{instance_id}`
44
+ #
45
+ # Note that location_id must be a GCP `region`; for example:
46
+ # * `projects/redpepper-1290/locations/us-central1/clusters/my-redis`
47
+ #
48
+ # We use API version selector for Flex APIs
49
+ # * The versioning strategy is release-based versioning
50
+ # * Our backend CLH only deals with the superset version (called v1main)
51
+ # * Existing backend for Redis Gen1 and MRR is not touched.
52
+ # * More details in go/redis-flex-api-versioning
53
+ #
54
+ class Client
55
+ include Paths
56
+
57
+ # @private
58
+ attr_reader :cloud_redis_cluster_stub
59
+
60
+ ##
61
+ # Configure the CloudRedisCluster Client class.
62
+ #
63
+ # See {::Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client::Configuration}
64
+ # for a description of the configuration fields.
65
+ #
66
+ # @example
67
+ #
68
+ # # Modify the configuration for all CloudRedisCluster clients
69
+ # ::Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client.configure do |config|
70
+ # config.timeout = 10.0
71
+ # end
72
+ #
73
+ # @yield [config] Configure the Client client.
74
+ # @yieldparam config [Client::Configuration]
75
+ #
76
+ # @return [Client::Configuration]
77
+ #
78
+ def self.configure
79
+ @configure ||= begin
80
+ namespace = ["Google", "Cloud", "Redis", "Cluster", "V1"]
81
+ parent_config = while namespace.any?
82
+ parent_name = namespace.join "::"
83
+ parent_const = const_get parent_name
84
+ break parent_const.configure if parent_const.respond_to? :configure
85
+ namespace.pop
86
+ end
87
+ default_config = Client::Configuration.new parent_config
88
+
89
+ default_config.rpcs.list_clusters.timeout = 600.0
90
+
91
+ default_config.rpcs.get_cluster.timeout = 600.0
92
+
93
+ default_config.rpcs.update_cluster.timeout = 600.0
94
+
95
+ default_config.rpcs.delete_cluster.timeout = 600.0
96
+
97
+ default_config.rpcs.create_cluster.timeout = 600.0
98
+
99
+ default_config
100
+ end
101
+ yield @configure if block_given?
102
+ @configure
103
+ end
104
+
105
+ ##
106
+ # Configure the CloudRedisCluster Client instance.
107
+ #
108
+ # The configuration is set to the derived mode, meaning that values can be changed,
109
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
110
+ # should be made on {Client.configure}.
111
+ #
112
+ # See {::Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client::Configuration}
113
+ # for a description of the configuration fields.
114
+ #
115
+ # @yield [config] Configure the Client client.
116
+ # @yieldparam config [Client::Configuration]
117
+ #
118
+ # @return [Client::Configuration]
119
+ #
120
+ def configure
121
+ yield @config if block_given?
122
+ @config
123
+ end
124
+
125
+ ##
126
+ # Create a new CloudRedisCluster client object.
127
+ #
128
+ # @example
129
+ #
130
+ # # Create a client using the default configuration
131
+ # client = ::Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client.new
132
+ #
133
+ # # Create a client using a custom configuration
134
+ # client = ::Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client.new do |config|
135
+ # config.timeout = 10.0
136
+ # end
137
+ #
138
+ # @yield [config] Configure the CloudRedisCluster client.
139
+ # @yieldparam config [Client::Configuration]
140
+ #
141
+ def initialize
142
+ # These require statements are intentionally placed here to initialize
143
+ # the gRPC module only when it's required.
144
+ # See https://github.com/googleapis/toolkit/issues/446
145
+ require "gapic/grpc"
146
+ require "google/cloud/redis/cluster/v1/cloud_redis_cluster_services_pb"
147
+
148
+ # Create the configuration object
149
+ @config = Configuration.new Client.configure
150
+
151
+ # Yield the configuration if needed
152
+ yield @config if block_given?
153
+
154
+ # Create credentials
155
+ credentials = @config.credentials
156
+ # Use self-signed JWT if the endpoint is unchanged from default,
157
+ # but only if the default endpoint does not have a region prefix.
158
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
159
+ !@config.endpoint.split(".").first.include?("-")
160
+ credentials ||= Credentials.default scope: @config.scope,
161
+ enable_self_signed_jwt: enable_self_signed_jwt
162
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
163
+ credentials = Credentials.new credentials, scope: @config.scope
164
+ end
165
+ @quota_project_id = @config.quota_project
166
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
167
+
168
+ @operations_client = Operations.new do |config|
169
+ config.credentials = credentials
170
+ config.quota_project = @quota_project_id
171
+ config.endpoint = @config.endpoint
172
+ end
173
+
174
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
175
+ config.credentials = credentials
176
+ config.quota_project = @quota_project_id
177
+ config.endpoint = @config.endpoint
178
+ end
179
+
180
+ @cloud_redis_cluster_stub = ::Gapic::ServiceStub.new(
181
+ ::Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Stub,
182
+ credentials: credentials,
183
+ endpoint: @config.endpoint,
184
+ channel_args: @config.channel_args,
185
+ interceptors: @config.interceptors,
186
+ channel_pool_config: @config.channel_pool
187
+ )
188
+ end
189
+
190
+ ##
191
+ # Get the associated client for long-running operations.
192
+ #
193
+ # @return [::Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Operations]
194
+ #
195
+ attr_reader :operations_client
196
+
197
+ ##
198
+ # Get the associated client for mix-in of the Locations.
199
+ #
200
+ # @return [Google::Cloud::Location::Locations::Client]
201
+ #
202
+ attr_reader :location_client
203
+
204
+ # Service calls
205
+
206
+ ##
207
+ # Lists all Redis clusters owned by a project in either the specified
208
+ # location (region) or all locations.
209
+ #
210
+ # The location should have the following format:
211
+ #
212
+ # * `projects/{project_id}/locations/{location_id}`
213
+ #
214
+ # If `location_id` is specified as `-` (wildcard), then all regions
215
+ # available to the project are queried, and the results are aggregated.
216
+ #
217
+ # @overload list_clusters(request, options = nil)
218
+ # Pass arguments to `list_clusters` via a request object, either of type
219
+ # {::Google::Cloud::Redis::Cluster::V1::ListClustersRequest} or an equivalent Hash.
220
+ #
221
+ # @param request [::Google::Cloud::Redis::Cluster::V1::ListClustersRequest, ::Hash]
222
+ # A request object representing the call parameters. Required. To specify no
223
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
224
+ # @param options [::Gapic::CallOptions, ::Hash]
225
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
226
+ #
227
+ # @overload list_clusters(parent: nil, page_size: nil, page_token: nil)
228
+ # Pass arguments to `list_clusters` via keyword arguments. Note that at
229
+ # least one keyword argument is required. To specify no parameters, or to keep all
230
+ # the default parameter values, pass an empty Hash as a request object (see above).
231
+ #
232
+ # @param parent [::String]
233
+ # Required. The resource name of the cluster location using the form:
234
+ # `projects/{project_id}/locations/{location_id}`
235
+ # where `location_id` refers to a GCP region.
236
+ # @param page_size [::Integer]
237
+ # The maximum number of items to return.
238
+ #
239
+ # If not specified, a default value of 1000 will be used by the service.
240
+ # Regardless of the page_size value, the response may include a partial list
241
+ # and a caller should only rely on response's
242
+ # {::Google::Cloud::Redis::Cluster::V1::ListClustersResponse#next_page_token `next_page_token`}
243
+ # to determine if there are more clusters left to be queried.
244
+ # @param page_token [::String]
245
+ # The `next_page_token` value returned from a previous
246
+ # [ListClusters][CloudRedis.ListClusters] request, if any.
247
+ #
248
+ # @yield [response, operation] Access the result along with the RPC operation
249
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Redis::Cluster::V1::Cluster>]
250
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
251
+ #
252
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Redis::Cluster::V1::Cluster>]
253
+ #
254
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
255
+ #
256
+ # @example Basic example
257
+ # require "google/cloud/redis/cluster/v1"
258
+ #
259
+ # # Create a client object. The client can be reused for multiple calls.
260
+ # client = Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client.new
261
+ #
262
+ # # Create a request. To set request fields, pass in keyword arguments.
263
+ # request = Google::Cloud::Redis::Cluster::V1::ListClustersRequest.new
264
+ #
265
+ # # Call the list_clusters method.
266
+ # result = client.list_clusters request
267
+ #
268
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
269
+ # # over elements, and API calls will be issued to fetch pages as needed.
270
+ # result.each do |item|
271
+ # # Each element is of type ::Google::Cloud::Redis::Cluster::V1::Cluster.
272
+ # p item
273
+ # end
274
+ #
275
+ def list_clusters request, options = nil
276
+ raise ::ArgumentError, "request must be provided" if request.nil?
277
+
278
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Redis::Cluster::V1::ListClustersRequest
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_clusters.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::Redis::Cluster::V1::VERSION
290
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
291
+
292
+ header_params = {}
293
+ if request.parent
294
+ header_params["parent"] = request.parent
295
+ end
296
+
297
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
298
+ metadata[:"x-goog-request-params"] ||= request_params_header
299
+
300
+ options.apply_defaults timeout: @config.rpcs.list_clusters.timeout,
301
+ metadata: metadata,
302
+ retry_policy: @config.rpcs.list_clusters.retry_policy
303
+
304
+ options.apply_defaults timeout: @config.timeout,
305
+ metadata: @config.metadata,
306
+ retry_policy: @config.retry_policy
307
+
308
+ @cloud_redis_cluster_stub.call_rpc :list_clusters, request, options: options do |response, operation|
309
+ response = ::Gapic::PagedEnumerable.new @cloud_redis_cluster_stub, :list_clusters, request, response, operation, options
310
+ yield response, operation if block_given?
311
+ return response
312
+ end
313
+ rescue ::GRPC::BadStatus => e
314
+ raise ::Google::Cloud::Error.from_error(e)
315
+ end
316
+
317
+ ##
318
+ # Gets the details of a specific Redis cluster.
319
+ #
320
+ # @overload get_cluster(request, options = nil)
321
+ # Pass arguments to `get_cluster` via a request object, either of type
322
+ # {::Google::Cloud::Redis::Cluster::V1::GetClusterRequest} or an equivalent Hash.
323
+ #
324
+ # @param request [::Google::Cloud::Redis::Cluster::V1::GetClusterRequest, ::Hash]
325
+ # A request object representing the call parameters. Required. To specify no
326
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
327
+ # @param options [::Gapic::CallOptions, ::Hash]
328
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
329
+ #
330
+ # @overload get_cluster(name: nil)
331
+ # Pass arguments to `get_cluster` via keyword arguments. Note that at
332
+ # least one keyword argument is required. To specify no parameters, or to keep all
333
+ # the default parameter values, pass an empty Hash as a request object (see above).
334
+ #
335
+ # @param name [::String]
336
+ # Required. Redis cluster resource name using the form:
337
+ # `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`
338
+ # where `location_id` refers to a GCP region.
339
+ #
340
+ # @yield [response, operation] Access the result along with the RPC operation
341
+ # @yieldparam response [::Google::Cloud::Redis::Cluster::V1::Cluster]
342
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
343
+ #
344
+ # @return [::Google::Cloud::Redis::Cluster::V1::Cluster]
345
+ #
346
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
347
+ #
348
+ # @example Basic example
349
+ # require "google/cloud/redis/cluster/v1"
350
+ #
351
+ # # Create a client object. The client can be reused for multiple calls.
352
+ # client = Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client.new
353
+ #
354
+ # # Create a request. To set request fields, pass in keyword arguments.
355
+ # request = Google::Cloud::Redis::Cluster::V1::GetClusterRequest.new
356
+ #
357
+ # # Call the get_cluster method.
358
+ # result = client.get_cluster request
359
+ #
360
+ # # The returned object is of type Google::Cloud::Redis::Cluster::V1::Cluster.
361
+ # p result
362
+ #
363
+ def get_cluster request, options = nil
364
+ raise ::ArgumentError, "request must be provided" if request.nil?
365
+
366
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Redis::Cluster::V1::GetClusterRequest
367
+
368
+ # Converts hash and nil to an options object
369
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
370
+
371
+ # Customize the options with defaults
372
+ metadata = @config.rpcs.get_cluster.metadata.to_h
373
+
374
+ # Set x-goog-api-client and x-goog-user-project headers
375
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
376
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
377
+ gapic_version: ::Google::Cloud::Redis::Cluster::V1::VERSION
378
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
379
+
380
+ header_params = {}
381
+ if request.name
382
+ header_params["name"] = request.name
383
+ end
384
+
385
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
386
+ metadata[:"x-goog-request-params"] ||= request_params_header
387
+
388
+ options.apply_defaults timeout: @config.rpcs.get_cluster.timeout,
389
+ metadata: metadata,
390
+ retry_policy: @config.rpcs.get_cluster.retry_policy
391
+
392
+ options.apply_defaults timeout: @config.timeout,
393
+ metadata: @config.metadata,
394
+ retry_policy: @config.retry_policy
395
+
396
+ @cloud_redis_cluster_stub.call_rpc :get_cluster, request, options: options do |response, operation|
397
+ yield response, operation if block_given?
398
+ return response
399
+ end
400
+ rescue ::GRPC::BadStatus => e
401
+ raise ::Google::Cloud::Error.from_error(e)
402
+ end
403
+
404
+ ##
405
+ # Updates the metadata and configuration of a specific Redis cluster.
406
+ #
407
+ # Completed longrunning.Operation will contain the new cluster object
408
+ # in the response field. The returned operation is automatically deleted
409
+ # after a few hours, so there is no need to call DeleteOperation.
410
+ #
411
+ # @overload update_cluster(request, options = nil)
412
+ # Pass arguments to `update_cluster` via a request object, either of type
413
+ # {::Google::Cloud::Redis::Cluster::V1::UpdateClusterRequest} or an equivalent Hash.
414
+ #
415
+ # @param request [::Google::Cloud::Redis::Cluster::V1::UpdateClusterRequest, ::Hash]
416
+ # A request object representing the call parameters. Required. To specify no
417
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
418
+ # @param options [::Gapic::CallOptions, ::Hash]
419
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
420
+ #
421
+ # @overload update_cluster(update_mask: nil, cluster: nil, request_id: nil)
422
+ # Pass arguments to `update_cluster` via keyword arguments. Note that at
423
+ # least one keyword argument is required. To specify no parameters, or to keep all
424
+ # the default parameter values, pass an empty Hash as a request object (see above).
425
+ #
426
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
427
+ # Required. Mask of fields to update. At least one path must be supplied in
428
+ # this field. The elements of the repeated paths field may only include these
429
+ # fields from {::Google::Cloud::Redis::Cluster::V1::Cluster Cluster}:
430
+ #
431
+ # * `size_gb`
432
+ # * `replica_count`
433
+ # @param cluster [::Google::Cloud::Redis::Cluster::V1::Cluster, ::Hash]
434
+ # Required. Update description.
435
+ # Only fields specified in update_mask are updated.
436
+ # @param request_id [::String]
437
+ # Idempotent request UUID.
438
+ #
439
+ # @yield [response, operation] Access the result along with the RPC operation
440
+ # @yieldparam response [::Gapic::Operation]
441
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
442
+ #
443
+ # @return [::Gapic::Operation]
444
+ #
445
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
446
+ #
447
+ # @example Basic example
448
+ # require "google/cloud/redis/cluster/v1"
449
+ #
450
+ # # Create a client object. The client can be reused for multiple calls.
451
+ # client = Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client.new
452
+ #
453
+ # # Create a request. To set request fields, pass in keyword arguments.
454
+ # request = Google::Cloud::Redis::Cluster::V1::UpdateClusterRequest.new
455
+ #
456
+ # # Call the update_cluster method.
457
+ # result = client.update_cluster request
458
+ #
459
+ # # The returned object is of type Gapic::Operation. You can use it to
460
+ # # check the status of an operation, cancel it, or wait for results.
461
+ # # Here is how to wait for a response.
462
+ # result.wait_until_done! timeout: 60
463
+ # if result.response?
464
+ # p result.response
465
+ # else
466
+ # puts "No response received."
467
+ # end
468
+ #
469
+ def update_cluster request, options = nil
470
+ raise ::ArgumentError, "request must be provided" if request.nil?
471
+
472
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Redis::Cluster::V1::UpdateClusterRequest
473
+
474
+ # Converts hash and nil to an options object
475
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
476
+
477
+ # Customize the options with defaults
478
+ metadata = @config.rpcs.update_cluster.metadata.to_h
479
+
480
+ # Set x-goog-api-client and x-goog-user-project headers
481
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
482
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
483
+ gapic_version: ::Google::Cloud::Redis::Cluster::V1::VERSION
484
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
485
+
486
+ header_params = {}
487
+ if request.cluster&.name
488
+ header_params["cluster.name"] = request.cluster.name
489
+ end
490
+
491
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
492
+ metadata[:"x-goog-request-params"] ||= request_params_header
493
+
494
+ options.apply_defaults timeout: @config.rpcs.update_cluster.timeout,
495
+ metadata: metadata,
496
+ retry_policy: @config.rpcs.update_cluster.retry_policy
497
+
498
+ options.apply_defaults timeout: @config.timeout,
499
+ metadata: @config.metadata,
500
+ retry_policy: @config.retry_policy
501
+
502
+ @cloud_redis_cluster_stub.call_rpc :update_cluster, request, options: options do |response, operation|
503
+ response = ::Gapic::Operation.new response, @operations_client, options: options
504
+ yield response, operation if block_given?
505
+ return response
506
+ end
507
+ rescue ::GRPC::BadStatus => e
508
+ raise ::Google::Cloud::Error.from_error(e)
509
+ end
510
+
511
+ ##
512
+ # Deletes a specific Redis cluster. Cluster stops serving and data is
513
+ # deleted.
514
+ #
515
+ # @overload delete_cluster(request, options = nil)
516
+ # Pass arguments to `delete_cluster` via a request object, either of type
517
+ # {::Google::Cloud::Redis::Cluster::V1::DeleteClusterRequest} or an equivalent Hash.
518
+ #
519
+ # @param request [::Google::Cloud::Redis::Cluster::V1::DeleteClusterRequest, ::Hash]
520
+ # A request object representing the call parameters. Required. To specify no
521
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
522
+ # @param options [::Gapic::CallOptions, ::Hash]
523
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
524
+ #
525
+ # @overload delete_cluster(name: nil, request_id: nil)
526
+ # Pass arguments to `delete_cluster` via keyword arguments. Note that at
527
+ # least one keyword argument is required. To specify no parameters, or to keep all
528
+ # the default parameter values, pass an empty Hash as a request object (see above).
529
+ #
530
+ # @param name [::String]
531
+ # Required. Redis cluster resource name using the form:
532
+ # `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`
533
+ # where `location_id` refers to a GCP region.
534
+ # @param request_id [::String]
535
+ # Idempotent request UUID.
536
+ #
537
+ # @yield [response, operation] Access the result along with the RPC operation
538
+ # @yieldparam response [::Gapic::Operation]
539
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
540
+ #
541
+ # @return [::Gapic::Operation]
542
+ #
543
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
544
+ #
545
+ # @example Basic example
546
+ # require "google/cloud/redis/cluster/v1"
547
+ #
548
+ # # Create a client object. The client can be reused for multiple calls.
549
+ # client = Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client.new
550
+ #
551
+ # # Create a request. To set request fields, pass in keyword arguments.
552
+ # request = Google::Cloud::Redis::Cluster::V1::DeleteClusterRequest.new
553
+ #
554
+ # # Call the delete_cluster method.
555
+ # result = client.delete_cluster request
556
+ #
557
+ # # The returned object is of type Gapic::Operation. You can use it to
558
+ # # check the status of an operation, cancel it, or wait for results.
559
+ # # Here is how to wait for a response.
560
+ # result.wait_until_done! timeout: 60
561
+ # if result.response?
562
+ # p result.response
563
+ # else
564
+ # puts "No response received."
565
+ # end
566
+ #
567
+ def delete_cluster request, options = nil
568
+ raise ::ArgumentError, "request must be provided" if request.nil?
569
+
570
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Redis::Cluster::V1::DeleteClusterRequest
571
+
572
+ # Converts hash and nil to an options object
573
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
574
+
575
+ # Customize the options with defaults
576
+ metadata = @config.rpcs.delete_cluster.metadata.to_h
577
+
578
+ # Set x-goog-api-client and x-goog-user-project headers
579
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
580
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
581
+ gapic_version: ::Google::Cloud::Redis::Cluster::V1::VERSION
582
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
583
+
584
+ header_params = {}
585
+ if request.name
586
+ header_params["name"] = request.name
587
+ end
588
+
589
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
590
+ metadata[:"x-goog-request-params"] ||= request_params_header
591
+
592
+ options.apply_defaults timeout: @config.rpcs.delete_cluster.timeout,
593
+ metadata: metadata,
594
+ retry_policy: @config.rpcs.delete_cluster.retry_policy
595
+
596
+ options.apply_defaults timeout: @config.timeout,
597
+ metadata: @config.metadata,
598
+ retry_policy: @config.retry_policy
599
+
600
+ @cloud_redis_cluster_stub.call_rpc :delete_cluster, request, options: options do |response, operation|
601
+ response = ::Gapic::Operation.new response, @operations_client, options: options
602
+ yield response, operation if block_given?
603
+ return response
604
+ end
605
+ rescue ::GRPC::BadStatus => e
606
+ raise ::Google::Cloud::Error.from_error(e)
607
+ end
608
+
609
+ ##
610
+ # Creates a Redis cluster based on the specified properties.
611
+ # The creation is executed asynchronously and callers may check the returned
612
+ # operation to track its progress. Once the operation is completed the Redis
613
+ # cluster will be fully functional. The completed longrunning.Operation will
614
+ # contain the new cluster object in the response field.
615
+ #
616
+ # The returned operation is automatically deleted after a few hours, so there
617
+ # is no need to call DeleteOperation.
618
+ #
619
+ # @overload create_cluster(request, options = nil)
620
+ # Pass arguments to `create_cluster` via a request object, either of type
621
+ # {::Google::Cloud::Redis::Cluster::V1::CreateClusterRequest} or an equivalent Hash.
622
+ #
623
+ # @param request [::Google::Cloud::Redis::Cluster::V1::CreateClusterRequest, ::Hash]
624
+ # A request object representing the call parameters. Required. To specify no
625
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
626
+ # @param options [::Gapic::CallOptions, ::Hash]
627
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
628
+ #
629
+ # @overload create_cluster(parent: nil, cluster_id: nil, cluster: nil, request_id: nil)
630
+ # Pass arguments to `create_cluster` via keyword arguments. Note that at
631
+ # least one keyword argument is required. To specify no parameters, or to keep all
632
+ # the default parameter values, pass an empty Hash as a request object (see above).
633
+ #
634
+ # @param parent [::String]
635
+ # Required. The resource name of the cluster location using the form:
636
+ # `projects/{project_id}/locations/{location_id}`
637
+ # where `location_id` refers to a GCP region.
638
+ # @param cluster_id [::String]
639
+ # Required. The logical name of the Redis cluster in the customer project
640
+ # with the following restrictions:
641
+ #
642
+ # * Must contain only lowercase letters, numbers, and hyphens.
643
+ # * Must start with a letter.
644
+ # * Must be between 1-63 characters.
645
+ # * Must end with a number or a letter.
646
+ # * Must be unique within the customer project / location
647
+ # @param cluster [::Google::Cloud::Redis::Cluster::V1::Cluster, ::Hash]
648
+ # Required. The cluster that is to be created.
649
+ # @param request_id [::String]
650
+ # Idempotent request UUID.
651
+ #
652
+ # @yield [response, operation] Access the result along with the RPC operation
653
+ # @yieldparam response [::Gapic::Operation]
654
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
655
+ #
656
+ # @return [::Gapic::Operation]
657
+ #
658
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
659
+ #
660
+ # @example Basic example
661
+ # require "google/cloud/redis/cluster/v1"
662
+ #
663
+ # # Create a client object. The client can be reused for multiple calls.
664
+ # client = Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client.new
665
+ #
666
+ # # Create a request. To set request fields, pass in keyword arguments.
667
+ # request = Google::Cloud::Redis::Cluster::V1::CreateClusterRequest.new
668
+ #
669
+ # # Call the create_cluster method.
670
+ # result = client.create_cluster request
671
+ #
672
+ # # The returned object is of type Gapic::Operation. You can use it to
673
+ # # check the status of an operation, cancel it, or wait for results.
674
+ # # Here is how to wait for a response.
675
+ # result.wait_until_done! timeout: 60
676
+ # if result.response?
677
+ # p result.response
678
+ # else
679
+ # puts "No response received."
680
+ # end
681
+ #
682
+ def create_cluster request, options = nil
683
+ raise ::ArgumentError, "request must be provided" if request.nil?
684
+
685
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Redis::Cluster::V1::CreateClusterRequest
686
+
687
+ # Converts hash and nil to an options object
688
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
689
+
690
+ # Customize the options with defaults
691
+ metadata = @config.rpcs.create_cluster.metadata.to_h
692
+
693
+ # Set x-goog-api-client and x-goog-user-project headers
694
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
695
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
696
+ gapic_version: ::Google::Cloud::Redis::Cluster::V1::VERSION
697
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
698
+
699
+ header_params = {}
700
+ if request.parent
701
+ header_params["parent"] = request.parent
702
+ end
703
+
704
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
705
+ metadata[:"x-goog-request-params"] ||= request_params_header
706
+
707
+ options.apply_defaults timeout: @config.rpcs.create_cluster.timeout,
708
+ metadata: metadata,
709
+ retry_policy: @config.rpcs.create_cluster.retry_policy
710
+
711
+ options.apply_defaults timeout: @config.timeout,
712
+ metadata: @config.metadata,
713
+ retry_policy: @config.retry_policy
714
+
715
+ @cloud_redis_cluster_stub.call_rpc :create_cluster, request, options: options do |response, operation|
716
+ response = ::Gapic::Operation.new response, @operations_client, options: options
717
+ yield response, operation if block_given?
718
+ return response
719
+ end
720
+ rescue ::GRPC::BadStatus => e
721
+ raise ::Google::Cloud::Error.from_error(e)
722
+ end
723
+
724
+ ##
725
+ # Configuration class for the CloudRedisCluster API.
726
+ #
727
+ # This class represents the configuration for CloudRedisCluster,
728
+ # providing control over timeouts, retry behavior, logging, transport
729
+ # parameters, and other low-level controls. Certain parameters can also be
730
+ # applied individually to specific RPCs. See
731
+ # {::Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client::Configuration::Rpcs}
732
+ # for a list of RPCs that can be configured independently.
733
+ #
734
+ # Configuration can be applied globally to all clients, or to a single client
735
+ # on construction.
736
+ #
737
+ # @example
738
+ #
739
+ # # Modify the global config, setting the timeout for
740
+ # # list_clusters to 20 seconds,
741
+ # # and all remaining timeouts to 10 seconds.
742
+ # ::Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client.configure do |config|
743
+ # config.timeout = 10.0
744
+ # config.rpcs.list_clusters.timeout = 20.0
745
+ # end
746
+ #
747
+ # # Apply the above configuration only to a new client.
748
+ # client = ::Google::Cloud::Redis::Cluster::V1::CloudRedisCluster::Client.new do |config|
749
+ # config.timeout = 10.0
750
+ # config.rpcs.list_clusters.timeout = 20.0
751
+ # end
752
+ #
753
+ # @!attribute [rw] endpoint
754
+ # The hostname or hostname:port of the service endpoint.
755
+ # Defaults to `"redis.googleapis.com"`.
756
+ # @return [::String]
757
+ # @!attribute [rw] credentials
758
+ # Credentials to send with calls. You may provide any of the following types:
759
+ # * (`String`) The path to a service account key file in JSON format
760
+ # * (`Hash`) A service account key as a Hash
761
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
762
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
763
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
764
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
765
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
766
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
767
+ # * (`nil`) indicating no credentials
768
+ # @return [::Object]
769
+ # @!attribute [rw] scope
770
+ # The OAuth scopes
771
+ # @return [::Array<::String>]
772
+ # @!attribute [rw] lib_name
773
+ # The library name as recorded in instrumentation and logging
774
+ # @return [::String]
775
+ # @!attribute [rw] lib_version
776
+ # The library version as recorded in instrumentation and logging
777
+ # @return [::String]
778
+ # @!attribute [rw] channel_args
779
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
780
+ # `GRPC::Core::Channel` object is provided as the credential.
781
+ # @return [::Hash]
782
+ # @!attribute [rw] interceptors
783
+ # An array of interceptors that are run before calls are executed.
784
+ # @return [::Array<::GRPC::ClientInterceptor>]
785
+ # @!attribute [rw] timeout
786
+ # The call timeout in seconds.
787
+ # @return [::Numeric]
788
+ # @!attribute [rw] metadata
789
+ # Additional gRPC headers to be sent with the call.
790
+ # @return [::Hash{::Symbol=>::String}]
791
+ # @!attribute [rw] retry_policy
792
+ # The retry policy. The value is a hash with the following keys:
793
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
794
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
795
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
796
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
797
+ # trigger a retry.
798
+ # @return [::Hash]
799
+ # @!attribute [rw] quota_project
800
+ # A separate project against which to charge quota.
801
+ # @return [::String]
802
+ #
803
+ class Configuration
804
+ extend ::Gapic::Config
805
+
806
+ DEFAULT_ENDPOINT = "redis.googleapis.com"
807
+
808
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
809
+ config_attr :credentials, nil do |value|
810
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
811
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
812
+ allowed.any? { |klass| klass === value }
813
+ end
814
+ config_attr :scope, nil, ::String, ::Array, nil
815
+ config_attr :lib_name, nil, ::String, nil
816
+ config_attr :lib_version, nil, ::String, nil
817
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
818
+ config_attr :interceptors, nil, ::Array, nil
819
+ config_attr :timeout, nil, ::Numeric, nil
820
+ config_attr :metadata, nil, ::Hash, nil
821
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
822
+ config_attr :quota_project, nil, ::String, nil
823
+
824
+ # @private
825
+ def initialize parent_config = nil
826
+ @parent_config = parent_config unless parent_config.nil?
827
+
828
+ yield self if block_given?
829
+ end
830
+
831
+ ##
832
+ # Configurations for individual RPCs
833
+ # @return [Rpcs]
834
+ #
835
+ def rpcs
836
+ @rpcs ||= begin
837
+ parent_rpcs = nil
838
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
839
+ Rpcs.new parent_rpcs
840
+ end
841
+ end
842
+
843
+ ##
844
+ # Configuration for the channel pool
845
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
846
+ #
847
+ def channel_pool
848
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
849
+ end
850
+
851
+ ##
852
+ # Configuration RPC class for the CloudRedisCluster API.
853
+ #
854
+ # Includes fields providing the configuration for each RPC in this service.
855
+ # Each configuration object is of type `Gapic::Config::Method` and includes
856
+ # the following configuration fields:
857
+ #
858
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
859
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
860
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
861
+ # include the following keys:
862
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
863
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
864
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
865
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
866
+ # trigger a retry.
867
+ #
868
+ class Rpcs
869
+ ##
870
+ # RPC-specific configuration for `list_clusters`
871
+ # @return [::Gapic::Config::Method]
872
+ #
873
+ attr_reader :list_clusters
874
+ ##
875
+ # RPC-specific configuration for `get_cluster`
876
+ # @return [::Gapic::Config::Method]
877
+ #
878
+ attr_reader :get_cluster
879
+ ##
880
+ # RPC-specific configuration for `update_cluster`
881
+ # @return [::Gapic::Config::Method]
882
+ #
883
+ attr_reader :update_cluster
884
+ ##
885
+ # RPC-specific configuration for `delete_cluster`
886
+ # @return [::Gapic::Config::Method]
887
+ #
888
+ attr_reader :delete_cluster
889
+ ##
890
+ # RPC-specific configuration for `create_cluster`
891
+ # @return [::Gapic::Config::Method]
892
+ #
893
+ attr_reader :create_cluster
894
+
895
+ # @private
896
+ def initialize parent_rpcs = nil
897
+ list_clusters_config = parent_rpcs.list_clusters if parent_rpcs.respond_to? :list_clusters
898
+ @list_clusters = ::Gapic::Config::Method.new list_clusters_config
899
+ get_cluster_config = parent_rpcs.get_cluster if parent_rpcs.respond_to? :get_cluster
900
+ @get_cluster = ::Gapic::Config::Method.new get_cluster_config
901
+ update_cluster_config = parent_rpcs.update_cluster if parent_rpcs.respond_to? :update_cluster
902
+ @update_cluster = ::Gapic::Config::Method.new update_cluster_config
903
+ delete_cluster_config = parent_rpcs.delete_cluster if parent_rpcs.respond_to? :delete_cluster
904
+ @delete_cluster = ::Gapic::Config::Method.new delete_cluster_config
905
+ create_cluster_config = parent_rpcs.create_cluster if parent_rpcs.respond_to? :create_cluster
906
+ @create_cluster = ::Gapic::Config::Method.new create_cluster_config
907
+
908
+ yield self if block_given?
909
+ end
910
+ end
911
+ end
912
+ end
913
+ end
914
+ end
915
+ end
916
+ end
917
+ end
918
+ end