google-cloud-redis 0.8.2 → 1.0.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 -1
- data/AUTHENTICATION.md +51 -54
- data/LICENSE.md +203 -0
- data/MIGRATING.md +272 -0
- data/README.md +35 -23
- data/lib/google-cloud-redis.rb +19 -0
- data/lib/google/cloud/redis.rb +82 -117
- data/lib/google/cloud/redis/version.rb +6 -2
- metadata +97 -62
- data/LICENSE +0 -201
- data/lib/google/cloud/redis/v1.rb +0 -160
- data/lib/google/cloud/redis/v1/cloud_redis_client.rb +0 -893
- data/lib/google/cloud/redis/v1/cloud_redis_client_config.json +0 -66
- data/lib/google/cloud/redis/v1/cloud_redis_pb.rb +0 -159
- data/lib/google/cloud/redis/v1/cloud_redis_services_pb.rb +0 -111
- data/lib/google/cloud/redis/v1/credentials.rb +0 -41
- data/lib/google/cloud/redis/v1/doc/google/cloud/redis/v1/cloud_redis.rb +0 -408
- data/lib/google/cloud/redis/v1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/redis/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/redis/v1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/redis/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/redis/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/redis/v1beta1.rb +0 -160
- data/lib/google/cloud/redis/v1beta1/cloud_redis_client.rb +0 -971
- data/lib/google/cloud/redis/v1beta1/cloud_redis_client_config.json +0 -71
- data/lib/google/cloud/redis/v1beta1/cloud_redis_pb.rb +0 -154
- data/lib/google/cloud/redis/v1beta1/cloud_redis_services_pb.rb +0 -114
- data/lib/google/cloud/redis/v1beta1/credentials.rb +0 -41
- data/lib/google/cloud/redis/v1beta1/doc/google/cloud/redis/v1beta1/cloud_redis.rb +0 -395
- data/lib/google/cloud/redis/v1beta1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/redis/v1beta1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/redis/v1beta1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/redis/v1beta1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/redis/v1beta1/doc/google/rpc/status.rb +0 -39
@@ -1,39 +0,0 @@
|
|
1
|
-
# Copyright 2020 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
|
-
|
16
|
-
module Google
|
17
|
-
module Rpc
|
18
|
-
# The `Status` type defines a logical error model that is suitable for
|
19
|
-
# different programming environments, including REST APIs and RPC APIs. It is
|
20
|
-
# used by [gRPC](https://github.com/grpc). Each `Status` message contains
|
21
|
-
# three pieces of data: error code, error message, and error details.
|
22
|
-
#
|
23
|
-
# You can find out more about this error model and how to work with it in the
|
24
|
-
# [API Design Guide](https://cloud.google.com/apis/design/errors).
|
25
|
-
# @!attribute [rw] code
|
26
|
-
# @return [Integer]
|
27
|
-
# The status code, which should be an enum value of {Google::Rpc::Code}.
|
28
|
-
# @!attribute [rw] message
|
29
|
-
# @return [String]
|
30
|
-
# A developer-facing error message, which should be in English. Any
|
31
|
-
# user-facing error message should be localized and sent in the
|
32
|
-
# {Google::Rpc::Status#details} field, or localized by the client.
|
33
|
-
# @!attribute [rw] details
|
34
|
-
# @return [Array<Google::Protobuf::Any>]
|
35
|
-
# A list of messages that carry the error details. There is a common set of
|
36
|
-
# message types for APIs to use.
|
37
|
-
class Status; end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,160 +0,0 @@
|
|
1
|
-
# Copyright 2020 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
|
-
|
16
|
-
require "google/cloud/redis/v1beta1/cloud_redis_client"
|
17
|
-
require "google/cloud/redis/v1beta1/cloud_redis_pb"
|
18
|
-
|
19
|
-
module Google
|
20
|
-
module Cloud
|
21
|
-
module Redis
|
22
|
-
# rubocop:disable LineLength
|
23
|
-
|
24
|
-
##
|
25
|
-
# # Ruby Client for Google Cloud Memorystore for Redis API
|
26
|
-
#
|
27
|
-
# [Google Cloud Memorystore for Redis API][Product Documentation]:
|
28
|
-
# Creates and manages Redis instances on the Google Cloud Platform.
|
29
|
-
# - [Product Documentation][]
|
30
|
-
#
|
31
|
-
# ## Quick Start
|
32
|
-
# In order to use this library, you first need to go through the following
|
33
|
-
# steps:
|
34
|
-
#
|
35
|
-
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
36
|
-
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
37
|
-
# 3. [Enable the Google Cloud Memorystore for Redis API.](https://console.cloud.google.com/apis/library/redis.googleapis.com)
|
38
|
-
# 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-redis/latest/file.AUTHENTICATION.html)
|
39
|
-
#
|
40
|
-
# ### Installation
|
41
|
-
# ```
|
42
|
-
# $ gem install google-cloud-redis
|
43
|
-
# ```
|
44
|
-
#
|
45
|
-
# ### Next Steps
|
46
|
-
# - Read the [Google Cloud Memorystore for Redis API Product documentation][Product Documentation]
|
47
|
-
# to learn more about the product and see How-to Guides.
|
48
|
-
# - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
49
|
-
# to see the full list of Cloud APIs that we cover.
|
50
|
-
#
|
51
|
-
# [Product Documentation]: https://cloud.google.com/memorystore
|
52
|
-
#
|
53
|
-
# ## Enabling Logging
|
54
|
-
#
|
55
|
-
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
56
|
-
# The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
|
57
|
-
# or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
|
58
|
-
# that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
59
|
-
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
60
|
-
#
|
61
|
-
# Configuring a Ruby stdlib logger:
|
62
|
-
#
|
63
|
-
# ```ruby
|
64
|
-
# require "logger"
|
65
|
-
#
|
66
|
-
# module MyLogger
|
67
|
-
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
68
|
-
# def logger
|
69
|
-
# LOGGER
|
70
|
-
# end
|
71
|
-
# end
|
72
|
-
#
|
73
|
-
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
74
|
-
# module GRPC
|
75
|
-
# extend MyLogger
|
76
|
-
# end
|
77
|
-
# ```
|
78
|
-
#
|
79
|
-
module V1beta1
|
80
|
-
# rubocop:enable LineLength
|
81
|
-
|
82
|
-
##
|
83
|
-
# Configures and manages Cloud Memorystore for Redis instances
|
84
|
-
#
|
85
|
-
# Google Cloud Memorystore for Redis v1beta1
|
86
|
-
#
|
87
|
-
# The `redis.googleapis.com` service implements the Google Cloud Memorystore
|
88
|
-
# for Redis API and defines the following resource model for managing Redis
|
89
|
-
# instances:
|
90
|
-
# * The service works with a collection of cloud projects, named: `/projects/*`
|
91
|
-
# * Each project has a collection of available locations, named: `/locations/*`
|
92
|
-
# * Each location has a collection of Redis instances, named: `/instances/*`
|
93
|
-
# * As such, Redis instances are resources of the form:
|
94
|
-
# `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
|
95
|
-
#
|
96
|
-
# Note that location_id must be refering to a GCP `region`; for example:
|
97
|
-
# * `projects/redpepper-1290/locations/us-central1/instances/my-redis`
|
98
|
-
#
|
99
|
-
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
100
|
-
# Provides the means for authenticating requests made by the client. This parameter can
|
101
|
-
# be many types.
|
102
|
-
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
103
|
-
# authenticating requests made by this client.
|
104
|
-
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
105
|
-
# credentials for this client.
|
106
|
-
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
107
|
-
# credentials for this client.
|
108
|
-
# A `GRPC::Core::Channel` will be used to make calls through.
|
109
|
-
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
110
|
-
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
111
|
-
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
112
|
-
# metadata for requests, generally, to give OAuth credentials.
|
113
|
-
# @param scopes [Array<String>]
|
114
|
-
# The OAuth scopes for this service. This parameter is ignored if
|
115
|
-
# an updater_proc is supplied.
|
116
|
-
# @param client_config [Hash]
|
117
|
-
# A Hash for call options for each method. See
|
118
|
-
# Google::Gax#construct_settings for the structure of
|
119
|
-
# this data. Falls back to the default config if not specified
|
120
|
-
# or the specified config is missing data points.
|
121
|
-
# @param timeout [Numeric]
|
122
|
-
# The default timeout, in seconds, for calls made through this client.
|
123
|
-
# @param metadata [Hash]
|
124
|
-
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
125
|
-
# @param service_address [String]
|
126
|
-
# Override for the service hostname, or `nil` to leave as the default.
|
127
|
-
# @param service_port [Integer]
|
128
|
-
# Override for the service port, or `nil` to leave as the default.
|
129
|
-
# @param exception_transformer [Proc]
|
130
|
-
# An optional proc that intercepts any exceptions raised during an API call to inject
|
131
|
-
# custom error handling.
|
132
|
-
def self.new \
|
133
|
-
credentials: nil,
|
134
|
-
scopes: nil,
|
135
|
-
client_config: nil,
|
136
|
-
timeout: nil,
|
137
|
-
metadata: nil,
|
138
|
-
service_address: nil,
|
139
|
-
service_port: nil,
|
140
|
-
exception_transformer: nil,
|
141
|
-
lib_name: nil,
|
142
|
-
lib_version: nil
|
143
|
-
kwargs = {
|
144
|
-
credentials: credentials,
|
145
|
-
scopes: scopes,
|
146
|
-
client_config: client_config,
|
147
|
-
timeout: timeout,
|
148
|
-
metadata: metadata,
|
149
|
-
exception_transformer: exception_transformer,
|
150
|
-
lib_name: lib_name,
|
151
|
-
service_address: service_address,
|
152
|
-
service_port: service_port,
|
153
|
-
lib_version: lib_version
|
154
|
-
}.select { |_, v| v != nil }
|
155
|
-
Google::Cloud::Redis::V1beta1::CloudRedisClient.new(**kwargs)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
@@ -1,971 +0,0 @@
|
|
1
|
-
# Copyright 2020 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
|
-
|
23
|
-
require "json"
|
24
|
-
require "pathname"
|
25
|
-
|
26
|
-
require "google/gax"
|
27
|
-
require "google/gax/operation"
|
28
|
-
require "google/longrunning/operations_client"
|
29
|
-
|
30
|
-
require "google/cloud/redis/v1beta1/cloud_redis_pb"
|
31
|
-
require "google/cloud/redis/v1beta1/credentials"
|
32
|
-
require "google/cloud/redis/version"
|
33
|
-
|
34
|
-
module Google
|
35
|
-
module Cloud
|
36
|
-
module Redis
|
37
|
-
module V1beta1
|
38
|
-
# Configures and manages Cloud Memorystore for Redis instances
|
39
|
-
#
|
40
|
-
# Google Cloud Memorystore for Redis v1beta1
|
41
|
-
#
|
42
|
-
# The `redis.googleapis.com` service implements the Google Cloud Memorystore
|
43
|
-
# for Redis API and defines the following resource model for managing Redis
|
44
|
-
# instances:
|
45
|
-
# * The service works with a collection of cloud projects, named: `/projects/*`
|
46
|
-
# * Each project has a collection of available locations, named: `/locations/*`
|
47
|
-
# * Each location has a collection of Redis instances, named: `/instances/*`
|
48
|
-
# * As such, Redis instances are resources of the form:
|
49
|
-
# `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
|
50
|
-
#
|
51
|
-
# Note that location_id must be refering to a GCP `region`; for example:
|
52
|
-
# * `projects/redpepper-1290/locations/us-central1/instances/my-redis`
|
53
|
-
#
|
54
|
-
# @!attribute [r] cloud_redis_stub
|
55
|
-
# @return [Google::Cloud::Redis::V1beta1::CloudRedis::Stub]
|
56
|
-
class CloudRedisClient
|
57
|
-
# @private
|
58
|
-
attr_reader :cloud_redis_stub
|
59
|
-
|
60
|
-
# The default address of the service.
|
61
|
-
SERVICE_ADDRESS = "redis.googleapis.com".freeze
|
62
|
-
|
63
|
-
# The default port of the service.
|
64
|
-
DEFAULT_SERVICE_PORT = 443
|
65
|
-
|
66
|
-
# The default set of gRPC interceptors.
|
67
|
-
GRPC_INTERCEPTORS = []
|
68
|
-
|
69
|
-
DEFAULT_TIMEOUT = 30
|
70
|
-
|
71
|
-
PAGE_DESCRIPTORS = {
|
72
|
-
"list_instances" => Google::Gax::PageDescriptor.new(
|
73
|
-
"page_token",
|
74
|
-
"next_page_token",
|
75
|
-
"instances")
|
76
|
-
}.freeze
|
77
|
-
|
78
|
-
private_constant :PAGE_DESCRIPTORS
|
79
|
-
|
80
|
-
# The scopes needed to make gRPC calls to all of the methods defined in
|
81
|
-
# this service.
|
82
|
-
ALL_SCOPES = [
|
83
|
-
"https://www.googleapis.com/auth/cloud-platform"
|
84
|
-
].freeze
|
85
|
-
|
86
|
-
# @private
|
87
|
-
class OperationsClient < Google::Longrunning::OperationsClient
|
88
|
-
self::SERVICE_ADDRESS = CloudRedisClient::SERVICE_ADDRESS
|
89
|
-
self::GRPC_INTERCEPTORS = CloudRedisClient::GRPC_INTERCEPTORS
|
90
|
-
end
|
91
|
-
|
92
|
-
INSTANCE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
93
|
-
"projects/{project}/locations/{location}/instances/{instance}"
|
94
|
-
)
|
95
|
-
|
96
|
-
private_constant :INSTANCE_PATH_TEMPLATE
|
97
|
-
|
98
|
-
LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
99
|
-
"projects/{project}/locations/{location}"
|
100
|
-
)
|
101
|
-
|
102
|
-
private_constant :LOCATION_PATH_TEMPLATE
|
103
|
-
|
104
|
-
# Returns a fully-qualified instance resource name string.
|
105
|
-
# @param project [String]
|
106
|
-
# @param location [String]
|
107
|
-
# @param instance [String]
|
108
|
-
# @return [String]
|
109
|
-
def self.instance_path project, location, instance
|
110
|
-
INSTANCE_PATH_TEMPLATE.render(
|
111
|
-
:"project" => project,
|
112
|
-
:"location" => location,
|
113
|
-
:"instance" => instance
|
114
|
-
)
|
115
|
-
end
|
116
|
-
|
117
|
-
# Returns a fully-qualified location resource name string.
|
118
|
-
# @param project [String]
|
119
|
-
# @param location [String]
|
120
|
-
# @return [String]
|
121
|
-
def self.location_path project, location
|
122
|
-
LOCATION_PATH_TEMPLATE.render(
|
123
|
-
:"project" => project,
|
124
|
-
:"location" => location
|
125
|
-
)
|
126
|
-
end
|
127
|
-
|
128
|
-
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
129
|
-
# Provides the means for authenticating requests made by the client. This parameter can
|
130
|
-
# be many types.
|
131
|
-
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
132
|
-
# authenticating requests made by this client.
|
133
|
-
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
134
|
-
# credentials for this client.
|
135
|
-
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
136
|
-
# credentials for this client.
|
137
|
-
# A `GRPC::Core::Channel` will be used to make calls through.
|
138
|
-
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
139
|
-
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
140
|
-
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
141
|
-
# metadata for requests, generally, to give OAuth credentials.
|
142
|
-
# @param scopes [Array<String>]
|
143
|
-
# The OAuth scopes for this service. This parameter is ignored if
|
144
|
-
# an updater_proc is supplied.
|
145
|
-
# @param client_config [Hash]
|
146
|
-
# A Hash for call options for each method. See
|
147
|
-
# Google::Gax#construct_settings for the structure of
|
148
|
-
# this data. Falls back to the default config if not specified
|
149
|
-
# or the specified config is missing data points.
|
150
|
-
# @param timeout [Numeric]
|
151
|
-
# The default timeout, in seconds, for calls made through this client.
|
152
|
-
# @param metadata [Hash]
|
153
|
-
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
154
|
-
# @param service_address [String]
|
155
|
-
# Override for the service hostname, or `nil` to leave as the default.
|
156
|
-
# @param service_port [Integer]
|
157
|
-
# Override for the service port, or `nil` to leave as the default.
|
158
|
-
# @param exception_transformer [Proc]
|
159
|
-
# An optional proc that intercepts any exceptions raised during an API call to inject
|
160
|
-
# custom error handling.
|
161
|
-
def initialize \
|
162
|
-
credentials: nil,
|
163
|
-
scopes: ALL_SCOPES,
|
164
|
-
client_config: {},
|
165
|
-
timeout: DEFAULT_TIMEOUT,
|
166
|
-
metadata: nil,
|
167
|
-
service_address: nil,
|
168
|
-
service_port: nil,
|
169
|
-
exception_transformer: nil,
|
170
|
-
lib_name: nil,
|
171
|
-
lib_version: ""
|
172
|
-
# These require statements are intentionally placed here to initialize
|
173
|
-
# the gRPC module only when it's required.
|
174
|
-
# See https://github.com/googleapis/toolkit/issues/446
|
175
|
-
require "google/gax/grpc"
|
176
|
-
require "google/cloud/redis/v1beta1/cloud_redis_services_pb"
|
177
|
-
|
178
|
-
credentials ||= Google::Cloud::Redis::V1beta1::Credentials.default
|
179
|
-
|
180
|
-
@operations_client = OperationsClient.new(
|
181
|
-
credentials: credentials,
|
182
|
-
scopes: scopes,
|
183
|
-
client_config: client_config,
|
184
|
-
timeout: timeout,
|
185
|
-
lib_name: lib_name,
|
186
|
-
service_address: service_address,
|
187
|
-
service_port: service_port,
|
188
|
-
lib_version: lib_version,
|
189
|
-
metadata: metadata,
|
190
|
-
)
|
191
|
-
|
192
|
-
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
193
|
-
updater_proc = Google::Cloud::Redis::V1beta1::Credentials.new(credentials).updater_proc
|
194
|
-
end
|
195
|
-
if credentials.is_a?(GRPC::Core::Channel)
|
196
|
-
channel = credentials
|
197
|
-
end
|
198
|
-
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
199
|
-
chan_creds = credentials
|
200
|
-
end
|
201
|
-
if credentials.is_a?(Proc)
|
202
|
-
updater_proc = credentials
|
203
|
-
end
|
204
|
-
if credentials.is_a?(Google::Auth::Credentials)
|
205
|
-
updater_proc = credentials.updater_proc
|
206
|
-
end
|
207
|
-
|
208
|
-
package_version = Google::Cloud::Redis::VERSION
|
209
|
-
|
210
|
-
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
211
|
-
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
212
|
-
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
213
|
-
google_api_client << " grpc/#{GRPC::VERSION}"
|
214
|
-
google_api_client.freeze
|
215
|
-
|
216
|
-
headers = { :"x-goog-api-client" => google_api_client }
|
217
|
-
if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
|
218
|
-
headers[:"x-goog-user-project"] = credentials.quota_project_id
|
219
|
-
end
|
220
|
-
headers.merge!(metadata) unless metadata.nil?
|
221
|
-
client_config_file = Pathname.new(__dir__).join(
|
222
|
-
"cloud_redis_client_config.json"
|
223
|
-
)
|
224
|
-
defaults = client_config_file.open do |f|
|
225
|
-
Google::Gax.construct_settings(
|
226
|
-
"google.cloud.redis.v1beta1.CloudRedis",
|
227
|
-
JSON.parse(f.read),
|
228
|
-
client_config,
|
229
|
-
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
230
|
-
timeout,
|
231
|
-
page_descriptors: PAGE_DESCRIPTORS,
|
232
|
-
errors: Google::Gax::Grpc::API_ERRORS,
|
233
|
-
metadata: headers
|
234
|
-
)
|
235
|
-
end
|
236
|
-
|
237
|
-
# Allow overriding the service path/port in subclasses.
|
238
|
-
service_path = service_address || self.class::SERVICE_ADDRESS
|
239
|
-
port = service_port || self.class::DEFAULT_SERVICE_PORT
|
240
|
-
interceptors = self.class::GRPC_INTERCEPTORS
|
241
|
-
@cloud_redis_stub = Google::Gax::Grpc.create_stub(
|
242
|
-
service_path,
|
243
|
-
port,
|
244
|
-
chan_creds: chan_creds,
|
245
|
-
channel: channel,
|
246
|
-
updater_proc: updater_proc,
|
247
|
-
scopes: scopes,
|
248
|
-
interceptors: interceptors,
|
249
|
-
&Google::Cloud::Redis::V1beta1::CloudRedis::Stub.method(:new)
|
250
|
-
)
|
251
|
-
|
252
|
-
@list_instances = Google::Gax.create_api_call(
|
253
|
-
@cloud_redis_stub.method(:list_instances),
|
254
|
-
defaults["list_instances"],
|
255
|
-
exception_transformer: exception_transformer,
|
256
|
-
params_extractor: proc do |request|
|
257
|
-
{'parent' => request.parent}
|
258
|
-
end
|
259
|
-
)
|
260
|
-
@get_instance = Google::Gax.create_api_call(
|
261
|
-
@cloud_redis_stub.method(:get_instance),
|
262
|
-
defaults["get_instance"],
|
263
|
-
exception_transformer: exception_transformer,
|
264
|
-
params_extractor: proc do |request|
|
265
|
-
{'name' => request.name}
|
266
|
-
end
|
267
|
-
)
|
268
|
-
@create_instance = Google::Gax.create_api_call(
|
269
|
-
@cloud_redis_stub.method(:create_instance),
|
270
|
-
defaults["create_instance"],
|
271
|
-
exception_transformer: exception_transformer,
|
272
|
-
params_extractor: proc do |request|
|
273
|
-
{'parent' => request.parent}
|
274
|
-
end
|
275
|
-
)
|
276
|
-
@update_instance = Google::Gax.create_api_call(
|
277
|
-
@cloud_redis_stub.method(:update_instance),
|
278
|
-
defaults["update_instance"],
|
279
|
-
exception_transformer: exception_transformer,
|
280
|
-
params_extractor: proc do |request|
|
281
|
-
{'instance.name' => request.instance.name}
|
282
|
-
end
|
283
|
-
)
|
284
|
-
@import_instance = Google::Gax.create_api_call(
|
285
|
-
@cloud_redis_stub.method(:import_instance),
|
286
|
-
defaults["import_instance"],
|
287
|
-
exception_transformer: exception_transformer,
|
288
|
-
params_extractor: proc do |request|
|
289
|
-
{'name' => request.name}
|
290
|
-
end
|
291
|
-
)
|
292
|
-
@export_instance = Google::Gax.create_api_call(
|
293
|
-
@cloud_redis_stub.method(:export_instance),
|
294
|
-
defaults["export_instance"],
|
295
|
-
exception_transformer: exception_transformer,
|
296
|
-
params_extractor: proc do |request|
|
297
|
-
{'name' => request.name}
|
298
|
-
end
|
299
|
-
)
|
300
|
-
@failover_instance = Google::Gax.create_api_call(
|
301
|
-
@cloud_redis_stub.method(:failover_instance),
|
302
|
-
defaults["failover_instance"],
|
303
|
-
exception_transformer: exception_transformer,
|
304
|
-
params_extractor: proc do |request|
|
305
|
-
{'name' => request.name}
|
306
|
-
end
|
307
|
-
)
|
308
|
-
@delete_instance = Google::Gax.create_api_call(
|
309
|
-
@cloud_redis_stub.method(:delete_instance),
|
310
|
-
defaults["delete_instance"],
|
311
|
-
exception_transformer: exception_transformer,
|
312
|
-
params_extractor: proc do |request|
|
313
|
-
{'name' => request.name}
|
314
|
-
end
|
315
|
-
)
|
316
|
-
@upgrade_instance = Google::Gax.create_api_call(
|
317
|
-
@cloud_redis_stub.method(:upgrade_instance),
|
318
|
-
defaults["upgrade_instance"],
|
319
|
-
exception_transformer: exception_transformer,
|
320
|
-
params_extractor: proc do |request|
|
321
|
-
{'name' => request.name}
|
322
|
-
end
|
323
|
-
)
|
324
|
-
end
|
325
|
-
|
326
|
-
# Service calls
|
327
|
-
|
328
|
-
# Lists all Redis instances owned by a project in either the specified
|
329
|
-
# location (region) or all locations.
|
330
|
-
#
|
331
|
-
# The location should have the following format:
|
332
|
-
#
|
333
|
-
# * `projects/{project_id}/locations/{location_id}`
|
334
|
-
#
|
335
|
-
# If `location_id` is specified as `-` (wildcard), then all regions
|
336
|
-
# available to the project are queried, and the results are aggregated.
|
337
|
-
#
|
338
|
-
# @param parent [String]
|
339
|
-
# Required. The resource name of the instance location using the form:
|
340
|
-
# `projects/{project_id}/locations/{location_id}`
|
341
|
-
# where `location_id` refers to a GCP region.
|
342
|
-
# @param page_size [Integer]
|
343
|
-
# The maximum number of resources contained in the underlying API
|
344
|
-
# response. If page streaming is performed per-resource, this
|
345
|
-
# parameter does not affect the return value. If page streaming is
|
346
|
-
# performed per-page, this determines the maximum number of
|
347
|
-
# resources in a page.
|
348
|
-
# @param options [Google::Gax::CallOptions]
|
349
|
-
# Overrides the default settings for this call, e.g, timeout,
|
350
|
-
# retries, etc.
|
351
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
352
|
-
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Redis::V1beta1::Instance>]
|
353
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
354
|
-
# @return [Google::Gax::PagedEnumerable<Google::Cloud::Redis::V1beta1::Instance>]
|
355
|
-
# An enumerable of Google::Cloud::Redis::V1beta1::Instance instances.
|
356
|
-
# See Google::Gax::PagedEnumerable documentation for other
|
357
|
-
# operations such as per-page iteration or access to the response
|
358
|
-
# object.
|
359
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
360
|
-
# @example
|
361
|
-
# require "google/cloud/redis"
|
362
|
-
#
|
363
|
-
# cloud_redis_client = Google::Cloud::Redis.new(version: :v1beta1)
|
364
|
-
# formatted_parent = Google::Cloud::Redis::V1beta1::CloudRedisClient.location_path("[PROJECT]", "[LOCATION]")
|
365
|
-
#
|
366
|
-
# # Iterate over all results.
|
367
|
-
# cloud_redis_client.list_instances(formatted_parent).each do |element|
|
368
|
-
# # Process element.
|
369
|
-
# end
|
370
|
-
#
|
371
|
-
# # Or iterate over results one page at a time.
|
372
|
-
# cloud_redis_client.list_instances(formatted_parent).each_page do |page|
|
373
|
-
# # Process each page at a time.
|
374
|
-
# page.each do |element|
|
375
|
-
# # Process element.
|
376
|
-
# end
|
377
|
-
# end
|
378
|
-
|
379
|
-
def list_instances \
|
380
|
-
parent,
|
381
|
-
page_size: nil,
|
382
|
-
options: nil,
|
383
|
-
&block
|
384
|
-
req = {
|
385
|
-
parent: parent,
|
386
|
-
page_size: page_size
|
387
|
-
}.delete_if { |_, v| v.nil? }
|
388
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::ListInstancesRequest)
|
389
|
-
@list_instances.call(req, options, &block)
|
390
|
-
end
|
391
|
-
|
392
|
-
# Gets the details of a specific Redis instance.
|
393
|
-
#
|
394
|
-
# @param name [String]
|
395
|
-
# Required. Redis instance resource name using the form:
|
396
|
-
# `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
|
397
|
-
# where `location_id` refers to a GCP region.
|
398
|
-
# @param options [Google::Gax::CallOptions]
|
399
|
-
# Overrides the default settings for this call, e.g, timeout,
|
400
|
-
# retries, etc.
|
401
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
402
|
-
# @yieldparam result [Google::Cloud::Redis::V1beta1::Instance]
|
403
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
404
|
-
# @return [Google::Cloud::Redis::V1beta1::Instance]
|
405
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
406
|
-
# @example
|
407
|
-
# require "google/cloud/redis"
|
408
|
-
#
|
409
|
-
# cloud_redis_client = Google::Cloud::Redis.new(version: :v1beta1)
|
410
|
-
# formatted_name = Google::Cloud::Redis::V1beta1::CloudRedisClient.instance_path("[PROJECT]", "[LOCATION]", "[INSTANCE]")
|
411
|
-
# response = cloud_redis_client.get_instance(formatted_name)
|
412
|
-
|
413
|
-
def get_instance \
|
414
|
-
name,
|
415
|
-
options: nil,
|
416
|
-
&block
|
417
|
-
req = {
|
418
|
-
name: name
|
419
|
-
}.delete_if { |_, v| v.nil? }
|
420
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::GetInstanceRequest)
|
421
|
-
@get_instance.call(req, options, &block)
|
422
|
-
end
|
423
|
-
|
424
|
-
# Creates a Redis instance based on the specified tier and memory size.
|
425
|
-
#
|
426
|
-
# By default, the instance is accessible from the project's
|
427
|
-
# [default network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks).
|
428
|
-
#
|
429
|
-
# The creation is executed asynchronously and callers may check the returned
|
430
|
-
# operation to track its progress. Once the operation is completed the Redis
|
431
|
-
# instance will be fully functional. Completed longrunning.Operation will
|
432
|
-
# contain the new instance object in the response field.
|
433
|
-
#
|
434
|
-
# The returned operation is automatically deleted after a few hours, so there
|
435
|
-
# is no need to call DeleteOperation.
|
436
|
-
#
|
437
|
-
# @param parent [String]
|
438
|
-
# Required. The resource name of the instance location using the form:
|
439
|
-
# `projects/{project_id}/locations/{location_id}`
|
440
|
-
# where `location_id` refers to a GCP region.
|
441
|
-
# @param instance_id [String]
|
442
|
-
# Required. The logical name of the Redis instance in the customer project
|
443
|
-
# with the following restrictions:
|
444
|
-
#
|
445
|
-
# * Must contain only lowercase letters, numbers, and hyphens.
|
446
|
-
# * Must start with a letter.
|
447
|
-
# * Must be between 1-40 characters.
|
448
|
-
# * Must end with a number or a letter.
|
449
|
-
# * Must be unique within the customer project / location
|
450
|
-
# @param instance [Google::Cloud::Redis::V1beta1::Instance | Hash]
|
451
|
-
# Required. A Redis [Instance] resource
|
452
|
-
# A hash of the same form as `Google::Cloud::Redis::V1beta1::Instance`
|
453
|
-
# can also be provided.
|
454
|
-
# @param options [Google::Gax::CallOptions]
|
455
|
-
# Overrides the default settings for this call, e.g, timeout,
|
456
|
-
# retries, etc.
|
457
|
-
# @return [Google::Gax::Operation]
|
458
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
459
|
-
# @example
|
460
|
-
# require "google/cloud/redis"
|
461
|
-
#
|
462
|
-
# cloud_redis_client = Google::Cloud::Redis.new(version: :v1beta1)
|
463
|
-
# formatted_parent = Google::Cloud::Redis::V1beta1::CloudRedisClient.location_path("[PROJECT]", "[LOCATION]")
|
464
|
-
# instance_id = "test_instance"
|
465
|
-
# tier = :BASIC
|
466
|
-
# memory_size_gb = 1
|
467
|
-
# instance = { tier: tier, memory_size_gb: memory_size_gb }
|
468
|
-
#
|
469
|
-
# # Register a callback during the method call.
|
470
|
-
# operation = cloud_redis_client.create_instance(formatted_parent, instance_id, instance) do |op|
|
471
|
-
# raise op.results.message if op.error?
|
472
|
-
# op_results = op.results
|
473
|
-
# # Process the results.
|
474
|
-
#
|
475
|
-
# metadata = op.metadata
|
476
|
-
# # Process the metadata.
|
477
|
-
# end
|
478
|
-
#
|
479
|
-
# # Or use the return value to register a callback.
|
480
|
-
# operation.on_done do |op|
|
481
|
-
# raise op.results.message if op.error?
|
482
|
-
# op_results = op.results
|
483
|
-
# # Process the results.
|
484
|
-
#
|
485
|
-
# metadata = op.metadata
|
486
|
-
# # Process the metadata.
|
487
|
-
# end
|
488
|
-
#
|
489
|
-
# # Manually reload the operation.
|
490
|
-
# operation.reload!
|
491
|
-
#
|
492
|
-
# # Or block until the operation completes, triggering callbacks on
|
493
|
-
# # completion.
|
494
|
-
# operation.wait_until_done!
|
495
|
-
|
496
|
-
def create_instance \
|
497
|
-
parent,
|
498
|
-
instance_id,
|
499
|
-
instance,
|
500
|
-
options: nil
|
501
|
-
req = {
|
502
|
-
parent: parent,
|
503
|
-
instance_id: instance_id,
|
504
|
-
instance: instance
|
505
|
-
}.delete_if { |_, v| v.nil? }
|
506
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::CreateInstanceRequest)
|
507
|
-
operation = Google::Gax::Operation.new(
|
508
|
-
@create_instance.call(req, options),
|
509
|
-
@operations_client,
|
510
|
-
Google::Cloud::Redis::V1beta1::Instance,
|
511
|
-
Google::Protobuf::Any,
|
512
|
-
call_options: options
|
513
|
-
)
|
514
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
515
|
-
operation
|
516
|
-
end
|
517
|
-
|
518
|
-
# Updates the metadata and configuration of a specific Redis instance.
|
519
|
-
#
|
520
|
-
# Completed longrunning.Operation will contain the new instance object
|
521
|
-
# in the response field. The returned operation is automatically deleted
|
522
|
-
# after a few hours, so there is no need to call DeleteOperation.
|
523
|
-
#
|
524
|
-
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
525
|
-
# Required. Mask of fields to update. At least one path must be supplied in
|
526
|
-
# this field. The elements of the repeated paths field may only include these
|
527
|
-
# fields from {Google::Cloud::Redis::V1beta1::Instance Instance}:
|
528
|
-
#
|
529
|
-
# * `displayName`
|
530
|
-
# * `labels`
|
531
|
-
# * `memorySizeGb`
|
532
|
-
# * `redisConfig`
|
533
|
-
# A hash of the same form as `Google::Protobuf::FieldMask`
|
534
|
-
# can also be provided.
|
535
|
-
# @param instance [Google::Cloud::Redis::V1beta1::Instance | Hash]
|
536
|
-
# Required. Update description.
|
537
|
-
# Only fields specified in update_mask are updated.
|
538
|
-
# A hash of the same form as `Google::Cloud::Redis::V1beta1::Instance`
|
539
|
-
# can also be provided.
|
540
|
-
# @param options [Google::Gax::CallOptions]
|
541
|
-
# Overrides the default settings for this call, e.g, timeout,
|
542
|
-
# retries, etc.
|
543
|
-
# @return [Google::Gax::Operation]
|
544
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
545
|
-
# @example
|
546
|
-
# require "google/cloud/redis"
|
547
|
-
#
|
548
|
-
# cloud_redis_client = Google::Cloud::Redis.new(version: :v1beta1)
|
549
|
-
# paths_element = "display_name"
|
550
|
-
# paths_element_2 = "memory_size_gb"
|
551
|
-
# paths = [paths_element, paths_element_2]
|
552
|
-
# update_mask = { paths: paths }
|
553
|
-
# display_name = "UpdatedDisplayName"
|
554
|
-
# name = "projects/<project-name>/locations/<location>/instances/<instance>"
|
555
|
-
# memory_size_gb = 4
|
556
|
-
# instance = {
|
557
|
-
# display_name: display_name,
|
558
|
-
# name: name,
|
559
|
-
# memory_size_gb: memory_size_gb
|
560
|
-
# }
|
561
|
-
#
|
562
|
-
# # Register a callback during the method call.
|
563
|
-
# operation = cloud_redis_client.update_instance(update_mask, instance) do |op|
|
564
|
-
# raise op.results.message if op.error?
|
565
|
-
# op_results = op.results
|
566
|
-
# # Process the results.
|
567
|
-
#
|
568
|
-
# metadata = op.metadata
|
569
|
-
# # Process the metadata.
|
570
|
-
# end
|
571
|
-
#
|
572
|
-
# # Or use the return value to register a callback.
|
573
|
-
# operation.on_done do |op|
|
574
|
-
# raise op.results.message if op.error?
|
575
|
-
# op_results = op.results
|
576
|
-
# # Process the results.
|
577
|
-
#
|
578
|
-
# metadata = op.metadata
|
579
|
-
# # Process the metadata.
|
580
|
-
# end
|
581
|
-
#
|
582
|
-
# # Manually reload the operation.
|
583
|
-
# operation.reload!
|
584
|
-
#
|
585
|
-
# # Or block until the operation completes, triggering callbacks on
|
586
|
-
# # completion.
|
587
|
-
# operation.wait_until_done!
|
588
|
-
|
589
|
-
def update_instance \
|
590
|
-
update_mask,
|
591
|
-
instance,
|
592
|
-
options: nil
|
593
|
-
req = {
|
594
|
-
update_mask: update_mask,
|
595
|
-
instance: instance
|
596
|
-
}.delete_if { |_, v| v.nil? }
|
597
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::UpdateInstanceRequest)
|
598
|
-
operation = Google::Gax::Operation.new(
|
599
|
-
@update_instance.call(req, options),
|
600
|
-
@operations_client,
|
601
|
-
Google::Cloud::Redis::V1beta1::Instance,
|
602
|
-
Google::Protobuf::Any,
|
603
|
-
call_options: options
|
604
|
-
)
|
605
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
606
|
-
operation
|
607
|
-
end
|
608
|
-
|
609
|
-
# Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
|
610
|
-
#
|
611
|
-
# Redis may stop serving during this operation. Instance state will be
|
612
|
-
# IMPORTING for entire operation. When complete, the instance will contain
|
613
|
-
# only data from the imported file.
|
614
|
-
#
|
615
|
-
# The returned operation is automatically deleted after a few hours, so
|
616
|
-
# there is no need to call DeleteOperation.
|
617
|
-
#
|
618
|
-
# @param name [String]
|
619
|
-
# Required. Redis instance resource name using the form:
|
620
|
-
# `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
|
621
|
-
# where `location_id` refers to a GCP region.
|
622
|
-
# @param input_config [Google::Cloud::Redis::V1beta1::InputConfig | Hash]
|
623
|
-
# Required. Specify data to be imported.
|
624
|
-
# A hash of the same form as `Google::Cloud::Redis::V1beta1::InputConfig`
|
625
|
-
# can also be provided.
|
626
|
-
# @param options [Google::Gax::CallOptions]
|
627
|
-
# Overrides the default settings for this call, e.g, timeout,
|
628
|
-
# retries, etc.
|
629
|
-
# @return [Google::Gax::Operation]
|
630
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
631
|
-
# @example
|
632
|
-
# require "google/cloud/redis"
|
633
|
-
#
|
634
|
-
# cloud_redis_client = Google::Cloud::Redis.new(version: :v1beta1)
|
635
|
-
#
|
636
|
-
# # TODO: Initialize `name`:
|
637
|
-
# name = ''
|
638
|
-
#
|
639
|
-
# # TODO: Initialize `input_config`:
|
640
|
-
# input_config = {}
|
641
|
-
#
|
642
|
-
# # Register a callback during the method call.
|
643
|
-
# operation = cloud_redis_client.import_instance(name, input_config) do |op|
|
644
|
-
# raise op.results.message if op.error?
|
645
|
-
# op_results = op.results
|
646
|
-
# # Process the results.
|
647
|
-
#
|
648
|
-
# metadata = op.metadata
|
649
|
-
# # Process the metadata.
|
650
|
-
# end
|
651
|
-
#
|
652
|
-
# # Or use the return value to register a callback.
|
653
|
-
# operation.on_done do |op|
|
654
|
-
# raise op.results.message if op.error?
|
655
|
-
# op_results = op.results
|
656
|
-
# # Process the results.
|
657
|
-
#
|
658
|
-
# metadata = op.metadata
|
659
|
-
# # Process the metadata.
|
660
|
-
# end
|
661
|
-
#
|
662
|
-
# # Manually reload the operation.
|
663
|
-
# operation.reload!
|
664
|
-
#
|
665
|
-
# # Or block until the operation completes, triggering callbacks on
|
666
|
-
# # completion.
|
667
|
-
# operation.wait_until_done!
|
668
|
-
|
669
|
-
def import_instance \
|
670
|
-
name,
|
671
|
-
input_config,
|
672
|
-
options: nil
|
673
|
-
req = {
|
674
|
-
name: name,
|
675
|
-
input_config: input_config
|
676
|
-
}.delete_if { |_, v| v.nil? }
|
677
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::ImportInstanceRequest)
|
678
|
-
operation = Google::Gax::Operation.new(
|
679
|
-
@import_instance.call(req, options),
|
680
|
-
@operations_client,
|
681
|
-
Google::Cloud::Redis::V1beta1::Instance,
|
682
|
-
Google::Protobuf::Any,
|
683
|
-
call_options: options
|
684
|
-
)
|
685
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
686
|
-
operation
|
687
|
-
end
|
688
|
-
|
689
|
-
# Export Redis instance data into a Redis RDB format file in Cloud Storage.
|
690
|
-
#
|
691
|
-
# Redis will continue serving during this operation.
|
692
|
-
#
|
693
|
-
# The returned operation is automatically deleted after a few hours, so
|
694
|
-
# there is no need to call DeleteOperation.
|
695
|
-
#
|
696
|
-
# @param name [String]
|
697
|
-
# Required. Redis instance resource name using the form:
|
698
|
-
# `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
|
699
|
-
# where `location_id` refers to a GCP region.
|
700
|
-
# @param output_config [Google::Cloud::Redis::V1beta1::OutputConfig | Hash]
|
701
|
-
# Required. Specify data to be exported.
|
702
|
-
# A hash of the same form as `Google::Cloud::Redis::V1beta1::OutputConfig`
|
703
|
-
# can also be provided.
|
704
|
-
# @param options [Google::Gax::CallOptions]
|
705
|
-
# Overrides the default settings for this call, e.g, timeout,
|
706
|
-
# retries, etc.
|
707
|
-
# @return [Google::Gax::Operation]
|
708
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
709
|
-
# @example
|
710
|
-
# require "google/cloud/redis"
|
711
|
-
#
|
712
|
-
# cloud_redis_client = Google::Cloud::Redis.new(version: :v1beta1)
|
713
|
-
#
|
714
|
-
# # TODO: Initialize `name`:
|
715
|
-
# name = ''
|
716
|
-
#
|
717
|
-
# # TODO: Initialize `output_config`:
|
718
|
-
# output_config = {}
|
719
|
-
#
|
720
|
-
# # Register a callback during the method call.
|
721
|
-
# operation = cloud_redis_client.export_instance(name, output_config) do |op|
|
722
|
-
# raise op.results.message if op.error?
|
723
|
-
# op_results = op.results
|
724
|
-
# # Process the results.
|
725
|
-
#
|
726
|
-
# metadata = op.metadata
|
727
|
-
# # Process the metadata.
|
728
|
-
# end
|
729
|
-
#
|
730
|
-
# # Or use the return value to register a callback.
|
731
|
-
# operation.on_done do |op|
|
732
|
-
# raise op.results.message if op.error?
|
733
|
-
# op_results = op.results
|
734
|
-
# # Process the results.
|
735
|
-
#
|
736
|
-
# metadata = op.metadata
|
737
|
-
# # Process the metadata.
|
738
|
-
# end
|
739
|
-
#
|
740
|
-
# # Manually reload the operation.
|
741
|
-
# operation.reload!
|
742
|
-
#
|
743
|
-
# # Or block until the operation completes, triggering callbacks on
|
744
|
-
# # completion.
|
745
|
-
# operation.wait_until_done!
|
746
|
-
|
747
|
-
def export_instance \
|
748
|
-
name,
|
749
|
-
output_config,
|
750
|
-
options: nil
|
751
|
-
req = {
|
752
|
-
name: name,
|
753
|
-
output_config: output_config
|
754
|
-
}.delete_if { |_, v| v.nil? }
|
755
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::ExportInstanceRequest)
|
756
|
-
operation = Google::Gax::Operation.new(
|
757
|
-
@export_instance.call(req, options),
|
758
|
-
@operations_client,
|
759
|
-
Google::Cloud::Redis::V1beta1::Instance,
|
760
|
-
Google::Protobuf::Any,
|
761
|
-
call_options: options
|
762
|
-
)
|
763
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
764
|
-
operation
|
765
|
-
end
|
766
|
-
|
767
|
-
# Initiates a failover of the master node to current replica node for a
|
768
|
-
# specific STANDARD tier Cloud Memorystore for Redis instance.
|
769
|
-
#
|
770
|
-
# @param name [String]
|
771
|
-
# Required. Redis instance resource name using the form:
|
772
|
-
# `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
|
773
|
-
# where `location_id` refers to a GCP region.
|
774
|
-
# @param data_protection_mode [Google::Cloud::Redis::V1beta1::FailoverInstanceRequest::DataProtectionMode]
|
775
|
-
# Optional. Available data protection modes that the user can choose. If it's
|
776
|
-
# unspecified, data protection mode will be LIMITED_DATA_LOSS by default.
|
777
|
-
# @param options [Google::Gax::CallOptions]
|
778
|
-
# Overrides the default settings for this call, e.g, timeout,
|
779
|
-
# retries, etc.
|
780
|
-
# @return [Google::Gax::Operation]
|
781
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
782
|
-
# @example
|
783
|
-
# require "google/cloud/redis"
|
784
|
-
#
|
785
|
-
# cloud_redis_client = Google::Cloud::Redis.new(version: :v1beta1)
|
786
|
-
# formatted_name = Google::Cloud::Redis::V1beta1::CloudRedisClient.instance_path("[PROJECT]", "[LOCATION]", "[INSTANCE]")
|
787
|
-
#
|
788
|
-
# # Register a callback during the method call.
|
789
|
-
# operation = cloud_redis_client.failover_instance(formatted_name) do |op|
|
790
|
-
# raise op.results.message if op.error?
|
791
|
-
# op_results = op.results
|
792
|
-
# # Process the results.
|
793
|
-
#
|
794
|
-
# metadata = op.metadata
|
795
|
-
# # Process the metadata.
|
796
|
-
# end
|
797
|
-
#
|
798
|
-
# # Or use the return value to register a callback.
|
799
|
-
# operation.on_done do |op|
|
800
|
-
# raise op.results.message if op.error?
|
801
|
-
# op_results = op.results
|
802
|
-
# # Process the results.
|
803
|
-
#
|
804
|
-
# metadata = op.metadata
|
805
|
-
# # Process the metadata.
|
806
|
-
# end
|
807
|
-
#
|
808
|
-
# # Manually reload the operation.
|
809
|
-
# operation.reload!
|
810
|
-
#
|
811
|
-
# # Or block until the operation completes, triggering callbacks on
|
812
|
-
# # completion.
|
813
|
-
# operation.wait_until_done!
|
814
|
-
|
815
|
-
def failover_instance \
|
816
|
-
name,
|
817
|
-
data_protection_mode: nil,
|
818
|
-
options: nil
|
819
|
-
req = {
|
820
|
-
name: name,
|
821
|
-
data_protection_mode: data_protection_mode
|
822
|
-
}.delete_if { |_, v| v.nil? }
|
823
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::FailoverInstanceRequest)
|
824
|
-
operation = Google::Gax::Operation.new(
|
825
|
-
@failover_instance.call(req, options),
|
826
|
-
@operations_client,
|
827
|
-
Google::Cloud::Redis::V1beta1::Instance,
|
828
|
-
Google::Protobuf::Any,
|
829
|
-
call_options: options
|
830
|
-
)
|
831
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
832
|
-
operation
|
833
|
-
end
|
834
|
-
|
835
|
-
# Deletes a specific Redis instance. Instance stops serving and data is
|
836
|
-
# deleted.
|
837
|
-
#
|
838
|
-
# @param name [String]
|
839
|
-
# Required. Redis instance resource name using the form:
|
840
|
-
# `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
|
841
|
-
# where `location_id` refers to a GCP region.
|
842
|
-
# @param options [Google::Gax::CallOptions]
|
843
|
-
# Overrides the default settings for this call, e.g, timeout,
|
844
|
-
# retries, etc.
|
845
|
-
# @return [Google::Gax::Operation]
|
846
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
847
|
-
# @example
|
848
|
-
# require "google/cloud/redis"
|
849
|
-
#
|
850
|
-
# cloud_redis_client = Google::Cloud::Redis.new(version: :v1beta1)
|
851
|
-
# formatted_name = Google::Cloud::Redis::V1beta1::CloudRedisClient.instance_path("[PROJECT]", "[LOCATION]", "[INSTANCE]")
|
852
|
-
#
|
853
|
-
# # Register a callback during the method call.
|
854
|
-
# operation = cloud_redis_client.delete_instance(formatted_name) do |op|
|
855
|
-
# raise op.results.message if op.error?
|
856
|
-
# op_results = op.results
|
857
|
-
# # Process the results.
|
858
|
-
#
|
859
|
-
# metadata = op.metadata
|
860
|
-
# # Process the metadata.
|
861
|
-
# end
|
862
|
-
#
|
863
|
-
# # Or use the return value to register a callback.
|
864
|
-
# operation.on_done do |op|
|
865
|
-
# raise op.results.message if op.error?
|
866
|
-
# op_results = op.results
|
867
|
-
# # Process the results.
|
868
|
-
#
|
869
|
-
# metadata = op.metadata
|
870
|
-
# # Process the metadata.
|
871
|
-
# end
|
872
|
-
#
|
873
|
-
# # Manually reload the operation.
|
874
|
-
# operation.reload!
|
875
|
-
#
|
876
|
-
# # Or block until the operation completes, triggering callbacks on
|
877
|
-
# # completion.
|
878
|
-
# operation.wait_until_done!
|
879
|
-
|
880
|
-
def delete_instance \
|
881
|
-
name,
|
882
|
-
options: nil
|
883
|
-
req = {
|
884
|
-
name: name
|
885
|
-
}.delete_if { |_, v| v.nil? }
|
886
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::DeleteInstanceRequest)
|
887
|
-
operation = Google::Gax::Operation.new(
|
888
|
-
@delete_instance.call(req, options),
|
889
|
-
@operations_client,
|
890
|
-
Google::Protobuf::Empty,
|
891
|
-
Google::Protobuf::Any,
|
892
|
-
call_options: options
|
893
|
-
)
|
894
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
895
|
-
operation
|
896
|
-
end
|
897
|
-
|
898
|
-
# Upgrades Redis instance to the newer Redis version specified in the
|
899
|
-
# request.
|
900
|
-
#
|
901
|
-
# @param name [String]
|
902
|
-
# Required. Redis instance resource name using the form:
|
903
|
-
# `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
|
904
|
-
# where `location_id` refers to a GCP region.
|
905
|
-
# @param redis_version [String]
|
906
|
-
# Required. Specifies the target version of Redis software to upgrade to.
|
907
|
-
# @param options [Google::Gax::CallOptions]
|
908
|
-
# Overrides the default settings for this call, e.g, timeout,
|
909
|
-
# retries, etc.
|
910
|
-
# @return [Google::Gax::Operation]
|
911
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
912
|
-
# @example
|
913
|
-
# require "google/cloud/redis"
|
914
|
-
#
|
915
|
-
# cloud_redis_client = Google::Cloud::Redis.new(version: :v1beta1)
|
916
|
-
# formatted_name = Google::Cloud::Redis::V1beta1::CloudRedisClient.instance_path("[PROJECT]", "[LOCATION]", "[INSTANCE]")
|
917
|
-
#
|
918
|
-
# # TODO: Initialize `redis_version`:
|
919
|
-
# redis_version = ''
|
920
|
-
#
|
921
|
-
# # Register a callback during the method call.
|
922
|
-
# operation = cloud_redis_client.upgrade_instance(formatted_name, redis_version) do |op|
|
923
|
-
# raise op.results.message if op.error?
|
924
|
-
# op_results = op.results
|
925
|
-
# # Process the results.
|
926
|
-
#
|
927
|
-
# metadata = op.metadata
|
928
|
-
# # Process the metadata.
|
929
|
-
# end
|
930
|
-
#
|
931
|
-
# # Or use the return value to register a callback.
|
932
|
-
# operation.on_done do |op|
|
933
|
-
# raise op.results.message if op.error?
|
934
|
-
# op_results = op.results
|
935
|
-
# # Process the results.
|
936
|
-
#
|
937
|
-
# metadata = op.metadata
|
938
|
-
# # Process the metadata.
|
939
|
-
# end
|
940
|
-
#
|
941
|
-
# # Manually reload the operation.
|
942
|
-
# operation.reload!
|
943
|
-
#
|
944
|
-
# # Or block until the operation completes, triggering callbacks on
|
945
|
-
# # completion.
|
946
|
-
# operation.wait_until_done!
|
947
|
-
|
948
|
-
def upgrade_instance \
|
949
|
-
name,
|
950
|
-
redis_version,
|
951
|
-
options: nil
|
952
|
-
req = {
|
953
|
-
name: name,
|
954
|
-
redis_version: redis_version
|
955
|
-
}.delete_if { |_, v| v.nil? }
|
956
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1beta1::UpgradeInstanceRequest)
|
957
|
-
operation = Google::Gax::Operation.new(
|
958
|
-
@upgrade_instance.call(req, options),
|
959
|
-
@operations_client,
|
960
|
-
Google::Cloud::Redis::V1beta1::Instance,
|
961
|
-
Google::Protobuf::Any,
|
962
|
-
call_options: options
|
963
|
-
)
|
964
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
965
|
-
operation
|
966
|
-
end
|
967
|
-
end
|
968
|
-
end
|
969
|
-
end
|
970
|
-
end
|
971
|
-
end
|