Class ForecastServiceClient (0.62.0)

GitHub RepositoryProduct Reference

Service Description: Provides methods for handling forecasting actions.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   NetworkName parent = NetworkName.of("[NETWORK_CODE]");
   RunAvailabilityForecastResponse response =
       forecastServiceClient.runAvailabilityForecast(parent);
 }
 

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

RunAvailabilityForecast

Gets the availability forecast for a [ProposalLineItem][] or LineItem. An availability forecast reports the maximum number of available units that the line item can book, and the total number of units matching the line item's targeting.

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

  • runAvailabilityForecast(RunAvailabilityForecastRequest request)

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

  • runAvailabilityForecast(NetworkName parent)

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

  • runAvailabilityForecastCallable()

RunDeliveryForecast

Runs a delivery simulation forecast for existing or prospective line items. A delivery forecast reports the number of units that will be delivered to each line item given the line item goals. The simulation considers contentions from other line items, including the other prospective line items in the request.

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

  • runDeliveryForecast(RunDeliveryForecastRequest request)

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

  • runDeliveryForecast(NetworkName parent)

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

  • runDeliveryForecastCallable()

RunTrafficData

Gets forecasted and historical traffic data for the segment of traffic specified by the provided request.

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

  • runTrafficData(RunTrafficDataRequest request)

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

  • runTrafficData(NetworkName parent)

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

  • runTrafficDataCallable()

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 ForecastServiceSettings 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
 ForecastServiceSettings forecastServiceSettings =
     ForecastServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ForecastServiceClient forecastServiceClient =
     ForecastServiceClient.create(forecastServiceSettings);
 

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
 ForecastServiceSettings forecastServiceSettings =
     ForecastServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 ForecastServiceClient forecastServiceClient =
     ForecastServiceClient.create(forecastServiceSettings);
 

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

Inheritance

java.lang.Object > ForecastServiceClient

Static Methods

create()

public static final ForecastServiceClient create()

Constructs an instance of ForecastServiceClient with default settings.

Returns
Type Description
ForecastServiceClient
Exceptions
Type Description
IOException

create(ForecastServiceSettings settings)

public static final ForecastServiceClient create(ForecastServiceSettings settings)

Constructs an instance of ForecastServiceClient, 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 ForecastServiceSettings
Returns
Type Description
ForecastServiceClient
Exceptions
Type Description
IOException

create(ForecastServiceStub stub)

public static final ForecastServiceClient create(ForecastServiceStub stub)

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

Parameter
Name Description
stub ForecastServiceStub
Returns
Type Description
ForecastServiceClient

Constructors

ForecastServiceClient(ForecastServiceSettings settings)

protected ForecastServiceClient(ForecastServiceSettings settings)

Constructs an instance of ForecastServiceClient, 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 ForecastServiceSettings

ForecastServiceClient(ForecastServiceStub stub)

protected ForecastServiceClient(ForecastServiceStub stub)
Parameter
Name Description
stub ForecastServiceStub

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()

getSettings()

public final @Nullable ForecastServiceSettings getSettings()
Returns
Type Description
@org.jspecify.annotations.Nullable com.google.ads.admanager.v1.ForecastServiceSettings

getStub()

public ForecastServiceStub getStub()
Returns
Type Description
ForecastServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

runAvailabilityForecast(@Nullable NetworkName parent)

public final RunAvailabilityForecastResponse runAvailabilityForecast(@Nullable NetworkName parent)

Gets the availability forecast for a [ProposalLineItem][] or LineItem. An availability forecast reports the maximum number of available units that the line item can book, and the total number of units matching the line item's targeting.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   NetworkName parent = NetworkName.of("[NETWORK_CODE]");
   RunAvailabilityForecastResponse response =
       forecastServiceClient.runAvailabilityForecast(parent);
 }
 
Parameter
Name Description
parent @org.jspecify.annotations.Nullable com.google.ads.admanager.v1.NetworkName

Required. Format: networks/{network_code}

Returns
Type Description
RunAvailabilityForecastResponse

runAvailabilityForecast(RunAvailabilityForecastRequest request)

public final RunAvailabilityForecastResponse runAvailabilityForecast(RunAvailabilityForecastRequest request)

Gets the availability forecast for a [ProposalLineItem][] or LineItem. An availability forecast reports the maximum number of available units that the line item can book, and the total number of units matching the line item's targeting.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   RunAvailabilityForecastRequest request =
       RunAvailabilityForecastRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setAvailabilityForecastOptions(AvailabilityForecastOptions.newBuilder().build())
           .build();
   RunAvailabilityForecastResponse response =
       forecastServiceClient.runAvailabilityForecast(request);
 }
 
Parameter
Name Description
request RunAvailabilityForecastRequest

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

Returns
Type Description
RunAvailabilityForecastResponse

runAvailabilityForecast(String parent)

public final RunAvailabilityForecastResponse runAvailabilityForecast(String parent)

Gets the availability forecast for a [ProposalLineItem][] or LineItem. An availability forecast reports the maximum number of available units that the line item can book, and the total number of units matching the line item's targeting.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   String parent = NetworkName.of("[NETWORK_CODE]").toString();
   RunAvailabilityForecastResponse response =
       forecastServiceClient.runAvailabilityForecast(parent);
 }
 
Parameter
Name Description
parent String

Required. Format: networks/{network_code}

Returns
Type Description
RunAvailabilityForecastResponse

runAvailabilityForecastCallable()

public final UnaryCallable<RunAvailabilityForecastRequest,RunAvailabilityForecastResponse> runAvailabilityForecastCallable()

Gets the availability forecast for a [ProposalLineItem][] or LineItem. An availability forecast reports the maximum number of available units that the line item can book, and the total number of units matching the line item's targeting.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   RunAvailabilityForecastRequest request =
       RunAvailabilityForecastRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setAvailabilityForecastOptions(AvailabilityForecastOptions.newBuilder().build())
           .build();
   ApiFuture<RunAvailabilityForecastResponse> future =
       forecastServiceClient.runAvailabilityForecastCallable().futureCall(request);
   // Do something.
   RunAvailabilityForecastResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<RunAvailabilityForecastRequest,RunAvailabilityForecastResponse>

runDeliveryForecast(@Nullable NetworkName parent)

public final RunDeliveryForecastResponse runDeliveryForecast(@Nullable NetworkName parent)

Runs a delivery simulation forecast for existing or prospective line items. A delivery forecast reports the number of units that will be delivered to each line item given the line item goals. The simulation considers contentions from other line items, including the other prospective line items in the request.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   NetworkName parent = NetworkName.of("[NETWORK_CODE]");
   RunDeliveryForecastResponse response = forecastServiceClient.runDeliveryForecast(parent);
 }
 
Parameter
Name Description
parent @org.jspecify.annotations.Nullable com.google.ads.admanager.v1.NetworkName

Required. Format: networks/{network_code}

Returns
Type Description
RunDeliveryForecastResponse

runDeliveryForecast(RunDeliveryForecastRequest request)

public final RunDeliveryForecastResponse runDeliveryForecast(RunDeliveryForecastRequest request)

Runs a delivery simulation forecast for existing or prospective line items. A delivery forecast reports the number of units that will be delivered to each line item given the line item goals. The simulation considers contentions from other line items, including the other prospective line items in the request.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   RunDeliveryForecastRequest request =
       RunDeliveryForecastRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setDeliveryForecastOptions(DeliveryForecastOptions.newBuilder().build())
           .build();
   RunDeliveryForecastResponse response = forecastServiceClient.runDeliveryForecast(request);
 }
 
Parameter
Name Description
request RunDeliveryForecastRequest

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

Returns
Type Description
RunDeliveryForecastResponse

runDeliveryForecast(String parent)

public final RunDeliveryForecastResponse runDeliveryForecast(String parent)

Runs a delivery simulation forecast for existing or prospective line items. A delivery forecast reports the number of units that will be delivered to each line item given the line item goals. The simulation considers contentions from other line items, including the other prospective line items in the request.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   String parent = NetworkName.of("[NETWORK_CODE]").toString();
   RunDeliveryForecastResponse response = forecastServiceClient.runDeliveryForecast(parent);
 }
 
Parameter
Name Description
parent String

Required. Format: networks/{network_code}

Returns
Type Description
RunDeliveryForecastResponse

runDeliveryForecastCallable()

public final UnaryCallable<RunDeliveryForecastRequest,RunDeliveryForecastResponse> runDeliveryForecastCallable()

Runs a delivery simulation forecast for existing or prospective line items. A delivery forecast reports the number of units that will be delivered to each line item given the line item goals. The simulation considers contentions from other line items, including the other prospective line items in the request.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   RunDeliveryForecastRequest request =
       RunDeliveryForecastRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setDeliveryForecastOptions(DeliveryForecastOptions.newBuilder().build())
           .build();
   ApiFuture<RunDeliveryForecastResponse> future =
       forecastServiceClient.runDeliveryForecastCallable().futureCall(request);
   // Do something.
   RunDeliveryForecastResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<RunDeliveryForecastRequest,RunDeliveryForecastResponse>

runTrafficData(@Nullable NetworkName parent)

public final RunTrafficDataResponse runTrafficData(@Nullable NetworkName parent)

Gets forecasted and historical traffic data for the segment of traffic specified by the provided request.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   NetworkName parent = NetworkName.of("[NETWORK_CODE]");
   RunTrafficDataResponse response = forecastServiceClient.runTrafficData(parent);
 }
 
Parameter
Name Description
parent @org.jspecify.annotations.Nullable com.google.ads.admanager.v1.NetworkName

Required. Format: networks/{network_code}

Returns
Type Description
RunTrafficDataResponse

runTrafficData(RunTrafficDataRequest request)

public final RunTrafficDataResponse runTrafficData(RunTrafficDataRequest request)

Gets forecasted and historical traffic data for the segment of traffic specified by the provided request.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   RunTrafficDataRequest request =
       RunTrafficDataRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setTargeting(Targeting.newBuilder().build())
           .setRequestedDateRange(DateRange.newBuilder().build())
           .build();
   RunTrafficDataResponse response = forecastServiceClient.runTrafficData(request);
 }
 
Parameter
Name Description
request RunTrafficDataRequest

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

Returns
Type Description
RunTrafficDataResponse

runTrafficData(String parent)

public final RunTrafficDataResponse runTrafficData(String parent)

Gets forecasted and historical traffic data for the segment of traffic specified by the provided request.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   String parent = NetworkName.of("[NETWORK_CODE]").toString();
   RunTrafficDataResponse response = forecastServiceClient.runTrafficData(parent);
 }
 
Parameter
Name Description
parent String

Required. Format: networks/{network_code}

Returns
Type Description
RunTrafficDataResponse

runTrafficDataCallable()

public final UnaryCallable<RunTrafficDataRequest,RunTrafficDataResponse> runTrafficDataCallable()

Gets forecasted and historical traffic data for the segment of traffic specified by the provided request.

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 (ForecastServiceClient forecastServiceClient = ForecastServiceClient.create()) {
   RunTrafficDataRequest request =
       RunTrafficDataRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setTargeting(Targeting.newBuilder().build())
           .setRequestedDateRange(DateRange.newBuilder().build())
           .build();
   ApiFuture<RunTrafficDataResponse> future =
       forecastServiceClient.runTrafficDataCallable().futureCall(request);
   // Do something.
   RunTrafficDataResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<RunTrafficDataRequest,RunTrafficDataResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()