google-cloud-redis 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +8 -0
- data/LICENSE +201 -0
- data/README.md +32 -0
- data/lib/google/cloud/redis.rb +119 -0
- data/lib/google/cloud/redis/credentials.rb +30 -0
- data/lib/google/cloud/redis/v1beta1.rb +113 -0
- data/lib/google/cloud/redis/v1beta1/cloud_redis_client.rb +578 -0
- data/lib/google/cloud/redis/v1beta1/cloud_redis_client_config.json +51 -0
- data/lib/google/cloud/redis/v1beta1/cloud_redis_pb.rb +93 -0
- data/lib/google/cloud/redis/v1beta1/cloud_redis_services_pb.rb +90 -0
- data/lib/google/cloud/redis/v1beta1/doc/google/cloud/redis/v1beta1/cloud_redis.rb +265 -0
- data/lib/google/cloud/redis/v1beta1/doc/google/protobuf/any.rb +124 -0
- data/lib/google/cloud/redis/v1beta1/doc/google/protobuf/field_mask.rb +223 -0
- data/lib/google/cloud/redis/v1beta1/doc/google/protobuf/timestamp.rb +106 -0
- data/lib/google/cloud/redis/v1beta1/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/redis/v1beta1/doc/overview.rb +55 -0
- metadata +116 -0
@@ -0,0 +1,578 @@
|
|
1
|
+
# Copyright 2018 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
#
|
15
|
+
# EDITING INSTRUCTIONS
|
16
|
+
# This file was generated from the file
|
17
|
+
# https://github.com/googleapis/googleapis/blob/master/google/cloud/redis/v1beta1/cloud_redis.proto,
|
18
|
+
# and updates to that file get reflected here through a refresh process.
|
19
|
+
# For the short term, the refresh process will only be runnable by Google
|
20
|
+
# engineers.
|
21
|
+
|
22
|
+
require "json"
|
23
|
+
require "pathname"
|
24
|
+
|
25
|
+
require "google/gax"
|
26
|
+
require "google/gax/operation"
|
27
|
+
require "google/longrunning/operations_client"
|
28
|
+
|
29
|
+
require "google/cloud/redis/v1beta1/cloud_redis_pb"
|
30
|
+
require "google/cloud/redis/credentials"
|
31
|
+
|
32
|
+
module Google
|
33
|
+
module Cloud
|
34
|
+
module Redis
|
35
|
+
module V1beta1
|
36
|
+
# Configures and manages Cloud Memorystore for Redis instances
|
37
|
+
#
|
38
|
+
# Google Cloud Memorystore for Redis v1beta1
|
39
|
+
#
|
40
|
+
# The +redis.googleapis.com+ service implements the Google Cloud Memorystore
|
41
|
+
# for Redis API and defines the following resource model for managing Redis
|
42
|
+
# instances:
|
43
|
+
# * The service works with a collection of cloud projects, named: +/projects/*+
|
44
|
+
# * Each project has a collection of available locations, named: +/locations/*+
|
45
|
+
# * Each location has a collection of Redis instances, named: +/instances/*+
|
46
|
+
# * As such, Redis instances are resources of the form:
|
47
|
+
# +/projects/{project_id}/locations/{location_id}/instances/{instance_id}+
|
48
|
+
#
|
49
|
+
# Note that location_id must be refering to a GCP +region+; for example:
|
50
|
+
# * +projects/redpepper-1290/locations/us-central1/instances/my-redis+
|
51
|
+
#
|
52
|
+
# @!attribute [r] cloud_redis_stub
|
53
|
+
# @return [Google::Cloud::Redis::V1beta1::CloudRedis::Stub]
|
54
|
+
class CloudRedisClient
|
55
|
+
attr_reader :cloud_redis_stub
|
56
|
+
|
57
|
+
# The default address of the service.
|
58
|
+
SERVICE_ADDRESS = "redis.googleapis.com".freeze
|
59
|
+
|
60
|
+
# The default port of the service.
|
61
|
+
DEFAULT_SERVICE_PORT = 443
|
62
|
+
|
63
|
+
DEFAULT_TIMEOUT = 30
|
64
|
+
|
65
|
+
PAGE_DESCRIPTORS = {
|
66
|
+
"list_instances" => Google::Gax::PageDescriptor.new(
|
67
|
+
"page_token",
|
68
|
+
"next_page_token",
|
69
|
+
"instances")
|
70
|
+
}.freeze
|
71
|
+
|
72
|
+
private_constant :PAGE_DESCRIPTORS
|
73
|
+
|
74
|
+
# The scopes needed to make gRPC calls to all of the methods defined in
|
75
|
+
# this service.
|
76
|
+
ALL_SCOPES = [
|
77
|
+
"https://www.googleapis.com/auth/cloud-platform"
|
78
|
+
].freeze
|
79
|
+
|
80
|
+
class OperationsClient < Google::Longrunning::OperationsClient
|
81
|
+
self::SERVICE_ADDRESS = CloudRedisClient::SERVICE_ADDRESS
|
82
|
+
end
|
83
|
+
|
84
|
+
LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
85
|
+
"projects/{project}/locations/{location}"
|
86
|
+
)
|
87
|
+
|
88
|
+
private_constant :LOCATION_PATH_TEMPLATE
|
89
|
+
|
90
|
+
INSTANCE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
91
|
+
"projects/{project}/locations/{location}/instances/{instance}"
|
92
|
+
)
|
93
|
+
|
94
|
+
private_constant :INSTANCE_PATH_TEMPLATE
|
95
|
+
|
96
|
+
# Returns a fully-qualified location resource name string.
|
97
|
+
# @param project [String]
|
98
|
+
# @param location [String]
|
99
|
+
# @return [String]
|
100
|
+
def self.location_path project, location
|
101
|
+
LOCATION_PATH_TEMPLATE.render(
|
102
|
+
:"project" => project,
|
103
|
+
:"location" => location
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Returns a fully-qualified instance resource name string.
|
108
|
+
# @param project [String]
|
109
|
+
# @param location [String]
|
110
|
+
# @param instance [String]
|
111
|
+
# @return [String]
|
112
|
+
def self.instance_path project, location, instance
|
113
|
+
INSTANCE_PATH_TEMPLATE.render(
|
114
|
+
:"project" => project,
|
115
|
+
:"location" => location,
|
116
|
+
:"instance" => instance
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
121
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
122
|
+
# be many types.
|
123
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
124
|
+
# authenticating requests made by this client.
|
125
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
126
|
+
# credentials for this client.
|
127
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
128
|
+
# credentials for this client.
|
129
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
130
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
131
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
132
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
133
|
+
# metadata for requests, generally, to give OAuth credentials.
|
134
|
+
# @param scopes [Array<String>]
|
135
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
136
|
+
# an updater_proc is supplied.
|
137
|
+
# @param client_config [Hash]
|
138
|
+
# A Hash for call options for each method. See
|
139
|
+
# Google::Gax#construct_settings for the structure of
|
140
|
+
# this data. Falls back to the default config if not specified
|
141
|
+
# or the specified config is missing data points.
|
142
|
+
# @param timeout [Numeric]
|
143
|
+
# The default timeout, in seconds, for calls made through this client.
|
144
|
+
def initialize \
|
145
|
+
credentials: nil,
|
146
|
+
scopes: ALL_SCOPES,
|
147
|
+
client_config: {},
|
148
|
+
timeout: DEFAULT_TIMEOUT,
|
149
|
+
lib_name: nil,
|
150
|
+
lib_version: ""
|
151
|
+
# These require statements are intentionally placed here to initialize
|
152
|
+
# the gRPC module only when it's required.
|
153
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
154
|
+
require "google/gax/grpc"
|
155
|
+
require "google/cloud/redis/v1beta1/cloud_redis_services_pb"
|
156
|
+
|
157
|
+
credentials ||= Google::Cloud::Redis::Credentials.default
|
158
|
+
|
159
|
+
@operations_client = OperationsClient.new(
|
160
|
+
credentials: credentials,
|
161
|
+
scopes: scopes,
|
162
|
+
client_config: client_config,
|
163
|
+
timeout: timeout,
|
164
|
+
lib_name: lib_name,
|
165
|
+
lib_version: lib_version,
|
166
|
+
)
|
167
|
+
|
168
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
169
|
+
updater_proc = Google::Cloud::Redis::Credentials.new(credentials).updater_proc
|
170
|
+
end
|
171
|
+
if credentials.is_a?(GRPC::Core::Channel)
|
172
|
+
channel = credentials
|
173
|
+
end
|
174
|
+
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
175
|
+
chan_creds = credentials
|
176
|
+
end
|
177
|
+
if credentials.is_a?(Proc)
|
178
|
+
updater_proc = credentials
|
179
|
+
end
|
180
|
+
if credentials.is_a?(Google::Auth::Credentials)
|
181
|
+
updater_proc = credentials.updater_proc
|
182
|
+
end
|
183
|
+
|
184
|
+
package_version = Gem.loaded_specs['google-cloud-redis'].version.version
|
185
|
+
|
186
|
+
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
187
|
+
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
188
|
+
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
189
|
+
google_api_client << " grpc/#{GRPC::VERSION}"
|
190
|
+
google_api_client.freeze
|
191
|
+
|
192
|
+
headers = { :"x-goog-api-client" => google_api_client }
|
193
|
+
client_config_file = Pathname.new(__dir__).join(
|
194
|
+
"cloud_redis_client_config.json"
|
195
|
+
)
|
196
|
+
defaults = client_config_file.open do |f|
|
197
|
+
Google::Gax.construct_settings(
|
198
|
+
"google.cloud.redis.v1beta1.CloudRedis",
|
199
|
+
JSON.parse(f.read),
|
200
|
+
client_config,
|
201
|
+
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
202
|
+
timeout,
|
203
|
+
page_descriptors: PAGE_DESCRIPTORS,
|
204
|
+
errors: Google::Gax::Grpc::API_ERRORS,
|
205
|
+
kwargs: headers
|
206
|
+
)
|
207
|
+
end
|
208
|
+
|
209
|
+
# Allow overriding the service path/port in subclasses.
|
210
|
+
service_path = self.class::SERVICE_ADDRESS
|
211
|
+
port = self.class::DEFAULT_SERVICE_PORT
|
212
|
+
@cloud_redis_stub = Google::Gax::Grpc.create_stub(
|
213
|
+
service_path,
|
214
|
+
port,
|
215
|
+
chan_creds: chan_creds,
|
216
|
+
channel: channel,
|
217
|
+
updater_proc: updater_proc,
|
218
|
+
scopes: scopes,
|
219
|
+
&Google::Cloud::Redis::V1beta1::CloudRedis::Stub.method(:new)
|
220
|
+
)
|
221
|
+
|
222
|
+
@list_instances = Google::Gax.create_api_call(
|
223
|
+
@cloud_redis_stub.method(:list_instances),
|
224
|
+
defaults["list_instances"]
|
225
|
+
)
|
226
|
+
@get_instance = Google::Gax.create_api_call(
|
227
|
+
@cloud_redis_stub.method(:get_instance),
|
228
|
+
defaults["get_instance"]
|
229
|
+
)
|
230
|
+
@create_instance = Google::Gax.create_api_call(
|
231
|
+
@cloud_redis_stub.method(:create_instance),
|
232
|
+
defaults["create_instance"]
|
233
|
+
)
|
234
|
+
@update_instance = Google::Gax.create_api_call(
|
235
|
+
@cloud_redis_stub.method(:update_instance),
|
236
|
+
defaults["update_instance"]
|
237
|
+
)
|
238
|
+
@delete_instance = Google::Gax.create_api_call(
|
239
|
+
@cloud_redis_stub.method(:delete_instance),
|
240
|
+
defaults["delete_instance"]
|
241
|
+
)
|
242
|
+
end
|
243
|
+
|
244
|
+
# Service calls
|
245
|
+
|
246
|
+
# Lists all Redis instances owned by a project in either the specified
|
247
|
+
# location (region) or all locations.
|
248
|
+
#
|
249
|
+
# The location should have the following format:
|
250
|
+
# * +projects/{project_id}/locations/{location_id}+
|
251
|
+
#
|
252
|
+
# If +location_id+ is specified as +-+ (wildcard), then all regions
|
253
|
+
# available to the project are queried, and the results are aggregated.
|
254
|
+
#
|
255
|
+
# @param parent [String]
|
256
|
+
# Required. The resource name of the instance location using the form:
|
257
|
+
# +projects/{project_id}/locations/{location_id}+
|
258
|
+
# where +location_id+ refers to a GCP region
|
259
|
+
# @param page_size [Integer]
|
260
|
+
# The maximum number of resources contained in the underlying API
|
261
|
+
# response. If page streaming is performed per-resource, this
|
262
|
+
# parameter does not affect the return value. If page streaming is
|
263
|
+
# performed per-page, this determines the maximum number of
|
264
|
+
# resources in a page.
|
265
|
+
# @param options [Google::Gax::CallOptions]
|
266
|
+
# Overrides the default settings for this call, e.g, timeout,
|
267
|
+
# retries, etc.
|
268
|
+
# @return [Google::Gax::PagedEnumerable<Google::Cloud::Redis::V1beta1::Instance>]
|
269
|
+
# An enumerable of Google::Cloud::Redis::V1beta1::Instance instances.
|
270
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
271
|
+
# operations such as per-page iteration or access to the response
|
272
|
+
# object.
|
273
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
274
|
+
# @example
|
275
|
+
# require "google/cloud/redis/v1beta1"
|
276
|
+
#
|
277
|
+
# cloud_redis_client = Google::Cloud::Redis::V1beta1.new
|
278
|
+
# formatted_parent = Google::Cloud::Redis::V1beta1::CloudRedisClient.location_path("[PROJECT]", "[LOCATION]")
|
279
|
+
#
|
280
|
+
# # Iterate over all results.
|
281
|
+
# cloud_redis_client.list_instances(formatted_parent).each do |element|
|
282
|
+
# # Process element.
|
283
|
+
# end
|
284
|
+
#
|
285
|
+
# # Or iterate over results one page at a time.
|
286
|
+
# cloud_redis_client.list_instances(formatted_parent).each_page do |page|
|
287
|
+
# # Process each page at a time.
|
288
|
+
# page.each do |element|
|
289
|
+
# # Process element.
|
290
|
+
# end
|
291
|
+
# end
|
292
|
+
|
293
|
+
def list_instances \
|
294
|
+
parent,
|
295
|
+
page_size: nil,
|
296
|
+
options: nil
|
297
|
+
req = {
|
298
|
+
parent: parent,
|
299
|
+
page_size: page_size
|
300
|
+
}.delete_if { |_, v| v.nil? }
|
301
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::ListInstancesRequest)
|
302
|
+
@list_instances.call(req, options)
|
303
|
+
end
|
304
|
+
|
305
|
+
# Gets the details of a specific Redis instance.
|
306
|
+
#
|
307
|
+
# @param name [String]
|
308
|
+
# Required. Redis instance resource name using the form:
|
309
|
+
# +projects/{project_id}/locations/{location_id}/instances/{instance_id}+
|
310
|
+
# where +location_id+ refers to a GCP region
|
311
|
+
# @param options [Google::Gax::CallOptions]
|
312
|
+
# Overrides the default settings for this call, e.g, timeout,
|
313
|
+
# retries, etc.
|
314
|
+
# @return [Google::Cloud::Redis::V1beta1::Instance]
|
315
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
316
|
+
# @example
|
317
|
+
# require "google/cloud/redis/v1beta1"
|
318
|
+
#
|
319
|
+
# cloud_redis_client = Google::Cloud::Redis::V1beta1.new
|
320
|
+
# formatted_name = Google::Cloud::Redis::V1beta1::CloudRedisClient.instance_path("[PROJECT]", "[LOCATION]", "[INSTANCE]")
|
321
|
+
# response = cloud_redis_client.get_instance(formatted_name)
|
322
|
+
|
323
|
+
def get_instance \
|
324
|
+
name,
|
325
|
+
options: nil
|
326
|
+
req = {
|
327
|
+
name: name
|
328
|
+
}.delete_if { |_, v| v.nil? }
|
329
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::GetInstanceRequest)
|
330
|
+
@get_instance.call(req, options)
|
331
|
+
end
|
332
|
+
|
333
|
+
# Creates a Redis instance based on the specified tier and memory size.
|
334
|
+
#
|
335
|
+
# By default, the instance is peered to the project's
|
336
|
+
# [default network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks).
|
337
|
+
#
|
338
|
+
# The creation is executed asynchronously and callers may check the returned
|
339
|
+
# operation to track its progress. Once the operation is completed the Redis
|
340
|
+
# instance will be fully functional. Completed longrunning.Operation will
|
341
|
+
# contain the new instance object in the response field.
|
342
|
+
#
|
343
|
+
# The returned operation is automatically deleted after a few hours, so there
|
344
|
+
# is no need to call DeleteOperation.
|
345
|
+
#
|
346
|
+
# @param parent [String]
|
347
|
+
# Required. The resource name of the instance location using the form:
|
348
|
+
# +projects/{project_id}/locations/{location_id}+
|
349
|
+
# where +location_id+ refers to a GCP region
|
350
|
+
# @param instance_id [String]
|
351
|
+
# Required. The logical name of the Redis instance in the customer project
|
352
|
+
# with the following restrictions:
|
353
|
+
#
|
354
|
+
# * Must contain only lowercase letters, numbers, and hyphens.
|
355
|
+
# * Must start with a letter.
|
356
|
+
# * Must be between 1-40 characters.
|
357
|
+
# * Must end with a number or a letter.
|
358
|
+
# * Must be unique within the customer project / location
|
359
|
+
# @param instance [Google::Cloud::Redis::V1beta1::Instance | Hash]
|
360
|
+
# Required. A Redis [Instance] resource
|
361
|
+
# A hash of the same form as `Google::Cloud::Redis::V1beta1::Instance`
|
362
|
+
# can also be provided.
|
363
|
+
# @param options [Google::Gax::CallOptions]
|
364
|
+
# Overrides the default settings for this call, e.g, timeout,
|
365
|
+
# retries, etc.
|
366
|
+
# @return [Google::Gax::Operation]
|
367
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
368
|
+
# @example
|
369
|
+
# require "google/cloud/redis/v1beta1"
|
370
|
+
#
|
371
|
+
# cloud_redis_client = Google::Cloud::Redis::V1beta1.new
|
372
|
+
# formatted_parent = Google::Cloud::Redis::V1beta1::CloudRedisClient.location_path("[PROJECT]", "[LOCATION]")
|
373
|
+
# instance_id = "test_instance"
|
374
|
+
# tier = :BASIC
|
375
|
+
# memory_size_gb = 1
|
376
|
+
# instance = { tier: tier, memory_size_gb: memory_size_gb }
|
377
|
+
#
|
378
|
+
# # Register a callback during the method call.
|
379
|
+
# operation = cloud_redis_client.create_instance(formatted_parent, instance_id, instance) do |op|
|
380
|
+
# raise op.results.message if op.error?
|
381
|
+
# op_results = op.results
|
382
|
+
# # Process the results.
|
383
|
+
#
|
384
|
+
# metadata = op.metadata
|
385
|
+
# # Process the metadata.
|
386
|
+
# end
|
387
|
+
#
|
388
|
+
# # Or use the return value to register a callback.
|
389
|
+
# operation.on_done do |op|
|
390
|
+
# raise op.results.message if op.error?
|
391
|
+
# op_results = op.results
|
392
|
+
# # Process the results.
|
393
|
+
#
|
394
|
+
# metadata = op.metadata
|
395
|
+
# # Process the metadata.
|
396
|
+
# end
|
397
|
+
#
|
398
|
+
# # Manually reload the operation.
|
399
|
+
# operation.reload!
|
400
|
+
#
|
401
|
+
# # Or block until the operation completes, triggering callbacks on
|
402
|
+
# # completion.
|
403
|
+
# operation.wait_until_done!
|
404
|
+
|
405
|
+
def create_instance \
|
406
|
+
parent,
|
407
|
+
instance_id,
|
408
|
+
instance,
|
409
|
+
options: nil
|
410
|
+
req = {
|
411
|
+
parent: parent,
|
412
|
+
instance_id: instance_id,
|
413
|
+
instance: instance
|
414
|
+
}.delete_if { |_, v| v.nil? }
|
415
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::CreateInstanceRequest)
|
416
|
+
operation = Google::Gax::Operation.new(
|
417
|
+
@create_instance.call(req, options),
|
418
|
+
@operations_client,
|
419
|
+
Google::Cloud::Redis::V1beta1::Instance,
|
420
|
+
Google::Protobuf::Any,
|
421
|
+
call_options: options
|
422
|
+
)
|
423
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
424
|
+
operation
|
425
|
+
end
|
426
|
+
|
427
|
+
# Updates the metadata and configuration of a specific Redis instance.
|
428
|
+
#
|
429
|
+
# Completed longrunning.Operation will contain the new instance object
|
430
|
+
# in the response field. The returned operation is automatically deleted
|
431
|
+
# after a few hours, so there is no need to call DeleteOperation.
|
432
|
+
#
|
433
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
434
|
+
# Required. Mask of fields to update. At least one path must be supplied in
|
435
|
+
# this field. The elements of the repeated paths field may only include these
|
436
|
+
# fields from {CloudRedis::Instance Instance}:
|
437
|
+
# * +display_name+
|
438
|
+
# * +labels+
|
439
|
+
# * +memory_size_gb+
|
440
|
+
# * +redis_config+
|
441
|
+
# A hash of the same form as `Google::Protobuf::FieldMask`
|
442
|
+
# can also be provided.
|
443
|
+
# @param instance [Google::Cloud::Redis::V1beta1::Instance | Hash]
|
444
|
+
# Required. Update description.
|
445
|
+
# Only fields specified in update_mask are updated.
|
446
|
+
# A hash of the same form as `Google::Cloud::Redis::V1beta1::Instance`
|
447
|
+
# can also be provided.
|
448
|
+
# @param options [Google::Gax::CallOptions]
|
449
|
+
# Overrides the default settings for this call, e.g, timeout,
|
450
|
+
# retries, etc.
|
451
|
+
# @return [Google::Gax::Operation]
|
452
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
453
|
+
# @example
|
454
|
+
# require "google/cloud/redis/v1beta1"
|
455
|
+
#
|
456
|
+
# cloud_redis_client = Google::Cloud::Redis::V1beta1.new
|
457
|
+
# paths_element = "display_name"
|
458
|
+
# paths_element_2 = "memory_size_gb"
|
459
|
+
# paths = [paths_element, paths_element_2]
|
460
|
+
# update_mask = { paths: paths }
|
461
|
+
# display_name = "UpdatedDisplayName"
|
462
|
+
# memory_size_gb = 4
|
463
|
+
# instance = { display_name: display_name, memory_size_gb: memory_size_gb }
|
464
|
+
#
|
465
|
+
# # Register a callback during the method call.
|
466
|
+
# operation = cloud_redis_client.update_instance(update_mask, instance) do |op|
|
467
|
+
# raise op.results.message if op.error?
|
468
|
+
# op_results = op.results
|
469
|
+
# # Process the results.
|
470
|
+
#
|
471
|
+
# metadata = op.metadata
|
472
|
+
# # Process the metadata.
|
473
|
+
# end
|
474
|
+
#
|
475
|
+
# # Or use the return value to register a callback.
|
476
|
+
# operation.on_done do |op|
|
477
|
+
# raise op.results.message if op.error?
|
478
|
+
# op_results = op.results
|
479
|
+
# # Process the results.
|
480
|
+
#
|
481
|
+
# metadata = op.metadata
|
482
|
+
# # Process the metadata.
|
483
|
+
# end
|
484
|
+
#
|
485
|
+
# # Manually reload the operation.
|
486
|
+
# operation.reload!
|
487
|
+
#
|
488
|
+
# # Or block until the operation completes, triggering callbacks on
|
489
|
+
# # completion.
|
490
|
+
# operation.wait_until_done!
|
491
|
+
|
492
|
+
def update_instance \
|
493
|
+
update_mask,
|
494
|
+
instance,
|
495
|
+
options: nil
|
496
|
+
req = {
|
497
|
+
update_mask: update_mask,
|
498
|
+
instance: instance
|
499
|
+
}.delete_if { |_, v| v.nil? }
|
500
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::UpdateInstanceRequest)
|
501
|
+
operation = Google::Gax::Operation.new(
|
502
|
+
@update_instance.call(req, options),
|
503
|
+
@operations_client,
|
504
|
+
Google::Cloud::Redis::V1beta1::Instance,
|
505
|
+
Google::Protobuf::Any,
|
506
|
+
call_options: options
|
507
|
+
)
|
508
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
509
|
+
operation
|
510
|
+
end
|
511
|
+
|
512
|
+
# Deletes a specific Redis instance. Instance stops serving and data is
|
513
|
+
# deleted.
|
514
|
+
#
|
515
|
+
# @param name [String]
|
516
|
+
# Required. Redis instance resource name using the form:
|
517
|
+
# +projects/{project_id}/locations/{location_id}/instances/{instance_id}+
|
518
|
+
# where +location_id+ refers to a GCP region
|
519
|
+
# @param options [Google::Gax::CallOptions]
|
520
|
+
# Overrides the default settings for this call, e.g, timeout,
|
521
|
+
# retries, etc.
|
522
|
+
# @return [Google::Gax::Operation]
|
523
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
524
|
+
# @example
|
525
|
+
# require "google/cloud/redis/v1beta1"
|
526
|
+
#
|
527
|
+
# cloud_redis_client = Google::Cloud::Redis::V1beta1.new
|
528
|
+
# formatted_name = Google::Cloud::Redis::V1beta1::CloudRedisClient.instance_path("[PROJECT]", "[LOCATION]", "[INSTANCE]")
|
529
|
+
#
|
530
|
+
# # Register a callback during the method call.
|
531
|
+
# operation = cloud_redis_client.delete_instance(formatted_name) do |op|
|
532
|
+
# raise op.results.message if op.error?
|
533
|
+
# op_results = op.results
|
534
|
+
# # Process the results.
|
535
|
+
#
|
536
|
+
# metadata = op.metadata
|
537
|
+
# # Process the metadata.
|
538
|
+
# end
|
539
|
+
#
|
540
|
+
# # Or use the return value to register a callback.
|
541
|
+
# operation.on_done do |op|
|
542
|
+
# raise op.results.message if op.error?
|
543
|
+
# op_results = op.results
|
544
|
+
# # Process the results.
|
545
|
+
#
|
546
|
+
# metadata = op.metadata
|
547
|
+
# # Process the metadata.
|
548
|
+
# end
|
549
|
+
#
|
550
|
+
# # Manually reload the operation.
|
551
|
+
# operation.reload!
|
552
|
+
#
|
553
|
+
# # Or block until the operation completes, triggering callbacks on
|
554
|
+
# # completion.
|
555
|
+
# operation.wait_until_done!
|
556
|
+
|
557
|
+
def delete_instance \
|
558
|
+
name,
|
559
|
+
options: nil
|
560
|
+
req = {
|
561
|
+
name: name
|
562
|
+
}.delete_if { |_, v| v.nil? }
|
563
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::DeleteInstanceRequest)
|
564
|
+
operation = Google::Gax::Operation.new(
|
565
|
+
@delete_instance.call(req, options),
|
566
|
+
@operations_client,
|
567
|
+
Google::Protobuf::Empty,
|
568
|
+
Google::Protobuf::Any,
|
569
|
+
call_options: options
|
570
|
+
)
|
571
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
572
|
+
operation
|
573
|
+
end
|
574
|
+
end
|
575
|
+
end
|
576
|
+
end
|
577
|
+
end
|
578
|
+
end
|