Class UsageServiceClient (0.1.0)

GitHub RepositoryProduct Reference

Service Description: Provides access to historical and forecasted usage data.

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


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   QueryUsageHistoriesRequest request =
       QueryUsageHistoriesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setIsSpot(true)
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setDiskType("diskType279771767")
           .setConfidentialMode(true)
           .setGpuType("gpuType240737798")
           .setTpuType("tpuType-1106616237")
           .setCloudResourceType("cloudResourceType-1446274243")
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .build();
   QueryUsageHistoriesResponse response = usageServiceClient.queryUsageHistories(request);
 }
 

Note: close() needs to be called on the UsageServiceClient 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

QueryUsageHistories

Returns a list of the usage histories that are in the parent parameter and match your specified filters.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • queryUsageHistories(QueryUsageHistoriesRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • queryUsageHistoriesCallable()

QueryForecasts

Returns a list of the forecasts that are in the parent parameter and match your specified filters.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • queryForecasts(QueryForecastsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • queryForecastsCallable()

QueryReservations

Returns a list of the reservations that are in the parent parameter and match your specified filters.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • queryReservations(QueryReservationsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • queryReservations(LocationName parent)

  • queryReservations(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.

  • queryReservationsCallable()

ExportUsageHistories

Exports historical usage data requested by user into either an existing Cloud Storage bucket or a BigQuery table.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • exportUsageHistoriesAsync(ExportUsageHistoriesRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • exportUsageHistoriesOperationCallable()

  • exportUsageHistoriesCallable()

ExportForecasts

Exports forecasted usage data requested by user into either an existing Cloud Storage bucket or a BigQuery table.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • exportForecastsAsync(ExportForecastsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • exportForecastsOperationCallable()

  • exportForecastsCallable()

ExportReservationsUsage

Exports reservations usage data requested by user into either an existing Cloud Storage bucket or a new/existing BigQuery table.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • exportReservationsUsageAsync(ExportReservationsUsageRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • exportReservationsUsageOperationCallable()

  • exportReservationsUsageCallable()

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 UsageServiceSettings to create(). For example:

To customize credentials:


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

To customize the endpoint:


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

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


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

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

Inheritance

java.lang.Object > UsageServiceClient

Static Methods

create()

public static final UsageServiceClient create()

Constructs an instance of UsageServiceClient with default settings.

Returns
Type Description
UsageServiceClient
Exceptions
Type Description
IOException

create(UsageServiceSettings settings)

public static final UsageServiceClient create(UsageServiceSettings settings)

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

Parameter
Name Description
settings UsageServiceSettings
Returns
Type Description
UsageServiceClient
Exceptions
Type Description
IOException

create(UsageServiceStub stub)

public static final UsageServiceClient create(UsageServiceStub stub)

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

Parameter
Name Description
stub UsageServiceStub
Returns
Type Description
UsageServiceClient

Constructors

UsageServiceClient(UsageServiceSettings settings)

protected UsageServiceClient(UsageServiceSettings settings)

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

Parameter
Name Description
settings UsageServiceSettings

UsageServiceClient(UsageServiceStub stub)

protected UsageServiceClient(UsageServiceStub stub)
Parameter
Name Description
stub UsageServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

close()

public final void close()

exportForecastsAsync(ExportForecastsRequest request)

public final OperationFuture<ExportForecastsResponse,OperationMetadata> exportForecastsAsync(ExportForecastsRequest request)

Exports forecasted usage data requested by user into either an existing Cloud Storage bucket or a BigQuery table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   ExportForecastsRequest request =
       ExportForecastsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setDiskType("diskType279771767")
           .setGpuType("gpuType240737798")
           .setTpuType("tpuType-1106616237")
           .setResourceType("resourceType-384364440")
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .setOutputConfig(OutputConfig.newBuilder().build())
           .build();
   ExportForecastsResponse response = usageServiceClient.exportForecastsAsync(request).get();
 }
 
Parameter
Name Description
request ExportForecastsRequest

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

Returns
Type Description
OperationFuture<ExportForecastsResponse,OperationMetadata>

exportForecastsCallable()

public final UnaryCallable<ExportForecastsRequest,Operation> exportForecastsCallable()

Exports forecasted usage data requested by user into either an existing Cloud Storage bucket or a BigQuery table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   ExportForecastsRequest request =
       ExportForecastsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setDiskType("diskType279771767")
           .setGpuType("gpuType240737798")
           .setTpuType("tpuType-1106616237")
           .setResourceType("resourceType-384364440")
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .setOutputConfig(OutputConfig.newBuilder().build())
           .build();
   ApiFuture<Operation> future =
       usageServiceClient.exportForecastsCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<ExportForecastsRequest,Operation>

exportForecastsOperationCallable()

public final OperationCallable<ExportForecastsRequest,ExportForecastsResponse,OperationMetadata> exportForecastsOperationCallable()

Exports forecasted usage data requested by user into either an existing Cloud Storage bucket or a BigQuery table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   ExportForecastsRequest request =
       ExportForecastsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setDiskType("diskType279771767")
           .setGpuType("gpuType240737798")
           .setTpuType("tpuType-1106616237")
           .setResourceType("resourceType-384364440")
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .setOutputConfig(OutputConfig.newBuilder().build())
           .build();
   OperationFuture<ExportForecastsResponse, OperationMetadata> future =
       usageServiceClient.exportForecastsOperationCallable().futureCall(request);
   // Do something.
   ExportForecastsResponse response = future.get();
 }
 
Returns
Type Description
OperationCallable<ExportForecastsRequest,ExportForecastsResponse,OperationMetadata>

exportReservationsUsageAsync(ExportReservationsUsageRequest request)

public final OperationFuture<ExportReservationsUsageResponse,OperationMetadata> exportReservationsUsageAsync(ExportReservationsUsageRequest request)

Exports reservations usage data requested by user into either an existing Cloud Storage bucket or a new/existing BigQuery table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   ExportReservationsUsageRequest request =
       ExportReservationsUsageRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setCloudResourceType("cloudResourceType-1446274243")
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .setOutputConfig(OutputConfig.newBuilder().build())
           .build();
   ExportReservationsUsageResponse response =
       usageServiceClient.exportReservationsUsageAsync(request).get();
 }
 
Parameter
Name Description
request ExportReservationsUsageRequest

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

Returns
Type Description
OperationFuture<ExportReservationsUsageResponse,OperationMetadata>

exportReservationsUsageCallable()

public final UnaryCallable<ExportReservationsUsageRequest,Operation> exportReservationsUsageCallable()

Exports reservations usage data requested by user into either an existing Cloud Storage bucket or a new/existing BigQuery table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   ExportReservationsUsageRequest request =
       ExportReservationsUsageRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setCloudResourceType("cloudResourceType-1446274243")
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .setOutputConfig(OutputConfig.newBuilder().build())
           .build();
   ApiFuture<Operation> future =
       usageServiceClient.exportReservationsUsageCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<ExportReservationsUsageRequest,Operation>

exportReservationsUsageOperationCallable()

public final OperationCallable<ExportReservationsUsageRequest,ExportReservationsUsageResponse,OperationMetadata> exportReservationsUsageOperationCallable()

Exports reservations usage data requested by user into either an existing Cloud Storage bucket or a new/existing BigQuery table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   ExportReservationsUsageRequest request =
       ExportReservationsUsageRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setCloudResourceType("cloudResourceType-1446274243")
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .setOutputConfig(OutputConfig.newBuilder().build())
           .build();
   OperationFuture<ExportReservationsUsageResponse, OperationMetadata> future =
       usageServiceClient.exportReservationsUsageOperationCallable().futureCall(request);
   // Do something.
   ExportReservationsUsageResponse response = future.get();
 }
 
Returns
Type Description
OperationCallable<ExportReservationsUsageRequest,ExportReservationsUsageResponse,OperationMetadata>

exportUsageHistoriesAsync(ExportUsageHistoriesRequest request)

public final OperationFuture<ExportUsageHistoriesResponse,OperationMetadata> exportUsageHistoriesAsync(ExportUsageHistoriesRequest request)

Exports historical usage data requested by user into either an existing Cloud Storage bucket or a BigQuery table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   ExportUsageHistoriesRequest request =
       ExportUsageHistoriesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setIsSpot(true)
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setDiskType("diskType279771767")
           .setGpuType("gpuType240737798")
           .setTpuType("tpuType-1106616237")
           .setResourceType("resourceType-384364440")
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .setOutputConfig(OutputConfig.newBuilder().build())
           .build();
   ExportUsageHistoriesResponse response =
       usageServiceClient.exportUsageHistoriesAsync(request).get();
 }
 
Parameter
Name Description
request ExportUsageHistoriesRequest

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

Returns
Type Description
OperationFuture<ExportUsageHistoriesResponse,OperationMetadata>

exportUsageHistoriesCallable()

public final UnaryCallable<ExportUsageHistoriesRequest,Operation> exportUsageHistoriesCallable()

Exports historical usage data requested by user into either an existing Cloud Storage bucket or a BigQuery table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   ExportUsageHistoriesRequest request =
       ExportUsageHistoriesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setIsSpot(true)
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setDiskType("diskType279771767")
           .setGpuType("gpuType240737798")
           .setTpuType("tpuType-1106616237")
           .setResourceType("resourceType-384364440")
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .setOutputConfig(OutputConfig.newBuilder().build())
           .build();
   ApiFuture<Operation> future =
       usageServiceClient.exportUsageHistoriesCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<ExportUsageHistoriesRequest,Operation>

exportUsageHistoriesOperationCallable()

public final OperationCallable<ExportUsageHistoriesRequest,ExportUsageHistoriesResponse,OperationMetadata> exportUsageHistoriesOperationCallable()

Exports historical usage data requested by user into either an existing Cloud Storage bucket or a BigQuery table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   ExportUsageHistoriesRequest request =
       ExportUsageHistoriesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setIsSpot(true)
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setDiskType("diskType279771767")
           .setGpuType("gpuType240737798")
           .setTpuType("tpuType-1106616237")
           .setResourceType("resourceType-384364440")
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .setOutputConfig(OutputConfig.newBuilder().build())
           .build();
   OperationFuture<ExportUsageHistoriesResponse, OperationMetadata> future =
       usageServiceClient.exportUsageHistoriesOperationCallable().futureCall(request);
   // Do something.
   ExportUsageHistoriesResponse response = future.get();
 }
 
Returns
Type Description
OperationCallable<ExportUsageHistoriesRequest,ExportUsageHistoriesResponse,OperationMetadata>

getHttpJsonOperationsClient()

public final OperationsClient getHttpJsonOperationsClient()

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

Returns
Type Description
OperationsClient

getOperationsClient()

public final OperationsClient getOperationsClient()

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

Returns
Type Description
OperationsClient

getSettings()

public final UsageServiceSettings getSettings()
Returns
Type Description
UsageServiceSettings

getStub()

public UsageServiceStub getStub()
Returns
Type Description
UsageServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

queryForecasts(QueryForecastsRequest request)

public final QueryForecastsResponse queryForecasts(QueryForecastsRequest request)

Returns a list of the forecasts that are in the parent parameter and match your specified filters.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   QueryForecastsRequest request =
       QueryForecastsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setDiskType("diskType279771767")
           .setConfidentialMode(true)
           .setGpuType("gpuType240737798")
           .setTpuType("tpuType-1106616237")
           .setCloudResourceType("cloudResourceType-1446274243")
           .build();
   QueryForecastsResponse response = usageServiceClient.queryForecasts(request);
 }
 
Parameter
Name Description
request QueryForecastsRequest

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

Returns
Type Description
QueryForecastsResponse

queryForecastsCallable()

public final UnaryCallable<QueryForecastsRequest,QueryForecastsResponse> queryForecastsCallable()

Returns a list of the forecasts that are in the parent parameter and match your specified filters.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   QueryForecastsRequest request =
       QueryForecastsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setDiskType("diskType279771767")
           .setConfidentialMode(true)
           .setGpuType("gpuType240737798")
           .setTpuType("tpuType-1106616237")
           .setCloudResourceType("cloudResourceType-1446274243")
           .build();
   ApiFuture<QueryForecastsResponse> future =
       usageServiceClient.queryForecastsCallable().futureCall(request);
   // Do something.
   QueryForecastsResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<QueryForecastsRequest,QueryForecastsResponse>

queryReservations(LocationName parent)

public final QueryReservationsResponse queryReservations(LocationName parent)

Returns a list of the reservations that are in the parent parameter and match your specified filters.

Sample code:


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

Required. The compute engine resource and location for the time series values to return. The format is:

projects/{project}/locations/{location} or organizations/{organization}/locations/{location} or folders/{folder}/locations/{location}

Returns
Type Description
QueryReservationsResponse

queryReservations(QueryReservationsRequest request)

public final QueryReservationsResponse queryReservations(QueryReservationsRequest request)

Returns a list of the reservations that are in the parent parameter and match your specified filters.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   QueryReservationsRequest request =
       QueryReservationsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setGpuType("gpuType240737798")
           .setCloudResourceType("cloudResourceType-1446274243")
           .setIncludeUnapprovedReservations(true)
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .build();
   QueryReservationsResponse response = usageServiceClient.queryReservations(request);
 }
 
Parameter
Name Description
request QueryReservationsRequest

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

Returns
Type Description
QueryReservationsResponse

queryReservations(String parent)

public final QueryReservationsResponse queryReservations(String parent)

Returns a list of the reservations that are in the parent parameter and match your specified filters.

Sample code:


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

Required. The compute engine resource and location for the time series values to return. The format is:

projects/{project}/locations/{location} or organizations/{organization}/locations/{location} or folders/{folder}/locations/{location}

Returns
Type Description
QueryReservationsResponse

queryReservationsCallable()

public final UnaryCallable<QueryReservationsRequest,QueryReservationsResponse> queryReservationsCallable()

Returns a list of the reservations that are in the parent parameter and match your specified filters.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   QueryReservationsRequest request =
       QueryReservationsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setGpuType("gpuType240737798")
           .setCloudResourceType("cloudResourceType-1446274243")
           .setIncludeUnapprovedReservations(true)
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .build();
   ApiFuture<QueryReservationsResponse> future =
       usageServiceClient.queryReservationsCallable().futureCall(request);
   // Do something.
   QueryReservationsResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<QueryReservationsRequest,QueryReservationsResponse>

queryUsageHistories(QueryUsageHistoriesRequest request)

public final QueryUsageHistoriesResponse queryUsageHistories(QueryUsageHistoriesRequest request)

Returns a list of the usage histories that are in the parent parameter and match your specified filters.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   QueryUsageHistoriesRequest request =
       QueryUsageHistoriesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setIsSpot(true)
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setDiskType("diskType279771767")
           .setConfidentialMode(true)
           .setGpuType("gpuType240737798")
           .setTpuType("tpuType-1106616237")
           .setCloudResourceType("cloudResourceType-1446274243")
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .build();
   QueryUsageHistoriesResponse response = usageServiceClient.queryUsageHistories(request);
 }
 
Parameter
Name Description
request QueryUsageHistoriesRequest

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

Returns
Type Description
QueryUsageHistoriesResponse

queryUsageHistoriesCallable()

public final UnaryCallable<QueryUsageHistoriesRequest,QueryUsageHistoriesResponse> queryUsageHistoriesCallable()

Returns a list of the usage histories that are in the parent parameter and match your specified filters.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (UsageServiceClient usageServiceClient = UsageServiceClient.create()) {
   QueryUsageHistoriesRequest request =
       QueryUsageHistoriesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setIsSpot(true)
           .setMachineFamily("machineFamily419822219")
           .setMachineShape(MachineShape.newBuilder().build())
           .setDiskType("diskType279771767")
           .setConfidentialMode(true)
           .setGpuType("gpuType240737798")
           .setTpuType("tpuType-1106616237")
           .setCloudResourceType("cloudResourceType-1446274243")
           .setStartDate(Date.newBuilder().build())
           .setEndDate(Date.newBuilder().build())
           .build();
   ApiFuture<QueryUsageHistoriesResponse> future =
       usageServiceClient.queryUsageHistoriesCallable().futureCall(request);
   // Do something.
   QueryUsageHistoriesResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<QueryUsageHistoriesRequest,QueryUsageHistoriesResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()