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