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