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