google-cloud-memcache-v1 0.1.0

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