com.google.cloud.tpu.v1.TpuClient Maven / Gradle / Ivy
Show all versions of google-cloud-tpu Show documentation
/*
* Copyright 2024 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.v1;
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.cloud.location.Location;
import com.google.cloud.tpu.v1.stub.TpuStub;
import com.google.cloud.tpu.v1.stub.TpuStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.longrunning.Operation;
import com.google.longrunning.OperationsClient;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* Service Description: Manages TPU nodes and other resources
*
* TPU API v1
*
*
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
* // 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().
*
*
* Methods
*
* Method
* Description
* Method Variants
*
*
* ListNodes
* Lists nodes.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* listNodes(ListNodesRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* listNodes(LocationName parent)
*
listNodes(String parent)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* listNodesPagedCallable()
*
listNodesCallable()
*
*
*
*
* GetNode
* Gets the details of a node.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* getNode(GetNodeRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* getNode(NodeName name)
*
getNode(String name)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* getNodeCallable()
*
*
*
*
* CreateNode
* Creates a node.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* createNodeAsync(CreateNodeRequest request)
*
* Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
*
* createNodeAsync(LocationName parent, Node node, String nodeId)
*
createNodeAsync(String parent, Node node, String nodeId)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* createNodeOperationCallable()
*
createNodeCallable()
*
*
*
*
* DeleteNode
* Deletes a node.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* deleteNodeAsync(DeleteNodeRequest request)
*
* Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
*
* deleteNodeAsync(NodeName name)
*
deleteNodeAsync(String name)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* deleteNodeOperationCallable()
*
deleteNodeCallable()
*
*
*
*
* ReimageNode
* Reimages a node's OS.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* reimageNodeAsync(ReimageNodeRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* reimageNodeOperationCallable()
*
reimageNodeCallable()
*
*
*
*
* StopNode
* Stops a node, this operation is only available with single TPU nodes.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* stopNodeAsync(StopNodeRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* stopNodeOperationCallable()
*
stopNodeCallable()
*
*
*
*
* StartNode
* Starts a node.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* startNodeAsync(StartNodeRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* startNodeOperationCallable()
*
startNodeCallable()
*
*
*
*
* ListTensorFlowVersions
* List TensorFlow versions supported by this API.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* listTensorFlowVersions(ListTensorFlowVersionsRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* listTensorFlowVersions(TensorFlowVersionName parent)
*
listTensorFlowVersions(String parent)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* listTensorFlowVersionsPagedCallable()
*
listTensorFlowVersionsCallable()
*
*
*
*
* GetTensorFlowVersion
* Gets TensorFlow Version.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* getTensorFlowVersion(GetTensorFlowVersionRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* getTensorFlowVersion(TensorFlowVersionName name)
*
getTensorFlowVersion(String name)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* getTensorFlowVersionCallable()
*
*
*
*
* ListAcceleratorTypes
* Lists accelerator types supported by this API.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* listAcceleratorTypes(ListAcceleratorTypesRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* listAcceleratorTypes(AcceleratorTypeName parent)
*
listAcceleratorTypes(String parent)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* listAcceleratorTypesPagedCallable()
*
listAcceleratorTypesCallable()
*
*
*
*
* GetAcceleratorType
* Gets AcceleratorType.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* getAcceleratorType(GetAcceleratorTypeRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* getAcceleratorType(AcceleratorTypeName name)
*
getAcceleratorType(String name)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* getAcceleratorTypeCallable()
*
*
*
*
* ListLocations
* Lists information about the supported locations for this service.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* listLocations(ListLocationsRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* listLocationsPagedCallable()
*
listLocationsCallable()
*
*
*
*
* GetLocation
* Gets information about a location.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* getLocation(GetLocationRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* getLocationCallable()
*
*
*
*
*
* 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
* // 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:
*
*
{@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
* 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.
*/
@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).
*/
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());
}
protected TpuClient(TpuStub stub) {
this.settings = null;
this.stub = stub;
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
}
public final TpuSettings getSettings() {
return settings;
}
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
* // 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);
* }
* }
* }
*
* @param parent Required. The parent resource name.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListNodesPagedResponse listNodes(LocationName 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
* // 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);
* }
* }
* }
*
* @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
* // 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);
* }
* }
* }
*
* @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
* // 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 future = tpuClient.listNodesPagedCallable().futureCall(request);
* // Do something.
* for (Node element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable listNodesPagedCallable() {
return stub.listNodesPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists nodes.
*
* Sample code:
*
*
{@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;
* }
* }
* }
* }
*/
public final UnaryCallable listNodesCallable() {
return stub.listNodesCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the details of a node.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @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
* // 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);
* }
* }
*
* @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
* // 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);
* }
* }
*
* @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
* // 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 future = tpuClient.getNodeCallable().futureCall(request);
* // Do something.
* Node response = future.get();
* }
* }
*/
public final UnaryCallable getNodeCallable() {
return stub.getNodeCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a node.
*
* Sample code:
*
*
{@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();
* }
* }
*
* @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 createNodeAsync(
LocationName parent, Node node, String nodeId) {
CreateNodeRequest request =
CreateNodeRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setNode(node)
.setNodeId(nodeId)
.build();
return createNodeAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a node.
*
* Sample code:
*
*
{@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();
* }
* }
*
* @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 createNodeAsync(
String parent, Node node, String nodeId) {
CreateNodeRequest request =
CreateNodeRequest.newBuilder().setParent(parent).setNode(node).setNodeId(nodeId).build();
return createNodeAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a node.
*
* Sample code:
*
*
{@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();
* }
* }
*
* @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 createNodeAsync(CreateNodeRequest request) {
return createNodeOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a node.
*
* Sample code:
*
*
{@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 future =
* tpuClient.createNodeOperationCallable().futureCall(request);
* // Do something.
* Node response = future.get();
* }
* }
*/
public final OperationCallable
createNodeOperationCallable() {
return stub.createNodeOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a node.
*
* Sample code:
*
*
{@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 future = tpuClient.createNodeCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable createNodeCallable() {
return stub.createNodeCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a node.
*
* Sample code:
*
*
{@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.deleteNodeAsync(name).get();
* }
* }
*
* @param name Required. The resource name.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture deleteNodeAsync(NodeName name) {
DeleteNodeRequest request =
DeleteNodeRequest.newBuilder().setName(name == null ? null : name.toString()).build();
return deleteNodeAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a node.
*
* Sample code:
*
*
{@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.deleteNodeAsync(name).get();
* }
* }
*
* @param name Required. The resource name.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture deleteNodeAsync(String name) {
DeleteNodeRequest request = DeleteNodeRequest.newBuilder().setName(name).build();
return deleteNodeAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a node.
*
* Sample code:
*
*
{@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();
* 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 deleteNodeAsync(DeleteNodeRequest request) {
return deleteNodeOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a node.
*
* Sample code:
*
*
{@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 future =
* tpuClient.deleteNodeOperationCallable().futureCall(request);
* // Do something.
* Node response = future.get();
* }
* }
*/
public final OperationCallable
deleteNodeOperationCallable() {
return stub.deleteNodeOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a node.
*
* Sample code:
*
*
{@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 future = tpuClient.deleteNodeCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable deleteNodeCallable() {
return stub.deleteNodeCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Reimages a node's OS.
*
* Sample code:
*
*
{@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()) {
* ReimageNodeRequest request =
* ReimageNodeRequest.newBuilder()
* .setName("name3373707")
* .setTensorflowVersion("tensorflowVersion-470125103")
* .build();
* Node response = tpuClient.reimageNodeAsync(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 reimageNodeAsync(
ReimageNodeRequest request) {
return reimageNodeOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Reimages a node's OS.
*
* Sample code:
*
*
{@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()) {
* ReimageNodeRequest request =
* ReimageNodeRequest.newBuilder()
* .setName("name3373707")
* .setTensorflowVersion("tensorflowVersion-470125103")
* .build();
* OperationFuture future =
* tpuClient.reimageNodeOperationCallable().futureCall(request);
* // Do something.
* Node response = future.get();
* }
* }
*/
public final OperationCallable
reimageNodeOperationCallable() {
return stub.reimageNodeOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Reimages a node's OS.
*
* Sample code:
*
*
{@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()) {
* ReimageNodeRequest request =
* ReimageNodeRequest.newBuilder()
* .setName("name3373707")
* .setTensorflowVersion("tensorflowVersion-470125103")
* .build();
* ApiFuture future = tpuClient.reimageNodeCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable reimageNodeCallable() {
return stub.reimageNodeCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Stops a node, this operation is only available with single TPU nodes.
*
* Sample code:
*
*
{@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("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 stopNodeAsync(StopNodeRequest request) {
return stopNodeOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Stops a node, this operation is only available with single TPU nodes.
*
* Sample code:
*
*
{@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("name3373707").build();
* OperationFuture future =
* tpuClient.stopNodeOperationCallable().futureCall(request);
* // Do something.
* Node response = future.get();
* }
* }
*/
public final OperationCallable
stopNodeOperationCallable() {
return stub.stopNodeOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Stops a node, this operation is only available with single TPU nodes.
*
* Sample code:
*
*
{@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("name3373707").build();
* ApiFuture future = tpuClient.stopNodeCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable stopNodeCallable() {
return stub.stopNodeCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Starts a node.
*
* Sample code:
*
*
{@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("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 startNodeAsync(StartNodeRequest request) {
return startNodeOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Starts a node.
*
* Sample code:
*
*
{@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("name3373707").build();
* OperationFuture future =
* tpuClient.startNodeOperationCallable().futureCall(request);
* // Do something.
* Node response = future.get();
* }
* }
*/
public final OperationCallable
startNodeOperationCallable() {
return stub.startNodeOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Starts a node.
*
* Sample code:
*
*
{@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("name3373707").build();
* ApiFuture future = tpuClient.startNodeCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable startNodeCallable() {
return stub.startNodeCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List TensorFlow versions supported by this API.
*
* Sample code:
*
*
{@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()) {
* TensorFlowVersionName parent =
* TensorFlowVersionName.of("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]");
* for (TensorFlowVersion element : tpuClient.listTensorFlowVersions(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 ListTensorFlowVersionsPagedResponse listTensorFlowVersions(
TensorFlowVersionName parent) {
ListTensorFlowVersionsRequest request =
ListTensorFlowVersionsRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.build();
return listTensorFlowVersions(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List TensorFlow versions supported by this API.
*
* Sample code:
*
*
{@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 =
* TensorFlowVersionName.of("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]").toString();
* for (TensorFlowVersion element : tpuClient.listTensorFlowVersions(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 ListTensorFlowVersionsPagedResponse listTensorFlowVersions(String parent) {
ListTensorFlowVersionsRequest request =
ListTensorFlowVersionsRequest.newBuilder().setParent(parent).build();
return listTensorFlowVersions(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List TensorFlow versions supported by this API.
*
* Sample code:
*
*
{@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()) {
* ListTensorFlowVersionsRequest request =
* ListTensorFlowVersionsRequest.newBuilder()
* .setParent(
* TensorFlowVersionName.of("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]")
* .toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .setOrderBy("orderBy-1207110587")
* .build();
* for (TensorFlowVersion element : tpuClient.listTensorFlowVersions(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 ListTensorFlowVersionsPagedResponse listTensorFlowVersions(
ListTensorFlowVersionsRequest request) {
return listTensorFlowVersionsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List TensorFlow versions supported by this API.
*
* Sample code:
*
*
{@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()) {
* ListTensorFlowVersionsRequest request =
* ListTensorFlowVersionsRequest.newBuilder()
* .setParent(
* TensorFlowVersionName.of("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]")
* .toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .setOrderBy("orderBy-1207110587")
* .build();
* ApiFuture future =
* tpuClient.listTensorFlowVersionsPagedCallable().futureCall(request);
* // Do something.
* for (TensorFlowVersion element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable
listTensorFlowVersionsPagedCallable() {
return stub.listTensorFlowVersionsPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List TensorFlow versions supported by this API.
*
* Sample code:
*
*
{@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()) {
* ListTensorFlowVersionsRequest request =
* ListTensorFlowVersionsRequest.newBuilder()
* .setParent(
* TensorFlowVersionName.of("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]")
* .toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .setOrderBy("orderBy-1207110587")
* .build();
* while (true) {
* ListTensorFlowVersionsResponse response =
* tpuClient.listTensorFlowVersionsCallable().call(request);
* for (TensorFlowVersion element : response.getTensorflowVersionsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* }
*/
public final UnaryCallable
listTensorFlowVersionsCallable() {
return stub.listTensorFlowVersionsCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets TensorFlow Version.
*
* Sample code:
*
*
{@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()) {
* TensorFlowVersionName name =
* TensorFlowVersionName.of("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]");
* TensorFlowVersion response = tpuClient.getTensorFlowVersion(name);
* }
* }
*
* @param name Required. The resource name.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final TensorFlowVersion getTensorFlowVersion(TensorFlowVersionName name) {
GetTensorFlowVersionRequest request =
GetTensorFlowVersionRequest.newBuilder()
.setName(name == null ? null : name.toString())
.build();
return getTensorFlowVersion(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets TensorFlow Version.
*
* Sample code:
*
*
{@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 =
* TensorFlowVersionName.of("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]").toString();
* TensorFlowVersion response = tpuClient.getTensorFlowVersion(name);
* }
* }
*
* @param name Required. The resource name.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final TensorFlowVersion getTensorFlowVersion(String name) {
GetTensorFlowVersionRequest request =
GetTensorFlowVersionRequest.newBuilder().setName(name).build();
return getTensorFlowVersion(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets TensorFlow Version.
*
* Sample code:
*
*
{@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()) {
* GetTensorFlowVersionRequest request =
* GetTensorFlowVersionRequest.newBuilder()
* .setName(
* TensorFlowVersionName.of("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]")
* .toString())
* .build();
* TensorFlowVersion response = tpuClient.getTensorFlowVersion(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 TensorFlowVersion getTensorFlowVersion(GetTensorFlowVersionRequest request) {
return getTensorFlowVersionCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets TensorFlow Version.
*
* Sample code:
*
*
{@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()) {
* GetTensorFlowVersionRequest request =
* GetTensorFlowVersionRequest.newBuilder()
* .setName(
* TensorFlowVersionName.of("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]")
* .toString())
* .build();
* ApiFuture future =
* tpuClient.getTensorFlowVersionCallable().futureCall(request);
* // Do something.
* TensorFlowVersion response = future.get();
* }
* }
*/
public final UnaryCallable
getTensorFlowVersionCallable() {
return stub.getTensorFlowVersionCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists accelerator types supported by this API.
*
* Sample code:
*
*
{@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 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
* // 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 =
* 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
* // 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(
* 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
* // 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(
* AcceleratorTypeName.of("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]")
* .toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .setOrderBy("orderBy-1207110587")
* .build();
* ApiFuture future =
* tpuClient.listAcceleratorTypesPagedCallable().futureCall(request);
* // Do something.
* for (AcceleratorType element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable
listAcceleratorTypesPagedCallable() {
return stub.listAcceleratorTypesPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists accelerator types supported by this API.
*
* Sample code:
*
*
{@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(
* 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.getAcceleratorTypesList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* }
*/
public final UnaryCallable
listAcceleratorTypesCallable() {
return stub.listAcceleratorTypesCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets AcceleratorType.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @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
* // 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);
* }
* }
*
* @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
* // 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);
* }
* }
*
* @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
* // 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 future =
* tpuClient.getAcceleratorTypeCallable().futureCall(request);
* // Do something.
* AcceleratorType response = future.get();
* }
* }
*/
public final UnaryCallable
getAcceleratorTypeCallable() {
return stub.getAcceleratorTypeCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* Sample code:
*
*
{@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);
* }
* }
* }
*
* @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 ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
return listLocationsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* Sample code:
*
*
{@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 future = tpuClient.listLocationsPagedCallable().futureCall(request);
* // Do something.
* for (Location element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable
listLocationsPagedCallable() {
return stub.listLocationsPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* Sample code:
*
*
{@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;
* }
* }
* }
* }
*/
public final UnaryCallable listLocationsCallable() {
return stub.listLocationsCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets information about a location.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @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 Location getLocation(GetLocationRequest request) {
return getLocationCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets information about a location.
*
* Sample code:
*
*
{@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 future = tpuClient.getLocationCallable().futureCall(request);
* // Do something.
* Location response = future.get();
* }
* }
*/
public final UnaryCallable getLocationCallable() {
return stub.getLocationCallable();
}
@Override
public final void close() {
stub.close();
}
@Override
public void shutdown() {
stub.shutdown();
}
@Override
public boolean isShutdown() {
return stub.isShutdown();
}
@Override
public boolean isTerminated() {
return stub.isTerminated();
}
@Override
public void shutdownNow() {
stub.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return stub.awaitTermination(duration, unit);
}
public static class ListNodesPagedResponse
extends AbstractPagedListResponse<
ListNodesRequest, ListNodesResponse, Node, ListNodesPage, ListNodesFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListNodesPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage, input -> new ListNodesPagedResponse(input), MoreExecutors.directExecutor());
}
private ListNodesPagedResponse(ListNodesPage page) {
super(page, ListNodesFixedSizeCollection.createEmptyCollection());
}
}
public static class ListNodesPage
extends AbstractPage {
private ListNodesPage(
PageContext context,
ListNodesResponse response) {
super(context, response);
}
private static ListNodesPage createEmptyPage() {
return new ListNodesPage(null, null);
}
@Override
protected ListNodesPage createPage(
PageContext context,
ListNodesResponse response) {
return new ListNodesPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListNodesFixedSizeCollection
extends AbstractFixedSizeCollection<
ListNodesRequest, ListNodesResponse, Node, ListNodesPage, ListNodesFixedSizeCollection> {
private ListNodesFixedSizeCollection(List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListNodesFixedSizeCollection createEmptyCollection() {
return new ListNodesFixedSizeCollection(null, 0);
}
@Override
protected ListNodesFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListNodesFixedSizeCollection(pages, collectionSize);
}
}
public static class ListTensorFlowVersionsPagedResponse
extends AbstractPagedListResponse<
ListTensorFlowVersionsRequest,
ListTensorFlowVersionsResponse,
TensorFlowVersion,
ListTensorFlowVersionsPage,
ListTensorFlowVersionsFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext<
ListTensorFlowVersionsRequest, ListTensorFlowVersionsResponse, TensorFlowVersion>
context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListTensorFlowVersionsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListTensorFlowVersionsPagedResponse(input),
MoreExecutors.directExecutor());
}
private ListTensorFlowVersionsPagedResponse(ListTensorFlowVersionsPage page) {
super(page, ListTensorFlowVersionsFixedSizeCollection.createEmptyCollection());
}
}
public static class ListTensorFlowVersionsPage
extends AbstractPage<
ListTensorFlowVersionsRequest,
ListTensorFlowVersionsResponse,
TensorFlowVersion,
ListTensorFlowVersionsPage> {
private ListTensorFlowVersionsPage(
PageContext<
ListTensorFlowVersionsRequest, ListTensorFlowVersionsResponse, TensorFlowVersion>
context,
ListTensorFlowVersionsResponse response) {
super(context, response);
}
private static ListTensorFlowVersionsPage createEmptyPage() {
return new ListTensorFlowVersionsPage(null, null);
}
@Override
protected ListTensorFlowVersionsPage createPage(
PageContext<
ListTensorFlowVersionsRequest, ListTensorFlowVersionsResponse, TensorFlowVersion>
context,
ListTensorFlowVersionsResponse response) {
return new ListTensorFlowVersionsPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext<
ListTensorFlowVersionsRequest, ListTensorFlowVersionsResponse, TensorFlowVersion>
context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListTensorFlowVersionsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListTensorFlowVersionsRequest,
ListTensorFlowVersionsResponse,
TensorFlowVersion,
ListTensorFlowVersionsPage,
ListTensorFlowVersionsFixedSizeCollection> {
private ListTensorFlowVersionsFixedSizeCollection(
List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListTensorFlowVersionsFixedSizeCollection createEmptyCollection() {
return new ListTensorFlowVersionsFixedSizeCollection(null, 0);
}
@Override
protected ListTensorFlowVersionsFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListTensorFlowVersionsFixedSizeCollection(pages, collectionSize);
}
}
public static class ListAcceleratorTypesPagedResponse
extends AbstractPagedListResponse<
ListAcceleratorTypesRequest,
ListAcceleratorTypesResponse,
AcceleratorType,
ListAcceleratorTypesPage,
ListAcceleratorTypesFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext
context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListAcceleratorTypesPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListAcceleratorTypesPagedResponse(input),
MoreExecutors.directExecutor());
}
private ListAcceleratorTypesPagedResponse(ListAcceleratorTypesPage page) {
super(page, ListAcceleratorTypesFixedSizeCollection.createEmptyCollection());
}
}
public static class ListAcceleratorTypesPage
extends AbstractPage<
ListAcceleratorTypesRequest,
ListAcceleratorTypesResponse,
AcceleratorType,
ListAcceleratorTypesPage> {
private ListAcceleratorTypesPage(
PageContext
context,
ListAcceleratorTypesResponse response) {
super(context, response);
}
private static ListAcceleratorTypesPage createEmptyPage() {
return new ListAcceleratorTypesPage(null, null);
}
@Override
protected ListAcceleratorTypesPage createPage(
PageContext
context,
ListAcceleratorTypesResponse response) {
return new ListAcceleratorTypesPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext
context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListAcceleratorTypesFixedSizeCollection
extends AbstractFixedSizeCollection<
ListAcceleratorTypesRequest,
ListAcceleratorTypesResponse,
AcceleratorType,
ListAcceleratorTypesPage,
ListAcceleratorTypesFixedSizeCollection> {
private ListAcceleratorTypesFixedSizeCollection(
List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListAcceleratorTypesFixedSizeCollection createEmptyCollection() {
return new ListAcceleratorTypesFixedSizeCollection(null, 0);
}
@Override
protected ListAcceleratorTypesFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListAcceleratorTypesFixedSizeCollection(pages, collectionSize);
}
}
public static class ListLocationsPagedResponse
extends AbstractPagedListResponse<
ListLocationsRequest,
ListLocationsResponse,
Location,
ListLocationsPage,
ListLocationsFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListLocationsPagedResponse(input),
MoreExecutors.directExecutor());
}
private ListLocationsPagedResponse(ListLocationsPage page) {
super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
}
}
public static class ListLocationsPage
extends AbstractPage<
ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
private ListLocationsPage(
PageContext context,
ListLocationsResponse response) {
super(context, response);
}
private static ListLocationsPage createEmptyPage() {
return new ListLocationsPage(null, null);
}
@Override
protected ListLocationsPage createPage(
PageContext context,
ListLocationsResponse response) {
return new ListLocationsPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListLocationsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListLocationsRequest,
ListLocationsResponse,
Location,
ListLocationsPage,
ListLocationsFixedSizeCollection> {
private ListLocationsFixedSizeCollection(List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListLocationsFixedSizeCollection createEmptyCollection() {
return new ListLocationsFixedSizeCollection(null, 0);
}
@Override
protected ListLocationsFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListLocationsFixedSizeCollection(pages, collectionSize);
}
}
}