google-cloud-memcache-v1 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,963 @@
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/memcache/v1/cloud_memcache_pb"
21
+ require "google/cloud/memcache/v1/cloud_memcache/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module Memcache
27
+ module V1
28
+ module CloudMemcache
29
+ module Rest
30
+ ##
31
+ # REST client for the CloudMemcache service.
32
+ #
33
+ # Configures and manages Cloud Memorystore for Memcached instances.
34
+ #
35
+ #
36
+ # The `memcache.googleapis.com` service implements the Google Cloud Memorystore
37
+ # for Memcached API and defines the following resource model for managing
38
+ # Memorystore Memcached (also called Memcached below) instances:
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 Memcached instances, named:
42
+ # `/instances/*`
43
+ # * As such, Memcached instances are resources of the form:
44
+ # `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
45
+ #
46
+ # Note that location_id must be a GCP `region`; for example:
47
+ # * `projects/my-memcached-project/locations/us-central1/instances/my-memcached`
48
+ #
49
+ class Client
50
+ include Paths
51
+
52
+ # @private
53
+ attr_reader :cloud_memcache_stub
54
+
55
+ ##
56
+ # Configure the CloudMemcache Client class.
57
+ #
58
+ # See {::Google::Cloud::Memcache::V1::CloudMemcache::Rest::Client::Configuration}
59
+ # for a description of the configuration fields.
60
+ #
61
+ # @example
62
+ #
63
+ # # Modify the configuration for all CloudMemcache clients
64
+ # ::Google::Cloud::Memcache::V1::CloudMemcache::Rest::Client.configure do |config|
65
+ # config.timeout = 10.0
66
+ # end
67
+ #
68
+ # @yield [config] Configure the Client client.
69
+ # @yieldparam config [Client::Configuration]
70
+ #
71
+ # @return [Client::Configuration]
72
+ #
73
+ def self.configure
74
+ @configure ||= begin
75
+ namespace = ["Google", "Cloud", "Memcache", "V1"]
76
+ parent_config = while namespace.any?
77
+ parent_name = namespace.join "::"
78
+ parent_const = const_get parent_name
79
+ break parent_const.configure if parent_const.respond_to? :configure
80
+ namespace.pop
81
+ end
82
+ default_config = Client::Configuration.new parent_config
83
+
84
+ default_config.rpcs.list_instances.timeout = 1200.0
85
+
86
+ default_config.rpcs.get_instance.timeout = 1200.0
87
+
88
+ default_config.rpcs.create_instance.timeout = 1200.0
89
+
90
+ default_config.rpcs.update_instance.timeout = 1200.0
91
+
92
+ default_config.rpcs.update_parameters.timeout = 1200.0
93
+
94
+ default_config.rpcs.delete_instance.timeout = 1200.0
95
+
96
+ default_config.rpcs.apply_parameters.timeout = 1200.0
97
+
98
+ default_config.rpcs.reschedule_maintenance.timeout = 1200.0
99
+
100
+ default_config
101
+ end
102
+ yield @configure if block_given?
103
+ @configure
104
+ end
105
+
106
+ ##
107
+ # Configure the CloudMemcache Client instance.
108
+ #
109
+ # The configuration is set to the derived mode, meaning that values can be changed,
110
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
111
+ # should be made on {Client.configure}.
112
+ #
113
+ # See {::Google::Cloud::Memcache::V1::CloudMemcache::Rest::Client::Configuration}
114
+ # for a description of the configuration fields.
115
+ #
116
+ # @yield [config] Configure the Client client.
117
+ # @yieldparam config [Client::Configuration]
118
+ #
119
+ # @return [Client::Configuration]
120
+ #
121
+ def configure
122
+ yield @config if block_given?
123
+ @config
124
+ end
125
+
126
+ ##
127
+ # Create a new CloudMemcache REST client object.
128
+ #
129
+ # @example
130
+ #
131
+ # # Create a client using the default configuration
132
+ # client = ::Google::Cloud::Memcache::V1::CloudMemcache::Rest::Client.new
133
+ #
134
+ # # Create a client using a custom configuration
135
+ # client = ::Google::Cloud::Memcache::V1::CloudMemcache::Rest::Client.new do |config|
136
+ # config.timeout = 10.0
137
+ # end
138
+ #
139
+ # @yield [config] Configure the CloudMemcache client.
140
+ # @yieldparam config [Client::Configuration]
141
+ #
142
+ def initialize
143
+ # Create the configuration object
144
+ @config = Configuration.new Client.configure
145
+
146
+ # Yield the configuration if needed
147
+ yield @config if block_given?
148
+
149
+ # Create credentials
150
+ credentials = @config.credentials
151
+ # Use self-signed JWT if the endpoint is unchanged from default,
152
+ # but only if the default endpoint does not have a region prefix.
153
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
154
+ !@config.endpoint.split(".").first.include?("-")
155
+ credentials ||= Credentials.default scope: @config.scope,
156
+ enable_self_signed_jwt: enable_self_signed_jwt
157
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
158
+ credentials = Credentials.new credentials, scope: @config.scope
159
+ end
160
+
161
+ @quota_project_id = @config.quota_project
162
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
163
+
164
+ @operations_client = ::Google::Cloud::Memcache::V1::CloudMemcache::Rest::Operations.new do |config|
165
+ config.credentials = credentials
166
+ config.quota_project = @quota_project_id
167
+ config.endpoint = @config.endpoint
168
+ end
169
+
170
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
171
+ config.credentials = credentials
172
+ config.quota_project = @quota_project_id
173
+ config.endpoint = @config.endpoint
174
+ config.bindings_override = @config.bindings_override
175
+ end
176
+
177
+ @cloud_memcache_stub = ::Google::Cloud::Memcache::V1::CloudMemcache::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
178
+ end
179
+
180
+ ##
181
+ # Get the associated client for long-running operations.
182
+ #
183
+ # @return [::Google::Cloud::Memcache::V1::CloudMemcache::Rest::Operations]
184
+ #
185
+ attr_reader :operations_client
186
+
187
+ ##
188
+ # Get the associated client for mix-in of the Locations.
189
+ #
190
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
191
+ #
192
+ attr_reader :location_client
193
+
194
+ # Service calls
195
+
196
+ ##
197
+ # Lists Instances in a given location.
198
+ #
199
+ # @overload list_instances(request, options = nil)
200
+ # Pass arguments to `list_instances` via a request object, either of type
201
+ # {::Google::Cloud::Memcache::V1::ListInstancesRequest} or an equivalent Hash.
202
+ #
203
+ # @param request [::Google::Cloud::Memcache::V1::ListInstancesRequest, ::Hash]
204
+ # A request object representing the call parameters. Required. To specify no
205
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
206
+ # @param options [::Gapic::CallOptions, ::Hash]
207
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
208
+ #
209
+ # @overload list_instances(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil)
210
+ # Pass arguments to `list_instances` via keyword arguments. Note that at
211
+ # least one keyword argument is required. To specify no parameters, or to keep all
212
+ # the default parameter values, pass an empty Hash as a request object (see above).
213
+ #
214
+ # @param parent [::String]
215
+ # Required. The resource name of the instance location using the form:
216
+ # `projects/{project_id}/locations/{location_id}`
217
+ # where `location_id` refers to a GCP region
218
+ # @param page_size [::Integer]
219
+ # The maximum number of items to return.
220
+ #
221
+ # If not specified, a default value of 1000 will be used by the service.
222
+ # Regardless of the `page_size` value, the response may include a partial
223
+ # list and a caller should only rely on response's
224
+ # {::Google::Cloud::Memcache::V1::ListInstancesResponse#next_page_token `next_page_token`}
225
+ # to determine if there are more instances left to be queried.
226
+ # @param page_token [::String]
227
+ # The `next_page_token` value returned from a previous List request, if any.
228
+ # @param filter [::String]
229
+ # List filter. For example, exclude all Memcached instances with name as
230
+ # my-instance by specifying `"name != my-instance"`.
231
+ # @param order_by [::String]
232
+ # Sort results. Supported values are "name", "name desc" or "" (unsorted).
233
+ # @yield [result, operation] Access the result along with the TransportOperation object
234
+ # @yieldparam result [::Google::Cloud::Memcache::V1::ListInstancesResponse]
235
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
236
+ #
237
+ # @return [::Google::Cloud::Memcache::V1::ListInstancesResponse]
238
+ #
239
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
240
+ def list_instances request, options = nil
241
+ raise ::ArgumentError, "request must be provided" if request.nil?
242
+
243
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1::ListInstancesRequest
244
+
245
+ # Converts hash and nil to an options object
246
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
247
+
248
+ # Customize the options with defaults
249
+ call_metadata = @config.rpcs.list_instances.metadata.to_h
250
+
251
+ # Set x-goog-api-client and x-goog-user-project headers
252
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
253
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
254
+ gapic_version: ::Google::Cloud::Memcache::V1::VERSION,
255
+ transports_version_send: [:rest]
256
+
257
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
258
+
259
+ options.apply_defaults timeout: @config.rpcs.list_instances.timeout,
260
+ metadata: call_metadata,
261
+ retry_policy: @config.rpcs.list_instances.retry_policy
262
+
263
+ options.apply_defaults timeout: @config.timeout,
264
+ metadata: @config.metadata,
265
+ retry_policy: @config.retry_policy
266
+
267
+ @cloud_memcache_stub.list_instances request, options do |result, operation|
268
+ yield result, operation if block_given?
269
+ return result
270
+ end
271
+ rescue ::Gapic::Rest::Error => e
272
+ raise ::Google::Cloud::Error.from_error(e)
273
+ end
274
+
275
+ ##
276
+ # Gets details of a single Instance.
277
+ #
278
+ # @overload get_instance(request, options = nil)
279
+ # Pass arguments to `get_instance` via a request object, either of type
280
+ # {::Google::Cloud::Memcache::V1::GetInstanceRequest} or an equivalent Hash.
281
+ #
282
+ # @param request [::Google::Cloud::Memcache::V1::GetInstanceRequest, ::Hash]
283
+ # A request object representing the call parameters. Required. To specify no
284
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
285
+ # @param options [::Gapic::CallOptions, ::Hash]
286
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
287
+ #
288
+ # @overload get_instance(name: nil)
289
+ # Pass arguments to `get_instance` via keyword arguments. Note that at
290
+ # least one keyword argument is required. To specify no parameters, or to keep all
291
+ # the default parameter values, pass an empty Hash as a request object (see above).
292
+ #
293
+ # @param name [::String]
294
+ # Required. Memcached instance resource name in the format:
295
+ # `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
296
+ # where `location_id` refers to a GCP region
297
+ # @yield [result, operation] Access the result along with the TransportOperation object
298
+ # @yieldparam result [::Google::Cloud::Memcache::V1::Instance]
299
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
300
+ #
301
+ # @return [::Google::Cloud::Memcache::V1::Instance]
302
+ #
303
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
304
+ def get_instance request, options = nil
305
+ raise ::ArgumentError, "request must be provided" if request.nil?
306
+
307
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1::GetInstanceRequest
308
+
309
+ # Converts hash and nil to an options object
310
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
311
+
312
+ # Customize the options with defaults
313
+ call_metadata = @config.rpcs.get_instance.metadata.to_h
314
+
315
+ # Set x-goog-api-client and x-goog-user-project headers
316
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
317
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
318
+ gapic_version: ::Google::Cloud::Memcache::V1::VERSION,
319
+ transports_version_send: [:rest]
320
+
321
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
322
+
323
+ options.apply_defaults timeout: @config.rpcs.get_instance.timeout,
324
+ metadata: call_metadata,
325
+ retry_policy: @config.rpcs.get_instance.retry_policy
326
+
327
+ options.apply_defaults timeout: @config.timeout,
328
+ metadata: @config.metadata,
329
+ retry_policy: @config.retry_policy
330
+
331
+ @cloud_memcache_stub.get_instance request, options do |result, operation|
332
+ yield result, operation if block_given?
333
+ return result
334
+ end
335
+ rescue ::Gapic::Rest::Error => e
336
+ raise ::Google::Cloud::Error.from_error(e)
337
+ end
338
+
339
+ ##
340
+ # Creates a new Instance in a given location.
341
+ #
342
+ # @overload create_instance(request, options = nil)
343
+ # Pass arguments to `create_instance` via a request object, either of type
344
+ # {::Google::Cloud::Memcache::V1::CreateInstanceRequest} or an equivalent Hash.
345
+ #
346
+ # @param request [::Google::Cloud::Memcache::V1::CreateInstanceRequest, ::Hash]
347
+ # A request object representing the call parameters. Required. To specify no
348
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
349
+ # @param options [::Gapic::CallOptions, ::Hash]
350
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
351
+ #
352
+ # @overload create_instance(parent: nil, instance_id: nil, instance: nil)
353
+ # Pass arguments to `create_instance` via keyword arguments. Note that at
354
+ # least one keyword argument is required. To specify no parameters, or to keep all
355
+ # the default parameter values, pass an empty Hash as a request object (see above).
356
+ #
357
+ # @param parent [::String]
358
+ # Required. The resource name of the instance location using the form:
359
+ # `projects/{project_id}/locations/{location_id}`
360
+ # where `location_id` refers to a GCP region
361
+ # @param instance_id [::String]
362
+ # Required. The logical name of the Memcached instance in the user
363
+ # project with the following restrictions:
364
+ #
365
+ # * Must contain only lowercase letters, numbers, and hyphens.
366
+ # * Must start with a letter.
367
+ # * Must be between 1-40 characters.
368
+ # * Must end with a number or a letter.
369
+ # * Must be unique within the user project / location.
370
+ #
371
+ # If any of the above are not met, the API raises an invalid argument error.
372
+ # @param instance [::Google::Cloud::Memcache::V1::Instance, ::Hash]
373
+ # Required. A Memcached Instance
374
+ # @yield [result, operation] Access the result along with the TransportOperation object
375
+ # @yieldparam result [::Gapic::Operation]
376
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
377
+ #
378
+ # @return [::Gapic::Operation]
379
+ #
380
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
381
+ def create_instance request, options = nil
382
+ raise ::ArgumentError, "request must be provided" if request.nil?
383
+
384
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1::CreateInstanceRequest
385
+
386
+ # Converts hash and nil to an options object
387
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
388
+
389
+ # Customize the options with defaults
390
+ call_metadata = @config.rpcs.create_instance.metadata.to_h
391
+
392
+ # Set x-goog-api-client and x-goog-user-project headers
393
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
394
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
395
+ gapic_version: ::Google::Cloud::Memcache::V1::VERSION,
396
+ transports_version_send: [:rest]
397
+
398
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
399
+
400
+ options.apply_defaults timeout: @config.rpcs.create_instance.timeout,
401
+ metadata: call_metadata,
402
+ retry_policy: @config.rpcs.create_instance.retry_policy
403
+
404
+ options.apply_defaults timeout: @config.timeout,
405
+ metadata: @config.metadata,
406
+ retry_policy: @config.retry_policy
407
+
408
+ @cloud_memcache_stub.create_instance request, options do |result, operation|
409
+ result = ::Gapic::Operation.new result, @operations_client, options: options
410
+ yield result, operation if block_given?
411
+ return result
412
+ end
413
+ rescue ::Gapic::Rest::Error => e
414
+ raise ::Google::Cloud::Error.from_error(e)
415
+ end
416
+
417
+ ##
418
+ # Updates an existing Instance in a given project and location.
419
+ #
420
+ # @overload update_instance(request, options = nil)
421
+ # Pass arguments to `update_instance` via a request object, either of type
422
+ # {::Google::Cloud::Memcache::V1::UpdateInstanceRequest} or an equivalent Hash.
423
+ #
424
+ # @param request [::Google::Cloud::Memcache::V1::UpdateInstanceRequest, ::Hash]
425
+ # A request object representing the call parameters. Required. To specify no
426
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
427
+ # @param options [::Gapic::CallOptions, ::Hash]
428
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
429
+ #
430
+ # @overload update_instance(update_mask: nil, instance: nil)
431
+ # Pass arguments to `update_instance` via keyword arguments. Note that at
432
+ # least one keyword argument is required. To specify no parameters, or to keep all
433
+ # the default parameter values, pass an empty Hash as a request object (see above).
434
+ #
435
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
436
+ # Required. Mask of fields to update.
437
+ #
438
+ # * `displayName`
439
+ # @param instance [::Google::Cloud::Memcache::V1::Instance, ::Hash]
440
+ # Required. A Memcached Instance.
441
+ # Only fields specified in update_mask are updated.
442
+ # @yield [result, operation] Access the result along with the TransportOperation object
443
+ # @yieldparam result [::Gapic::Operation]
444
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
445
+ #
446
+ # @return [::Gapic::Operation]
447
+ #
448
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
449
+ def update_instance request, options = nil
450
+ raise ::ArgumentError, "request must be provided" if request.nil?
451
+
452
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1::UpdateInstanceRequest
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
+ call_metadata = @config.rpcs.update_instance.metadata.to_h
459
+
460
+ # Set x-goog-api-client and x-goog-user-project headers
461
+ call_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::Memcache::V1::VERSION,
464
+ transports_version_send: [:rest]
465
+
466
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
467
+
468
+ options.apply_defaults timeout: @config.rpcs.update_instance.timeout,
469
+ metadata: call_metadata,
470
+ retry_policy: @config.rpcs.update_instance.retry_policy
471
+
472
+ options.apply_defaults timeout: @config.timeout,
473
+ metadata: @config.metadata,
474
+ retry_policy: @config.retry_policy
475
+
476
+ @cloud_memcache_stub.update_instance request, options do |result, operation|
477
+ result = ::Gapic::Operation.new result, @operations_client, options: options
478
+ yield result, operation if block_given?
479
+ return result
480
+ end
481
+ rescue ::Gapic::Rest::Error => e
482
+ raise ::Google::Cloud::Error.from_error(e)
483
+ end
484
+
485
+ ##
486
+ # Updates the defined Memcached parameters for an existing instance.
487
+ # This method only stages the parameters, it must be followed by
488
+ # `ApplyParameters` to apply the parameters to nodes of the Memcached
489
+ # instance.
490
+ #
491
+ # @overload update_parameters(request, options = nil)
492
+ # Pass arguments to `update_parameters` via a request object, either of type
493
+ # {::Google::Cloud::Memcache::V1::UpdateParametersRequest} or an equivalent Hash.
494
+ #
495
+ # @param request [::Google::Cloud::Memcache::V1::UpdateParametersRequest, ::Hash]
496
+ # A request object representing the call parameters. Required. To specify no
497
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
498
+ # @param options [::Gapic::CallOptions, ::Hash]
499
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
500
+ #
501
+ # @overload update_parameters(name: nil, update_mask: nil, parameters: nil)
502
+ # Pass arguments to `update_parameters` via keyword arguments. Note that at
503
+ # least one keyword argument is required. To specify no parameters, or to keep all
504
+ # the default parameter values, pass an empty Hash as a request object (see above).
505
+ #
506
+ # @param name [::String]
507
+ # Required. Resource name of the Memcached instance for which the parameters should be
508
+ # updated.
509
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
510
+ # Required. Mask of fields to update.
511
+ # @param parameters [::Google::Cloud::Memcache::V1::MemcacheParameters, ::Hash]
512
+ # The parameters to apply to the instance.
513
+ # @yield [result, operation] Access the result along with the TransportOperation object
514
+ # @yieldparam result [::Gapic::Operation]
515
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
516
+ #
517
+ # @return [::Gapic::Operation]
518
+ #
519
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
520
+ def update_parameters request, options = nil
521
+ raise ::ArgumentError, "request must be provided" if request.nil?
522
+
523
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1::UpdateParametersRequest
524
+
525
+ # Converts hash and nil to an options object
526
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
527
+
528
+ # Customize the options with defaults
529
+ call_metadata = @config.rpcs.update_parameters.metadata.to_h
530
+
531
+ # Set x-goog-api-client and x-goog-user-project headers
532
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
533
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
534
+ gapic_version: ::Google::Cloud::Memcache::V1::VERSION,
535
+ transports_version_send: [:rest]
536
+
537
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
538
+
539
+ options.apply_defaults timeout: @config.rpcs.update_parameters.timeout,
540
+ metadata: call_metadata,
541
+ retry_policy: @config.rpcs.update_parameters.retry_policy
542
+
543
+ options.apply_defaults timeout: @config.timeout,
544
+ metadata: @config.metadata,
545
+ retry_policy: @config.retry_policy
546
+
547
+ @cloud_memcache_stub.update_parameters request, options do |result, operation|
548
+ result = ::Gapic::Operation.new result, @operations_client, options: options
549
+ yield result, operation if block_given?
550
+ return result
551
+ end
552
+ rescue ::Gapic::Rest::Error => e
553
+ raise ::Google::Cloud::Error.from_error(e)
554
+ end
555
+
556
+ ##
557
+ # Deletes a single Instance.
558
+ #
559
+ # @overload delete_instance(request, options = nil)
560
+ # Pass arguments to `delete_instance` via a request object, either of type
561
+ # {::Google::Cloud::Memcache::V1::DeleteInstanceRequest} or an equivalent Hash.
562
+ #
563
+ # @param request [::Google::Cloud::Memcache::V1::DeleteInstanceRequest, ::Hash]
564
+ # A request object representing the call parameters. Required. To specify no
565
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
566
+ # @param options [::Gapic::CallOptions, ::Hash]
567
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
568
+ #
569
+ # @overload delete_instance(name: nil)
570
+ # Pass arguments to `delete_instance` via keyword arguments. Note that at
571
+ # least one keyword argument is required. To specify no parameters, or to keep all
572
+ # the default parameter values, pass an empty Hash as a request object (see above).
573
+ #
574
+ # @param name [::String]
575
+ # Required. Memcached instance resource name in the format:
576
+ # `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
577
+ # where `location_id` refers to a GCP region
578
+ # @yield [result, operation] Access the result along with the TransportOperation object
579
+ # @yieldparam result [::Gapic::Operation]
580
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
581
+ #
582
+ # @return [::Gapic::Operation]
583
+ #
584
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
585
+ def delete_instance request, options = nil
586
+ raise ::ArgumentError, "request must be provided" if request.nil?
587
+
588
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1::DeleteInstanceRequest
589
+
590
+ # Converts hash and nil to an options object
591
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
592
+
593
+ # Customize the options with defaults
594
+ call_metadata = @config.rpcs.delete_instance.metadata.to_h
595
+
596
+ # Set x-goog-api-client and x-goog-user-project headers
597
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
598
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
599
+ gapic_version: ::Google::Cloud::Memcache::V1::VERSION,
600
+ transports_version_send: [:rest]
601
+
602
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
603
+
604
+ options.apply_defaults timeout: @config.rpcs.delete_instance.timeout,
605
+ metadata: call_metadata,
606
+ retry_policy: @config.rpcs.delete_instance.retry_policy
607
+
608
+ options.apply_defaults timeout: @config.timeout,
609
+ metadata: @config.metadata,
610
+ retry_policy: @config.retry_policy
611
+
612
+ @cloud_memcache_stub.delete_instance request, options do |result, operation|
613
+ result = ::Gapic::Operation.new result, @operations_client, options: options
614
+ yield result, operation if block_given?
615
+ return result
616
+ end
617
+ rescue ::Gapic::Rest::Error => e
618
+ raise ::Google::Cloud::Error.from_error(e)
619
+ end
620
+
621
+ ##
622
+ # `ApplyParameters` restarts the set of specified nodes in order to update
623
+ # them to the current set of parameters for the Memcached Instance.
624
+ #
625
+ # @overload apply_parameters(request, options = nil)
626
+ # Pass arguments to `apply_parameters` via a request object, either of type
627
+ # {::Google::Cloud::Memcache::V1::ApplyParametersRequest} or an equivalent Hash.
628
+ #
629
+ # @param request [::Google::Cloud::Memcache::V1::ApplyParametersRequest, ::Hash]
630
+ # A request object representing the call parameters. Required. To specify no
631
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
632
+ # @param options [::Gapic::CallOptions, ::Hash]
633
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
634
+ #
635
+ # @overload apply_parameters(name: nil, node_ids: nil, apply_all: nil)
636
+ # Pass arguments to `apply_parameters` via keyword arguments. Note that at
637
+ # least one keyword argument is required. To specify no parameters, or to keep all
638
+ # the default parameter values, pass an empty Hash as a request object (see above).
639
+ #
640
+ # @param name [::String]
641
+ # Required. Resource name of the Memcached instance for which parameter group updates
642
+ # should be applied.
643
+ # @param node_ids [::Array<::String>]
644
+ # Nodes to which the instance-level parameter group is applied.
645
+ # @param apply_all [::Boolean]
646
+ # Whether to apply instance-level parameter group to all nodes. If set to
647
+ # true, users are restricted from specifying individual nodes, and
648
+ # `ApplyParameters` updates all nodes within the instance.
649
+ # @yield [result, operation] Access the result along with the TransportOperation object
650
+ # @yieldparam result [::Gapic::Operation]
651
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
652
+ #
653
+ # @return [::Gapic::Operation]
654
+ #
655
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
656
+ def apply_parameters request, options = nil
657
+ raise ::ArgumentError, "request must be provided" if request.nil?
658
+
659
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1::ApplyParametersRequest
660
+
661
+ # Converts hash and nil to an options object
662
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
663
+
664
+ # Customize the options with defaults
665
+ call_metadata = @config.rpcs.apply_parameters.metadata.to_h
666
+
667
+ # Set x-goog-api-client and x-goog-user-project headers
668
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
669
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
670
+ gapic_version: ::Google::Cloud::Memcache::V1::VERSION,
671
+ transports_version_send: [:rest]
672
+
673
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
674
+
675
+ options.apply_defaults timeout: @config.rpcs.apply_parameters.timeout,
676
+ metadata: call_metadata,
677
+ retry_policy: @config.rpcs.apply_parameters.retry_policy
678
+
679
+ options.apply_defaults timeout: @config.timeout,
680
+ metadata: @config.metadata,
681
+ retry_policy: @config.retry_policy
682
+
683
+ @cloud_memcache_stub.apply_parameters request, options do |result, operation|
684
+ result = ::Gapic::Operation.new result, @operations_client, options: options
685
+ yield result, operation if block_given?
686
+ return result
687
+ end
688
+ rescue ::Gapic::Rest::Error => e
689
+ raise ::Google::Cloud::Error.from_error(e)
690
+ end
691
+
692
+ ##
693
+ # Reschedules upcoming maintenance event.
694
+ #
695
+ # @overload reschedule_maintenance(request, options = nil)
696
+ # Pass arguments to `reschedule_maintenance` via a request object, either of type
697
+ # {::Google::Cloud::Memcache::V1::RescheduleMaintenanceRequest} or an equivalent Hash.
698
+ #
699
+ # @param request [::Google::Cloud::Memcache::V1::RescheduleMaintenanceRequest, ::Hash]
700
+ # A request object representing the call parameters. Required. To specify no
701
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
702
+ # @param options [::Gapic::CallOptions, ::Hash]
703
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
704
+ #
705
+ # @overload reschedule_maintenance(instance: nil, reschedule_type: nil, schedule_time: nil)
706
+ # Pass arguments to `reschedule_maintenance` via keyword arguments. Note that at
707
+ # least one keyword argument is required. To specify no parameters, or to keep all
708
+ # the default parameter values, pass an empty Hash as a request object (see above).
709
+ #
710
+ # @param instance [::String]
711
+ # Required. Memcache instance resource name using the form:
712
+ # `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
713
+ # where `location_id` refers to a GCP region.
714
+ # @param reschedule_type [::Google::Cloud::Memcache::V1::RescheduleMaintenanceRequest::RescheduleType]
715
+ # Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well.
716
+ # @param schedule_time [::Google::Protobuf::Timestamp, ::Hash]
717
+ # Timestamp when the maintenance shall be rescheduled to if
718
+ # reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for
719
+ # example `2012-11-15T16:19:00.094Z`.
720
+ # @yield [result, operation] Access the result along with the TransportOperation object
721
+ # @yieldparam result [::Gapic::Operation]
722
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
723
+ #
724
+ # @return [::Gapic::Operation]
725
+ #
726
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
727
+ def reschedule_maintenance request, options = nil
728
+ raise ::ArgumentError, "request must be provided" if request.nil?
729
+
730
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1::RescheduleMaintenanceRequest
731
+
732
+ # Converts hash and nil to an options object
733
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
734
+
735
+ # Customize the options with defaults
736
+ call_metadata = @config.rpcs.reschedule_maintenance.metadata.to_h
737
+
738
+ # Set x-goog-api-client and x-goog-user-project headers
739
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
740
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
741
+ gapic_version: ::Google::Cloud::Memcache::V1::VERSION,
742
+ transports_version_send: [:rest]
743
+
744
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
745
+
746
+ options.apply_defaults timeout: @config.rpcs.reschedule_maintenance.timeout,
747
+ metadata: call_metadata,
748
+ retry_policy: @config.rpcs.reschedule_maintenance.retry_policy
749
+
750
+ options.apply_defaults timeout: @config.timeout,
751
+ metadata: @config.metadata,
752
+ retry_policy: @config.retry_policy
753
+
754
+ @cloud_memcache_stub.reschedule_maintenance request, options do |result, operation|
755
+ result = ::Gapic::Operation.new result, @operations_client, options: options
756
+ yield result, operation if block_given?
757
+ return result
758
+ end
759
+ rescue ::Gapic::Rest::Error => e
760
+ raise ::Google::Cloud::Error.from_error(e)
761
+ end
762
+
763
+ ##
764
+ # Configuration class for the CloudMemcache REST API.
765
+ #
766
+ # This class represents the configuration for CloudMemcache REST,
767
+ # providing control over timeouts, retry behavior, logging, transport
768
+ # parameters, and other low-level controls. Certain parameters can also be
769
+ # applied individually to specific RPCs. See
770
+ # {::Google::Cloud::Memcache::V1::CloudMemcache::Rest::Client::Configuration::Rpcs}
771
+ # for a list of RPCs that can be configured independently.
772
+ #
773
+ # Configuration can be applied globally to all clients, or to a single client
774
+ # on construction.
775
+ #
776
+ # @example
777
+ #
778
+ # # Modify the global config, setting the timeout for
779
+ # # list_instances to 20 seconds,
780
+ # # and all remaining timeouts to 10 seconds.
781
+ # ::Google::Cloud::Memcache::V1::CloudMemcache::Rest::Client.configure do |config|
782
+ # config.timeout = 10.0
783
+ # config.rpcs.list_instances.timeout = 20.0
784
+ # end
785
+ #
786
+ # # Apply the above configuration only to a new client.
787
+ # client = ::Google::Cloud::Memcache::V1::CloudMemcache::Rest::Client.new do |config|
788
+ # config.timeout = 10.0
789
+ # config.rpcs.list_instances.timeout = 20.0
790
+ # end
791
+ #
792
+ # @!attribute [rw] endpoint
793
+ # The hostname or hostname:port of the service endpoint.
794
+ # Defaults to `"memcache.googleapis.com"`.
795
+ # @return [::String]
796
+ # @!attribute [rw] credentials
797
+ # Credentials to send with calls. You may provide any of the following types:
798
+ # * (`String`) The path to a service account key file in JSON format
799
+ # * (`Hash`) A service account key as a Hash
800
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
801
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
802
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
803
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
804
+ # * (`nil`) indicating no credentials
805
+ # @return [::Object]
806
+ # @!attribute [rw] scope
807
+ # The OAuth scopes
808
+ # @return [::Array<::String>]
809
+ # @!attribute [rw] lib_name
810
+ # The library name as recorded in instrumentation and logging
811
+ # @return [::String]
812
+ # @!attribute [rw] lib_version
813
+ # The library version as recorded in instrumentation and logging
814
+ # @return [::String]
815
+ # @!attribute [rw] timeout
816
+ # The call timeout in seconds.
817
+ # @return [::Numeric]
818
+ # @!attribute [rw] metadata
819
+ # Additional headers to be sent with the call.
820
+ # @return [::Hash{::Symbol=>::String}]
821
+ # @!attribute [rw] retry_policy
822
+ # The retry policy. The value is a hash with the following keys:
823
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
824
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
825
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
826
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
827
+ # trigger a retry.
828
+ # @return [::Hash]
829
+ # @!attribute [rw] quota_project
830
+ # A separate project against which to charge quota.
831
+ # @return [::String]
832
+ #
833
+ class Configuration
834
+ extend ::Gapic::Config
835
+
836
+ config_attr :endpoint, "memcache.googleapis.com", ::String
837
+ config_attr :credentials, nil do |value|
838
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
839
+ allowed.any? { |klass| klass === value }
840
+ end
841
+ config_attr :scope, nil, ::String, ::Array, nil
842
+ config_attr :lib_name, nil, ::String, nil
843
+ config_attr :lib_version, nil, ::String, nil
844
+ config_attr :timeout, nil, ::Numeric, nil
845
+ config_attr :metadata, nil, ::Hash, nil
846
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
847
+ config_attr :quota_project, nil, ::String, nil
848
+
849
+ # @private
850
+ # Overrides for http bindings for the RPCs of this service
851
+ # are only used when this service is used as mixin, and only
852
+ # by the host service.
853
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
854
+ config_attr :bindings_override, {}, ::Hash, nil
855
+
856
+ # @private
857
+ def initialize parent_config = nil
858
+ @parent_config = parent_config unless parent_config.nil?
859
+
860
+ yield self if block_given?
861
+ end
862
+
863
+ ##
864
+ # Configurations for individual RPCs
865
+ # @return [Rpcs]
866
+ #
867
+ def rpcs
868
+ @rpcs ||= begin
869
+ parent_rpcs = nil
870
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
871
+ Rpcs.new parent_rpcs
872
+ end
873
+ end
874
+
875
+ ##
876
+ # Configuration RPC class for the CloudMemcache API.
877
+ #
878
+ # Includes fields providing the configuration for each RPC in this service.
879
+ # Each configuration object is of type `Gapic::Config::Method` and includes
880
+ # the following configuration fields:
881
+ #
882
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
883
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
884
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
885
+ # include the following keys:
886
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
887
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
888
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
889
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
890
+ # trigger a retry.
891
+ #
892
+ class Rpcs
893
+ ##
894
+ # RPC-specific configuration for `list_instances`
895
+ # @return [::Gapic::Config::Method]
896
+ #
897
+ attr_reader :list_instances
898
+ ##
899
+ # RPC-specific configuration for `get_instance`
900
+ # @return [::Gapic::Config::Method]
901
+ #
902
+ attr_reader :get_instance
903
+ ##
904
+ # RPC-specific configuration for `create_instance`
905
+ # @return [::Gapic::Config::Method]
906
+ #
907
+ attr_reader :create_instance
908
+ ##
909
+ # RPC-specific configuration for `update_instance`
910
+ # @return [::Gapic::Config::Method]
911
+ #
912
+ attr_reader :update_instance
913
+ ##
914
+ # RPC-specific configuration for `update_parameters`
915
+ # @return [::Gapic::Config::Method]
916
+ #
917
+ attr_reader :update_parameters
918
+ ##
919
+ # RPC-specific configuration for `delete_instance`
920
+ # @return [::Gapic::Config::Method]
921
+ #
922
+ attr_reader :delete_instance
923
+ ##
924
+ # RPC-specific configuration for `apply_parameters`
925
+ # @return [::Gapic::Config::Method]
926
+ #
927
+ attr_reader :apply_parameters
928
+ ##
929
+ # RPC-specific configuration for `reschedule_maintenance`
930
+ # @return [::Gapic::Config::Method]
931
+ #
932
+ attr_reader :reschedule_maintenance
933
+
934
+ # @private
935
+ def initialize parent_rpcs = nil
936
+ list_instances_config = parent_rpcs.list_instances if parent_rpcs.respond_to? :list_instances
937
+ @list_instances = ::Gapic::Config::Method.new list_instances_config
938
+ get_instance_config = parent_rpcs.get_instance if parent_rpcs.respond_to? :get_instance
939
+ @get_instance = ::Gapic::Config::Method.new get_instance_config
940
+ create_instance_config = parent_rpcs.create_instance if parent_rpcs.respond_to? :create_instance
941
+ @create_instance = ::Gapic::Config::Method.new create_instance_config
942
+ update_instance_config = parent_rpcs.update_instance if parent_rpcs.respond_to? :update_instance
943
+ @update_instance = ::Gapic::Config::Method.new update_instance_config
944
+ update_parameters_config = parent_rpcs.update_parameters if parent_rpcs.respond_to? :update_parameters
945
+ @update_parameters = ::Gapic::Config::Method.new update_parameters_config
946
+ delete_instance_config = parent_rpcs.delete_instance if parent_rpcs.respond_to? :delete_instance
947
+ @delete_instance = ::Gapic::Config::Method.new delete_instance_config
948
+ apply_parameters_config = parent_rpcs.apply_parameters if parent_rpcs.respond_to? :apply_parameters
949
+ @apply_parameters = ::Gapic::Config::Method.new apply_parameters_config
950
+ reschedule_maintenance_config = parent_rpcs.reschedule_maintenance if parent_rpcs.respond_to? :reschedule_maintenance
951
+ @reschedule_maintenance = ::Gapic::Config::Method.new reschedule_maintenance_config
952
+
953
+ yield self if block_given?
954
+ end
955
+ end
956
+ end
957
+ end
958
+ end
959
+ end
960
+ end
961
+ end
962
+ end
963
+ end