TPU API v2alpha1 + * + *
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: + * + *
{@code + * 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: + * + *
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: + * + *
{@code + * TpuSettings tpuSettings = + * TpuSettings.newBuilder() + * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + * .build(); + * TpuClient tpuClient = TpuClient.create(tpuSettings); + * }+ * + *
To customize the endpoint: + * + *
{@code + * TpuSettings tpuSettings = TpuSettings.newBuilder().setEndpoint(myEndpoint).build(); + * TpuClient tpuClient = TpuClient.create(tpuSettings); + * }+ * + *
Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class TpuClient implements BackgroundResource { + private final TpuSettings settings; + private final TpuStub stub; + private final OperationsClient operationsClient; + + /** Constructs an instance of TpuClient with default settings. */ + public static final TpuClient create() throws IOException { + return create(TpuSettings.newBuilder().build()); + } + + /** + * 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. + */ + public static final TpuClient create(TpuSettings settings) throws IOException { + return new TpuClient(settings); + } + + /** + * Constructs an instance of TpuClient, using the given stub for making calls. This is for + * advanced usage - prefer using create(TpuSettings). + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final TpuClient create(TpuStub stub) { + return new TpuClient(stub); + } + + /** + * 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. + */ + protected TpuClient(TpuSettings settings) throws IOException { + this.settings = settings; + this.stub = ((TpuStubSettings) settings.getStubSettings()).createStub(); + this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected TpuClient(TpuStub stub) { + this.settings = null; + this.stub = stub; + this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + } + + public final TpuSettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public TpuStub getStub() { + return stub; + } + + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getOperationsClient() { + return operationsClient; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists nodes. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * NodeName parent = NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]"); + * for (Node element : tpuClient.listNodes(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The parent resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListNodesPagedResponse listNodes(NodeName parent) { + ListNodesRequest request = + ListNodesRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); + return listNodes(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists nodes. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * String parent = NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString(); + * for (Node element : tpuClient.listNodes(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The parent resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListNodesPagedResponse listNodes(String parent) { + ListNodesRequest request = ListNodesRequest.newBuilder().setParent(parent).build(); + return listNodes(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists nodes. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * ListNodesRequest request = + * ListNodesRequest.newBuilder() + * .setParent(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * for (Node element : tpuClient.listNodes(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListNodesPagedResponse listNodes(ListNodesRequest request) { + return listNodesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists nodes. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * ListNodesRequest request = + * ListNodesRequest.newBuilder() + * .setParent(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = tpuClient.listNodesPagedCallable().futureCall(request); + * // Do something. + * for (Node element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * ListNodesRequest request = + * ListNodesRequest.newBuilder() + * .setParent(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * while (true) { + * ListNodesResponse response = tpuClient.listNodesCallable().call(request); + * for (Node element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }+ */ + public final UnaryCallable
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * NodeName name = NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]"); + * Node response = tpuClient.getNode(name); + * } + * }+ * + * @param name Required. The resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Node getNode(NodeName name) { + GetNodeRequest request = + GetNodeRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getNode(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the details of a node. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * String name = NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString(); + * Node response = tpuClient.getNode(name); + * } + * }+ * + * @param name Required. The resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Node getNode(String name) { + GetNodeRequest request = GetNodeRequest.newBuilder().setName(name).build(); + return getNode(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the details of a node. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * GetNodeRequest request = + * GetNodeRequest.newBuilder() + * .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString()) + * .build(); + * Node response = tpuClient.getNode(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Node getNode(GetNodeRequest request) { + return getNodeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the details of a node. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * GetNodeRequest request = + * GetNodeRequest.newBuilder() + * .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = tpuClient.getNodeCallable().futureCall(request); + * // Do something. + * Node response = future.get(); + * } + * }
Sample code: + * + *
{@code + * 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(); + * } + * }+ * + * @param parent Required. The parent resource name. + * @param node Required. The node. + * @param nodeId The unqualified resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture
Sample code: + * + *
{@code + * 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(); + * } + * }+ * + * @param parent Required. The parent resource name. + * @param node Required. The node. + * @param nodeId The unqualified resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture
Sample code: + * + *
{@code + * 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(); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * CreateNodeRequest request = + * CreateNodeRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setNodeId("nodeId-1040171331") + * .setNode(Node.newBuilder().build()) + * .build(); + * OperationFuture+ */ + public final OperationCallablefuture = + * tpuClient.createNodeOperationCallable().futureCall(request); + * // Do something. + * Node response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * CreateNodeRequest request = + * CreateNodeRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setNodeId("nodeId-1040171331") + * .setNode(Node.newBuilder().build()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = tpuClient.createNodeCallable().futureCall(request); + * // Do something. + * Operation response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * NodeName name = NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]"); + * Node response = tpuClient.deleteNodeAsync(name).get(); + * } + * }+ * + * @param name Required. The resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * String name = NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString(); + * Node response = tpuClient.deleteNodeAsync(name).get(); + * } + * }+ * + * @param name Required. The resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * DeleteNodeRequest request = + * DeleteNodeRequest.newBuilder() + * .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString()) + * .build(); + * Node response = tpuClient.deleteNodeAsync(request).get(); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * DeleteNodeRequest request = + * DeleteNodeRequest.newBuilder() + * .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString()) + * .build(); + * OperationFuture+ */ + public final OperationCallablefuture = + * tpuClient.deleteNodeOperationCallable().futureCall(request); + * // Do something. + * Node response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * DeleteNodeRequest request = + * DeleteNodeRequest.newBuilder() + * .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = tpuClient.deleteNodeCallable().futureCall(request); + * // Do something. + * Operation response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * StopNodeRequest request = StopNodeRequest.newBuilder().setName("name3373707").build(); + * Node response = tpuClient.stopNodeAsync(request).get(); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * StopNodeRequest request = StopNodeRequest.newBuilder().setName("name3373707").build(); + * OperationFuture+ */ + public final OperationCallablefuture = + * tpuClient.stopNodeOperationCallable().futureCall(request); + * // Do something. + * Node response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * StopNodeRequest request = StopNodeRequest.newBuilder().setName("name3373707").build(); + * ApiFuture+ */ + public final UnaryCallablefuture = tpuClient.stopNodeCallable().futureCall(request); + * // Do something. + * Operation response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * StartNodeRequest request = StartNodeRequest.newBuilder().setName("name3373707").build(); + * Node response = tpuClient.startNodeAsync(request).get(); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * StartNodeRequest request = StartNodeRequest.newBuilder().setName("name3373707").build(); + * OperationFuture+ */ + public final OperationCallablefuture = + * tpuClient.startNodeOperationCallable().futureCall(request); + * // Do something. + * Node response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * StartNodeRequest request = StartNodeRequest.newBuilder().setName("name3373707").build(); + * ApiFuture+ */ + public final UnaryCallablefuture = tpuClient.startNodeCallable().futureCall(request); + * // Do something. + * Operation response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * Node node = Node.newBuilder().build(); + * FieldMask updateMask = FieldMask.newBuilder().build(); + * Node response = tpuClient.updateNodeAsync(node, updateMask).get(); + * } + * }+ * + * @param node Required. The node. Only fields specified in update_mask are updated. + * @param updateMask Required. Mask of fields from [Node][Tpu.Node] to update. Supported fields: + * None. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * UpdateNodeRequest request = + * UpdateNodeRequest.newBuilder() + * .setUpdateMask(FieldMask.newBuilder().build()) + * .setNode(Node.newBuilder().build()) + * .build(); + * Node response = tpuClient.updateNodeAsync(request).get(); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * UpdateNodeRequest request = + * UpdateNodeRequest.newBuilder() + * .setUpdateMask(FieldMask.newBuilder().build()) + * .setNode(Node.newBuilder().build()) + * .build(); + * OperationFuture+ */ + public final OperationCallablefuture = + * tpuClient.updateNodeOperationCallable().futureCall(request); + * // Do something. + * Node response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * UpdateNodeRequest request = + * UpdateNodeRequest.newBuilder() + * .setUpdateMask(FieldMask.newBuilder().build()) + * .setNode(Node.newBuilder().build()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = tpuClient.updateNodeCallable().futureCall(request); + * // Do something. + * Operation response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * GenerateServiceIdentityRequest request = + * GenerateServiceIdentityRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .build(); + * GenerateServiceIdentityResponse response = tpuClient.generateServiceIdentity(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final GenerateServiceIdentityResponse generateServiceIdentity( + GenerateServiceIdentityRequest request) { + return generateServiceIdentityCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Generates the Cloud TPU service identity for the project. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * GenerateServiceIdentityRequest request = + * GenerateServiceIdentityRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * tpuClient.generateServiceIdentityCallable().futureCall(request); + * // Do something. + * GenerateServiceIdentityResponse response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * AcceleratorTypeName parent = + * AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]"); + * for (AcceleratorType element : tpuClient.listAcceleratorTypes(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The parent resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListAcceleratorTypesPagedResponse listAcceleratorTypes(AcceleratorTypeName parent) { + ListAcceleratorTypesRequest request = + ListAcceleratorTypesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listAcceleratorTypes(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists accelerator types supported by this API. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * String parent = + * AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]").toString(); + * for (AcceleratorType element : tpuClient.listAcceleratorTypes(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The parent resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListAcceleratorTypesPagedResponse listAcceleratorTypes(String parent) { + ListAcceleratorTypesRequest request = + ListAcceleratorTypesRequest.newBuilder().setParent(parent).build(); + return listAcceleratorTypes(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists accelerator types supported by this API. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * ListAcceleratorTypesRequest request = + * ListAcceleratorTypesRequest.newBuilder() + * .setParent( + * AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]") + * .toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setFilter("filter-1274492040") + * .setOrderBy("orderBy-1207110587") + * .build(); + * for (AcceleratorType element : tpuClient.listAcceleratorTypes(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListAcceleratorTypesPagedResponse listAcceleratorTypes( + ListAcceleratorTypesRequest request) { + return listAcceleratorTypesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists accelerator types supported by this API. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * ListAcceleratorTypesRequest request = + * ListAcceleratorTypesRequest.newBuilder() + * .setParent( + * AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]") + * .toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setFilter("filter-1274492040") + * .setOrderBy("orderBy-1207110587") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * tpuClient.listAcceleratorTypesPagedCallable().futureCall(request); + * // Do something. + * for (AcceleratorType element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * ListAcceleratorTypesRequest request = + * ListAcceleratorTypesRequest.newBuilder() + * .setParent( + * AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]") + * .toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setFilter("filter-1274492040") + * .setOrderBy("orderBy-1207110587") + * .build(); + * while (true) { + * ListAcceleratorTypesResponse response = + * tpuClient.listAcceleratorTypesCallable().call(request); + * for (AcceleratorType element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }+ */ + public final UnaryCallable
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * AcceleratorTypeName name = + * AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]"); + * AcceleratorType response = tpuClient.getAcceleratorType(name); + * } + * }+ * + * @param name Required. The resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final AcceleratorType getAcceleratorType(AcceleratorTypeName name) { + GetAcceleratorTypeRequest request = + GetAcceleratorTypeRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getAcceleratorType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets AcceleratorType. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * String name = + * AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]").toString(); + * AcceleratorType response = tpuClient.getAcceleratorType(name); + * } + * }+ * + * @param name Required. The resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final AcceleratorType getAcceleratorType(String name) { + GetAcceleratorTypeRequest request = + GetAcceleratorTypeRequest.newBuilder().setName(name).build(); + return getAcceleratorType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets AcceleratorType. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * GetAcceleratorTypeRequest request = + * GetAcceleratorTypeRequest.newBuilder() + * .setName( + * AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]") + * .toString()) + * .build(); + * AcceleratorType response = tpuClient.getAcceleratorType(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final AcceleratorType getAcceleratorType(GetAcceleratorTypeRequest request) { + return getAcceleratorTypeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets AcceleratorType. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * GetAcceleratorTypeRequest request = + * GetAcceleratorTypeRequest.newBuilder() + * .setName( + * AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]") + * .toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * tpuClient.getAcceleratorTypeCallable().futureCall(request); + * // Do something. + * AcceleratorType response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * RuntimeVersionName parent = + * RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]"); + * for (RuntimeVersion element : tpuClient.listRuntimeVersions(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The parent resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListRuntimeVersionsPagedResponse listRuntimeVersions(RuntimeVersionName parent) { + ListRuntimeVersionsRequest request = + ListRuntimeVersionsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listRuntimeVersions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists runtime versions supported by this API. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * String parent = + * RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]").toString(); + * for (RuntimeVersion element : tpuClient.listRuntimeVersions(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The parent resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListRuntimeVersionsPagedResponse listRuntimeVersions(String parent) { + ListRuntimeVersionsRequest request = + ListRuntimeVersionsRequest.newBuilder().setParent(parent).build(); + return listRuntimeVersions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists runtime versions supported by this API. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * ListRuntimeVersionsRequest request = + * ListRuntimeVersionsRequest.newBuilder() + * .setParent( + * RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setFilter("filter-1274492040") + * .setOrderBy("orderBy-1207110587") + * .build(); + * for (RuntimeVersion element : tpuClient.listRuntimeVersions(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListRuntimeVersionsPagedResponse listRuntimeVersions( + ListRuntimeVersionsRequest request) { + return listRuntimeVersionsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists runtime versions supported by this API. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * ListRuntimeVersionsRequest request = + * ListRuntimeVersionsRequest.newBuilder() + * .setParent( + * RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setFilter("filter-1274492040") + * .setOrderBy("orderBy-1207110587") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * tpuClient.listRuntimeVersionsPagedCallable().futureCall(request); + * // Do something. + * for (RuntimeVersion element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * ListRuntimeVersionsRequest request = + * ListRuntimeVersionsRequest.newBuilder() + * .setParent( + * RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setFilter("filter-1274492040") + * .setOrderBy("orderBy-1207110587") + * .build(); + * while (true) { + * ListRuntimeVersionsResponse response = + * tpuClient.listRuntimeVersionsCallable().call(request); + * for (RuntimeVersion element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }+ */ + public final UnaryCallable
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * RuntimeVersionName name = + * RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]"); + * RuntimeVersion response = tpuClient.getRuntimeVersion(name); + * } + * }+ * + * @param name Required. The resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final RuntimeVersion getRuntimeVersion(RuntimeVersionName name) { + GetRuntimeVersionRequest request = + GetRuntimeVersionRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getRuntimeVersion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a runtime version. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * String name = + * RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]").toString(); + * RuntimeVersion response = tpuClient.getRuntimeVersion(name); + * } + * }+ * + * @param name Required. The resource name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final RuntimeVersion getRuntimeVersion(String name) { + GetRuntimeVersionRequest request = GetRuntimeVersionRequest.newBuilder().setName(name).build(); + return getRuntimeVersion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a runtime version. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * GetRuntimeVersionRequest request = + * GetRuntimeVersionRequest.newBuilder() + * .setName( + * RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]").toString()) + * .build(); + * RuntimeVersion response = tpuClient.getRuntimeVersion(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final RuntimeVersion getRuntimeVersion(GetRuntimeVersionRequest request) { + return getRuntimeVersionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a runtime version. + * + *
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * GetRuntimeVersionRequest request = + * GetRuntimeVersionRequest.newBuilder() + * .setName( + * RuntimeVersionName.of("[PROJECT]", "[LOCATION]", "[RUNTIME_VERSION]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = tpuClient.getRuntimeVersionCallable().futureCall(request); + * // Do something. + * RuntimeVersion response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * GetGuestAttributesRequest request = + * GetGuestAttributesRequest.newBuilder() + * .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString()) + * .setQueryPath("queryPath-1807004403") + * .addAllWorkerIds(new ArrayList+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final GetGuestAttributesResponse getGuestAttributes(GetGuestAttributesRequest request) { + return getGuestAttributesCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves the guest attributes for the node. + * + *()) + * .build(); + * GetGuestAttributesResponse response = tpuClient.getGuestAttributes(request); + * } + * }
Sample code: + * + *
{@code + * try (TpuClient tpuClient = TpuClient.create()) { + * GetGuestAttributesRequest request = + * GetGuestAttributesRequest.newBuilder() + * .setName(NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]").toString()) + * .setQueryPath("queryPath-1807004403") + * .addAllWorkerIds(new ArrayList+ */ + public final UnaryCallable()) + * .build(); + * ApiFuture future = + * tpuClient.getGuestAttributesCallable().futureCall(request); + * // Do something. + * GetGuestAttributesResponse response = future.get(); + * } + * }
The default instance has everything set to sensible defaults: + * + *
The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *
For example, to set the total timeout of getNode to 30 seconds: + * + *
{@code + * TpuSettings.Builder tpuSettingsBuilder = TpuSettings.newBuilder(); + * tpuSettingsBuilder + * .getNodeSettings() + * .setRetrySettings( + * tpuSettingsBuilder + * .getNodeSettings() + * .getRetrySettings() + * .toBuilder() + * .setTotalTimeout(Duration.ofSeconds(30)) + * .build()); + * TpuSettings tpuSettings = tpuSettingsBuilder.build(); + * }+ */ +@BetaApi +@Generated("by gapic-generator-java") +public class TpuSettings extends ClientSettings
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction The interfaces provided are listed below, along with usage samples.
+ *
+ * ======================= TpuClient =======================
+ *
+ * Service Description: Manages TPU nodes and other resources
+ *
+ * TPU API v2alpha1
+ *
+ * Sample for TpuClient:
+ *
+ * This class is for advanced usage.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class GrpcTpuCallableFactory implements GrpcStubCallableFactory {
+
+ @Override
+ public This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class GrpcTpuStub extends TpuStub {
+ private static final MethodDescriptor This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public abstract class TpuStub implements BackgroundResource {
+
+ public OperationsStub getOperationsStub() {
+ throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
+ }
+
+ public UnaryCallable{@code
+ * try (TpuClient tpuClient = TpuClient.create()) {
+ * NodeName name = NodeName.of("[PROJECT]", "[LOCATION]", "[NODE]");
+ * Node response = tpuClient.getNode(name);
+ * }
+ * }
+ */
+@Generated("by gapic-generator-java")
+package com.google.cloud.tpu.v2alpha1;
+
+import javax.annotation.Generated;
diff --git a/google-cloud-tpu/src/main/java/com/google/cloud/tpu/v2alpha1/stub/GrpcTpuCallableFactory.java b/google-cloud-tpu/src/main/java/com/google/cloud/tpu/v2alpha1/stub/GrpcTpuCallableFactory.java
new file mode 100644
index 00000000..0c8ac5c2
--- /dev/null
+++ b/google-cloud-tpu/src/main/java/com/google/cloud/tpu/v2alpha1/stub/GrpcTpuCallableFactory.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2021 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.tpu.v2alpha1.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.BidiStreamingCallable;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientStreamingCallable;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallable;
+import com.google.api.gax.rpc.StreamingCallSettings;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * gRPC callable factory implementation for the Tpu service API.
+ *
+ *