google-cloud-redis 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fed899bf9329b19a9e191a298f6a6afe90e4940e2264c211b3bdb1235d60352
4
- data.tar.gz: c35be3b5206389734cea6a548a9dea1cdf6f783d51b4c48bba96c0d336c16960
3
+ metadata.gz: eb6683f598b300a7809cbe916b7df247dab57d69d232ccc4145c91e1a78e85b0
4
+ data.tar.gz: 6ecb53c6b045e0d5f5a0ee6698b27f50c382c511578f848073d56ac30d8d5221
5
5
  SHA512:
6
- metadata.gz: eb801e54e12faf777e24a34171f7a6bb3b4c7e7facd03d00018258c8fcbf0a7fa4aa2812fb248dd933857cd452b76ebecb6aff9684202300e6519202fdf60d2f
7
- data.tar.gz: 8099882147658ca64c9605cf8e5f6c0d098eed62f34cfd00717607824ae24890558b557a280fcc286964d5002b0f6f8eedd072d10b6e7c86eb6db7f1992ddc1d
6
+ metadata.gz: ce7f29a719809df063e21d87e4f9771b3674a5ea1c5bb633f207822fb0dff685683d2618fccdce20f2bda237811d5ad464a46c80d883b895493590123a54fa8a
7
+ data.tar.gz: 86ac8a55ea31a9d72eb72ed92d83a3a9ef4588fcc866010935386da37310367870935ca39464e8e70d7453aa62613647363bcebe038c30e8b4c91bf8b4a3fd5c
data/README.md CHANGED
@@ -28,7 +28,7 @@ $ gem install google-cloud-redis
28
28
  - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
29
29
  to see the full list of Cloud APIs that we cover.
30
30
 
31
- [Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-redis/latest/google/cloud/redis/v1beta1
31
+ [Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-redis/latest/google/cloud/redis/v1
32
32
  [Product Documentation]: https://cloud.google.com/memorystore
33
33
 
34
34
  ## Enabling Logging
@@ -90,7 +90,7 @@ module Google
90
90
  ##
91
91
  # Configures and manages Cloud Memorystore for Redis instances
92
92
  #
93
- # Google Cloud Memorystore for Redis v1beta1
93
+ # Google Cloud Memorystore for Redis v1
94
94
  #
95
95
  # The +redis.googleapis.com+ service implements the Google Cloud Memorystore
96
96
  # for Redis API and defines the following resource model for managing Redis
@@ -105,7 +105,7 @@ module Google
105
105
  # * +projects/redpepper-1290/locations/us-central1/instances/my-redis+
106
106
  #
107
107
  # @param version [Symbol, String]
108
- # The major version of the service to be used. By default :v1beta1
108
+ # The major version of the service to be used. By default :v1
109
109
  # is used.
110
110
  # @overload new(version:, credentials:, scopes:, client_config:, timeout:)
111
111
  # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
@@ -137,7 +137,7 @@ module Google
137
137
  # @param exception_transformer [Proc]
138
138
  # An optional proc that intercepts any exceptions raised during an API call to inject
139
139
  # custom error handling.
140
- def self.new(*args, version: :v1beta1, **kwargs)
140
+ def self.new(*args, version: :v1, **kwargs)
141
141
  unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
142
142
  raise "The version: #{version} is not available. The available versions " \
143
143
  "are: [#{AVAILABLE_VERSIONS.join(", ")}]"
@@ -0,0 +1,153 @@
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
+
16
+ require "google/cloud/redis/v1/cloud_redis_client"
17
+ require "google/cloud/redis/v1/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 ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
26
+ #
27
+ # [Google Cloud Memorystore for Redis API][Product Documentation]:
28
+ # The Google Cloud Memorystore for Redis API is used for creating and managing
29
+ # Redis instances on the Google Cloud Platform.
30
+ # - [Product Documentation][]
31
+ #
32
+ # ## Quick Start
33
+ # In order to use this library, you first need to go through the following
34
+ # steps:
35
+ #
36
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
37
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
38
+ # 3. [Enable the Google Cloud Memorystore for Redis API.](https://console.cloud.google.com/apis/library/redis.googleapis.com)
39
+ # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
40
+ #
41
+ # ### Installation
42
+ # ```
43
+ # $ gem install google-cloud-redis
44
+ # ```
45
+ #
46
+ # ### Next Steps
47
+ # - Read the [Google Cloud Memorystore for Redis API Product documentation][Product Documentation]
48
+ # to learn more about the product and see How-to Guides.
49
+ # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
50
+ # to see the full list of Cloud APIs that we cover.
51
+ #
52
+ # [Product Documentation]: https://cloud.google.com/memorystore
53
+ #
54
+ # ## Enabling Logging
55
+ #
56
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
57
+ # 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,
58
+ # or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
59
+ # 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)
60
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
61
+ #
62
+ # Configuring a Ruby stdlib logger:
63
+ #
64
+ # ```ruby
65
+ # require "logger"
66
+ #
67
+ # module MyLogger
68
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
69
+ # def logger
70
+ # LOGGER
71
+ # end
72
+ # end
73
+ #
74
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
75
+ # module GRPC
76
+ # extend MyLogger
77
+ # end
78
+ # ```
79
+ #
80
+ module V1
81
+ # rubocop:enable LineLength
82
+
83
+ ##
84
+ # Configures and manages Cloud Memorystore for Redis instances
85
+ #
86
+ # Google Cloud Memorystore for Redis v1
87
+ #
88
+ # The +redis.googleapis.com+ service implements the Google Cloud Memorystore
89
+ # for Redis API and defines the following resource model for managing Redis
90
+ # instances:
91
+ # * The service works with a collection of cloud projects, named: +/projects/*+
92
+ # * Each project has a collection of available locations, named: +/locations/*+
93
+ # * Each location has a collection of Redis instances, named: +/instances/*+
94
+ # * As such, Redis instances are resources of the form:
95
+ # +/projects/\\{project_id}/locations/\\{location_id}/instances/\\{instance_id}+
96
+ #
97
+ # Note that location_id must be refering to a GCP +region+; for example:
98
+ # * +projects/redpepper-1290/locations/us-central1/instances/my-redis+
99
+ #
100
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
101
+ # Provides the means for authenticating requests made by the client. This parameter can
102
+ # be many types.
103
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
104
+ # authenticating requests made by this client.
105
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
106
+ # credentials for this client.
107
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
108
+ # credentials for this client.
109
+ # A `GRPC::Core::Channel` will be used to make calls through.
110
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
111
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
112
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
113
+ # metadata for requests, generally, to give OAuth credentials.
114
+ # @param scopes [Array<String>]
115
+ # The OAuth scopes for this service. This parameter is ignored if
116
+ # an updater_proc is supplied.
117
+ # @param client_config [Hash]
118
+ # A Hash for call options for each method. See
119
+ # Google::Gax#construct_settings for the structure of
120
+ # this data. Falls back to the default config if not specified
121
+ # or the specified config is missing data points.
122
+ # @param timeout [Numeric]
123
+ # The default timeout, in seconds, for calls made through this client.
124
+ # @param metadata [Hash]
125
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
126
+ # @param exception_transformer [Proc]
127
+ # An optional proc that intercepts any exceptions raised during an API call to inject
128
+ # custom error handling.
129
+ def self.new \
130
+ credentials: nil,
131
+ scopes: nil,
132
+ client_config: nil,
133
+ timeout: nil,
134
+ metadata: nil,
135
+ exception_transformer: nil,
136
+ lib_name: nil,
137
+ lib_version: nil
138
+ kwargs = {
139
+ credentials: credentials,
140
+ scopes: scopes,
141
+ client_config: client_config,
142
+ timeout: timeout,
143
+ metadata: metadata,
144
+ exception_transformer: exception_transformer,
145
+ lib_name: lib_name,
146
+ lib_version: lib_version
147
+ }.select { |_, v| v != nil }
148
+ Google::Cloud::Redis::V1::CloudRedisClient.new(**kwargs)
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,609 @@
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/v1/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/v1/cloud_redis_pb"
31
+ require "google/cloud/redis/v1/credentials"
32
+
33
+ module Google
34
+ module Cloud
35
+ module Redis
36
+ module V1
37
+ # Configures and manages Cloud Memorystore for Redis instances
38
+ #
39
+ # Google Cloud Memorystore for Redis v1
40
+ #
41
+ # The +redis.googleapis.com+ service implements the Google Cloud Memorystore
42
+ # for Redis API and defines the following resource model for managing Redis
43
+ # instances:
44
+ # * The service works with a collection of cloud projects, named: +/projects/*+
45
+ # * Each project has a collection of available locations, named: +/locations/*+
46
+ # * Each location has a collection of Redis instances, named: +/instances/*+
47
+ # * As such, Redis instances are resources of the form:
48
+ # +/projects/\\{project_id}/locations/\\{location_id}/instances/\\{instance_id}+
49
+ #
50
+ # Note that location_id must be refering to a GCP +region+; for example:
51
+ # * +projects/redpepper-1290/locations/us-central1/instances/my-redis+
52
+ #
53
+ # @!attribute [r] cloud_redis_stub
54
+ # @return [Google::Cloud::Redis::V1::CloudRedis::Stub]
55
+ class CloudRedisClient
56
+ # @private
57
+ attr_reader :cloud_redis_stub
58
+
59
+ # The default address of the service.
60
+ SERVICE_ADDRESS = "redis.googleapis.com".freeze
61
+
62
+ # The default port of the service.
63
+ DEFAULT_SERVICE_PORT = 443
64
+
65
+ # The default set of gRPC interceptors.
66
+ GRPC_INTERCEPTORS = []
67
+
68
+ DEFAULT_TIMEOUT = 30
69
+
70
+ PAGE_DESCRIPTORS = {
71
+ "list_instances" => Google::Gax::PageDescriptor.new(
72
+ "page_token",
73
+ "next_page_token",
74
+ "instances")
75
+ }.freeze
76
+
77
+ private_constant :PAGE_DESCRIPTORS
78
+
79
+ # The scopes needed to make gRPC calls to all of the methods defined in
80
+ # this service.
81
+ ALL_SCOPES = [
82
+ "https://www.googleapis.com/auth/cloud-platform"
83
+ ].freeze
84
+
85
+ # @private
86
+ class OperationsClient < Google::Longrunning::OperationsClient
87
+ self::SERVICE_ADDRESS = CloudRedisClient::SERVICE_ADDRESS
88
+ self::GRPC_INTERCEPTORS = CloudRedisClient::GRPC_INTERCEPTORS
89
+ end
90
+
91
+ LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
92
+ "projects/{project}/locations/{location}"
93
+ )
94
+
95
+ private_constant :LOCATION_PATH_TEMPLATE
96
+
97
+ INSTANCE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
98
+ "projects/{project}/locations/{location}/instances/{instance}"
99
+ )
100
+
101
+ private_constant :INSTANCE_PATH_TEMPLATE
102
+
103
+ # Returns a fully-qualified location resource name string.
104
+ # @param project [String]
105
+ # @param location [String]
106
+ # @return [String]
107
+ def self.location_path project, location
108
+ LOCATION_PATH_TEMPLATE.render(
109
+ :"project" => project,
110
+ :"location" => location
111
+ )
112
+ end
113
+
114
+ # Returns a fully-qualified instance resource name string.
115
+ # @param project [String]
116
+ # @param location [String]
117
+ # @param instance [String]
118
+ # @return [String]
119
+ def self.instance_path project, location, instance
120
+ INSTANCE_PATH_TEMPLATE.render(
121
+ :"project" => project,
122
+ :"location" => location,
123
+ :"instance" => instance
124
+ )
125
+ end
126
+
127
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
128
+ # Provides the means for authenticating requests made by the client. This parameter can
129
+ # be many types.
130
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
131
+ # authenticating requests made by this client.
132
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
133
+ # credentials for this client.
134
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
135
+ # credentials for this client.
136
+ # A `GRPC::Core::Channel` will be used to make calls through.
137
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
138
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
139
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
140
+ # metadata for requests, generally, to give OAuth credentials.
141
+ # @param scopes [Array<String>]
142
+ # The OAuth scopes for this service. This parameter is ignored if
143
+ # an updater_proc is supplied.
144
+ # @param client_config [Hash]
145
+ # A Hash for call options for each method. See
146
+ # Google::Gax#construct_settings for the structure of
147
+ # this data. Falls back to the default config if not specified
148
+ # or the specified config is missing data points.
149
+ # @param timeout [Numeric]
150
+ # The default timeout, in seconds, for calls made through this client.
151
+ # @param metadata [Hash]
152
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
153
+ # @param exception_transformer [Proc]
154
+ # An optional proc that intercepts any exceptions raised during an API call to inject
155
+ # custom error handling.
156
+ def initialize \
157
+ credentials: nil,
158
+ scopes: ALL_SCOPES,
159
+ client_config: {},
160
+ timeout: DEFAULT_TIMEOUT,
161
+ metadata: nil,
162
+ exception_transformer: nil,
163
+ lib_name: nil,
164
+ lib_version: ""
165
+ # These require statements are intentionally placed here to initialize
166
+ # the gRPC module only when it's required.
167
+ # See https://github.com/googleapis/toolkit/issues/446
168
+ require "google/gax/grpc"
169
+ require "google/cloud/redis/v1/cloud_redis_services_pb"
170
+
171
+ credentials ||= Google::Cloud::Redis::V1::Credentials.default
172
+
173
+ @operations_client = OperationsClient.new(
174
+ credentials: credentials,
175
+ scopes: scopes,
176
+ client_config: client_config,
177
+ timeout: timeout,
178
+ lib_name: lib_name,
179
+ lib_version: lib_version,
180
+ )
181
+
182
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
183
+ updater_proc = Google::Cloud::Redis::V1::Credentials.new(credentials).updater_proc
184
+ end
185
+ if credentials.is_a?(GRPC::Core::Channel)
186
+ channel = credentials
187
+ end
188
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
189
+ chan_creds = credentials
190
+ end
191
+ if credentials.is_a?(Proc)
192
+ updater_proc = credentials
193
+ end
194
+ if credentials.is_a?(Google::Auth::Credentials)
195
+ updater_proc = credentials.updater_proc
196
+ end
197
+
198
+ package_version = Gem.loaded_specs['google-cloud-redis'].version.version
199
+
200
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
201
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
202
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
203
+ google_api_client << " grpc/#{GRPC::VERSION}"
204
+ google_api_client.freeze
205
+
206
+ headers = { :"x-goog-api-client" => google_api_client }
207
+ headers.merge!(metadata) unless metadata.nil?
208
+ client_config_file = Pathname.new(__dir__).join(
209
+ "cloud_redis_client_config.json"
210
+ )
211
+ defaults = client_config_file.open do |f|
212
+ Google::Gax.construct_settings(
213
+ "google.cloud.redis.v1.CloudRedis",
214
+ JSON.parse(f.read),
215
+ client_config,
216
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
217
+ timeout,
218
+ page_descriptors: PAGE_DESCRIPTORS,
219
+ errors: Google::Gax::Grpc::API_ERRORS,
220
+ metadata: headers
221
+ )
222
+ end
223
+
224
+ # Allow overriding the service path/port in subclasses.
225
+ service_path = self.class::SERVICE_ADDRESS
226
+ port = self.class::DEFAULT_SERVICE_PORT
227
+ interceptors = self.class::GRPC_INTERCEPTORS
228
+ @cloud_redis_stub = Google::Gax::Grpc.create_stub(
229
+ service_path,
230
+ port,
231
+ chan_creds: chan_creds,
232
+ channel: channel,
233
+ updater_proc: updater_proc,
234
+ scopes: scopes,
235
+ interceptors: interceptors,
236
+ &Google::Cloud::Redis::V1::CloudRedis::Stub.method(:new)
237
+ )
238
+
239
+ @list_instances = Google::Gax.create_api_call(
240
+ @cloud_redis_stub.method(:list_instances),
241
+ defaults["list_instances"],
242
+ exception_transformer: exception_transformer
243
+ )
244
+ @get_instance = Google::Gax.create_api_call(
245
+ @cloud_redis_stub.method(:get_instance),
246
+ defaults["get_instance"],
247
+ exception_transformer: exception_transformer
248
+ )
249
+ @create_instance = Google::Gax.create_api_call(
250
+ @cloud_redis_stub.method(:create_instance),
251
+ defaults["create_instance"],
252
+ exception_transformer: exception_transformer
253
+ )
254
+ @update_instance = Google::Gax.create_api_call(
255
+ @cloud_redis_stub.method(:update_instance),
256
+ defaults["update_instance"],
257
+ exception_transformer: exception_transformer
258
+ )
259
+ @delete_instance = Google::Gax.create_api_call(
260
+ @cloud_redis_stub.method(:delete_instance),
261
+ defaults["delete_instance"],
262
+ exception_transformer: exception_transformer
263
+ )
264
+ end
265
+
266
+ # Service calls
267
+
268
+ # Lists all Redis instances owned by a project in either the specified
269
+ # location (region) or all locations.
270
+ #
271
+ # The location should have the following format:
272
+ # * +projects/\\{project_id}/locations/\\{location_id}+
273
+ #
274
+ # If +location_id+ is specified as +-+ (wildcard), then all regions
275
+ # available to the project are queried, and the results are aggregated.
276
+ #
277
+ # @param parent [String]
278
+ # Required. The resource name of the instance location using the form:
279
+ # +projects/\\{project_id}/locations/\\{location_id}+
280
+ # where +location_id+ refers to a GCP region
281
+ # @param page_size [Integer]
282
+ # The maximum number of resources contained in the underlying API
283
+ # response. If page streaming is performed per-resource, this
284
+ # parameter does not affect the return value. If page streaming is
285
+ # performed per-page, this determines the maximum number of
286
+ # resources in a page.
287
+ # @param options [Google::Gax::CallOptions]
288
+ # Overrides the default settings for this call, e.g, timeout,
289
+ # retries, etc.
290
+ # @yield [result, operation] Access the result along with the RPC operation
291
+ # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Redis::V1::Instance>]
292
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
293
+ # @return [Google::Gax::PagedEnumerable<Google::Cloud::Redis::V1::Instance>]
294
+ # An enumerable of Google::Cloud::Redis::V1::Instance instances.
295
+ # See Google::Gax::PagedEnumerable documentation for other
296
+ # operations such as per-page iteration or access to the response
297
+ # object.
298
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
299
+ # @example
300
+ # require "google/cloud/redis"
301
+ #
302
+ # cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
303
+ # formatted_parent = Google::Cloud::Redis::V1::CloudRedisClient.location_path("[PROJECT]", "[LOCATION]")
304
+ #
305
+ # # Iterate over all results.
306
+ # cloud_redis_client.list_instances(formatted_parent).each do |element|
307
+ # # Process element.
308
+ # end
309
+ #
310
+ # # Or iterate over results one page at a time.
311
+ # cloud_redis_client.list_instances(formatted_parent).each_page do |page|
312
+ # # Process each page at a time.
313
+ # page.each do |element|
314
+ # # Process element.
315
+ # end
316
+ # end
317
+
318
+ def list_instances \
319
+ parent,
320
+ page_size: nil,
321
+ options: nil,
322
+ &block
323
+ req = {
324
+ parent: parent,
325
+ page_size: page_size
326
+ }.delete_if { |_, v| v.nil? }
327
+ req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::ListInstancesRequest)
328
+ @list_instances.call(req, options, &block)
329
+ end
330
+
331
+ # Gets the details of a specific Redis instance.
332
+ #
333
+ # @param name [String]
334
+ # Required. Redis instance resource name using the form:
335
+ # +projects/\\{project_id}/locations/\\{location_id}/instances/\\{instance_id}+
336
+ # where +location_id+ refers to a GCP region
337
+ # @param options [Google::Gax::CallOptions]
338
+ # Overrides the default settings for this call, e.g, timeout,
339
+ # retries, etc.
340
+ # @yield [result, operation] Access the result along with the RPC operation
341
+ # @yieldparam result [Google::Cloud::Redis::V1::Instance]
342
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
343
+ # @return [Google::Cloud::Redis::V1::Instance]
344
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
345
+ # @example
346
+ # require "google/cloud/redis"
347
+ #
348
+ # cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
349
+ # formatted_name = Google::Cloud::Redis::V1::CloudRedisClient.instance_path("[PROJECT]", "[LOCATION]", "[INSTANCE]")
350
+ # response = cloud_redis_client.get_instance(formatted_name)
351
+
352
+ def get_instance \
353
+ name,
354
+ options: nil,
355
+ &block
356
+ req = {
357
+ name: name
358
+ }.delete_if { |_, v| v.nil? }
359
+ req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::GetInstanceRequest)
360
+ @get_instance.call(req, options, &block)
361
+ end
362
+
363
+ # Creates a Redis instance based on the specified tier and memory size.
364
+ #
365
+ # By default, the instance is accessible from the project's
366
+ # [default network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks).
367
+ #
368
+ # The creation is executed asynchronously and callers may check the returned
369
+ # operation to track its progress. Once the operation is completed the Redis
370
+ # instance will be fully functional. Completed longrunning.Operation will
371
+ # contain the new instance object in the response field.
372
+ #
373
+ # The returned operation is automatically deleted after a few hours, so there
374
+ # is no need to call DeleteOperation.
375
+ #
376
+ # @param parent [String]
377
+ # Required. The resource name of the instance location using the form:
378
+ # +projects/\\{project_id}/locations/\\{location_id}+
379
+ # where +location_id+ refers to a GCP region
380
+ # @param instance_id [String]
381
+ # Required. The logical name of the Redis instance in the customer project
382
+ # with the following restrictions:
383
+ #
384
+ # * Must contain only lowercase letters, numbers, and hyphens.
385
+ # * Must start with a letter.
386
+ # * Must be between 1-40 characters.
387
+ # * Must end with a number or a letter.
388
+ # * Must be unique within the customer project / location
389
+ # @param instance [Google::Cloud::Redis::V1::Instance | Hash]
390
+ # Required. A Redis [Instance] resource
391
+ # A hash of the same form as `Google::Cloud::Redis::V1::Instance`
392
+ # can also be provided.
393
+ # @param options [Google::Gax::CallOptions]
394
+ # Overrides the default settings for this call, e.g, timeout,
395
+ # retries, etc.
396
+ # @return [Google::Gax::Operation]
397
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
398
+ # @example
399
+ # require "google/cloud/redis"
400
+ #
401
+ # cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
402
+ # formatted_parent = Google::Cloud::Redis::V1::CloudRedisClient.location_path("[PROJECT]", "[LOCATION]")
403
+ # instance_id = "test_instance"
404
+ # tier = :BASIC
405
+ # memory_size_gb = 1
406
+ # instance = { tier: tier, memory_size_gb: memory_size_gb }
407
+ #
408
+ # # Register a callback during the method call.
409
+ # operation = cloud_redis_client.create_instance(formatted_parent, instance_id, instance) do |op|
410
+ # raise op.results.message if op.error?
411
+ # op_results = op.results
412
+ # # Process the results.
413
+ #
414
+ # metadata = op.metadata
415
+ # # Process the metadata.
416
+ # end
417
+ #
418
+ # # Or use the return value to register a callback.
419
+ # operation.on_done do |op|
420
+ # raise op.results.message if op.error?
421
+ # op_results = op.results
422
+ # # Process the results.
423
+ #
424
+ # metadata = op.metadata
425
+ # # Process the metadata.
426
+ # end
427
+ #
428
+ # # Manually reload the operation.
429
+ # operation.reload!
430
+ #
431
+ # # Or block until the operation completes, triggering callbacks on
432
+ # # completion.
433
+ # operation.wait_until_done!
434
+
435
+ def create_instance \
436
+ parent,
437
+ instance_id,
438
+ instance,
439
+ options: nil
440
+ req = {
441
+ parent: parent,
442
+ instance_id: instance_id,
443
+ instance: instance
444
+ }.delete_if { |_, v| v.nil? }
445
+ req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::CreateInstanceRequest)
446
+ operation = Google::Gax::Operation.new(
447
+ @create_instance.call(req, options),
448
+ @operations_client,
449
+ Google::Cloud::Redis::V1::Instance,
450
+ Google::Cloud::Redis::V1::OperationMetadata,
451
+ call_options: options
452
+ )
453
+ operation.on_done { |operation| yield(operation) } if block_given?
454
+ operation
455
+ end
456
+
457
+ # Updates the metadata and configuration of a specific Redis instance.
458
+ #
459
+ # Completed longrunning.Operation will contain the new instance object
460
+ # in the response field. The returned operation is automatically deleted
461
+ # after a few hours, so there is no need to call DeleteOperation.
462
+ #
463
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
464
+ # Required. Mask of fields to update. At least one path must be supplied in
465
+ # this field. The elements of the repeated paths field may only include these
466
+ # fields from {CloudRedis::Instance Instance}:
467
+ #
468
+ # * +displayName+
469
+ # * +labels+
470
+ # * +memorySizeGb+
471
+ # * +redisConfig+
472
+ # A hash of the same form as `Google::Protobuf::FieldMask`
473
+ # can also be provided.
474
+ # @param instance [Google::Cloud::Redis::V1::Instance | Hash]
475
+ # Required. Update description.
476
+ # Only fields specified in update_mask are updated.
477
+ # A hash of the same form as `Google::Cloud::Redis::V1::Instance`
478
+ # can also be provided.
479
+ # @param options [Google::Gax::CallOptions]
480
+ # Overrides the default settings for this call, e.g, timeout,
481
+ # retries, etc.
482
+ # @return [Google::Gax::Operation]
483
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
484
+ # @example
485
+ # require "google/cloud/redis"
486
+ #
487
+ # cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
488
+ # paths_element = "display_name"
489
+ # paths_element_2 = "memory_size_gb"
490
+ # paths = [paths_element, paths_element_2]
491
+ # update_mask = { paths: paths }
492
+ # display_name = "UpdatedDisplayName"
493
+ # memory_size_gb = 4
494
+ # instance = { display_name: display_name, memory_size_gb: memory_size_gb }
495
+ #
496
+ # # Register a callback during the method call.
497
+ # operation = cloud_redis_client.update_instance(update_mask, instance) do |op|
498
+ # raise op.results.message if op.error?
499
+ # op_results = op.results
500
+ # # Process the results.
501
+ #
502
+ # metadata = op.metadata
503
+ # # Process the metadata.
504
+ # end
505
+ #
506
+ # # Or use the return value to register a callback.
507
+ # operation.on_done do |op|
508
+ # raise op.results.message if op.error?
509
+ # op_results = op.results
510
+ # # Process the results.
511
+ #
512
+ # metadata = op.metadata
513
+ # # Process the metadata.
514
+ # end
515
+ #
516
+ # # Manually reload the operation.
517
+ # operation.reload!
518
+ #
519
+ # # Or block until the operation completes, triggering callbacks on
520
+ # # completion.
521
+ # operation.wait_until_done!
522
+
523
+ def update_instance \
524
+ update_mask,
525
+ instance,
526
+ options: nil
527
+ req = {
528
+ update_mask: update_mask,
529
+ instance: instance
530
+ }.delete_if { |_, v| v.nil? }
531
+ req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::UpdateInstanceRequest)
532
+ operation = Google::Gax::Operation.new(
533
+ @update_instance.call(req, options),
534
+ @operations_client,
535
+ Google::Cloud::Redis::V1::Instance,
536
+ Google::Cloud::Redis::V1::OperationMetadata,
537
+ call_options: options
538
+ )
539
+ operation.on_done { |operation| yield(operation) } if block_given?
540
+ operation
541
+ end
542
+
543
+ # Deletes a specific Redis instance. Instance stops serving and data is
544
+ # deleted.
545
+ #
546
+ # @param name [String]
547
+ # Required. Redis instance resource name using the form:
548
+ # +projects/\\{project_id}/locations/\\{location_id}/instances/\\{instance_id}+
549
+ # where +location_id+ refers to a GCP region
550
+ # @param options [Google::Gax::CallOptions]
551
+ # Overrides the default settings for this call, e.g, timeout,
552
+ # retries, etc.
553
+ # @return [Google::Gax::Operation]
554
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
555
+ # @example
556
+ # require "google/cloud/redis"
557
+ #
558
+ # cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
559
+ # formatted_name = Google::Cloud::Redis::V1::CloudRedisClient.instance_path("[PROJECT]", "[LOCATION]", "[INSTANCE]")
560
+ #
561
+ # # Register a callback during the method call.
562
+ # operation = cloud_redis_client.delete_instance(formatted_name) do |op|
563
+ # raise op.results.message if op.error?
564
+ # op_results = op.results
565
+ # # Process the results.
566
+ #
567
+ # metadata = op.metadata
568
+ # # Process the metadata.
569
+ # end
570
+ #
571
+ # # Or use the return value to register a callback.
572
+ # operation.on_done do |op|
573
+ # raise op.results.message if op.error?
574
+ # op_results = op.results
575
+ # # Process the results.
576
+ #
577
+ # metadata = op.metadata
578
+ # # Process the metadata.
579
+ # end
580
+ #
581
+ # # Manually reload the operation.
582
+ # operation.reload!
583
+ #
584
+ # # Or block until the operation completes, triggering callbacks on
585
+ # # completion.
586
+ # operation.wait_until_done!
587
+
588
+ def delete_instance \
589
+ name,
590
+ options: nil
591
+ req = {
592
+ name: name
593
+ }.delete_if { |_, v| v.nil? }
594
+ req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::DeleteInstanceRequest)
595
+ operation = Google::Gax::Operation.new(
596
+ @delete_instance.call(req, options),
597
+ @operations_client,
598
+ Google::Protobuf::Empty,
599
+ Google::Cloud::Redis::V1::OperationMetadata,
600
+ call_options: options
601
+ )
602
+ operation.on_done { |operation| yield(operation) } if block_given?
603
+ operation
604
+ end
605
+ end
606
+ end
607
+ end
608
+ end
609
+ end