google-cloud-redis 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -0
- data/AUTHENTICATION.md +199 -0
- data/README.md +1 -2
- data/lib/google/cloud/redis.rb +3 -4
- data/lib/google/cloud/redis/v1.rb +3 -4
- data/lib/google/cloud/redis/v1/cloud_redis_client.rb +117 -23
- data/lib/google/cloud/redis/v1/cloud_redis_client_config.json +5 -0
- data/lib/google/cloud/redis/v1/cloud_redis_pb.rb +14 -0
- data/lib/google/cloud/redis/v1/cloud_redis_services_pb.rb +6 -2
- data/lib/google/cloud/redis/v1/credentials.rb +1 -1
- data/lib/google/cloud/redis/v1/doc/google/cloud/redis/v1/cloud_redis.rb +33 -3
- data/lib/google/cloud/redis/v1/doc/google/longrunning/operations.rb +2 -44
- data/lib/google/cloud/redis/v1/doc/google/protobuf/any.rb +3 -2
- data/lib/google/cloud/redis/v1/doc/google/protobuf/field_mask.rb +19 -27
- data/lib/google/cloud/redis/v1/doc/google/protobuf/timestamp.rb +16 -14
- data/lib/google/cloud/redis/v1/doc/google/rpc/status.rb +18 -15
- data/lib/google/cloud/redis/v1beta1.rb +2 -3
- data/lib/google/cloud/redis/v1beta1/cloud_redis_client.rb +123 -28
- data/lib/google/cloud/redis/v1beta1/cloud_redis_client_config.json +5 -0
- data/lib/google/cloud/redis/v1beta1/cloud_redis_pb.rb +15 -0
- data/lib/google/cloud/redis/v1beta1/cloud_redis_services_pb.rb +6 -2
- data/lib/google/cloud/redis/v1beta1/credentials.rb +1 -1
- data/lib/google/cloud/redis/v1beta1/doc/google/cloud/redis/v1beta1/cloud_redis.rb +79 -25
- data/lib/google/cloud/redis/v1beta1/doc/google/longrunning/operations.rb +2 -44
- data/lib/google/cloud/redis/v1beta1/doc/google/protobuf/any.rb +3 -2
- data/lib/google/cloud/redis/v1beta1/doc/google/protobuf/field_mask.rb +19 -27
- data/lib/google/cloud/redis/v1beta1/doc/google/protobuf/timestamp.rb +16 -14
- data/lib/google/cloud/redis/v1beta1/doc/google/rpc/status.rb +18 -15
- metadata +26 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77259a383da44a43dc112d8e849560089fbc35b5c0b539becb033008e4dbd07f
|
4
|
+
data.tar.gz: 36a3f0c3d32cc3bf9de0acb214a9acc29b186a2b5729077a34d24a9284f3ed84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 189e8912ae7fa344a20ed36b824d71b5fab86f28f969ef59ad94d17b80d119100919852ed934770121e7325d5ee4afc2c85f5fe8596602e8ee9d608ea4571fe1
|
7
|
+
data.tar.gz: e444e4a28bd9f59f3d9350b719fed22d57c0026c130a2cfadd95d45b90ff90ec288e007704823172756916f88e06664cb27e3ed8bc22bb969d04e67c31a3eb48
|
data/.yardopts
CHANGED
data/AUTHENTICATION.md
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
# Authentication
|
2
|
+
|
3
|
+
In general, the google-cloud-redis library uses [Service
|
4
|
+
Account](https://cloud.google.com/iam/docs/creating-managing-service-accounts)
|
5
|
+
credentials to connect to Google Cloud services. When running within [Google
|
6
|
+
Cloud Platform environments](#google-cloud-platform-environments)
|
7
|
+
the credentials will be discovered automatically. When running on other
|
8
|
+
environments, the Service Account credentials can be specified by providing the
|
9
|
+
path to the [JSON
|
10
|
+
keyfile](https://cloud.google.com/iam/docs/managing-service-account-keys) for
|
11
|
+
the account (or the JSON itself) in [environment
|
12
|
+
variables](#environment-variables). Additionally, Cloud SDK credentials can also
|
13
|
+
be discovered automatically, but this is only recommended during development.
|
14
|
+
|
15
|
+
## Quickstart
|
16
|
+
|
17
|
+
1. [Create a service account and credentials](#creating-a-service-account).
|
18
|
+
2. Set the [environment variable](#environment-variables).
|
19
|
+
|
20
|
+
```sh
|
21
|
+
export REDIS_CREDENTIALS=/path/to/json`
|
22
|
+
```
|
23
|
+
|
24
|
+
3. Initialize the client.
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require "google/cloud/redis"
|
28
|
+
|
29
|
+
client = Google::Cloud::Redis.new
|
30
|
+
```
|
31
|
+
|
32
|
+
## Project and Credential Lookup
|
33
|
+
|
34
|
+
The google-cloud-redis library aims to make authentication
|
35
|
+
as simple as possible, and provides several mechanisms to configure your system
|
36
|
+
without providing **Project ID** and **Service Account Credentials** directly in
|
37
|
+
code.
|
38
|
+
|
39
|
+
**Project ID** is discovered in the following order:
|
40
|
+
|
41
|
+
1. Specify project ID in method arguments
|
42
|
+
2. Specify project ID in configuration
|
43
|
+
3. Discover project ID in environment variables
|
44
|
+
4. Discover GCE project ID
|
45
|
+
5. Discover project ID in credentials JSON
|
46
|
+
|
47
|
+
**Credentials** are discovered in the following order:
|
48
|
+
|
49
|
+
1. Specify credentials in method arguments
|
50
|
+
2. Specify credentials in configuration
|
51
|
+
3. Discover credentials path in environment variables
|
52
|
+
4. Discover credentials JSON in environment variables
|
53
|
+
5. Discover credentials file in the Cloud SDK's path
|
54
|
+
6. Discover GCE credentials
|
55
|
+
|
56
|
+
### Google Cloud Platform environments
|
57
|
+
|
58
|
+
While running on Google Cloud Platform environments such as Google Compute
|
59
|
+
Engine, Google App Engine and Google Kubernetes Engine, no extra work is needed.
|
60
|
+
The **Project ID** and **Credentials** and are discovered automatically. Code
|
61
|
+
should be written as if already authenticated. Just be sure when you [set up the
|
62
|
+
GCE instance][gce-how-to], you add the correct scopes for the APIs you want to
|
63
|
+
access. For example:
|
64
|
+
|
65
|
+
* **All APIs**
|
66
|
+
* `https://www.googleapis.com/auth/cloud-platform`
|
67
|
+
* `https://www.googleapis.com/auth/cloud-platform.read-only`
|
68
|
+
* **BigQuery**
|
69
|
+
* `https://www.googleapis.com/auth/bigquery`
|
70
|
+
* `https://www.googleapis.com/auth/bigquery.insertdata`
|
71
|
+
* **Compute Engine**
|
72
|
+
* `https://www.googleapis.com/auth/compute`
|
73
|
+
* **Datastore**
|
74
|
+
* `https://www.googleapis.com/auth/datastore`
|
75
|
+
* `https://www.googleapis.com/auth/userinfo.email`
|
76
|
+
* **DNS**
|
77
|
+
* `https://www.googleapis.com/auth/ndev.clouddns.readwrite`
|
78
|
+
* **Pub/Sub**
|
79
|
+
* `https://www.googleapis.com/auth/pubsub`
|
80
|
+
* **Storage**
|
81
|
+
* `https://www.googleapis.com/auth/devstorage.full_control`
|
82
|
+
* `https://www.googleapis.com/auth/devstorage.read_only`
|
83
|
+
* `https://www.googleapis.com/auth/devstorage.read_write`
|
84
|
+
|
85
|
+
### Environment Variables
|
86
|
+
|
87
|
+
The **Project ID** and **Credentials JSON** can be placed in environment
|
88
|
+
variables instead of declaring them directly in code. Each service has its own
|
89
|
+
environment variable, allowing for different service accounts to be used for
|
90
|
+
different services. (See the READMEs for the individual service gems for
|
91
|
+
details.) The path to the **Credentials JSON** file can be stored in the
|
92
|
+
environment variable, or the **Credentials JSON** itself can be stored for
|
93
|
+
environments such as Docker containers where writing files is difficult or not
|
94
|
+
encouraged.
|
95
|
+
|
96
|
+
The environment variables that google-cloud-redis checks for project ID are:
|
97
|
+
|
98
|
+
1. `REDIS_PROJECT`
|
99
|
+
2. `GOOGLE_CLOUD_PROJECT`
|
100
|
+
|
101
|
+
The environment variables that google-cloud-redis checks for credentials are configured on {Google::Cloud::Redis::V1::Credentials}:
|
102
|
+
|
103
|
+
1. `REDIS_CREDENTIALS` - Path to JSON file, or JSON contents
|
104
|
+
2. `REDIS_KEYFILE` - Path to JSON file, or JSON contents
|
105
|
+
3. `GOOGLE_CLOUD_CREDENTIALS` - Path to JSON file, or JSON contents
|
106
|
+
4. `GOOGLE_CLOUD_KEYFILE` - Path to JSON file, or JSON contents
|
107
|
+
5. `GOOGLE_APPLICATION_CREDENTIALS` - Path to JSON file
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
require "google/cloud/redis"
|
111
|
+
|
112
|
+
ENV["REDIS_PROJECT"] = "my-project-id"
|
113
|
+
ENV["REDIS_CREDENTIALS"] = "path/to/keyfile.json"
|
114
|
+
|
115
|
+
client = Google::Cloud::Redis.new
|
116
|
+
```
|
117
|
+
|
118
|
+
### Configuration
|
119
|
+
|
120
|
+
The **Project ID** and **Credentials JSON** can be configured instead of placing them in environment variables or providing them as arguments.
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
require "google/cloud/redis"
|
124
|
+
|
125
|
+
Google::Cloud::Redis.configure do |config|
|
126
|
+
config.project_id = "my-project-id"
|
127
|
+
config.credentials = "path/to/keyfile.json"
|
128
|
+
end
|
129
|
+
|
130
|
+
client = Google::Cloud::Redis.new
|
131
|
+
```
|
132
|
+
|
133
|
+
### Cloud SDK
|
134
|
+
|
135
|
+
This option allows for an easy way to authenticate during development. If
|
136
|
+
credentials are not provided in code or in environment variables, then Cloud SDK
|
137
|
+
credentials are discovered.
|
138
|
+
|
139
|
+
To configure your system for this, simply:
|
140
|
+
|
141
|
+
1. [Download and install the Cloud SDK](https://cloud.google.com/sdk)
|
142
|
+
2. Authenticate using OAuth 2.0 `$ gcloud auth login`
|
143
|
+
3. Write code as if already authenticated.
|
144
|
+
|
145
|
+
**NOTE:** This is _not_ recommended for running in production. The Cloud SDK
|
146
|
+
*should* only be used during development.
|
147
|
+
|
148
|
+
[gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
|
149
|
+
[dev-console]: https://console.cloud.google.com/project
|
150
|
+
|
151
|
+
[enable-apis]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/enable-apis.png
|
152
|
+
|
153
|
+
[create-new-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account.png
|
154
|
+
[create-new-service-account-existing-keys]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account-existing-keys.png
|
155
|
+
[reuse-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/reuse-service-account.png
|
156
|
+
|
157
|
+
## Creating a Service Account
|
158
|
+
|
159
|
+
Google Cloud requires a **Project ID** and **Service Account Credentials** to
|
160
|
+
connect to the APIs. You will use the **Project ID** and **JSON key file** to
|
161
|
+
connect to most services with google-cloud-redis.
|
162
|
+
|
163
|
+
If you are not running this client within [Google Cloud Platform
|
164
|
+
environments](#google-cloud-platform-environments), you need a Google
|
165
|
+
Developers service account.
|
166
|
+
|
167
|
+
1. Visit the [Google Developers Console][dev-console].
|
168
|
+
1. Create a new project or click on an existing project.
|
169
|
+
1. Activate the slide-out navigation tray and select **API Manager**. From
|
170
|
+
here, you will enable the APIs that your application requires.
|
171
|
+
|
172
|
+
![Enable the APIs that your application requires][enable-apis]
|
173
|
+
|
174
|
+
*Note: You may need to enable billing in order to use these services.*
|
175
|
+
|
176
|
+
1. Select **Credentials** from the side navigation.
|
177
|
+
|
178
|
+
You should see a screen like one of the following.
|
179
|
+
|
180
|
+
![Create a new service account][create-new-service-account]
|
181
|
+
|
182
|
+
![Create a new service account With Existing Keys][create-new-service-account-existing-keys]
|
183
|
+
|
184
|
+
Find the "Add credentials" drop down and select "Service account" to be
|
185
|
+
guided through downloading a new JSON key file.
|
186
|
+
|
187
|
+
If you want to re-use an existing service account, you can easily generate a
|
188
|
+
new key file. Just select the account you wish to re-use, and click "Generate
|
189
|
+
new JSON key":
|
190
|
+
|
191
|
+
![Re-use an existing service account][reuse-service-account]
|
192
|
+
|
193
|
+
The key file you download will be used by this library to authenticate API
|
194
|
+
requests and should be stored in a secure location.
|
195
|
+
|
196
|
+
## Troubleshooting
|
197
|
+
|
198
|
+
If you're having trouble authenticating you can ask for help by following the
|
199
|
+
{file:TROUBLESHOOTING.md Troubleshooting Guide}.
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# Ruby Client for Google Cloud Memorystore for Redis API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
|
2
2
|
|
3
3
|
[Google Cloud Memorystore for Redis API][Product Documentation]:
|
4
|
-
|
5
|
-
Redis instances on the Google Cloud Platform.
|
4
|
+
Creates and manages Redis instances on the Google Cloud Platform.
|
6
5
|
- [Client Library Documentation][]
|
7
6
|
- [Product Documentation][]
|
8
7
|
|
data/lib/google/cloud/redis.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2019 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -24,8 +24,7 @@ module Google
|
|
24
24
|
# # Ruby Client for Google Cloud Memorystore for Redis API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
|
25
25
|
#
|
26
26
|
# [Google Cloud Memorystore for Redis API][Product Documentation]:
|
27
|
-
#
|
28
|
-
# Redis instances on the Google Cloud Platform.
|
27
|
+
# Creates and manages Redis instances on the Google Cloud Platform.
|
29
28
|
# - [Product Documentation][]
|
30
29
|
#
|
31
30
|
# ## Quick Start
|
@@ -101,7 +100,7 @@ module Google
|
|
101
100
|
# * As such, Redis instances are resources of the form:
|
102
101
|
# `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
|
103
102
|
#
|
104
|
-
# Note that location_id must be
|
103
|
+
# Note that location_id must be referring to a GCP `region`; for example:
|
105
104
|
# * `projects/redpepper-1290/locations/us-central1/instances/my-redis`
|
106
105
|
#
|
107
106
|
# @param version [Symbol, String]
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2019 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -25,8 +25,7 @@ module Google
|
|
25
25
|
# # Ruby Client for Google Cloud Memorystore for Redis API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
|
26
26
|
#
|
27
27
|
# [Google Cloud Memorystore for Redis API][Product Documentation]:
|
28
|
-
#
|
29
|
-
# Redis instances on the Google Cloud Platform.
|
28
|
+
# Creates and manages Redis instances on the Google Cloud Platform.
|
30
29
|
# - [Product Documentation][]
|
31
30
|
#
|
32
31
|
# ## Quick Start
|
@@ -94,7 +93,7 @@ module Google
|
|
94
93
|
# * As such, Redis instances are resources of the form:
|
95
94
|
# `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
|
96
95
|
#
|
97
|
-
# Note that location_id must be
|
96
|
+
# Note that location_id must be referring to a GCP `region`; for example:
|
98
97
|
# * `projects/redpepper-1290/locations/us-central1/instances/my-redis`
|
99
98
|
#
|
100
99
|
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2019 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -47,7 +47,7 @@ module Google
|
|
47
47
|
# * As such, Redis instances are resources of the form:
|
48
48
|
# `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
|
49
49
|
#
|
50
|
-
# Note that location_id must be
|
50
|
+
# Note that location_id must be referring to a GCP `region`; for example:
|
51
51
|
# * `projects/redpepper-1290/locations/us-central1/instances/my-redis`
|
52
52
|
#
|
53
53
|
# @!attribute [r] cloud_redis_stub
|
@@ -88,28 +88,17 @@ module Google
|
|
88
88
|
self::GRPC_INTERCEPTORS = CloudRedisClient::GRPC_INTERCEPTORS
|
89
89
|
end
|
90
90
|
|
91
|
-
LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
92
|
-
"projects/{project}/locations/{location}"
|
93
|
-
)
|
94
|
-
|
95
|
-
private_constant :LOCATION_PATH_TEMPLATE
|
96
|
-
|
97
91
|
INSTANCE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
98
92
|
"projects/{project}/locations/{location}/instances/{instance}"
|
99
93
|
)
|
100
94
|
|
101
95
|
private_constant :INSTANCE_PATH_TEMPLATE
|
102
96
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
LOCATION_PATH_TEMPLATE.render(
|
109
|
-
:"project" => project,
|
110
|
-
:"location" => location
|
111
|
-
)
|
112
|
-
end
|
97
|
+
LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
98
|
+
"projects/{project}/locations/{location}"
|
99
|
+
)
|
100
|
+
|
101
|
+
private_constant :LOCATION_PATH_TEMPLATE
|
113
102
|
|
114
103
|
# Returns a fully-qualified instance resource name string.
|
115
104
|
# @param project [String]
|
@@ -124,6 +113,17 @@ module Google
|
|
124
113
|
)
|
125
114
|
end
|
126
115
|
|
116
|
+
# Returns a fully-qualified location resource name string.
|
117
|
+
# @param project [String]
|
118
|
+
# @param location [String]
|
119
|
+
# @return [String]
|
120
|
+
def self.location_path project, location
|
121
|
+
LOCATION_PATH_TEMPLATE.render(
|
122
|
+
:"project" => project,
|
123
|
+
:"location" => location
|
124
|
+
)
|
125
|
+
end
|
126
|
+
|
127
127
|
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
128
128
|
# Provides the means for authenticating requests made by the client. This parameter can
|
129
129
|
# be many types.
|
@@ -239,27 +239,50 @@ module Google
|
|
239
239
|
@list_instances = Google::Gax.create_api_call(
|
240
240
|
@cloud_redis_stub.method(:list_instances),
|
241
241
|
defaults["list_instances"],
|
242
|
-
exception_transformer: exception_transformer
|
242
|
+
exception_transformer: exception_transformer,
|
243
|
+
params_extractor: proc do |request|
|
244
|
+
{'parent' => request.parent}
|
245
|
+
end
|
243
246
|
)
|
244
247
|
@get_instance = Google::Gax.create_api_call(
|
245
248
|
@cloud_redis_stub.method(:get_instance),
|
246
249
|
defaults["get_instance"],
|
247
|
-
exception_transformer: exception_transformer
|
250
|
+
exception_transformer: exception_transformer,
|
251
|
+
params_extractor: proc do |request|
|
252
|
+
{'name' => request.name}
|
253
|
+
end
|
248
254
|
)
|
249
255
|
@create_instance = Google::Gax.create_api_call(
|
250
256
|
@cloud_redis_stub.method(:create_instance),
|
251
257
|
defaults["create_instance"],
|
252
|
-
exception_transformer: exception_transformer
|
258
|
+
exception_transformer: exception_transformer,
|
259
|
+
params_extractor: proc do |request|
|
260
|
+
{'parent' => request.parent}
|
261
|
+
end
|
253
262
|
)
|
254
263
|
@update_instance = Google::Gax.create_api_call(
|
255
264
|
@cloud_redis_stub.method(:update_instance),
|
256
265
|
defaults["update_instance"],
|
257
|
-
exception_transformer: exception_transformer
|
266
|
+
exception_transformer: exception_transformer,
|
267
|
+
params_extractor: proc do |request|
|
268
|
+
{'instance.name' => request.instance.name}
|
269
|
+
end
|
258
270
|
)
|
259
271
|
@delete_instance = Google::Gax.create_api_call(
|
260
272
|
@cloud_redis_stub.method(:delete_instance),
|
261
273
|
defaults["delete_instance"],
|
262
|
-
exception_transformer: exception_transformer
|
274
|
+
exception_transformer: exception_transformer,
|
275
|
+
params_extractor: proc do |request|
|
276
|
+
{'name' => request.name}
|
277
|
+
end
|
278
|
+
)
|
279
|
+
@failover_instance = Google::Gax.create_api_call(
|
280
|
+
@cloud_redis_stub.method(:failover_instance),
|
281
|
+
defaults["failover_instance"],
|
282
|
+
exception_transformer: exception_transformer,
|
283
|
+
params_extractor: proc do |request|
|
284
|
+
{'name' => request.name}
|
285
|
+
end
|
263
286
|
)
|
264
287
|
end
|
265
288
|
|
@@ -602,6 +625,77 @@ module Google
|
|
602
625
|
operation.on_done { |operation| yield(operation) } if block_given?
|
603
626
|
operation
|
604
627
|
end
|
628
|
+
|
629
|
+
# Failover the master role to current replica node against a specific
|
630
|
+
# STANDARD tier redis instance.
|
631
|
+
#
|
632
|
+
# @param name [String]
|
633
|
+
# Required. Redis instance resource name using the form:
|
634
|
+
# `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
|
635
|
+
# where `location_id` refers to a GCP region
|
636
|
+
# @param data_protection_mode [Google::Cloud::Redis::V1::FailoverInstanceRequest::DataProtectionMode]
|
637
|
+
# Optional. Available data protection modes that the user can choose. If it's
|
638
|
+
# unspecified, data protection mode will be LIMITED_DATA_LOSS by default.
|
639
|
+
# @param options [Google::Gax::CallOptions]
|
640
|
+
# Overrides the default settings for this call, e.g, timeout,
|
641
|
+
# retries, etc.
|
642
|
+
# @return [Google::Gax::Operation]
|
643
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
644
|
+
# @example
|
645
|
+
# require "google/cloud/redis"
|
646
|
+
#
|
647
|
+
# cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
|
648
|
+
# formatted_name = Google::Cloud::Redis::V1::CloudRedisClient.instance_path("[PROJECT]", "[LOCATION]", "[INSTANCE]")
|
649
|
+
#
|
650
|
+
# # TODO: Initialize `data_protection_mode`:
|
651
|
+
# data_protection_mode = :DATA_PROTECTION_MODE_UNSPECIFIED
|
652
|
+
#
|
653
|
+
# # Register a callback during the method call.
|
654
|
+
# operation = cloud_redis_client.failover_instance(formatted_name, data_protection_mode) do |op|
|
655
|
+
# raise op.results.message if op.error?
|
656
|
+
# op_results = op.results
|
657
|
+
# # Process the results.
|
658
|
+
#
|
659
|
+
# metadata = op.metadata
|
660
|
+
# # Process the metadata.
|
661
|
+
# end
|
662
|
+
#
|
663
|
+
# # Or use the return value to register a callback.
|
664
|
+
# operation.on_done do |op|
|
665
|
+
# raise op.results.message if op.error?
|
666
|
+
# op_results = op.results
|
667
|
+
# # Process the results.
|
668
|
+
#
|
669
|
+
# metadata = op.metadata
|
670
|
+
# # Process the metadata.
|
671
|
+
# end
|
672
|
+
#
|
673
|
+
# # Manually reload the operation.
|
674
|
+
# operation.reload!
|
675
|
+
#
|
676
|
+
# # Or block until the operation completes, triggering callbacks on
|
677
|
+
# # completion.
|
678
|
+
# operation.wait_until_done!
|
679
|
+
|
680
|
+
def failover_instance \
|
681
|
+
name,
|
682
|
+
data_protection_mode,
|
683
|
+
options: nil
|
684
|
+
req = {
|
685
|
+
name: name,
|
686
|
+
data_protection_mode: data_protection_mode
|
687
|
+
}.delete_if { |_, v| v.nil? }
|
688
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::FailoverInstanceRequest)
|
689
|
+
operation = Google::Gax::Operation.new(
|
690
|
+
@failover_instance.call(req, options),
|
691
|
+
@operations_client,
|
692
|
+
Google::Cloud::Redis::V1::Instance,
|
693
|
+
Google::Cloud::Redis::V1::OperationMetadata,
|
694
|
+
call_options: options
|
695
|
+
)
|
696
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
697
|
+
operation
|
698
|
+
end
|
605
699
|
end
|
606
700
|
end
|
607
701
|
end
|