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