Class TpuClient (2.19.0)

public class TpuClient implements BackgroundResource

Service Description: Manages TPU nodes and other resources

TPU API v2

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   NodeName name = NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]");
   Node response = tpuClient.getNode(name);
 }
 

Note: close() needs to be called on the TpuClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of TpuSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 TpuSettings tpuSettings =
     TpuSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 TpuClient tpuClient = TpuClient.create(tpuSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 TpuSettings tpuSettings = TpuSettings.newBuilder().setEndpoint(myEndpoint).build();
 TpuClient tpuClient = TpuClient.create(tpuSettings);
 

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 TpuSettings tpuSettings = TpuSettings.newHttpJsonBuilder().build();
 TpuClient tpuClient = TpuClient.create(tpuSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > TpuClient

Implements

BackgroundResource

Static Methods

create()

public static final TpuClient create()

Constructs an instance of TpuClient with default settings.

Returns
TypeDescription
TpuClient
Exceptions
TypeDescription
IOException

create(TpuSettings settings)

public static final TpuClient create(TpuSettings settings)

Constructs an instance of TpuClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
NameDescription
settingsTpuSettings
Returns
TypeDescription
TpuClient
Exceptions
TypeDescription
IOException

create(TpuStub stub)

public static final TpuClient create(TpuStub stub)

Constructs an instance of TpuClient, using the given stub for making calls. This is for advanced usage - prefer using create(TpuSettings).

Parameter
NameDescription
stubTpuStub
Returns
TypeDescription
TpuClient

Constructors

TpuClient(TpuSettings settings)

protected TpuClient(TpuSettings settings)

Constructs an instance of TpuClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
NameDescription
settingsTpuSettings

TpuClient(TpuStub stub)

protected TpuClient(TpuStub stub)
Parameter
NameDescription
stubTpuStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

createNodeAsync(CreateNodeRequest request)

public final OperationFuture<Node,OperationMetadata> createNodeAsync(CreateNodeRequest request)

Creates a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   CreateNodeRequest request =
       CreateNodeRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setNodeId("nodeId-1040171331")
           .setNode(Node.newBuilder().build())
           .build();
   Node response = tpuClient.createNodeAsync(request).get();
 }
 
Parameter
NameDescription
requestCreateNodeRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Node,OperationMetadata>

createNodeAsync(LocationName parent, Node node, String nodeId)

public final OperationFuture<Node,OperationMetadata> createNodeAsync(LocationName parent, Node node, String nodeId)

Creates a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   Node node = Node.newBuilder().build();
   String nodeId = "nodeId-1040171331";
   Node response = tpuClient.createNodeAsync(parent, node, nodeId).get();
 }
 
Parameters
NameDescription
parentLocationName

Required. The parent resource name.

nodeNode

Required. The node.

nodeIdString

The unqualified resource name.

Returns
TypeDescription
OperationFuture<Node,OperationMetadata>

createNodeAsync(String parent, Node node, String nodeId)

public final OperationFuture<Node,OperationMetadata> createNodeAsync(String parent, Node node, String nodeId)

Creates a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   Node node = Node.newBuilder().build();
   String nodeId = "nodeId-1040171331";
   Node response = tpuClient.createNodeAsync(parent, node, nodeId).get();
 }
 
Parameters
NameDescription
parentString

Required. The parent resource name.

nodeNode

Required. The node.

nodeIdString

The unqualified resource name.

Returns
TypeDescription
OperationFuture<Node,OperationMetadata>

createNodeCallable()

public final UnaryCallable<CreateNodeRequest,Operation> createNodeCallable()

Creates a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   CreateNodeRequest request =
       CreateNodeRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setNodeId("nodeId-1040171331")
           .setNode(Node.newBuilder().build())
           .build();
   ApiFuture<Operation> future = tpuClient.createNodeCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateNodeRequest,Operation>

createNodeOperationCallable()

public final OperationCallable<CreateNodeRequest,Node,OperationMetadata> createNodeOperationCallable()

Creates a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   CreateNodeRequest request =
       CreateNodeRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setNodeId("nodeId-1040171331")
           .setNode(Node.newBuilder().build())
           .build();
   OperationFuture<Node, OperationMetadata> future =
       tpuClient.createNodeOperationCallable().futureCall(request);
   // Do something.
   Node response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<CreateNodeRequest,Node,OperationMetadata>

deleteNodeAsync(DeleteNodeRequest request)

public final OperationFuture<Empty,OperationMetadata> deleteNodeAsync(DeleteNodeRequest request)

Deletes a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   DeleteNodeRequest request =
       DeleteNodeRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .build();
   tpuClient.deleteNodeAsync(request).get();
 }
 
Parameter
NameDescription
requestDeleteNodeRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Empty,OperationMetadata>

deleteNodeAsync(NodeName name)

public final OperationFuture<Empty,OperationMetadata> deleteNodeAsync(NodeName name)

Deletes a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   NodeName name = NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]");
   tpuClient.deleteNodeAsync(name).get();
 }
 
Parameter
NameDescription
nameNodeName

Required. The resource name.

Returns
TypeDescription
OperationFuture<Empty,OperationMetadata>

deleteNodeAsync(String name)

public final OperationFuture<Empty,OperationMetadata> deleteNodeAsync(String name)

Deletes a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   String name = NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString();
   tpuClient.deleteNodeAsync(name).get();
 }
 
Parameter
NameDescription
nameString

Required. The resource name.

Returns
TypeDescription
OperationFuture<Empty,OperationMetadata>

deleteNodeCallable()

public final UnaryCallable<DeleteNodeRequest,Operation> deleteNodeCallable()

Deletes a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   DeleteNodeRequest request =
       DeleteNodeRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .build();
   ApiFuture<Operation> future = tpuClient.deleteNodeCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteNodeRequest,Operation>

deleteNodeOperationCallable()

public final OperationCallable<DeleteNodeRequest,Empty,OperationMetadata> deleteNodeOperationCallable()

Deletes a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   DeleteNodeRequest request =
       DeleteNodeRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .build();
   OperationFuture<Empty, OperationMetadata> future =
       tpuClient.deleteNodeOperationCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
OperationCallable<DeleteNodeRequest,Empty,OperationMetadata>

generateServiceIdentity(GenerateServiceIdentityRequest request)

public final GenerateServiceIdentityResponse generateServiceIdentity(GenerateServiceIdentityRequest request)

Generates the Cloud TPU service identity for the project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   GenerateServiceIdentityRequest request =
       GenerateServiceIdentityRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .build();
   GenerateServiceIdentityResponse response = tpuClient.generateServiceIdentity(request);
 }
 
Parameter
NameDescription
requestGenerateServiceIdentityRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
GenerateServiceIdentityResponse

generateServiceIdentityCallable()

public final UnaryCallable<GenerateServiceIdentityRequest,GenerateServiceIdentityResponse> generateServiceIdentityCallable()

Generates the Cloud TPU service identity for the project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   GenerateServiceIdentityRequest request =
       GenerateServiceIdentityRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .build();
   ApiFuture<GenerateServiceIdentityResponse> future =
       tpuClient.generateServiceIdentityCallable().futureCall(request);
   // Do something.
   GenerateServiceIdentityResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GenerateServiceIdentityRequest,GenerateServiceIdentityResponse>

getAcceleratorType(AcceleratorTypeName name)

public final AcceleratorType getAcceleratorType(AcceleratorTypeName name)

Gets AcceleratorType.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   AcceleratorTypeName name =
       AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]");
   AcceleratorType response = tpuClient.getAcceleratorType(name);
 }
 
Parameter
NameDescription
nameAcceleratorTypeName

Required. The resource name.

Returns
TypeDescription
AcceleratorType

getAcceleratorType(GetAcceleratorTypeRequest request)

public final AcceleratorType getAcceleratorType(GetAcceleratorTypeRequest request)

Gets AcceleratorType.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   GetAcceleratorTypeRequest request =
       GetAcceleratorTypeRequest.newBuilder()
           .setName(
               AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]")
                   .toString())
           .build();
   AcceleratorType response = tpuClient.getAcceleratorType(request);
 }
 
Parameter
NameDescription
requestGetAcceleratorTypeRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
AcceleratorType

getAcceleratorType(String name)

public final AcceleratorType getAcceleratorType(String name)

Gets AcceleratorType.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   String name =
       AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]").toString();
   AcceleratorType response = tpuClient.getAcceleratorType(name);
 }
 
Parameter
NameDescription
nameString

Required. The resource name.

Returns
TypeDescription
AcceleratorType

getAcceleratorTypeCallable()

public final UnaryCallable<GetAcceleratorTypeRequest,AcceleratorType> getAcceleratorTypeCallable()

Gets AcceleratorType.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   GetAcceleratorTypeRequest request =
       GetAcceleratorTypeRequest.newBuilder()
           .setName(
               AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]")
                   .toString())
           .build();
   ApiFuture<AcceleratorType> future =
       tpuClient.getAcceleratorTypeCallable().futureCall(request);
   // Do something.
   AcceleratorType response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetAcceleratorTypeRequest,AcceleratorType>

getGuestAttributes(GetGuestAttributesRequest request)

public final GetGuestAttributesResponse getGuestAttributes(GetGuestAttributesRequest request)

Retrieves the guest attributes for the node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   GetGuestAttributesRequest request =
       GetGuestAttributesRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .setQueryPath("queryPath-1807004403")
           .addAllWorkerIds(new ArrayList<String>())
           .build();
   GetGuestAttributesResponse response = tpuClient.getGuestAttributes(request);
 }
 
Parameter
NameDescription
requestGetGuestAttributesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
GetGuestAttributesResponse

getGuestAttributesCallable()

public final UnaryCallable<GetGuestAttributesRequest,GetGuestAttributesResponse> getGuestAttributesCallable()

Retrieves the guest attributes for the node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   GetGuestAttributesRequest request =
       GetGuestAttributesRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .setQueryPath("queryPath-1807004403")
           .addAllWorkerIds(new ArrayList<String>())
           .build();
   ApiFuture<GetGuestAttributesResponse> future =
       tpuClient.getGuestAttributesCallable().futureCall(request);
   // Do something.
   GetGuestAttributesResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetGuestAttributesRequest,GetGuestAttributesResponse>

getHttpJsonOperationsClient()

public final OperationsClient getHttpJsonOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getLocation(GetLocationRequest request)

public final Location getLocation(GetLocationRequest request)

Gets information about a location.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
   Location response = tpuClient.getLocation(request);
 }
 
Parameter
NameDescription
requestcom.google.cloud.location.GetLocationRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
com.google.cloud.location.Location

getLocationCallable()

public final UnaryCallable<GetLocationRequest,Location> getLocationCallable()

Gets information about a location.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
   ApiFuture<Location> future = tpuClient.getLocationCallable().futureCall(request);
   // Do something.
   Location response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location>

getNode(GetNodeRequest request)

public final Node getNode(GetNodeRequest request)

Gets the details of a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   GetNodeRequest request =
       GetNodeRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .build();
   Node response = tpuClient.getNode(request);
 }
 
Parameter
NameDescription
requestGetNodeRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Node

getNode(NodeName name)

public final Node getNode(NodeName name)

Gets the details of a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   NodeName name = NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]");
   Node response = tpuClient.getNode(name);
 }
 
Parameter
NameDescription
nameNodeName

Required. The resource name.

Returns
TypeDescription
Node

getNode(String name)

public final Node getNode(String name)

Gets the details of a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   String name = NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString();
   Node response = tpuClient.getNode(name);
 }
 
Parameter
NameDescription
nameString

Required. The resource name.

Returns
TypeDescription
Node

getNodeCallable()

public final UnaryCallable<GetNodeRequest,Node> getNodeCallable()

Gets the details of a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   GetNodeRequest request =
       GetNodeRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .build();
   ApiFuture<Node> future = tpuClient.getNodeCallable().futureCall(request);
   // Do something.
   Node response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetNodeRequest,Node>

getOperationsClient()

public final OperationsClient getOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getRuntimeVersion(GetRuntimeVersionRequest request)

public final RuntimeVersion getRuntimeVersion(GetRuntimeVersionRequest request)

Gets a runtime version.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   GetRuntimeVersionRequest request =
       GetRuntimeVersionRequest.newBuilder()
           .setName(
               RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]").toString())
           .build();
   RuntimeVersion response = tpuClient.getRuntimeVersion(request);
 }
 
Parameter
NameDescription
requestGetRuntimeVersionRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
RuntimeVersion

getRuntimeVersion(RuntimeVersionName name)

public final RuntimeVersion getRuntimeVersion(RuntimeVersionName name)

Gets a runtime version.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   RuntimeVersionName name =
       RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]");
   RuntimeVersion response = tpuClient.getRuntimeVersion(name);
 }
 
Parameter
NameDescription
nameRuntimeVersionName

Required. The resource name.

Returns
TypeDescription
RuntimeVersion

getRuntimeVersion(String name)

public final RuntimeVersion getRuntimeVersion(String name)

Gets a runtime version.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   String name =
       RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]").toString();
   RuntimeVersion response = tpuClient.getRuntimeVersion(name);
 }
 
Parameter
NameDescription
nameString

Required. The resource name.

Returns
TypeDescription
RuntimeVersion

getRuntimeVersionCallable()

public final UnaryCallable<GetRuntimeVersionRequest,RuntimeVersion> getRuntimeVersionCallable()

Gets a runtime version.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   GetRuntimeVersionRequest request =
       GetRuntimeVersionRequest.newBuilder()
           .setName(
               RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]").toString())
           .build();
   ApiFuture<RuntimeVersion> future = tpuClient.getRuntimeVersionCallable().futureCall(request);
   // Do something.
   RuntimeVersion response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetRuntimeVersionRequest,RuntimeVersion>

getSettings()

public final TpuSettings getSettings()
Returns
TypeDescription
TpuSettings

getStub()

public TpuStub getStub()
Returns
TypeDescription
TpuStub

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

listAcceleratorTypes(ListAcceleratorTypesRequest request)

public final TpuClient.ListAcceleratorTypesPagedResponse listAcceleratorTypes(ListAcceleratorTypesRequest request)

Lists accelerator types supported by this API.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   ListAcceleratorTypesRequest request =
       ListAcceleratorTypesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .build();
   for (AcceleratorType element : tpuClient.listAcceleratorTypes(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListAcceleratorTypesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
TpuClient.ListAcceleratorTypesPagedResponse

listAcceleratorTypes(LocationName parent)

public final TpuClient.ListAcceleratorTypesPagedResponse listAcceleratorTypes(LocationName parent)

Lists accelerator types supported by this API.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (AcceleratorType element : tpuClient.listAcceleratorTypes(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentLocationName

Required. The parent resource name.

Returns
TypeDescription
TpuClient.ListAcceleratorTypesPagedResponse

listAcceleratorTypes(String parent)

public final TpuClient.ListAcceleratorTypesPagedResponse listAcceleratorTypes(String parent)

Lists accelerator types supported by this API.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   for (AcceleratorType element : tpuClient.listAcceleratorTypes(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The parent resource name.

Returns
TypeDescription
TpuClient.ListAcceleratorTypesPagedResponse

listAcceleratorTypesCallable()

public final UnaryCallable<ListAcceleratorTypesRequest,ListAcceleratorTypesResponse> listAcceleratorTypesCallable()

Lists accelerator types supported by this API.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   ListAcceleratorTypesRequest request =
       ListAcceleratorTypesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .build();
   while (true) {
     ListAcceleratorTypesResponse response =
         tpuClient.listAcceleratorTypesCallable().call(request);
     for (AcceleratorType element : response.getAcceleratorTypesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListAcceleratorTypesRequest,ListAcceleratorTypesResponse>

listAcceleratorTypesPagedCallable()

public final UnaryCallable<ListAcceleratorTypesRequest,TpuClient.ListAcceleratorTypesPagedResponse> listAcceleratorTypesPagedCallable()

Lists accelerator types supported by this API.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   ListAcceleratorTypesRequest request =
       ListAcceleratorTypesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .build();
   ApiFuture<AcceleratorType> future =
       tpuClient.listAcceleratorTypesPagedCallable().futureCall(request);
   // Do something.
   for (AcceleratorType element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListAcceleratorTypesRequest,ListAcceleratorTypesPagedResponse>

listLocations(ListLocationsRequest request)

public final TpuClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request)

Lists information about the supported locations for this service.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Location element : tpuClient.listLocations(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestcom.google.cloud.location.ListLocationsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
TpuClient.ListLocationsPagedResponse

listLocationsCallable()

public final UnaryCallable<ListLocationsRequest,ListLocationsResponse> listLocationsCallable()

Lists information about the supported locations for this service.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListLocationsResponse response = tpuClient.listLocationsCallable().call(request);
     for (Location element : response.getLocationsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse>

listLocationsPagedCallable()

public final UnaryCallable<ListLocationsRequest,TpuClient.ListLocationsPagedResponse> listLocationsPagedCallable()

Lists information about the supported locations for this service.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   ListLocationsRequest request =
       ListLocationsRequest.newBuilder()
           .setName("name3373707")
           .setFilter("filter-1274492040")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Location> future = tpuClient.listLocationsPagedCallable().futureCall(request);
   // Do something.
   for (Location element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<com.google.cloud.location.ListLocationsRequest,ListLocationsPagedResponse>

listNodes(ListNodesRequest request)

public final TpuClient.ListNodesPagedResponse listNodes(ListNodesRequest request)

Lists nodes.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   ListNodesRequest request =
       ListNodesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Node element : tpuClient.listNodes(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListNodesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
TpuClient.ListNodesPagedResponse

listNodes(LocationName parent)

public final TpuClient.ListNodesPagedResponse listNodes(LocationName parent)

Lists nodes.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (Node element : tpuClient.listNodes(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentLocationName

Required. The parent resource name.

Returns
TypeDescription
TpuClient.ListNodesPagedResponse

listNodes(String parent)

public final TpuClient.ListNodesPagedResponse listNodes(String parent)

Lists nodes.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   for (Node element : tpuClient.listNodes(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The parent resource name.

Returns
TypeDescription
TpuClient.ListNodesPagedResponse

listNodesCallable()

public final UnaryCallable<ListNodesRequest,ListNodesResponse> listNodesCallable()

Lists nodes.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   ListNodesRequest request =
       ListNodesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListNodesResponse response = tpuClient.listNodesCallable().call(request);
     for (Node element : response.getNodesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListNodesRequest,ListNodesResponse>

listNodesPagedCallable()

public final UnaryCallable<ListNodesRequest,TpuClient.ListNodesPagedResponse> listNodesPagedCallable()

Lists nodes.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   ListNodesRequest request =
       ListNodesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Node> future = tpuClient.listNodesPagedCallable().futureCall(request);
   // Do something.
   for (Node element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListNodesRequest,ListNodesPagedResponse>

listRuntimeVersions(ListRuntimeVersionsRequest request)

public final TpuClient.ListRuntimeVersionsPagedResponse listRuntimeVersions(ListRuntimeVersionsRequest request)

Lists runtime versions supported by this API.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   ListRuntimeVersionsRequest request =
       ListRuntimeVersionsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .build();
   for (RuntimeVersion element : tpuClient.listRuntimeVersions(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListRuntimeVersionsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
TpuClient.ListRuntimeVersionsPagedResponse

listRuntimeVersions(LocationName parent)

public final TpuClient.ListRuntimeVersionsPagedResponse listRuntimeVersions(LocationName parent)

Lists runtime versions supported by this API.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (RuntimeVersion element : tpuClient.listRuntimeVersions(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentLocationName

Required. The parent resource name.

Returns
TypeDescription
TpuClient.ListRuntimeVersionsPagedResponse

listRuntimeVersions(String parent)

public final TpuClient.ListRuntimeVersionsPagedResponse listRuntimeVersions(String parent)

Lists runtime versions supported by this API.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   for (RuntimeVersion element : tpuClient.listRuntimeVersions(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The parent resource name.

Returns
TypeDescription
TpuClient.ListRuntimeVersionsPagedResponse

listRuntimeVersionsCallable()

public final UnaryCallable<ListRuntimeVersionsRequest,ListRuntimeVersionsResponse> listRuntimeVersionsCallable()

Lists runtime versions supported by this API.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   ListRuntimeVersionsRequest request =
       ListRuntimeVersionsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .build();
   while (true) {
     ListRuntimeVersionsResponse response =
         tpuClient.listRuntimeVersionsCallable().call(request);
     for (RuntimeVersion element : response.getRuntimeVersionsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListRuntimeVersionsRequest,ListRuntimeVersionsResponse>

listRuntimeVersionsPagedCallable()

public final UnaryCallable<ListRuntimeVersionsRequest,TpuClient.ListRuntimeVersionsPagedResponse> listRuntimeVersionsPagedCallable()

Lists runtime versions supported by this API.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   ListRuntimeVersionsRequest request =
       ListRuntimeVersionsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .build();
   ApiFuture<RuntimeVersion> future =
       tpuClient.listRuntimeVersionsPagedCallable().futureCall(request);
   // Do something.
   for (RuntimeVersion element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListRuntimeVersionsRequest,ListRuntimeVersionsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

startNodeAsync(StartNodeRequest request)

public final OperationFuture<Node,OperationMetadata> startNodeAsync(StartNodeRequest request)

Starts a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   StartNodeRequest request =
       StartNodeRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .build();
   Node response = tpuClient.startNodeAsync(request).get();
 }
 
Parameter
NameDescription
requestStartNodeRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Node,OperationMetadata>

startNodeCallable()

public final UnaryCallable<StartNodeRequest,Operation> startNodeCallable()

Starts a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   StartNodeRequest request =
       StartNodeRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .build();
   ApiFuture<Operation> future = tpuClient.startNodeCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<StartNodeRequest,Operation>

startNodeOperationCallable()

public final OperationCallable<StartNodeRequest,Node,OperationMetadata> startNodeOperationCallable()

Starts a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   StartNodeRequest request =
       StartNodeRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .build();
   OperationFuture<Node, OperationMetadata> future =
       tpuClient.startNodeOperationCallable().futureCall(request);
   // Do something.
   Node response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<StartNodeRequest,Node,OperationMetadata>

stopNodeAsync(StopNodeRequest request)

public final OperationFuture<Node,OperationMetadata> stopNodeAsync(StopNodeRequest request)

Stops a node. This operation is only available with single TPU nodes.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   StopNodeRequest request =
       StopNodeRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .build();
   Node response = tpuClient.stopNodeAsync(request).get();
 }
 
Parameter
NameDescription
requestStopNodeRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Node,OperationMetadata>

stopNodeCallable()

public final UnaryCallable<StopNodeRequest,Operation> stopNodeCallable()

Stops a node. This operation is only available with single TPU nodes.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   StopNodeRequest request =
       StopNodeRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .build();
   ApiFuture<Operation> future = tpuClient.stopNodeCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<StopNodeRequest,Operation>

stopNodeOperationCallable()

public final OperationCallable<StopNodeRequest,Node,OperationMetadata> stopNodeOperationCallable()

Stops a node. This operation is only available with single TPU nodes.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   StopNodeRequest request =
       StopNodeRequest.newBuilder()
           .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString())
           .build();
   OperationFuture<Node, OperationMetadata> future =
       tpuClient.stopNodeOperationCallable().futureCall(request);
   // Do something.
   Node response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<StopNodeRequest,Node,OperationMetadata>

updateNodeAsync(Node node, FieldMask updateMask)

public final OperationFuture<Node,OperationMetadata> updateNodeAsync(Node node, FieldMask updateMask)

Updates the configurations of a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   Node node = Node.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Node response = tpuClient.updateNodeAsync(node, updateMask).get();
 }
 
Parameters
NameDescription
nodeNode

Required. The node. Only fields specified in update_mask are updated.

updateMaskFieldMask

Required. Mask of fields from Node to update. Supported fields: [description, tags, labels, metadata, network_config.enable_external_ips].

Returns
TypeDescription
OperationFuture<Node,OperationMetadata>

updateNodeAsync(UpdateNodeRequest request)

public final OperationFuture<Node,OperationMetadata> updateNodeAsync(UpdateNodeRequest request)

Updates the configurations of a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   UpdateNodeRequest request =
       UpdateNodeRequest.newBuilder()
           .setUpdateMask(FieldMask.newBuilder().build())
           .setNode(Node.newBuilder().build())
           .build();
   Node response = tpuClient.updateNodeAsync(request).get();
 }
 
Parameter
NameDescription
requestUpdateNodeRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Node,OperationMetadata>

updateNodeCallable()

public final UnaryCallable<UpdateNodeRequest,Operation> updateNodeCallable()

Updates the configurations of a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   UpdateNodeRequest request =
       UpdateNodeRequest.newBuilder()
           .setUpdateMask(FieldMask.newBuilder().build())
           .setNode(Node.newBuilder().build())
           .build();
   ApiFuture<Operation> future = tpuClient.updateNodeCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<UpdateNodeRequest,Operation>

updateNodeOperationCallable()

public final OperationCallable<UpdateNodeRequest,Node,OperationMetadata> updateNodeOperationCallable()

Updates the configurations of a node.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TpuClient tpuClient = TpuClient.create()) {
   UpdateNodeRequest request =
       UpdateNodeRequest.newBuilder()
           .setUpdateMask(FieldMask.newBuilder().build())
           .setNode(Node.newBuilder().build())
           .build();
   OperationFuture<Node, OperationMetadata> future =
       tpuClient.updateNodeOperationCallable().futureCall(request);
   // Do something.
   Node response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<UpdateNodeRequest,Node,OperationMetadata>