• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.cloud.redis.v1beta1;
18 
19 import com.google.api.core.ApiFuture;
20 import com.google.api.core.ApiFutures;
21 import com.google.api.core.BetaApi;
22 import com.google.api.gax.core.BackgroundResource;
23 import com.google.api.gax.httpjson.longrunning.OperationsClient;
24 import com.google.api.gax.longrunning.OperationFuture;
25 import com.google.api.gax.paging.AbstractFixedSizeCollection;
26 import com.google.api.gax.paging.AbstractPage;
27 import com.google.api.gax.paging.AbstractPagedListResponse;
28 import com.google.api.gax.rpc.OperationCallable;
29 import com.google.api.gax.rpc.PageContext;
30 import com.google.api.gax.rpc.UnaryCallable;
31 import com.google.cloud.redis.v1beta1.stub.CloudRedisStub;
32 import com.google.cloud.redis.v1beta1.stub.CloudRedisStubSettings;
33 import com.google.common.util.concurrent.MoreExecutors;
34 import com.google.longrunning.Operation;
35 import com.google.protobuf.Any;
36 import com.google.protobuf.Empty;
37 import com.google.protobuf.FieldMask;
38 import com.google.protobuf.Timestamp;
39 import java.io.IOException;
40 import java.util.List;
41 import java.util.concurrent.TimeUnit;
42 import javax.annotation.Generated;
43 
44 // AUTO-GENERATED DOCUMENTATION AND CLASS.
45 /**
46  * Service Description: Configures and manages Cloud Memorystore for Redis instances
47  *
48  * <p>Google Cloud Memorystore for Redis v1beta1
49  *
50  * <p>The `redis.googleapis.com` service implements the Google Cloud Memorystore for Redis API and
51  * defines the following resource model for managing Redis instances:
52  *
53  * <ul>
54  *   <li>The service works with a collection of cloud projects, named: `/projects/&#42;`
55  *   <li>Each project has a collection of available locations, named: `/locations/&#42;`
56  *   <li>Each location has a collection of Redis instances, named: `/instances/&#42;`
57  *   <li>As such, Redis instances are resources of the form:
58  *       `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
59  * </ul>
60  *
61  * <p>Note that location_id must be referring to a GCP `region`; for example:
62  *
63  * <ul>
64  *   <li>`projects/redpepper-1290/locations/us-central1/instances/my-redis`
65  * </ul>
66  *
67  * <p>This class provides the ability to make remote calls to the backing service through method
68  * calls that map to API methods. Sample code to get started:
69  *
70  * <pre>{@code
71  * // This snippet has been automatically generated and should be regarded as a code template only.
72  * // It will require modifications to work:
73  * // - It may require correct/in-range values for request initialization.
74  * // - It may require specifying regional endpoints when creating the service client as shown in
75  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
76  * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
77  *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
78  *   Instance response = cloudRedisClient.getInstance(name);
79  * }
80  * }</pre>
81  *
82  * <p>Note: close() needs to be called on the CloudRedisClient object to clean up resources such as
83  * threads. In the example above, try-with-resources is used, which automatically calls close().
84  *
85  * <p>The surface of this class includes several types of Java methods for each of the API's
86  * methods:
87  *
88  * <ol>
89  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
90  *       converted into function parameters. It may be the case that not all fields are available as
91  *       parameters, and not every API method will have a flattened method entry point.
92  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
93  *       which must be constructed before the call. Not every API method will have a request object
94  *       method.
95  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
96  *       callable object, which can be used to initiate calls to the service.
97  * </ol>
98  *
99  * <p>See the individual methods for example code.
100  *
101  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
102  * these names, this class includes a format method for each type of name, and additionally a parse
103  * method to extract the individual identifiers contained within names that are returned.
104  *
105  * <p>This class can be customized by passing in a custom instance of CloudRedisSettings to
106  * create(). For example:
107  *
108  * <p>To customize credentials:
109  *
110  * <pre>{@code
111  * // This snippet has been automatically generated and should be regarded as a code template only.
112  * // It will require modifications to work:
113  * // - It may require correct/in-range values for request initialization.
114  * // - It may require specifying regional endpoints when creating the service client as shown in
115  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
116  * CloudRedisSettings cloudRedisSettings =
117  *     CloudRedisSettings.newBuilder()
118  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
119  *         .build();
120  * CloudRedisClient cloudRedisClient = CloudRedisClient.create(cloudRedisSettings);
121  * }</pre>
122  *
123  * <p>To customize the endpoint:
124  *
125  * <pre>{@code
126  * // This snippet has been automatically generated and should be regarded as a code template only.
127  * // It will require modifications to work:
128  * // - It may require correct/in-range values for request initialization.
129  * // - It may require specifying regional endpoints when creating the service client as shown in
130  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
131  * CloudRedisSettings cloudRedisSettings =
132  *     CloudRedisSettings.newBuilder().setEndpoint(myEndpoint).build();
133  * CloudRedisClient cloudRedisClient = CloudRedisClient.create(cloudRedisSettings);
134  * }</pre>
135  *
136  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
137  * the wire:
138  *
139  * <pre>{@code
140  * // This snippet has been automatically generated and should be regarded as a code template only.
141  * // It will require modifications to work:
142  * // - It may require correct/in-range values for request initialization.
143  * // - It may require specifying regional endpoints when creating the service client as shown in
144  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
145  * CloudRedisSettings cloudRedisSettings = CloudRedisSettings.newHttpJsonBuilder().build();
146  * CloudRedisClient cloudRedisClient = CloudRedisClient.create(cloudRedisSettings);
147  * }</pre>
148  *
149  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
150  */
151 @BetaApi
152 @Generated("by gapic-generator-java")
153 public class CloudRedisClient implements BackgroundResource {
154   private final CloudRedisSettings settings;
155   private final CloudRedisStub stub;
156   private final OperationsClient httpJsonOperationsClient;
157   private final com.google.longrunning.OperationsClient operationsClient;
158 
159   /** Constructs an instance of CloudRedisClient with default settings. */
create()160   public static final CloudRedisClient create() throws IOException {
161     return create(CloudRedisSettings.newBuilder().build());
162   }
163 
164   /**
165    * Constructs an instance of CloudRedisClient, using the given settings. The channels are created
166    * based on the settings passed in, or defaults for any settings that are not set.
167    */
create(CloudRedisSettings settings)168   public static final CloudRedisClient create(CloudRedisSettings settings) throws IOException {
169     return new CloudRedisClient(settings);
170   }
171 
172   /**
173    * Constructs an instance of CloudRedisClient, using the given stub for making calls. This is for
174    * advanced usage - prefer using create(CloudRedisSettings).
175    */
create(CloudRedisStub stub)176   public static final CloudRedisClient create(CloudRedisStub stub) {
177     return new CloudRedisClient(stub);
178   }
179 
180   /**
181    * Constructs an instance of CloudRedisClient, using the given settings. This is protected so that
182    * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
183    */
CloudRedisClient(CloudRedisSettings settings)184   protected CloudRedisClient(CloudRedisSettings settings) throws IOException {
185     this.settings = settings;
186     this.stub = ((CloudRedisStubSettings) settings.getStubSettings()).createStub();
187     this.operationsClient =
188         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
189     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
190   }
191 
CloudRedisClient(CloudRedisStub stub)192   protected CloudRedisClient(CloudRedisStub stub) {
193     this.settings = null;
194     this.stub = stub;
195     this.operationsClient =
196         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
197     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
198   }
199 
getSettings()200   public final CloudRedisSettings getSettings() {
201     return settings;
202   }
203 
getStub()204   public CloudRedisStub getStub() {
205     return stub;
206   }
207 
208   /**
209    * Returns the OperationsClient that can be used to query the status of a long-running operation
210    * returned by another API method call.
211    */
getOperationsClient()212   public final com.google.longrunning.OperationsClient getOperationsClient() {
213     return operationsClient;
214   }
215 
216   /**
217    * Returns the OperationsClient that can be used to query the status of a long-running operation
218    * returned by another API method call.
219    */
220   @BetaApi
getHttpJsonOperationsClient()221   public final OperationsClient getHttpJsonOperationsClient() {
222     return httpJsonOperationsClient;
223   }
224 
225   // AUTO-GENERATED DOCUMENTATION AND METHOD.
226   /**
227    * Lists all Redis instances owned by a project in either the specified location (region) or all
228    * locations.
229    *
230    * <p>The location should have the following format:
231    *
232    * <ul>
233    *   <li>`projects/{project_id}/locations/{location_id}`
234    * </ul>
235    *
236    * <p>If `location_id` is specified as `-` (wildcard), then all regions available to the project
237    * are queried, and the results are aggregated.
238    *
239    * <p>Sample code:
240    *
241    * <pre>{@code
242    * // This snippet has been automatically generated and should be regarded as a code template only.
243    * // It will require modifications to work:
244    * // - It may require correct/in-range values for request initialization.
245    * // - It may require specifying regional endpoints when creating the service client as shown in
246    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
247    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
248    *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
249    *   for (Instance element : cloudRedisClient.listInstances(parent).iterateAll()) {
250    *     // doThingsWith(element);
251    *   }
252    * }
253    * }</pre>
254    *
255    * @param parent Required. The resource name of the instance location using the form:
256    *     `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region.
257    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
258    */
listInstances(LocationName parent)259   public final ListInstancesPagedResponse listInstances(LocationName parent) {
260     ListInstancesRequest request =
261         ListInstancesRequest.newBuilder()
262             .setParent(parent == null ? null : parent.toString())
263             .build();
264     return listInstances(request);
265   }
266 
267   // AUTO-GENERATED DOCUMENTATION AND METHOD.
268   /**
269    * Lists all Redis instances owned by a project in either the specified location (region) or all
270    * locations.
271    *
272    * <p>The location should have the following format:
273    *
274    * <ul>
275    *   <li>`projects/{project_id}/locations/{location_id}`
276    * </ul>
277    *
278    * <p>If `location_id` is specified as `-` (wildcard), then all regions available to the project
279    * are queried, and the results are aggregated.
280    *
281    * <p>Sample code:
282    *
283    * <pre>{@code
284    * // This snippet has been automatically generated and should be regarded as a code template only.
285    * // It will require modifications to work:
286    * // - It may require correct/in-range values for request initialization.
287    * // - It may require specifying regional endpoints when creating the service client as shown in
288    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
289    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
290    *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
291    *   for (Instance element : cloudRedisClient.listInstances(parent).iterateAll()) {
292    *     // doThingsWith(element);
293    *   }
294    * }
295    * }</pre>
296    *
297    * @param parent Required. The resource name of the instance location using the form:
298    *     `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region.
299    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
300    */
listInstances(String parent)301   public final ListInstancesPagedResponse listInstances(String parent) {
302     ListInstancesRequest request = ListInstancesRequest.newBuilder().setParent(parent).build();
303     return listInstances(request);
304   }
305 
306   // AUTO-GENERATED DOCUMENTATION AND METHOD.
307   /**
308    * Lists all Redis instances owned by a project in either the specified location (region) or all
309    * locations.
310    *
311    * <p>The location should have the following format:
312    *
313    * <ul>
314    *   <li>`projects/{project_id}/locations/{location_id}`
315    * </ul>
316    *
317    * <p>If `location_id` is specified as `-` (wildcard), then all regions available to the project
318    * are queried, and the results are aggregated.
319    *
320    * <p>Sample code:
321    *
322    * <pre>{@code
323    * // This snippet has been automatically generated and should be regarded as a code template only.
324    * // It will require modifications to work:
325    * // - It may require correct/in-range values for request initialization.
326    * // - It may require specifying regional endpoints when creating the service client as shown in
327    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
328    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
329    *   ListInstancesRequest request =
330    *       ListInstancesRequest.newBuilder()
331    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
332    *           .setPageSize(883849137)
333    *           .setPageToken("pageToken873572522")
334    *           .build();
335    *   for (Instance element : cloudRedisClient.listInstances(request).iterateAll()) {
336    *     // doThingsWith(element);
337    *   }
338    * }
339    * }</pre>
340    *
341    * @param request The request object containing all of the parameters for the API call.
342    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
343    */
listInstances(ListInstancesRequest request)344   public final ListInstancesPagedResponse listInstances(ListInstancesRequest request) {
345     return listInstancesPagedCallable().call(request);
346   }
347 
348   // AUTO-GENERATED DOCUMENTATION AND METHOD.
349   /**
350    * Lists all Redis instances owned by a project in either the specified location (region) or all
351    * locations.
352    *
353    * <p>The location should have the following format:
354    *
355    * <ul>
356    *   <li>`projects/{project_id}/locations/{location_id}`
357    * </ul>
358    *
359    * <p>If `location_id` is specified as `-` (wildcard), then all regions available to the project
360    * are queried, and the results are aggregated.
361    *
362    * <p>Sample code:
363    *
364    * <pre>{@code
365    * // This snippet has been automatically generated and should be regarded as a code template only.
366    * // It will require modifications to work:
367    * // - It may require correct/in-range values for request initialization.
368    * // - It may require specifying regional endpoints when creating the service client as shown in
369    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
370    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
371    *   ListInstancesRequest request =
372    *       ListInstancesRequest.newBuilder()
373    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
374    *           .setPageSize(883849137)
375    *           .setPageToken("pageToken873572522")
376    *           .build();
377    *   ApiFuture<Instance> future =
378    *       cloudRedisClient.listInstancesPagedCallable().futureCall(request);
379    *   // Do something.
380    *   for (Instance element : future.get().iterateAll()) {
381    *     // doThingsWith(element);
382    *   }
383    * }
384    * }</pre>
385    */
386   public final UnaryCallable<ListInstancesRequest, ListInstancesPagedResponse>
listInstancesPagedCallable()387       listInstancesPagedCallable() {
388     return stub.listInstancesPagedCallable();
389   }
390 
391   // AUTO-GENERATED DOCUMENTATION AND METHOD.
392   /**
393    * Lists all Redis instances owned by a project in either the specified location (region) or all
394    * locations.
395    *
396    * <p>The location should have the following format:
397    *
398    * <ul>
399    *   <li>`projects/{project_id}/locations/{location_id}`
400    * </ul>
401    *
402    * <p>If `location_id` is specified as `-` (wildcard), then all regions available to the project
403    * are queried, and the results are aggregated.
404    *
405    * <p>Sample code:
406    *
407    * <pre>{@code
408    * // This snippet has been automatically generated and should be regarded as a code template only.
409    * // It will require modifications to work:
410    * // - It may require correct/in-range values for request initialization.
411    * // - It may require specifying regional endpoints when creating the service client as shown in
412    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
413    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
414    *   ListInstancesRequest request =
415    *       ListInstancesRequest.newBuilder()
416    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
417    *           .setPageSize(883849137)
418    *           .setPageToken("pageToken873572522")
419    *           .build();
420    *   while (true) {
421    *     ListInstancesResponse response = cloudRedisClient.listInstancesCallable().call(request);
422    *     for (Instance element : response.getInstancesList()) {
423    *       // doThingsWith(element);
424    *     }
425    *     String nextPageToken = response.getNextPageToken();
426    *     if (!Strings.isNullOrEmpty(nextPageToken)) {
427    *       request = request.toBuilder().setPageToken(nextPageToken).build();
428    *     } else {
429    *       break;
430    *     }
431    *   }
432    * }
433    * }</pre>
434    */
listInstancesCallable()435   public final UnaryCallable<ListInstancesRequest, ListInstancesResponse> listInstancesCallable() {
436     return stub.listInstancesCallable();
437   }
438 
439   // AUTO-GENERATED DOCUMENTATION AND METHOD.
440   /**
441    * Gets the details of a specific Redis instance.
442    *
443    * <p>Sample code:
444    *
445    * <pre>{@code
446    * // This snippet has been automatically generated and should be regarded as a code template only.
447    * // It will require modifications to work:
448    * // - It may require correct/in-range values for request initialization.
449    * // - It may require specifying regional endpoints when creating the service client as shown in
450    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
451    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
452    *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
453    *   Instance response = cloudRedisClient.getInstance(name);
454    * }
455    * }</pre>
456    *
457    * @param name Required. Redis instance resource name using the form:
458    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
459    *     refers to a GCP region.
460    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
461    */
getInstance(InstanceName name)462   public final Instance getInstance(InstanceName name) {
463     GetInstanceRequest request =
464         GetInstanceRequest.newBuilder().setName(name == null ? null : name.toString()).build();
465     return getInstance(request);
466   }
467 
468   // AUTO-GENERATED DOCUMENTATION AND METHOD.
469   /**
470    * Gets the details of a specific Redis instance.
471    *
472    * <p>Sample code:
473    *
474    * <pre>{@code
475    * // This snippet has been automatically generated and should be regarded as a code template only.
476    * // It will require modifications to work:
477    * // - It may require correct/in-range values for request initialization.
478    * // - It may require specifying regional endpoints when creating the service client as shown in
479    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
480    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
481    *   String name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString();
482    *   Instance response = cloudRedisClient.getInstance(name);
483    * }
484    * }</pre>
485    *
486    * @param name Required. Redis instance resource name using the form:
487    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
488    *     refers to a GCP region.
489    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
490    */
getInstance(String name)491   public final Instance getInstance(String name) {
492     GetInstanceRequest request = GetInstanceRequest.newBuilder().setName(name).build();
493     return getInstance(request);
494   }
495 
496   // AUTO-GENERATED DOCUMENTATION AND METHOD.
497   /**
498    * Gets the details of a specific Redis instance.
499    *
500    * <p>Sample code:
501    *
502    * <pre>{@code
503    * // This snippet has been automatically generated and should be regarded as a code template only.
504    * // It will require modifications to work:
505    * // - It may require correct/in-range values for request initialization.
506    * // - It may require specifying regional endpoints when creating the service client as shown in
507    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
508    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
509    *   GetInstanceRequest request =
510    *       GetInstanceRequest.newBuilder()
511    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
512    *           .build();
513    *   Instance response = cloudRedisClient.getInstance(request);
514    * }
515    * }</pre>
516    *
517    * @param request The request object containing all of the parameters for the API call.
518    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
519    */
getInstance(GetInstanceRequest request)520   public final Instance getInstance(GetInstanceRequest request) {
521     return getInstanceCallable().call(request);
522   }
523 
524   // AUTO-GENERATED DOCUMENTATION AND METHOD.
525   /**
526    * Gets the details of a specific Redis instance.
527    *
528    * <p>Sample code:
529    *
530    * <pre>{@code
531    * // This snippet has been automatically generated and should be regarded as a code template only.
532    * // It will require modifications to work:
533    * // - It may require correct/in-range values for request initialization.
534    * // - It may require specifying regional endpoints when creating the service client as shown in
535    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
536    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
537    *   GetInstanceRequest request =
538    *       GetInstanceRequest.newBuilder()
539    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
540    *           .build();
541    *   ApiFuture<Instance> future = cloudRedisClient.getInstanceCallable().futureCall(request);
542    *   // Do something.
543    *   Instance response = future.get();
544    * }
545    * }</pre>
546    */
getInstanceCallable()547   public final UnaryCallable<GetInstanceRequest, Instance> getInstanceCallable() {
548     return stub.getInstanceCallable();
549   }
550 
551   // AUTO-GENERATED DOCUMENTATION AND METHOD.
552   /**
553    * Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response
554    * will be empty. This information is not included in the details returned to GetInstance.
555    *
556    * <p>Sample code:
557    *
558    * <pre>{@code
559    * // This snippet has been automatically generated and should be regarded as a code template only.
560    * // It will require modifications to work:
561    * // - It may require correct/in-range values for request initialization.
562    * // - It may require specifying regional endpoints when creating the service client as shown in
563    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
564    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
565    *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
566    *   InstanceAuthString response = cloudRedisClient.getInstanceAuthString(name);
567    * }
568    * }</pre>
569    *
570    * @param name Required. Redis instance resource name using the form:
571    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
572    *     refers to a GCP region.
573    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
574    */
getInstanceAuthString(InstanceName name)575   public final InstanceAuthString getInstanceAuthString(InstanceName name) {
576     GetInstanceAuthStringRequest request =
577         GetInstanceAuthStringRequest.newBuilder()
578             .setName(name == null ? null : name.toString())
579             .build();
580     return getInstanceAuthString(request);
581   }
582 
583   // AUTO-GENERATED DOCUMENTATION AND METHOD.
584   /**
585    * Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response
586    * will be empty. This information is not included in the details returned to GetInstance.
587    *
588    * <p>Sample code:
589    *
590    * <pre>{@code
591    * // This snippet has been automatically generated and should be regarded as a code template only.
592    * // It will require modifications to work:
593    * // - It may require correct/in-range values for request initialization.
594    * // - It may require specifying regional endpoints when creating the service client as shown in
595    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
596    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
597    *   String name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString();
598    *   InstanceAuthString response = cloudRedisClient.getInstanceAuthString(name);
599    * }
600    * }</pre>
601    *
602    * @param name Required. Redis instance resource name using the form:
603    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
604    *     refers to a GCP region.
605    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
606    */
getInstanceAuthString(String name)607   public final InstanceAuthString getInstanceAuthString(String name) {
608     GetInstanceAuthStringRequest request =
609         GetInstanceAuthStringRequest.newBuilder().setName(name).build();
610     return getInstanceAuthString(request);
611   }
612 
613   // AUTO-GENERATED DOCUMENTATION AND METHOD.
614   /**
615    * Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response
616    * will be empty. This information is not included in the details returned to GetInstance.
617    *
618    * <p>Sample code:
619    *
620    * <pre>{@code
621    * // This snippet has been automatically generated and should be regarded as a code template only.
622    * // It will require modifications to work:
623    * // - It may require correct/in-range values for request initialization.
624    * // - It may require specifying regional endpoints when creating the service client as shown in
625    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
626    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
627    *   GetInstanceAuthStringRequest request =
628    *       GetInstanceAuthStringRequest.newBuilder()
629    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
630    *           .build();
631    *   InstanceAuthString response = cloudRedisClient.getInstanceAuthString(request);
632    * }
633    * }</pre>
634    *
635    * @param request The request object containing all of the parameters for the API call.
636    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
637    */
getInstanceAuthString(GetInstanceAuthStringRequest request)638   public final InstanceAuthString getInstanceAuthString(GetInstanceAuthStringRequest request) {
639     return getInstanceAuthStringCallable().call(request);
640   }
641 
642   // AUTO-GENERATED DOCUMENTATION AND METHOD.
643   /**
644    * Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response
645    * will be empty. This information is not included in the details returned to GetInstance.
646    *
647    * <p>Sample code:
648    *
649    * <pre>{@code
650    * // This snippet has been automatically generated and should be regarded as a code template only.
651    * // It will require modifications to work:
652    * // - It may require correct/in-range values for request initialization.
653    * // - It may require specifying regional endpoints when creating the service client as shown in
654    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
655    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
656    *   GetInstanceAuthStringRequest request =
657    *       GetInstanceAuthStringRequest.newBuilder()
658    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
659    *           .build();
660    *   ApiFuture<InstanceAuthString> future =
661    *       cloudRedisClient.getInstanceAuthStringCallable().futureCall(request);
662    *   // Do something.
663    *   InstanceAuthString response = future.get();
664    * }
665    * }</pre>
666    */
667   public final UnaryCallable<GetInstanceAuthStringRequest, InstanceAuthString>
getInstanceAuthStringCallable()668       getInstanceAuthStringCallable() {
669     return stub.getInstanceAuthStringCallable();
670   }
671 
672   // AUTO-GENERATED DOCUMENTATION AND METHOD.
673   /**
674    * Creates a Redis instance based on the specified tier and memory size.
675    *
676    * <p>By default, the instance is accessible from the project's [default
677    * network](https://cloud.google.com/vpc/docs/vpc).
678    *
679    * <p>The creation is executed asynchronously and callers may check the returned operation to
680    * track its progress. Once the operation is completed the Redis instance will be fully
681    * functional. The completed longrunning.Operation will contain the new instance object in the
682    * response field.
683    *
684    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
685    * call DeleteOperation.
686    *
687    * <p>Sample code:
688    *
689    * <pre>{@code
690    * // This snippet has been automatically generated and should be regarded as a code template only.
691    * // It will require modifications to work:
692    * // - It may require correct/in-range values for request initialization.
693    * // - It may require specifying regional endpoints when creating the service client as shown in
694    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
695    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
696    *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
697    *   String instanceId = "instanceId902024336";
698    *   Instance instance = Instance.newBuilder().build();
699    *   Instance response = cloudRedisClient.createInstanceAsync(parent, instanceId, instance).get();
700    * }
701    * }</pre>
702    *
703    * @param parent Required. The resource name of the instance location using the form:
704    *     `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region.
705    * @param instanceId Required. The logical name of the Redis instance in the customer project with
706    *     the following restrictions:
707    *     <ul>
708    *       <li>Must contain only lowercase letters, numbers, and hyphens.
709    *       <li>Must start with a letter.
710    *       <li>Must be between 1-40 characters.
711    *       <li>Must end with a number or a letter.
712    *       <li>Must be unique within the customer project / location
713    *     </ul>
714    *
715    * @param instance Required. A Redis [Instance] resource
716    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
717    */
createInstanceAsync( LocationName parent, String instanceId, Instance instance)718   public final OperationFuture<Instance, Any> createInstanceAsync(
719       LocationName parent, String instanceId, Instance instance) {
720     CreateInstanceRequest request =
721         CreateInstanceRequest.newBuilder()
722             .setParent(parent == null ? null : parent.toString())
723             .setInstanceId(instanceId)
724             .setInstance(instance)
725             .build();
726     return createInstanceAsync(request);
727   }
728 
729   // AUTO-GENERATED DOCUMENTATION AND METHOD.
730   /**
731    * Creates a Redis instance based on the specified tier and memory size.
732    *
733    * <p>By default, the instance is accessible from the project's [default
734    * network](https://cloud.google.com/vpc/docs/vpc).
735    *
736    * <p>The creation is executed asynchronously and callers may check the returned operation to
737    * track its progress. Once the operation is completed the Redis instance will be fully
738    * functional. The completed longrunning.Operation will contain the new instance object in the
739    * response field.
740    *
741    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
742    * call DeleteOperation.
743    *
744    * <p>Sample code:
745    *
746    * <pre>{@code
747    * // This snippet has been automatically generated and should be regarded as a code template only.
748    * // It will require modifications to work:
749    * // - It may require correct/in-range values for request initialization.
750    * // - It may require specifying regional endpoints when creating the service client as shown in
751    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
752    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
753    *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
754    *   String instanceId = "instanceId902024336";
755    *   Instance instance = Instance.newBuilder().build();
756    *   Instance response = cloudRedisClient.createInstanceAsync(parent, instanceId, instance).get();
757    * }
758    * }</pre>
759    *
760    * @param parent Required. The resource name of the instance location using the form:
761    *     `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region.
762    * @param instanceId Required. The logical name of the Redis instance in the customer project with
763    *     the following restrictions:
764    *     <ul>
765    *       <li>Must contain only lowercase letters, numbers, and hyphens.
766    *       <li>Must start with a letter.
767    *       <li>Must be between 1-40 characters.
768    *       <li>Must end with a number or a letter.
769    *       <li>Must be unique within the customer project / location
770    *     </ul>
771    *
772    * @param instance Required. A Redis [Instance] resource
773    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
774    */
createInstanceAsync( String parent, String instanceId, Instance instance)775   public final OperationFuture<Instance, Any> createInstanceAsync(
776       String parent, String instanceId, Instance instance) {
777     CreateInstanceRequest request =
778         CreateInstanceRequest.newBuilder()
779             .setParent(parent)
780             .setInstanceId(instanceId)
781             .setInstance(instance)
782             .build();
783     return createInstanceAsync(request);
784   }
785 
786   // AUTO-GENERATED DOCUMENTATION AND METHOD.
787   /**
788    * Creates a Redis instance based on the specified tier and memory size.
789    *
790    * <p>By default, the instance is accessible from the project's [default
791    * network](https://cloud.google.com/vpc/docs/vpc).
792    *
793    * <p>The creation is executed asynchronously and callers may check the returned operation to
794    * track its progress. Once the operation is completed the Redis instance will be fully
795    * functional. The completed longrunning.Operation will contain the new instance object in the
796    * response field.
797    *
798    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
799    * call DeleteOperation.
800    *
801    * <p>Sample code:
802    *
803    * <pre>{@code
804    * // This snippet has been automatically generated and should be regarded as a code template only.
805    * // It will require modifications to work:
806    * // - It may require correct/in-range values for request initialization.
807    * // - It may require specifying regional endpoints when creating the service client as shown in
808    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
809    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
810    *   CreateInstanceRequest request =
811    *       CreateInstanceRequest.newBuilder()
812    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
813    *           .setInstanceId("instanceId902024336")
814    *           .setInstance(Instance.newBuilder().build())
815    *           .build();
816    *   Instance response = cloudRedisClient.createInstanceAsync(request).get();
817    * }
818    * }</pre>
819    *
820    * @param request The request object containing all of the parameters for the API call.
821    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
822    */
createInstanceAsync(CreateInstanceRequest request)823   public final OperationFuture<Instance, Any> createInstanceAsync(CreateInstanceRequest request) {
824     return createInstanceOperationCallable().futureCall(request);
825   }
826 
827   // AUTO-GENERATED DOCUMENTATION AND METHOD.
828   /**
829    * Creates a Redis instance based on the specified tier and memory size.
830    *
831    * <p>By default, the instance is accessible from the project's [default
832    * network](https://cloud.google.com/vpc/docs/vpc).
833    *
834    * <p>The creation is executed asynchronously and callers may check the returned operation to
835    * track its progress. Once the operation is completed the Redis instance will be fully
836    * functional. The completed longrunning.Operation will contain the new instance object in the
837    * response field.
838    *
839    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
840    * call DeleteOperation.
841    *
842    * <p>Sample code:
843    *
844    * <pre>{@code
845    * // This snippet has been automatically generated and should be regarded as a code template only.
846    * // It will require modifications to work:
847    * // - It may require correct/in-range values for request initialization.
848    * // - It may require specifying regional endpoints when creating the service client as shown in
849    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
850    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
851    *   CreateInstanceRequest request =
852    *       CreateInstanceRequest.newBuilder()
853    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
854    *           .setInstanceId("instanceId902024336")
855    *           .setInstance(Instance.newBuilder().build())
856    *           .build();
857    *   OperationFuture<Instance, Any> future =
858    *       cloudRedisClient.createInstanceOperationCallable().futureCall(request);
859    *   // Do something.
860    *   Instance response = future.get();
861    * }
862    * }</pre>
863    */
864   public final OperationCallable<CreateInstanceRequest, Instance, Any>
createInstanceOperationCallable()865       createInstanceOperationCallable() {
866     return stub.createInstanceOperationCallable();
867   }
868 
869   // AUTO-GENERATED DOCUMENTATION AND METHOD.
870   /**
871    * Creates a Redis instance based on the specified tier and memory size.
872    *
873    * <p>By default, the instance is accessible from the project's [default
874    * network](https://cloud.google.com/vpc/docs/vpc).
875    *
876    * <p>The creation is executed asynchronously and callers may check the returned operation to
877    * track its progress. Once the operation is completed the Redis instance will be fully
878    * functional. The completed longrunning.Operation will contain the new instance object in the
879    * response field.
880    *
881    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
882    * call DeleteOperation.
883    *
884    * <p>Sample code:
885    *
886    * <pre>{@code
887    * // This snippet has been automatically generated and should be regarded as a code template only.
888    * // It will require modifications to work:
889    * // - It may require correct/in-range values for request initialization.
890    * // - It may require specifying regional endpoints when creating the service client as shown in
891    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
892    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
893    *   CreateInstanceRequest request =
894    *       CreateInstanceRequest.newBuilder()
895    *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
896    *           .setInstanceId("instanceId902024336")
897    *           .setInstance(Instance.newBuilder().build())
898    *           .build();
899    *   ApiFuture<Operation> future = cloudRedisClient.createInstanceCallable().futureCall(request);
900    *   // Do something.
901    *   Operation response = future.get();
902    * }
903    * }</pre>
904    */
createInstanceCallable()905   public final UnaryCallable<CreateInstanceRequest, Operation> createInstanceCallable() {
906     return stub.createInstanceCallable();
907   }
908 
909   // AUTO-GENERATED DOCUMENTATION AND METHOD.
910   /**
911    * Updates the metadata and configuration of a specific Redis instance.
912    *
913    * <p>Completed longrunning.Operation will contain the new instance object in the response field.
914    * The returned operation is automatically deleted after a few hours, so there is no need to call
915    * DeleteOperation.
916    *
917    * <p>Sample code:
918    *
919    * <pre>{@code
920    * // This snippet has been automatically generated and should be regarded as a code template only.
921    * // It will require modifications to work:
922    * // - It may require correct/in-range values for request initialization.
923    * // - It may require specifying regional endpoints when creating the service client as shown in
924    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
925    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
926    *   FieldMask updateMask = FieldMask.newBuilder().build();
927    *   Instance instance = Instance.newBuilder().build();
928    *   Instance response = cloudRedisClient.updateInstanceAsync(updateMask, instance).get();
929    * }
930    * }</pre>
931    *
932    * @param updateMask Required. Mask of fields to update. At least one path must be supplied in
933    *     this field. The elements of the repeated paths field may only include these fields from
934    *     [Instance][google.cloud.redis.v1beta1.Instance]:
935    *     <p>&#42; `displayName` &#42; `labels` &#42; `memorySizeGb` &#42; `redisConfig` &#42;
936    *     `replica_count`
937    * @param instance Required. Update description. Only fields specified in update_mask are updated.
938    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
939    */
updateInstanceAsync( FieldMask updateMask, Instance instance)940   public final OperationFuture<Instance, Any> updateInstanceAsync(
941       FieldMask updateMask, Instance instance) {
942     UpdateInstanceRequest request =
943         UpdateInstanceRequest.newBuilder().setUpdateMask(updateMask).setInstance(instance).build();
944     return updateInstanceAsync(request);
945   }
946 
947   // AUTO-GENERATED DOCUMENTATION AND METHOD.
948   /**
949    * Updates the metadata and configuration of a specific Redis instance.
950    *
951    * <p>Completed longrunning.Operation will contain the new instance object in the response field.
952    * The returned operation is automatically deleted after a few hours, so there is no need to call
953    * DeleteOperation.
954    *
955    * <p>Sample code:
956    *
957    * <pre>{@code
958    * // This snippet has been automatically generated and should be regarded as a code template only.
959    * // It will require modifications to work:
960    * // - It may require correct/in-range values for request initialization.
961    * // - It may require specifying regional endpoints when creating the service client as shown in
962    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
963    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
964    *   UpdateInstanceRequest request =
965    *       UpdateInstanceRequest.newBuilder()
966    *           .setUpdateMask(FieldMask.newBuilder().build())
967    *           .setInstance(Instance.newBuilder().build())
968    *           .build();
969    *   Instance response = cloudRedisClient.updateInstanceAsync(request).get();
970    * }
971    * }</pre>
972    *
973    * @param request The request object containing all of the parameters for the API call.
974    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
975    */
updateInstanceAsync(UpdateInstanceRequest request)976   public final OperationFuture<Instance, Any> updateInstanceAsync(UpdateInstanceRequest request) {
977     return updateInstanceOperationCallable().futureCall(request);
978   }
979 
980   // AUTO-GENERATED DOCUMENTATION AND METHOD.
981   /**
982    * Updates the metadata and configuration of a specific Redis instance.
983    *
984    * <p>Completed longrunning.Operation will contain the new instance object in the response field.
985    * The returned operation is automatically deleted after a few hours, so there is no need to call
986    * DeleteOperation.
987    *
988    * <p>Sample code:
989    *
990    * <pre>{@code
991    * // This snippet has been automatically generated and should be regarded as a code template only.
992    * // It will require modifications to work:
993    * // - It may require correct/in-range values for request initialization.
994    * // - It may require specifying regional endpoints when creating the service client as shown in
995    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
996    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
997    *   UpdateInstanceRequest request =
998    *       UpdateInstanceRequest.newBuilder()
999    *           .setUpdateMask(FieldMask.newBuilder().build())
1000    *           .setInstance(Instance.newBuilder().build())
1001    *           .build();
1002    *   OperationFuture<Instance, Any> future =
1003    *       cloudRedisClient.updateInstanceOperationCallable().futureCall(request);
1004    *   // Do something.
1005    *   Instance response = future.get();
1006    * }
1007    * }</pre>
1008    */
1009   public final OperationCallable<UpdateInstanceRequest, Instance, Any>
updateInstanceOperationCallable()1010       updateInstanceOperationCallable() {
1011     return stub.updateInstanceOperationCallable();
1012   }
1013 
1014   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1015   /**
1016    * Updates the metadata and configuration of a specific Redis instance.
1017    *
1018    * <p>Completed longrunning.Operation will contain the new instance object in the response field.
1019    * The returned operation is automatically deleted after a few hours, so there is no need to call
1020    * DeleteOperation.
1021    *
1022    * <p>Sample code:
1023    *
1024    * <pre>{@code
1025    * // This snippet has been automatically generated and should be regarded as a code template only.
1026    * // It will require modifications to work:
1027    * // - It may require correct/in-range values for request initialization.
1028    * // - It may require specifying regional endpoints when creating the service client as shown in
1029    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1030    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1031    *   UpdateInstanceRequest request =
1032    *       UpdateInstanceRequest.newBuilder()
1033    *           .setUpdateMask(FieldMask.newBuilder().build())
1034    *           .setInstance(Instance.newBuilder().build())
1035    *           .build();
1036    *   ApiFuture<Operation> future = cloudRedisClient.updateInstanceCallable().futureCall(request);
1037    *   // Do something.
1038    *   Operation response = future.get();
1039    * }
1040    * }</pre>
1041    */
updateInstanceCallable()1042   public final UnaryCallable<UpdateInstanceRequest, Operation> updateInstanceCallable() {
1043     return stub.updateInstanceCallable();
1044   }
1045 
1046   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1047   /**
1048    * Upgrades Redis instance to the newer Redis version specified in the request.
1049    *
1050    * <p>Sample code:
1051    *
1052    * <pre>{@code
1053    * // This snippet has been automatically generated and should be regarded as a code template only.
1054    * // It will require modifications to work:
1055    * // - It may require correct/in-range values for request initialization.
1056    * // - It may require specifying regional endpoints when creating the service client as shown in
1057    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1058    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1059    *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
1060    *   String redisVersion = "redisVersion-1972584739";
1061    *   Instance response = cloudRedisClient.upgradeInstanceAsync(name, redisVersion).get();
1062    * }
1063    * }</pre>
1064    *
1065    * @param name Required. Redis instance resource name using the form:
1066    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
1067    *     refers to a GCP region.
1068    * @param redisVersion Required. Specifies the target version of Redis software to upgrade to.
1069    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1070    */
upgradeInstanceAsync( InstanceName name, String redisVersion)1071   public final OperationFuture<Instance, Any> upgradeInstanceAsync(
1072       InstanceName name, String redisVersion) {
1073     UpgradeInstanceRequest request =
1074         UpgradeInstanceRequest.newBuilder()
1075             .setName(name == null ? null : name.toString())
1076             .setRedisVersion(redisVersion)
1077             .build();
1078     return upgradeInstanceAsync(request);
1079   }
1080 
1081   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1082   /**
1083    * Upgrades Redis instance to the newer Redis version specified in the request.
1084    *
1085    * <p>Sample code:
1086    *
1087    * <pre>{@code
1088    * // This snippet has been automatically generated and should be regarded as a code template only.
1089    * // It will require modifications to work:
1090    * // - It may require correct/in-range values for request initialization.
1091    * // - It may require specifying regional endpoints when creating the service client as shown in
1092    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1093    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1094    *   String name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString();
1095    *   String redisVersion = "redisVersion-1972584739";
1096    *   Instance response = cloudRedisClient.upgradeInstanceAsync(name, redisVersion).get();
1097    * }
1098    * }</pre>
1099    *
1100    * @param name Required. Redis instance resource name using the form:
1101    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
1102    *     refers to a GCP region.
1103    * @param redisVersion Required. Specifies the target version of Redis software to upgrade to.
1104    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1105    */
upgradeInstanceAsync( String name, String redisVersion)1106   public final OperationFuture<Instance, Any> upgradeInstanceAsync(
1107       String name, String redisVersion) {
1108     UpgradeInstanceRequest request =
1109         UpgradeInstanceRequest.newBuilder().setName(name).setRedisVersion(redisVersion).build();
1110     return upgradeInstanceAsync(request);
1111   }
1112 
1113   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1114   /**
1115    * Upgrades Redis instance to the newer Redis version specified in the request.
1116    *
1117    * <p>Sample code:
1118    *
1119    * <pre>{@code
1120    * // This snippet has been automatically generated and should be regarded as a code template only.
1121    * // It will require modifications to work:
1122    * // - It may require correct/in-range values for request initialization.
1123    * // - It may require specifying regional endpoints when creating the service client as shown in
1124    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1125    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1126    *   UpgradeInstanceRequest request =
1127    *       UpgradeInstanceRequest.newBuilder()
1128    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
1129    *           .setRedisVersion("redisVersion-1972584739")
1130    *           .build();
1131    *   Instance response = cloudRedisClient.upgradeInstanceAsync(request).get();
1132    * }
1133    * }</pre>
1134    *
1135    * @param request The request object containing all of the parameters for the API call.
1136    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1137    */
upgradeInstanceAsync(UpgradeInstanceRequest request)1138   public final OperationFuture<Instance, Any> upgradeInstanceAsync(UpgradeInstanceRequest request) {
1139     return upgradeInstanceOperationCallable().futureCall(request);
1140   }
1141 
1142   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1143   /**
1144    * Upgrades Redis instance to the newer Redis version specified in the request.
1145    *
1146    * <p>Sample code:
1147    *
1148    * <pre>{@code
1149    * // This snippet has been automatically generated and should be regarded as a code template only.
1150    * // It will require modifications to work:
1151    * // - It may require correct/in-range values for request initialization.
1152    * // - It may require specifying regional endpoints when creating the service client as shown in
1153    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1154    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1155    *   UpgradeInstanceRequest request =
1156    *       UpgradeInstanceRequest.newBuilder()
1157    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
1158    *           .setRedisVersion("redisVersion-1972584739")
1159    *           .build();
1160    *   OperationFuture<Instance, Any> future =
1161    *       cloudRedisClient.upgradeInstanceOperationCallable().futureCall(request);
1162    *   // Do something.
1163    *   Instance response = future.get();
1164    * }
1165    * }</pre>
1166    */
1167   public final OperationCallable<UpgradeInstanceRequest, Instance, Any>
upgradeInstanceOperationCallable()1168       upgradeInstanceOperationCallable() {
1169     return stub.upgradeInstanceOperationCallable();
1170   }
1171 
1172   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1173   /**
1174    * Upgrades Redis instance to the newer Redis version specified in the request.
1175    *
1176    * <p>Sample code:
1177    *
1178    * <pre>{@code
1179    * // This snippet has been automatically generated and should be regarded as a code template only.
1180    * // It will require modifications to work:
1181    * // - It may require correct/in-range values for request initialization.
1182    * // - It may require specifying regional endpoints when creating the service client as shown in
1183    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1184    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1185    *   UpgradeInstanceRequest request =
1186    *       UpgradeInstanceRequest.newBuilder()
1187    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
1188    *           .setRedisVersion("redisVersion-1972584739")
1189    *           .build();
1190    *   ApiFuture<Operation> future = cloudRedisClient.upgradeInstanceCallable().futureCall(request);
1191    *   // Do something.
1192    *   Operation response = future.get();
1193    * }
1194    * }</pre>
1195    */
upgradeInstanceCallable()1196   public final UnaryCallable<UpgradeInstanceRequest, Operation> upgradeInstanceCallable() {
1197     return stub.upgradeInstanceCallable();
1198   }
1199 
1200   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1201   /**
1202    * Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
1203    *
1204    * <p>Redis may stop serving during this operation. Instance state will be IMPORTING for entire
1205    * operation. When complete, the instance will contain only data from the imported file.
1206    *
1207    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
1208    * call DeleteOperation.
1209    *
1210    * <p>Sample code:
1211    *
1212    * <pre>{@code
1213    * // This snippet has been automatically generated and should be regarded as a code template only.
1214    * // It will require modifications to work:
1215    * // - It may require correct/in-range values for request initialization.
1216    * // - It may require specifying regional endpoints when creating the service client as shown in
1217    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1218    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1219    *   String name = "name3373707";
1220    *   InputConfig inputConfig = InputConfig.newBuilder().build();
1221    *   Instance response = cloudRedisClient.importInstanceAsync(name, inputConfig).get();
1222    * }
1223    * }</pre>
1224    *
1225    * @param name Required. Redis instance resource name using the form:
1226    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
1227    *     refers to a GCP region.
1228    * @param inputConfig Required. Specify data to be imported.
1229    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1230    */
importInstanceAsync( String name, InputConfig inputConfig)1231   public final OperationFuture<Instance, Any> importInstanceAsync(
1232       String name, InputConfig inputConfig) {
1233     ImportInstanceRequest request =
1234         ImportInstanceRequest.newBuilder().setName(name).setInputConfig(inputConfig).build();
1235     return importInstanceAsync(request);
1236   }
1237 
1238   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1239   /**
1240    * Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
1241    *
1242    * <p>Redis may stop serving during this operation. Instance state will be IMPORTING for entire
1243    * operation. When complete, the instance will contain only data from the imported file.
1244    *
1245    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
1246    * call DeleteOperation.
1247    *
1248    * <p>Sample code:
1249    *
1250    * <pre>{@code
1251    * // This snippet has been automatically generated and should be regarded as a code template only.
1252    * // It will require modifications to work:
1253    * // - It may require correct/in-range values for request initialization.
1254    * // - It may require specifying regional endpoints when creating the service client as shown in
1255    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1256    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1257    *   ImportInstanceRequest request =
1258    *       ImportInstanceRequest.newBuilder()
1259    *           .setName("name3373707")
1260    *           .setInputConfig(InputConfig.newBuilder().build())
1261    *           .build();
1262    *   Instance response = cloudRedisClient.importInstanceAsync(request).get();
1263    * }
1264    * }</pre>
1265    *
1266    * @param request The request object containing all of the parameters for the API call.
1267    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1268    */
importInstanceAsync(ImportInstanceRequest request)1269   public final OperationFuture<Instance, Any> importInstanceAsync(ImportInstanceRequest request) {
1270     return importInstanceOperationCallable().futureCall(request);
1271   }
1272 
1273   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1274   /**
1275    * Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
1276    *
1277    * <p>Redis may stop serving during this operation. Instance state will be IMPORTING for entire
1278    * operation. When complete, the instance will contain only data from the imported file.
1279    *
1280    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
1281    * call DeleteOperation.
1282    *
1283    * <p>Sample code:
1284    *
1285    * <pre>{@code
1286    * // This snippet has been automatically generated and should be regarded as a code template only.
1287    * // It will require modifications to work:
1288    * // - It may require correct/in-range values for request initialization.
1289    * // - It may require specifying regional endpoints when creating the service client as shown in
1290    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1291    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1292    *   ImportInstanceRequest request =
1293    *       ImportInstanceRequest.newBuilder()
1294    *           .setName("name3373707")
1295    *           .setInputConfig(InputConfig.newBuilder().build())
1296    *           .build();
1297    *   OperationFuture<Instance, Any> future =
1298    *       cloudRedisClient.importInstanceOperationCallable().futureCall(request);
1299    *   // Do something.
1300    *   Instance response = future.get();
1301    * }
1302    * }</pre>
1303    */
1304   public final OperationCallable<ImportInstanceRequest, Instance, Any>
importInstanceOperationCallable()1305       importInstanceOperationCallable() {
1306     return stub.importInstanceOperationCallable();
1307   }
1308 
1309   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1310   /**
1311    * Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
1312    *
1313    * <p>Redis may stop serving during this operation. Instance state will be IMPORTING for entire
1314    * operation. When complete, the instance will contain only data from the imported file.
1315    *
1316    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
1317    * call DeleteOperation.
1318    *
1319    * <p>Sample code:
1320    *
1321    * <pre>{@code
1322    * // This snippet has been automatically generated and should be regarded as a code template only.
1323    * // It will require modifications to work:
1324    * // - It may require correct/in-range values for request initialization.
1325    * // - It may require specifying regional endpoints when creating the service client as shown in
1326    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1327    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1328    *   ImportInstanceRequest request =
1329    *       ImportInstanceRequest.newBuilder()
1330    *           .setName("name3373707")
1331    *           .setInputConfig(InputConfig.newBuilder().build())
1332    *           .build();
1333    *   ApiFuture<Operation> future = cloudRedisClient.importInstanceCallable().futureCall(request);
1334    *   // Do something.
1335    *   Operation response = future.get();
1336    * }
1337    * }</pre>
1338    */
importInstanceCallable()1339   public final UnaryCallable<ImportInstanceRequest, Operation> importInstanceCallable() {
1340     return stub.importInstanceCallable();
1341   }
1342 
1343   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1344   /**
1345    * Export Redis instance data into a Redis RDB format file in Cloud Storage.
1346    *
1347    * <p>Redis will continue serving during this operation.
1348    *
1349    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
1350    * call DeleteOperation.
1351    *
1352    * <p>Sample code:
1353    *
1354    * <pre>{@code
1355    * // This snippet has been automatically generated and should be regarded as a code template only.
1356    * // It will require modifications to work:
1357    * // - It may require correct/in-range values for request initialization.
1358    * // - It may require specifying regional endpoints when creating the service client as shown in
1359    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1360    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1361    *   String name = "name3373707";
1362    *   OutputConfig outputConfig = OutputConfig.newBuilder().build();
1363    *   Instance response = cloudRedisClient.exportInstanceAsync(name, outputConfig).get();
1364    * }
1365    * }</pre>
1366    *
1367    * @param name Required. Redis instance resource name using the form:
1368    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
1369    *     refers to a GCP region.
1370    * @param outputConfig Required. Specify data to be exported.
1371    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1372    */
exportInstanceAsync( String name, OutputConfig outputConfig)1373   public final OperationFuture<Instance, Any> exportInstanceAsync(
1374       String name, OutputConfig outputConfig) {
1375     ExportInstanceRequest request =
1376         ExportInstanceRequest.newBuilder().setName(name).setOutputConfig(outputConfig).build();
1377     return exportInstanceAsync(request);
1378   }
1379 
1380   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1381   /**
1382    * Export Redis instance data into a Redis RDB format file in Cloud Storage.
1383    *
1384    * <p>Redis will continue serving during this operation.
1385    *
1386    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
1387    * call DeleteOperation.
1388    *
1389    * <p>Sample code:
1390    *
1391    * <pre>{@code
1392    * // This snippet has been automatically generated and should be regarded as a code template only.
1393    * // It will require modifications to work:
1394    * // - It may require correct/in-range values for request initialization.
1395    * // - It may require specifying regional endpoints when creating the service client as shown in
1396    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1397    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1398    *   ExportInstanceRequest request =
1399    *       ExportInstanceRequest.newBuilder()
1400    *           .setName("name3373707")
1401    *           .setOutputConfig(OutputConfig.newBuilder().build())
1402    *           .build();
1403    *   Instance response = cloudRedisClient.exportInstanceAsync(request).get();
1404    * }
1405    * }</pre>
1406    *
1407    * @param request The request object containing all of the parameters for the API call.
1408    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1409    */
exportInstanceAsync(ExportInstanceRequest request)1410   public final OperationFuture<Instance, Any> exportInstanceAsync(ExportInstanceRequest request) {
1411     return exportInstanceOperationCallable().futureCall(request);
1412   }
1413 
1414   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1415   /**
1416    * Export Redis instance data into a Redis RDB format file in Cloud Storage.
1417    *
1418    * <p>Redis will continue serving during this operation.
1419    *
1420    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
1421    * call DeleteOperation.
1422    *
1423    * <p>Sample code:
1424    *
1425    * <pre>{@code
1426    * // This snippet has been automatically generated and should be regarded as a code template only.
1427    * // It will require modifications to work:
1428    * // - It may require correct/in-range values for request initialization.
1429    * // - It may require specifying regional endpoints when creating the service client as shown in
1430    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1431    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1432    *   ExportInstanceRequest request =
1433    *       ExportInstanceRequest.newBuilder()
1434    *           .setName("name3373707")
1435    *           .setOutputConfig(OutputConfig.newBuilder().build())
1436    *           .build();
1437    *   OperationFuture<Instance, Any> future =
1438    *       cloudRedisClient.exportInstanceOperationCallable().futureCall(request);
1439    *   // Do something.
1440    *   Instance response = future.get();
1441    * }
1442    * }</pre>
1443    */
1444   public final OperationCallable<ExportInstanceRequest, Instance, Any>
exportInstanceOperationCallable()1445       exportInstanceOperationCallable() {
1446     return stub.exportInstanceOperationCallable();
1447   }
1448 
1449   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1450   /**
1451    * Export Redis instance data into a Redis RDB format file in Cloud Storage.
1452    *
1453    * <p>Redis will continue serving during this operation.
1454    *
1455    * <p>The returned operation is automatically deleted after a few hours, so there is no need to
1456    * call DeleteOperation.
1457    *
1458    * <p>Sample code:
1459    *
1460    * <pre>{@code
1461    * // This snippet has been automatically generated and should be regarded as a code template only.
1462    * // It will require modifications to work:
1463    * // - It may require correct/in-range values for request initialization.
1464    * // - It may require specifying regional endpoints when creating the service client as shown in
1465    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1466    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1467    *   ExportInstanceRequest request =
1468    *       ExportInstanceRequest.newBuilder()
1469    *           .setName("name3373707")
1470    *           .setOutputConfig(OutputConfig.newBuilder().build())
1471    *           .build();
1472    *   ApiFuture<Operation> future = cloudRedisClient.exportInstanceCallable().futureCall(request);
1473    *   // Do something.
1474    *   Operation response = future.get();
1475    * }
1476    * }</pre>
1477    */
exportInstanceCallable()1478   public final UnaryCallable<ExportInstanceRequest, Operation> exportInstanceCallable() {
1479     return stub.exportInstanceCallable();
1480   }
1481 
1482   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1483   /**
1484    * Initiates a failover of the primary node to current replica node for a specific STANDARD tier
1485    * Cloud Memorystore for Redis instance.
1486    *
1487    * <p>Sample code:
1488    *
1489    * <pre>{@code
1490    * // This snippet has been automatically generated and should be regarded as a code template only.
1491    * // It will require modifications to work:
1492    * // - It may require correct/in-range values for request initialization.
1493    * // - It may require specifying regional endpoints when creating the service client as shown in
1494    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1495    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1496    *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
1497    *   FailoverInstanceRequest.DataProtectionMode dataProtectionMode =
1498    *       FailoverInstanceRequest.DataProtectionMode.forNumber(0);
1499    *   Instance response = cloudRedisClient.failoverInstanceAsync(name, dataProtectionMode).get();
1500    * }
1501    * }</pre>
1502    *
1503    * @param name Required. Redis instance resource name using the form:
1504    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
1505    *     refers to a GCP region.
1506    * @param dataProtectionMode Optional. Available data protection modes that the user can choose.
1507    *     If it's unspecified, data protection mode will be LIMITED_DATA_LOSS by default.
1508    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1509    */
failoverInstanceAsync( InstanceName name, FailoverInstanceRequest.DataProtectionMode dataProtectionMode)1510   public final OperationFuture<Instance, Any> failoverInstanceAsync(
1511       InstanceName name, FailoverInstanceRequest.DataProtectionMode dataProtectionMode) {
1512     FailoverInstanceRequest request =
1513         FailoverInstanceRequest.newBuilder()
1514             .setName(name == null ? null : name.toString())
1515             .setDataProtectionMode(dataProtectionMode)
1516             .build();
1517     return failoverInstanceAsync(request);
1518   }
1519 
1520   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1521   /**
1522    * Initiates a failover of the primary node to current replica node for a specific STANDARD tier
1523    * Cloud Memorystore for Redis instance.
1524    *
1525    * <p>Sample code:
1526    *
1527    * <pre>{@code
1528    * // This snippet has been automatically generated and should be regarded as a code template only.
1529    * // It will require modifications to work:
1530    * // - It may require correct/in-range values for request initialization.
1531    * // - It may require specifying regional endpoints when creating the service client as shown in
1532    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1533    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1534    *   String name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString();
1535    *   FailoverInstanceRequest.DataProtectionMode dataProtectionMode =
1536    *       FailoverInstanceRequest.DataProtectionMode.forNumber(0);
1537    *   Instance response = cloudRedisClient.failoverInstanceAsync(name, dataProtectionMode).get();
1538    * }
1539    * }</pre>
1540    *
1541    * @param name Required. Redis instance resource name using the form:
1542    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
1543    *     refers to a GCP region.
1544    * @param dataProtectionMode Optional. Available data protection modes that the user can choose.
1545    *     If it's unspecified, data protection mode will be LIMITED_DATA_LOSS by default.
1546    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1547    */
failoverInstanceAsync( String name, FailoverInstanceRequest.DataProtectionMode dataProtectionMode)1548   public final OperationFuture<Instance, Any> failoverInstanceAsync(
1549       String name, FailoverInstanceRequest.DataProtectionMode dataProtectionMode) {
1550     FailoverInstanceRequest request =
1551         FailoverInstanceRequest.newBuilder()
1552             .setName(name)
1553             .setDataProtectionMode(dataProtectionMode)
1554             .build();
1555     return failoverInstanceAsync(request);
1556   }
1557 
1558   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1559   /**
1560    * Initiates a failover of the primary node to current replica node for a specific STANDARD tier
1561    * Cloud Memorystore for Redis instance.
1562    *
1563    * <p>Sample code:
1564    *
1565    * <pre>{@code
1566    * // This snippet has been automatically generated and should be regarded as a code template only.
1567    * // It will require modifications to work:
1568    * // - It may require correct/in-range values for request initialization.
1569    * // - It may require specifying regional endpoints when creating the service client as shown in
1570    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1571    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1572    *   FailoverInstanceRequest request =
1573    *       FailoverInstanceRequest.newBuilder()
1574    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
1575    *           .build();
1576    *   Instance response = cloudRedisClient.failoverInstanceAsync(request).get();
1577    * }
1578    * }</pre>
1579    *
1580    * @param request The request object containing all of the parameters for the API call.
1581    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1582    */
failoverInstanceAsync( FailoverInstanceRequest request)1583   public final OperationFuture<Instance, Any> failoverInstanceAsync(
1584       FailoverInstanceRequest request) {
1585     return failoverInstanceOperationCallable().futureCall(request);
1586   }
1587 
1588   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1589   /**
1590    * Initiates a failover of the primary node to current replica node for a specific STANDARD tier
1591    * Cloud Memorystore for Redis instance.
1592    *
1593    * <p>Sample code:
1594    *
1595    * <pre>{@code
1596    * // This snippet has been automatically generated and should be regarded as a code template only.
1597    * // It will require modifications to work:
1598    * // - It may require correct/in-range values for request initialization.
1599    * // - It may require specifying regional endpoints when creating the service client as shown in
1600    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1601    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1602    *   FailoverInstanceRequest request =
1603    *       FailoverInstanceRequest.newBuilder()
1604    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
1605    *           .build();
1606    *   OperationFuture<Instance, Any> future =
1607    *       cloudRedisClient.failoverInstanceOperationCallable().futureCall(request);
1608    *   // Do something.
1609    *   Instance response = future.get();
1610    * }
1611    * }</pre>
1612    */
1613   public final OperationCallable<FailoverInstanceRequest, Instance, Any>
failoverInstanceOperationCallable()1614       failoverInstanceOperationCallable() {
1615     return stub.failoverInstanceOperationCallable();
1616   }
1617 
1618   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1619   /**
1620    * Initiates a failover of the primary node to current replica node for a specific STANDARD tier
1621    * Cloud Memorystore for Redis instance.
1622    *
1623    * <p>Sample code:
1624    *
1625    * <pre>{@code
1626    * // This snippet has been automatically generated and should be regarded as a code template only.
1627    * // It will require modifications to work:
1628    * // - It may require correct/in-range values for request initialization.
1629    * // - It may require specifying regional endpoints when creating the service client as shown in
1630    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1631    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1632    *   FailoverInstanceRequest request =
1633    *       FailoverInstanceRequest.newBuilder()
1634    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
1635    *           .build();
1636    *   ApiFuture<Operation> future = cloudRedisClient.failoverInstanceCallable().futureCall(request);
1637    *   // Do something.
1638    *   Operation response = future.get();
1639    * }
1640    * }</pre>
1641    */
failoverInstanceCallable()1642   public final UnaryCallable<FailoverInstanceRequest, Operation> failoverInstanceCallable() {
1643     return stub.failoverInstanceCallable();
1644   }
1645 
1646   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1647   /**
1648    * Deletes a specific Redis instance. Instance stops serving and data is deleted.
1649    *
1650    * <p>Sample code:
1651    *
1652    * <pre>{@code
1653    * // This snippet has been automatically generated and should be regarded as a code template only.
1654    * // It will require modifications to work:
1655    * // - It may require correct/in-range values for request initialization.
1656    * // - It may require specifying regional endpoints when creating the service client as shown in
1657    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1658    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1659    *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
1660    *   cloudRedisClient.deleteInstanceAsync(name).get();
1661    * }
1662    * }</pre>
1663    *
1664    * @param name Required. Redis instance resource name using the form:
1665    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
1666    *     refers to a GCP region.
1667    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1668    */
deleteInstanceAsync(InstanceName name)1669   public final OperationFuture<Empty, Any> deleteInstanceAsync(InstanceName name) {
1670     DeleteInstanceRequest request =
1671         DeleteInstanceRequest.newBuilder().setName(name == null ? null : name.toString()).build();
1672     return deleteInstanceAsync(request);
1673   }
1674 
1675   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1676   /**
1677    * Deletes a specific Redis instance. Instance stops serving and data is deleted.
1678    *
1679    * <p>Sample code:
1680    *
1681    * <pre>{@code
1682    * // This snippet has been automatically generated and should be regarded as a code template only.
1683    * // It will require modifications to work:
1684    * // - It may require correct/in-range values for request initialization.
1685    * // - It may require specifying regional endpoints when creating the service client as shown in
1686    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1687    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1688    *   String name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString();
1689    *   cloudRedisClient.deleteInstanceAsync(name).get();
1690    * }
1691    * }</pre>
1692    *
1693    * @param name Required. Redis instance resource name using the form:
1694    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
1695    *     refers to a GCP region.
1696    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1697    */
deleteInstanceAsync(String name)1698   public final OperationFuture<Empty, Any> deleteInstanceAsync(String name) {
1699     DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder().setName(name).build();
1700     return deleteInstanceAsync(request);
1701   }
1702 
1703   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1704   /**
1705    * Deletes a specific Redis instance. Instance stops serving and data is deleted.
1706    *
1707    * <p>Sample code:
1708    *
1709    * <pre>{@code
1710    * // This snippet has been automatically generated and should be regarded as a code template only.
1711    * // It will require modifications to work:
1712    * // - It may require correct/in-range values for request initialization.
1713    * // - It may require specifying regional endpoints when creating the service client as shown in
1714    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1715    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1716    *   DeleteInstanceRequest request =
1717    *       DeleteInstanceRequest.newBuilder()
1718    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
1719    *           .build();
1720    *   cloudRedisClient.deleteInstanceAsync(request).get();
1721    * }
1722    * }</pre>
1723    *
1724    * @param request The request object containing all of the parameters for the API call.
1725    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1726    */
deleteInstanceAsync(DeleteInstanceRequest request)1727   public final OperationFuture<Empty, Any> deleteInstanceAsync(DeleteInstanceRequest request) {
1728     return deleteInstanceOperationCallable().futureCall(request);
1729   }
1730 
1731   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1732   /**
1733    * Deletes a specific Redis instance. Instance stops serving and data is deleted.
1734    *
1735    * <p>Sample code:
1736    *
1737    * <pre>{@code
1738    * // This snippet has been automatically generated and should be regarded as a code template only.
1739    * // It will require modifications to work:
1740    * // - It may require correct/in-range values for request initialization.
1741    * // - It may require specifying regional endpoints when creating the service client as shown in
1742    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1743    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1744    *   DeleteInstanceRequest request =
1745    *       DeleteInstanceRequest.newBuilder()
1746    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
1747    *           .build();
1748    *   OperationFuture<Empty, Any> future =
1749    *       cloudRedisClient.deleteInstanceOperationCallable().futureCall(request);
1750    *   // Do something.
1751    *   future.get();
1752    * }
1753    * }</pre>
1754    */
1755   public final OperationCallable<DeleteInstanceRequest, Empty, Any>
deleteInstanceOperationCallable()1756       deleteInstanceOperationCallable() {
1757     return stub.deleteInstanceOperationCallable();
1758   }
1759 
1760   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1761   /**
1762    * Deletes a specific Redis instance. Instance stops serving and data is deleted.
1763    *
1764    * <p>Sample code:
1765    *
1766    * <pre>{@code
1767    * // This snippet has been automatically generated and should be regarded as a code template only.
1768    * // It will require modifications to work:
1769    * // - It may require correct/in-range values for request initialization.
1770    * // - It may require specifying regional endpoints when creating the service client as shown in
1771    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1772    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1773    *   DeleteInstanceRequest request =
1774    *       DeleteInstanceRequest.newBuilder()
1775    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
1776    *           .build();
1777    *   ApiFuture<Operation> future = cloudRedisClient.deleteInstanceCallable().futureCall(request);
1778    *   // Do something.
1779    *   future.get();
1780    * }
1781    * }</pre>
1782    */
deleteInstanceCallable()1783   public final UnaryCallable<DeleteInstanceRequest, Operation> deleteInstanceCallable() {
1784     return stub.deleteInstanceCallable();
1785   }
1786 
1787   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1788   /**
1789    * Reschedule maintenance for a given instance in a given project and location.
1790    *
1791    * <p>Sample code:
1792    *
1793    * <pre>{@code
1794    * // This snippet has been automatically generated and should be regarded as a code template only.
1795    * // It will require modifications to work:
1796    * // - It may require correct/in-range values for request initialization.
1797    * // - It may require specifying regional endpoints when creating the service client as shown in
1798    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1799    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1800    *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
1801    *   RescheduleMaintenanceRequest.RescheduleType rescheduleType =
1802    *       RescheduleMaintenanceRequest.RescheduleType.forNumber(0);
1803    *   Timestamp scheduleTime = Timestamp.newBuilder().build();
1804    *   Instance response =
1805    *       cloudRedisClient.rescheduleMaintenanceAsync(name, rescheduleType, scheduleTime).get();
1806    * }
1807    * }</pre>
1808    *
1809    * @param name Required. Redis instance resource name using the form:
1810    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
1811    *     refers to a GCP region.
1812    * @param rescheduleType Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time
1813    *     as well.
1814    * @param scheduleTime Optional. Timestamp when the maintenance shall be rescheduled to if
1815    *     reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for example `2012-11-15T16:19:00.094Z`.
1816    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1817    */
rescheduleMaintenanceAsync( InstanceName name, RescheduleMaintenanceRequest.RescheduleType rescheduleType, Timestamp scheduleTime)1818   public final OperationFuture<Instance, Any> rescheduleMaintenanceAsync(
1819       InstanceName name,
1820       RescheduleMaintenanceRequest.RescheduleType rescheduleType,
1821       Timestamp scheduleTime) {
1822     RescheduleMaintenanceRequest request =
1823         RescheduleMaintenanceRequest.newBuilder()
1824             .setName(name == null ? null : name.toString())
1825             .setRescheduleType(rescheduleType)
1826             .setScheduleTime(scheduleTime)
1827             .build();
1828     return rescheduleMaintenanceAsync(request);
1829   }
1830 
1831   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1832   /**
1833    * Reschedule maintenance for a given instance in a given project and location.
1834    *
1835    * <p>Sample code:
1836    *
1837    * <pre>{@code
1838    * // This snippet has been automatically generated and should be regarded as a code template only.
1839    * // It will require modifications to work:
1840    * // - It may require correct/in-range values for request initialization.
1841    * // - It may require specifying regional endpoints when creating the service client as shown in
1842    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1843    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1844    *   String name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString();
1845    *   RescheduleMaintenanceRequest.RescheduleType rescheduleType =
1846    *       RescheduleMaintenanceRequest.RescheduleType.forNumber(0);
1847    *   Timestamp scheduleTime = Timestamp.newBuilder().build();
1848    *   Instance response =
1849    *       cloudRedisClient.rescheduleMaintenanceAsync(name, rescheduleType, scheduleTime).get();
1850    * }
1851    * }</pre>
1852    *
1853    * @param name Required. Redis instance resource name using the form:
1854    *     `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
1855    *     refers to a GCP region.
1856    * @param rescheduleType Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time
1857    *     as well.
1858    * @param scheduleTime Optional. Timestamp when the maintenance shall be rescheduled to if
1859    *     reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for example `2012-11-15T16:19:00.094Z`.
1860    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1861    */
rescheduleMaintenanceAsync( String name, RescheduleMaintenanceRequest.RescheduleType rescheduleType, Timestamp scheduleTime)1862   public final OperationFuture<Instance, Any> rescheduleMaintenanceAsync(
1863       String name,
1864       RescheduleMaintenanceRequest.RescheduleType rescheduleType,
1865       Timestamp scheduleTime) {
1866     RescheduleMaintenanceRequest request =
1867         RescheduleMaintenanceRequest.newBuilder()
1868             .setName(name)
1869             .setRescheduleType(rescheduleType)
1870             .setScheduleTime(scheduleTime)
1871             .build();
1872     return rescheduleMaintenanceAsync(request);
1873   }
1874 
1875   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1876   /**
1877    * Reschedule maintenance for a given instance in a given project and location.
1878    *
1879    * <p>Sample code:
1880    *
1881    * <pre>{@code
1882    * // This snippet has been automatically generated and should be regarded as a code template only.
1883    * // It will require modifications to work:
1884    * // - It may require correct/in-range values for request initialization.
1885    * // - It may require specifying regional endpoints when creating the service client as shown in
1886    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1887    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1888    *   RescheduleMaintenanceRequest request =
1889    *       RescheduleMaintenanceRequest.newBuilder()
1890    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
1891    *           .setScheduleTime(Timestamp.newBuilder().build())
1892    *           .build();
1893    *   Instance response = cloudRedisClient.rescheduleMaintenanceAsync(request).get();
1894    * }
1895    * }</pre>
1896    *
1897    * @param request The request object containing all of the parameters for the API call.
1898    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1899    */
rescheduleMaintenanceAsync( RescheduleMaintenanceRequest request)1900   public final OperationFuture<Instance, Any> rescheduleMaintenanceAsync(
1901       RescheduleMaintenanceRequest request) {
1902     return rescheduleMaintenanceOperationCallable().futureCall(request);
1903   }
1904 
1905   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1906   /**
1907    * Reschedule maintenance for a given instance in a given project and location.
1908    *
1909    * <p>Sample code:
1910    *
1911    * <pre>{@code
1912    * // This snippet has been automatically generated and should be regarded as a code template only.
1913    * // It will require modifications to work:
1914    * // - It may require correct/in-range values for request initialization.
1915    * // - It may require specifying regional endpoints when creating the service client as shown in
1916    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1917    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1918    *   RescheduleMaintenanceRequest request =
1919    *       RescheduleMaintenanceRequest.newBuilder()
1920    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
1921    *           .setScheduleTime(Timestamp.newBuilder().build())
1922    *           .build();
1923    *   OperationFuture<Instance, Any> future =
1924    *       cloudRedisClient.rescheduleMaintenanceOperationCallable().futureCall(request);
1925    *   // Do something.
1926    *   Instance response = future.get();
1927    * }
1928    * }</pre>
1929    */
1930   public final OperationCallable<RescheduleMaintenanceRequest, Instance, Any>
rescheduleMaintenanceOperationCallable()1931       rescheduleMaintenanceOperationCallable() {
1932     return stub.rescheduleMaintenanceOperationCallable();
1933   }
1934 
1935   // AUTO-GENERATED DOCUMENTATION AND METHOD.
1936   /**
1937    * Reschedule maintenance for a given instance in a given project and location.
1938    *
1939    * <p>Sample code:
1940    *
1941    * <pre>{@code
1942    * // This snippet has been automatically generated and should be regarded as a code template only.
1943    * // It will require modifications to work:
1944    * // - It may require correct/in-range values for request initialization.
1945    * // - It may require specifying regional endpoints when creating the service client as shown in
1946    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
1947    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
1948    *   RescheduleMaintenanceRequest request =
1949    *       RescheduleMaintenanceRequest.newBuilder()
1950    *           .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
1951    *           .setScheduleTime(Timestamp.newBuilder().build())
1952    *           .build();
1953    *   ApiFuture<Operation> future =
1954    *       cloudRedisClient.rescheduleMaintenanceCallable().futureCall(request);
1955    *   // Do something.
1956    *   Operation response = future.get();
1957    * }
1958    * }</pre>
1959    */
1960   public final UnaryCallable<RescheduleMaintenanceRequest, Operation>
rescheduleMaintenanceCallable()1961       rescheduleMaintenanceCallable() {
1962     return stub.rescheduleMaintenanceCallable();
1963   }
1964 
1965   @Override
close()1966   public final void close() {
1967     stub.close();
1968   }
1969 
1970   @Override
shutdown()1971   public void shutdown() {
1972     stub.shutdown();
1973   }
1974 
1975   @Override
isShutdown()1976   public boolean isShutdown() {
1977     return stub.isShutdown();
1978   }
1979 
1980   @Override
isTerminated()1981   public boolean isTerminated() {
1982     return stub.isTerminated();
1983   }
1984 
1985   @Override
shutdownNow()1986   public void shutdownNow() {
1987     stub.shutdownNow();
1988   }
1989 
1990   @Override
awaitTermination(long duration, TimeUnit unit)1991   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
1992     return stub.awaitTermination(duration, unit);
1993   }
1994 
1995   public static class ListInstancesPagedResponse
1996       extends AbstractPagedListResponse<
1997           ListInstancesRequest,
1998           ListInstancesResponse,
1999           Instance,
2000           ListInstancesPage,
2001           ListInstancesFixedSizeCollection> {
2002 
createAsync( PageContext<ListInstancesRequest, ListInstancesResponse, Instance> context, ApiFuture<ListInstancesResponse> futureResponse)2003     public static ApiFuture<ListInstancesPagedResponse> createAsync(
2004         PageContext<ListInstancesRequest, ListInstancesResponse, Instance> context,
2005         ApiFuture<ListInstancesResponse> futureResponse) {
2006       ApiFuture<ListInstancesPage> futurePage =
2007           ListInstancesPage.createEmptyPage().createPageAsync(context, futureResponse);
2008       return ApiFutures.transform(
2009           futurePage,
2010           input -> new ListInstancesPagedResponse(input),
2011           MoreExecutors.directExecutor());
2012     }
2013 
ListInstancesPagedResponse(ListInstancesPage page)2014     private ListInstancesPagedResponse(ListInstancesPage page) {
2015       super(page, ListInstancesFixedSizeCollection.createEmptyCollection());
2016     }
2017   }
2018 
2019   public static class ListInstancesPage
2020       extends AbstractPage<
2021           ListInstancesRequest, ListInstancesResponse, Instance, ListInstancesPage> {
2022 
ListInstancesPage( PageContext<ListInstancesRequest, ListInstancesResponse, Instance> context, ListInstancesResponse response)2023     private ListInstancesPage(
2024         PageContext<ListInstancesRequest, ListInstancesResponse, Instance> context,
2025         ListInstancesResponse response) {
2026       super(context, response);
2027     }
2028 
createEmptyPage()2029     private static ListInstancesPage createEmptyPage() {
2030       return new ListInstancesPage(null, null);
2031     }
2032 
2033     @Override
createPage( PageContext<ListInstancesRequest, ListInstancesResponse, Instance> context, ListInstancesResponse response)2034     protected ListInstancesPage createPage(
2035         PageContext<ListInstancesRequest, ListInstancesResponse, Instance> context,
2036         ListInstancesResponse response) {
2037       return new ListInstancesPage(context, response);
2038     }
2039 
2040     @Override
createPageAsync( PageContext<ListInstancesRequest, ListInstancesResponse, Instance> context, ApiFuture<ListInstancesResponse> futureResponse)2041     public ApiFuture<ListInstancesPage> createPageAsync(
2042         PageContext<ListInstancesRequest, ListInstancesResponse, Instance> context,
2043         ApiFuture<ListInstancesResponse> futureResponse) {
2044       return super.createPageAsync(context, futureResponse);
2045     }
2046   }
2047 
2048   public static class ListInstancesFixedSizeCollection
2049       extends AbstractFixedSizeCollection<
2050           ListInstancesRequest,
2051           ListInstancesResponse,
2052           Instance,
2053           ListInstancesPage,
2054           ListInstancesFixedSizeCollection> {
2055 
ListInstancesFixedSizeCollection(List<ListInstancesPage> pages, int collectionSize)2056     private ListInstancesFixedSizeCollection(List<ListInstancesPage> pages, int collectionSize) {
2057       super(pages, collectionSize);
2058     }
2059 
createEmptyCollection()2060     private static ListInstancesFixedSizeCollection createEmptyCollection() {
2061       return new ListInstancesFixedSizeCollection(null, 0);
2062     }
2063 
2064     @Override
createCollection( List<ListInstancesPage> pages, int collectionSize)2065     protected ListInstancesFixedSizeCollection createCollection(
2066         List<ListInstancesPage> pages, int collectionSize) {
2067       return new ListInstancesFixedSizeCollection(pages, collectionSize);
2068     }
2069   }
2070 }
2071