google-cloud-redis 0.8.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -59
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +318 -0
  6. data/README.md +35 -23
  7. data/lib/google-cloud-redis.rb +19 -0
  8. data/lib/google/cloud/redis.rb +88 -117
  9. data/lib/google/cloud/redis/version.rb +6 -2
  10. metadata +71 -64
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/redis/v1.rb +0 -160
  13. data/lib/google/cloud/redis/v1/cloud_redis_client.rb +0 -893
  14. data/lib/google/cloud/redis/v1/cloud_redis_client_config.json +0 -66
  15. data/lib/google/cloud/redis/v1/cloud_redis_pb.rb +0 -159
  16. data/lib/google/cloud/redis/v1/cloud_redis_services_pb.rb +0 -111
  17. data/lib/google/cloud/redis/v1/credentials.rb +0 -41
  18. data/lib/google/cloud/redis/v1/doc/google/cloud/redis/v1/cloud_redis.rb +0 -408
  19. data/lib/google/cloud/redis/v1/doc/google/longrunning/operations.rb +0 -51
  20. data/lib/google/cloud/redis/v1/doc/google/protobuf/any.rb +0 -131
  21. data/lib/google/cloud/redis/v1/doc/google/protobuf/field_mask.rb +0 -222
  22. data/lib/google/cloud/redis/v1/doc/google/protobuf/timestamp.rb +0 -113
  23. data/lib/google/cloud/redis/v1/doc/google/rpc/status.rb +0 -39
  24. data/lib/google/cloud/redis/v1beta1.rb +0 -160
  25. data/lib/google/cloud/redis/v1beta1/cloud_redis_client.rb +0 -971
  26. data/lib/google/cloud/redis/v1beta1/cloud_redis_client_config.json +0 -71
  27. data/lib/google/cloud/redis/v1beta1/cloud_redis_pb.rb +0 -154
  28. data/lib/google/cloud/redis/v1beta1/cloud_redis_services_pb.rb +0 -114
  29. data/lib/google/cloud/redis/v1beta1/credentials.rb +0 -41
  30. data/lib/google/cloud/redis/v1beta1/doc/google/cloud/redis/v1beta1/cloud_redis.rb +0 -395
  31. data/lib/google/cloud/redis/v1beta1/doc/google/longrunning/operations.rb +0 -51
  32. data/lib/google/cloud/redis/v1beta1/doc/google/protobuf/any.rb +0 -131
  33. data/lib/google/cloud/redis/v1beta1/doc/google/protobuf/field_mask.rb +0 -222
  34. data/lib/google/cloud/redis/v1beta1/doc/google/protobuf/timestamp.rb +0 -113
  35. data/lib/google/cloud/redis/v1beta1/doc/google/rpc/status.rb +0 -39
data/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- https://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- https://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
@@ -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/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
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 V1
80
- # rubocop:enable LineLength
81
-
82
- ##
83
- # Configures and manages Cloud Memorystore for Redis instances
84
- #
85
- # Google Cloud Memorystore for Redis v1
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 referring 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::V1::CloudRedisClient.new(**kwargs)
156
- end
157
- end
158
- end
159
- end
160
- end
@@ -1,893 +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/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
- require "google/cloud/redis/version"
33
-
34
- module Google
35
- module Cloud
36
- module Redis
37
- module V1
38
- # Configures and manages Cloud Memorystore for Redis instances
39
- #
40
- # Google Cloud Memorystore for Redis v1
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 referring 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::V1::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/v1/cloud_redis_services_pb"
177
-
178
- credentials ||= Google::Cloud::Redis::V1::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::V1::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.v1.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::V1::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
- end
317
-
318
- # Service calls
319
-
320
- # Lists all Redis instances owned by a project in either the specified
321
- # location (region) or all locations.
322
- #
323
- # The location should have the following format:
324
- #
325
- # * `projects/{project_id}/locations/{location_id}`
326
- #
327
- # If `location_id` is specified as `-` (wildcard), then all regions
328
- # available to the project are queried, and the results are aggregated.
329
- #
330
- # @param parent [String]
331
- # Required. The resource name of the instance location using the form:
332
- # `projects/{project_id}/locations/{location_id}`
333
- # where `location_id` refers to a GCP region.
334
- # @param page_size [Integer]
335
- # The maximum number of resources contained in the underlying API
336
- # response. If page streaming is performed per-resource, this
337
- # parameter does not affect the return value. If page streaming is
338
- # performed per-page, this determines the maximum number of
339
- # resources in a page.
340
- # @param options [Google::Gax::CallOptions]
341
- # Overrides the default settings for this call, e.g, timeout,
342
- # retries, etc.
343
- # @yield [result, operation] Access the result along with the RPC operation
344
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Redis::V1::Instance>]
345
- # @yieldparam operation [GRPC::ActiveCall::Operation]
346
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Redis::V1::Instance>]
347
- # An enumerable of Google::Cloud::Redis::V1::Instance instances.
348
- # See Google::Gax::PagedEnumerable documentation for other
349
- # operations such as per-page iteration or access to the response
350
- # object.
351
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
352
- # @example
353
- # require "google/cloud/redis"
354
- #
355
- # cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
356
- # formatted_parent = Google::Cloud::Redis::V1::CloudRedisClient.location_path("[PROJECT]", "[LOCATION]")
357
- #
358
- # # Iterate over all results.
359
- # cloud_redis_client.list_instances(formatted_parent).each do |element|
360
- # # Process element.
361
- # end
362
- #
363
- # # Or iterate over results one page at a time.
364
- # cloud_redis_client.list_instances(formatted_parent).each_page do |page|
365
- # # Process each page at a time.
366
- # page.each do |element|
367
- # # Process element.
368
- # end
369
- # end
370
-
371
- def list_instances \
372
- parent,
373
- page_size: nil,
374
- options: nil,
375
- &block
376
- req = {
377
- parent: parent,
378
- page_size: page_size
379
- }.delete_if { |_, v| v.nil? }
380
- req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::ListInstancesRequest)
381
- @list_instances.call(req, options, &block)
382
- end
383
-
384
- # Gets the details of a specific Redis instance.
385
- #
386
- # @param name [String]
387
- # Required. Redis instance resource name using the form:
388
- # `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
389
- # where `location_id` refers to a GCP region.
390
- # @param options [Google::Gax::CallOptions]
391
- # Overrides the default settings for this call, e.g, timeout,
392
- # retries, etc.
393
- # @yield [result, operation] Access the result along with the RPC operation
394
- # @yieldparam result [Google::Cloud::Redis::V1::Instance]
395
- # @yieldparam operation [GRPC::ActiveCall::Operation]
396
- # @return [Google::Cloud::Redis::V1::Instance]
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_name = Google::Cloud::Redis::V1::CloudRedisClient.instance_path("[PROJECT]", "[LOCATION]", "[INSTANCE]")
403
- # response = cloud_redis_client.get_instance(formatted_name)
404
-
405
- def get_instance \
406
- name,
407
- options: nil,
408
- &block
409
- req = {
410
- name: name
411
- }.delete_if { |_, v| v.nil? }
412
- req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::GetInstanceRequest)
413
- @get_instance.call(req, options, &block)
414
- end
415
-
416
- # Creates a Redis instance based on the specified tier and memory size.
417
- #
418
- # By default, the instance is accessible from the project's
419
- # [default network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks).
420
- #
421
- # The creation is executed asynchronously and callers may check the returned
422
- # operation to track its progress. Once the operation is completed the Redis
423
- # instance will be fully functional. Completed longrunning.Operation will
424
- # contain the new instance object in the response field.
425
- #
426
- # The returned operation is automatically deleted after a few hours, so there
427
- # is no need to call DeleteOperation.
428
- #
429
- # @param parent [String]
430
- # Required. The resource name of the instance location using the form:
431
- # `projects/{project_id}/locations/{location_id}`
432
- # where `location_id` refers to a GCP region.
433
- # @param instance_id [String]
434
- # Required. The logical name of the Redis instance in the customer project
435
- # with the following restrictions:
436
- #
437
- # * Must contain only lowercase letters, numbers, and hyphens.
438
- # * Must start with a letter.
439
- # * Must be between 1-40 characters.
440
- # * Must end with a number or a letter.
441
- # * Must be unique within the customer project / location
442
- # @param instance [Google::Cloud::Redis::V1::Instance | Hash]
443
- # Required. A Redis [Instance] resource
444
- # A hash of the same form as `Google::Cloud::Redis::V1::Instance`
445
- # can also be provided.
446
- # @param options [Google::Gax::CallOptions]
447
- # Overrides the default settings for this call, e.g, timeout,
448
- # retries, etc.
449
- # @return [Google::Gax::Operation]
450
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
451
- # @example
452
- # require "google/cloud/redis"
453
- #
454
- # cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
455
- # formatted_parent = Google::Cloud::Redis::V1::CloudRedisClient.location_path("[PROJECT]", "[LOCATION]")
456
- # instance_id = "test_instance"
457
- # tier = :BASIC
458
- # memory_size_gb = 1
459
- # instance = { tier: tier, memory_size_gb: memory_size_gb }
460
- #
461
- # # Register a callback during the method call.
462
- # operation = cloud_redis_client.create_instance(formatted_parent, instance_id, instance) do |op|
463
- # raise op.results.message if op.error?
464
- # op_results = op.results
465
- # # Process the results.
466
- #
467
- # metadata = op.metadata
468
- # # Process the metadata.
469
- # end
470
- #
471
- # # Or use the return value to register a callback.
472
- # operation.on_done do |op|
473
- # raise op.results.message if op.error?
474
- # op_results = op.results
475
- # # Process the results.
476
- #
477
- # metadata = op.metadata
478
- # # Process the metadata.
479
- # end
480
- #
481
- # # Manually reload the operation.
482
- # operation.reload!
483
- #
484
- # # Or block until the operation completes, triggering callbacks on
485
- # # completion.
486
- # operation.wait_until_done!
487
-
488
- def create_instance \
489
- parent,
490
- instance_id,
491
- instance,
492
- options: nil
493
- req = {
494
- parent: parent,
495
- instance_id: instance_id,
496
- instance: instance
497
- }.delete_if { |_, v| v.nil? }
498
- req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::CreateInstanceRequest)
499
- operation = Google::Gax::Operation.new(
500
- @create_instance.call(req, options),
501
- @operations_client,
502
- Google::Cloud::Redis::V1::Instance,
503
- Google::Cloud::Redis::V1::OperationMetadata,
504
- call_options: options
505
- )
506
- operation.on_done { |operation| yield(operation) } if block_given?
507
- operation
508
- end
509
-
510
- # Updates the metadata and configuration of a specific Redis instance.
511
- #
512
- # Completed longrunning.Operation will contain the new instance object
513
- # in the response field. The returned operation is automatically deleted
514
- # after a few hours, so there is no need to call DeleteOperation.
515
- #
516
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
517
- # Required. Mask of fields to update. At least one path must be supplied in
518
- # this field. The elements of the repeated paths field may only include these
519
- # fields from {Google::Cloud::Redis::V1::Instance Instance}:
520
- #
521
- # * `displayName`
522
- # * `labels`
523
- # * `memorySizeGb`
524
- # * `redisConfig`
525
- # A hash of the same form as `Google::Protobuf::FieldMask`
526
- # can also be provided.
527
- # @param instance [Google::Cloud::Redis::V1::Instance | Hash]
528
- # Required. Update description.
529
- # Only fields specified in update_mask are updated.
530
- # A hash of the same form as `Google::Cloud::Redis::V1::Instance`
531
- # can also be provided.
532
- # @param options [Google::Gax::CallOptions]
533
- # Overrides the default settings for this call, e.g, timeout,
534
- # retries, etc.
535
- # @return [Google::Gax::Operation]
536
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
537
- # @example
538
- # require "google/cloud/redis"
539
- #
540
- # cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
541
- # paths_element = "display_name"
542
- # paths_element_2 = "memory_size_gb"
543
- # paths = [paths_element, paths_element_2]
544
- # update_mask = { paths: paths }
545
- # display_name = "UpdatedDisplayName"
546
- # name = "projects/<project-name>/locations/<location>/instances/<instance>"
547
- # memory_size_gb = 4
548
- # instance = {
549
- # display_name: display_name,
550
- # name: name,
551
- # memory_size_gb: memory_size_gb
552
- # }
553
- #
554
- # # Register a callback during the method call.
555
- # operation = cloud_redis_client.update_instance(update_mask, instance) do |op|
556
- # raise op.results.message if op.error?
557
- # op_results = op.results
558
- # # Process the results.
559
- #
560
- # metadata = op.metadata
561
- # # Process the metadata.
562
- # end
563
- #
564
- # # Or use the return value to register a callback.
565
- # operation.on_done do |op|
566
- # raise op.results.message if op.error?
567
- # op_results = op.results
568
- # # Process the results.
569
- #
570
- # metadata = op.metadata
571
- # # Process the metadata.
572
- # end
573
- #
574
- # # Manually reload the operation.
575
- # operation.reload!
576
- #
577
- # # Or block until the operation completes, triggering callbacks on
578
- # # completion.
579
- # operation.wait_until_done!
580
-
581
- def update_instance \
582
- update_mask,
583
- instance,
584
- options: nil
585
- req = {
586
- update_mask: update_mask,
587
- instance: instance
588
- }.delete_if { |_, v| v.nil? }
589
- req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::UpdateInstanceRequest)
590
- operation = Google::Gax::Operation.new(
591
- @update_instance.call(req, options),
592
- @operations_client,
593
- Google::Cloud::Redis::V1::Instance,
594
- Google::Cloud::Redis::V1::OperationMetadata,
595
- call_options: options
596
- )
597
- operation.on_done { |operation| yield(operation) } if block_given?
598
- operation
599
- end
600
-
601
- # Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
602
- #
603
- # Redis may stop serving during this operation. Instance state will be
604
- # IMPORTING for entire operation. When complete, the instance will contain
605
- # only data from the imported file.
606
- #
607
- # The returned operation is automatically deleted after a few hours, so
608
- # there is no need to call DeleteOperation.
609
- #
610
- # @param name [String]
611
- # Required. Redis instance resource name using the form:
612
- # `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
613
- # where `location_id` refers to a GCP region.
614
- # @param input_config [Google::Cloud::Redis::V1::InputConfig | Hash]
615
- # Required. Specify data to be imported.
616
- # A hash of the same form as `Google::Cloud::Redis::V1::InputConfig`
617
- # can also be provided.
618
- # @param options [Google::Gax::CallOptions]
619
- # Overrides the default settings for this call, e.g, timeout,
620
- # retries, etc.
621
- # @return [Google::Gax::Operation]
622
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
623
- # @example
624
- # require "google/cloud/redis"
625
- #
626
- # cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
627
- #
628
- # # TODO: Initialize `name`:
629
- # name = ''
630
- #
631
- # # TODO: Initialize `input_config`:
632
- # input_config = {}
633
- #
634
- # # Register a callback during the method call.
635
- # operation = cloud_redis_client.import_instance(name, input_config) do |op|
636
- # raise op.results.message if op.error?
637
- # op_results = op.results
638
- # # Process the results.
639
- #
640
- # metadata = op.metadata
641
- # # Process the metadata.
642
- # end
643
- #
644
- # # Or use the return value to register a callback.
645
- # operation.on_done do |op|
646
- # raise op.results.message if op.error?
647
- # op_results = op.results
648
- # # Process the results.
649
- #
650
- # metadata = op.metadata
651
- # # Process the metadata.
652
- # end
653
- #
654
- # # Manually reload the operation.
655
- # operation.reload!
656
- #
657
- # # Or block until the operation completes, triggering callbacks on
658
- # # completion.
659
- # operation.wait_until_done!
660
-
661
- def import_instance \
662
- name,
663
- input_config,
664
- options: nil
665
- req = {
666
- name: name,
667
- input_config: input_config
668
- }.delete_if { |_, v| v.nil? }
669
- req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::ImportInstanceRequest)
670
- operation = Google::Gax::Operation.new(
671
- @import_instance.call(req, options),
672
- @operations_client,
673
- Google::Cloud::Redis::V1::Instance,
674
- Google::Cloud::Redis::V1::OperationMetadata,
675
- call_options: options
676
- )
677
- operation.on_done { |operation| yield(operation) } if block_given?
678
- operation
679
- end
680
-
681
- # Export Redis instance data into a Redis RDB format file in Cloud Storage.
682
- #
683
- # Redis will continue serving during this operation.
684
- #
685
- # The returned operation is automatically deleted after a few hours, so
686
- # there is no need to call DeleteOperation.
687
- #
688
- # @param name [String]
689
- # Required. Redis instance resource name using the form:
690
- # `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
691
- # where `location_id` refers to a GCP region.
692
- # @param output_config [Google::Cloud::Redis::V1::OutputConfig | Hash]
693
- # Required. Specify data to be exported.
694
- # A hash of the same form as `Google::Cloud::Redis::V1::OutputConfig`
695
- # can also be provided.
696
- # @param options [Google::Gax::CallOptions]
697
- # Overrides the default settings for this call, e.g, timeout,
698
- # retries, etc.
699
- # @return [Google::Gax::Operation]
700
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
701
- # @example
702
- # require "google/cloud/redis"
703
- #
704
- # cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
705
- #
706
- # # TODO: Initialize `name`:
707
- # name = ''
708
- #
709
- # # TODO: Initialize `output_config`:
710
- # output_config = {}
711
- #
712
- # # Register a callback during the method call.
713
- # operation = cloud_redis_client.export_instance(name, output_config) do |op|
714
- # raise op.results.message if op.error?
715
- # op_results = op.results
716
- # # Process the results.
717
- #
718
- # metadata = op.metadata
719
- # # Process the metadata.
720
- # end
721
- #
722
- # # Or use the return value to register a callback.
723
- # operation.on_done do |op|
724
- # raise op.results.message if op.error?
725
- # op_results = op.results
726
- # # Process the results.
727
- #
728
- # metadata = op.metadata
729
- # # Process the metadata.
730
- # end
731
- #
732
- # # Manually reload the operation.
733
- # operation.reload!
734
- #
735
- # # Or block until the operation completes, triggering callbacks on
736
- # # completion.
737
- # operation.wait_until_done!
738
-
739
- def export_instance \
740
- name,
741
- output_config,
742
- options: nil
743
- req = {
744
- name: name,
745
- output_config: output_config
746
- }.delete_if { |_, v| v.nil? }
747
- req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::ExportInstanceRequest)
748
- operation = Google::Gax::Operation.new(
749
- @export_instance.call(req, options),
750
- @operations_client,
751
- Google::Cloud::Redis::V1::Instance,
752
- Google::Cloud::Redis::V1::OperationMetadata,
753
- call_options: options
754
- )
755
- operation.on_done { |operation| yield(operation) } if block_given?
756
- operation
757
- end
758
-
759
- # Initiates a failover of the master node to current replica node for a
760
- # specific STANDARD tier Cloud Memorystore for Redis instance.
761
- #
762
- # @param name [String]
763
- # Required. Redis instance resource name using the form:
764
- # `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
765
- # where `location_id` refers to a GCP region.
766
- # @param data_protection_mode [Google::Cloud::Redis::V1::FailoverInstanceRequest::DataProtectionMode]
767
- # Optional. Available data protection modes that the user can choose. If it's
768
- # unspecified, data protection mode will be LIMITED_DATA_LOSS by default.
769
- # @param options [Google::Gax::CallOptions]
770
- # Overrides the default settings for this call, e.g, timeout,
771
- # retries, etc.
772
- # @return [Google::Gax::Operation]
773
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
774
- # @example
775
- # require "google/cloud/redis"
776
- #
777
- # cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
778
- # formatted_name = Google::Cloud::Redis::V1::CloudRedisClient.instance_path("[PROJECT]", "[LOCATION]", "[INSTANCE]")
779
- #
780
- # # Register a callback during the method call.
781
- # operation = cloud_redis_client.failover_instance(formatted_name) do |op|
782
- # raise op.results.message if op.error?
783
- # op_results = op.results
784
- # # Process the results.
785
- #
786
- # metadata = op.metadata
787
- # # Process the metadata.
788
- # end
789
- #
790
- # # Or use the return value to register a callback.
791
- # operation.on_done do |op|
792
- # raise op.results.message if op.error?
793
- # op_results = op.results
794
- # # Process the results.
795
- #
796
- # metadata = op.metadata
797
- # # Process the metadata.
798
- # end
799
- #
800
- # # Manually reload the operation.
801
- # operation.reload!
802
- #
803
- # # Or block until the operation completes, triggering callbacks on
804
- # # completion.
805
- # operation.wait_until_done!
806
-
807
- def failover_instance \
808
- name,
809
- data_protection_mode: nil,
810
- options: nil
811
- req = {
812
- name: name,
813
- data_protection_mode: data_protection_mode
814
- }.delete_if { |_, v| v.nil? }
815
- req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::FailoverInstanceRequest)
816
- operation = Google::Gax::Operation.new(
817
- @failover_instance.call(req, options),
818
- @operations_client,
819
- Google::Cloud::Redis::V1::Instance,
820
- Google::Cloud::Redis::V1::OperationMetadata,
821
- call_options: options
822
- )
823
- operation.on_done { |operation| yield(operation) } if block_given?
824
- operation
825
- end
826
-
827
- # Deletes a specific Redis instance. Instance stops serving and data is
828
- # deleted.
829
- #
830
- # @param name [String]
831
- # Required. Redis instance resource name using the form:
832
- # `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
833
- # where `location_id` refers to a GCP region.
834
- # @param options [Google::Gax::CallOptions]
835
- # Overrides the default settings for this call, e.g, timeout,
836
- # retries, etc.
837
- # @return [Google::Gax::Operation]
838
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
839
- # @example
840
- # require "google/cloud/redis"
841
- #
842
- # cloud_redis_client = Google::Cloud::Redis.new(version: :v1)
843
- # formatted_name = Google::Cloud::Redis::V1::CloudRedisClient.instance_path("[PROJECT]", "[LOCATION]", "[INSTANCE]")
844
- #
845
- # # Register a callback during the method call.
846
- # operation = cloud_redis_client.delete_instance(formatted_name) do |op|
847
- # raise op.results.message if op.error?
848
- # op_results = op.results
849
- # # Process the results.
850
- #
851
- # metadata = op.metadata
852
- # # Process the metadata.
853
- # end
854
- #
855
- # # Or use the return value to register a callback.
856
- # operation.on_done do |op|
857
- # raise op.results.message if op.error?
858
- # op_results = op.results
859
- # # Process the results.
860
- #
861
- # metadata = op.metadata
862
- # # Process the metadata.
863
- # end
864
- #
865
- # # Manually reload the operation.
866
- # operation.reload!
867
- #
868
- # # Or block until the operation completes, triggering callbacks on
869
- # # completion.
870
- # operation.wait_until_done!
871
-
872
- def delete_instance \
873
- name,
874
- options: nil
875
- req = {
876
- name: name
877
- }.delete_if { |_, v| v.nil? }
878
- req = Google::Gax::to_proto(req, Google::Cloud::Redis::V1::DeleteInstanceRequest)
879
- operation = Google::Gax::Operation.new(
880
- @delete_instance.call(req, options),
881
- @operations_client,
882
- Google::Protobuf::Empty,
883
- Google::Cloud::Redis::V1::OperationMetadata,
884
- call_options: options
885
- )
886
- operation.on_done { |operation| yield(operation) } if block_given?
887
- operation
888
- end
889
- end
890
- end
891
- end
892
- end
893
- end