Class ReachPlanServiceClient

  • All Implemented Interfaces:
    com.google.api.gax.core.BackgroundResource, java.lang.AutoCloseable

    @Generated("by gapic-generator-java")
    public class ReachPlanServiceClient
    extends java.lang.Object
    implements com.google.api.gax.core.BackgroundResource
    Service Description: Reach Plan Service gives users information about audience size that can be reached through advertisement on YouTube. In particular, GenerateReachForecast provides estimated number of people of specified demographics that can be reached by an ad in a given market by a campaign of certain duration with a defined budget.

    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:

    
     try (ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.create()) {
       ListPlannableLocationsRequest request = ListPlannableLocationsRequest.newBuilder().build();
       ListPlannableLocationsResponse response =
           reachPlanServiceClient.listPlannableLocations(request);
     }
     

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

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

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

    See the individual methods for example code.

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

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

    To customize credentials:

    
     ReachPlanServiceSettings reachPlanServiceSettings =
         ReachPlanServiceSettings.newBuilder()
             .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
             .build();
     ReachPlanServiceClient reachPlanServiceClient =
         ReachPlanServiceClient.create(reachPlanServiceSettings);
     

    To customize the endpoint:

    
     ReachPlanServiceSettings reachPlanServiceSettings =
         ReachPlanServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
     ReachPlanServiceClient reachPlanServiceClient =
         ReachPlanServiceClient.create(reachPlanServiceSettings);
     

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

    • Constructor Detail

      • ReachPlanServiceClient

        protected ReachPlanServiceClient​(ReachPlanServiceSettings settings)
                                  throws java.io.IOException
        Constructs an instance of ReachPlanServiceClient, 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.
        Throws:
        java.io.IOException
      • ReachPlanServiceClient

        @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
        protected ReachPlanServiceClient​(ReachPlanServiceStub stub)
    • Method Detail

      • create

        public static final ReachPlanServiceClient create()
                                                   throws java.io.IOException
        Constructs an instance of ReachPlanServiceClient with default settings.
        Throws:
        java.io.IOException
      • create

        public static final ReachPlanServiceClient create​(ReachPlanServiceSettings settings)
                                                   throws java.io.IOException
        Constructs an instance of ReachPlanServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
        Throws:
        java.io.IOException
      • create

        @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
        public static final ReachPlanServiceClient create​(ReachPlanServiceStub stub)
        Constructs an instance of ReachPlanServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ReachPlanServiceSettings).
      • getStub

        @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
        public ReachPlanServiceStub getStub()
      • listPlannableLocations

        public final ListPlannableLocationsResponse listPlannableLocations​(ListPlannableLocationsRequest request)
        Returns the list of plannable locations (for example, countries & DMAs).

        List of thrown errors: [AuthenticationError]() [AuthorizationError]() [HeaderError]() [InternalError]() [QuotaError]() [RequestError]()

        Sample code:

        
         try (ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.create()) {
           ListPlannableLocationsRequest request = ListPlannableLocationsRequest.newBuilder().build();
           ListPlannableLocationsResponse response =
               reachPlanServiceClient.listPlannableLocations(request);
         }
         
        Parameters:
        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
      • listPlannableLocationsCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListPlannableLocationsRequest,​ListPlannableLocationsResponse> listPlannableLocationsCallable()
        Returns the list of plannable locations (for example, countries & DMAs).

        List of thrown errors: [AuthenticationError]() [AuthorizationError]() [HeaderError]() [InternalError]() [QuotaError]() [RequestError]()

        Sample code:

        
         try (ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.create()) {
           ListPlannableLocationsRequest request = ListPlannableLocationsRequest.newBuilder().build();
           ApiFuture<ListPlannableLocationsResponse> future =
               reachPlanServiceClient.listPlannableLocationsCallable().futureCall(request);
           // Do something.
           ListPlannableLocationsResponse response = future.get();
         }
         
      • listPlannableProducts

        public final ListPlannableProductsResponse listPlannableProducts​(java.lang.String plannableLocationId)
        Returns the list of per-location plannable YouTube ad formats with allowed targeting.

        List of thrown errors: [AuthenticationError]() [AuthorizationError]() [HeaderError]() [InternalError]() [QuotaError]() [RequestError]()

        Sample code:

        
         try (ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.create()) {
           String plannableLocationId = "plannableLocationId-1266753969";
           ListPlannableProductsResponse response =
               reachPlanServiceClient.listPlannableProducts(plannableLocationId);
         }
         
        Parameters:
        plannableLocationId - Required. The ID of the selected location for planning. To list the available plannable location ids use [ReachPlanService.ListPlannableLocations][google.ads.googleads.v10.services.ReachPlanService.ListPlannableLocations].
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listPlannableProducts

        public final ListPlannableProductsResponse listPlannableProducts​(ListPlannableProductsRequest request)
        Returns the list of per-location plannable YouTube ad formats with allowed targeting.

        List of thrown errors: [AuthenticationError]() [AuthorizationError]() [HeaderError]() [InternalError]() [QuotaError]() [RequestError]()

        Sample code:

        
         try (ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.create()) {
           ListPlannableProductsRequest request =
               ListPlannableProductsRequest.newBuilder()
                   .setPlannableLocationId("plannableLocationId-1266753969")
                   .build();
           ListPlannableProductsResponse response =
               reachPlanServiceClient.listPlannableProducts(request);
         }
         
        Parameters:
        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
      • listPlannableProductsCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListPlannableProductsRequest,​ListPlannableProductsResponse> listPlannableProductsCallable()
        Returns the list of per-location plannable YouTube ad formats with allowed targeting.

        List of thrown errors: [AuthenticationError]() [AuthorizationError]() [HeaderError]() [InternalError]() [QuotaError]() [RequestError]()

        Sample code:

        
         try (ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.create()) {
           ListPlannableProductsRequest request =
               ListPlannableProductsRequest.newBuilder()
                   .setPlannableLocationId("plannableLocationId-1266753969")
                   .build();
           ApiFuture<ListPlannableProductsResponse> future =
               reachPlanServiceClient.listPlannableProductsCallable().futureCall(request);
           // Do something.
           ListPlannableProductsResponse response = future.get();
         }
         
      • generateProductMixIdeas

        public final GenerateProductMixIdeasResponse generateProductMixIdeas​(java.lang.String customerId,
                                                                             java.lang.String plannableLocationId,
                                                                             java.lang.String currencyCode,
                                                                             long budgetMicros)
        Generates a product mix ideas given a set of preferences. This method helps the advertiser to obtain a good mix of ad formats and budget allocations based on its preferences.

        List of thrown errors: [AuthenticationError]() [AuthorizationError]() [HeaderError]() [InternalError]() [QuotaError]() [ReachPlanError]() [RequestError]()

        Sample code:

        
         try (ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.create()) {
           String customerId = "customerId-1581184615";
           String plannableLocationId = "plannableLocationId-1266753969";
           String currencyCode = "currencyCode1004773790";
           long budgetMicros = 933896297;
           GenerateProductMixIdeasResponse response =
               reachPlanServiceClient.generateProductMixIdeas(
                   customerId, plannableLocationId, currencyCode, budgetMicros);
         }
         
        Parameters:
        customerId - Required. The ID of the customer.
        plannableLocationId - Required. The ID of the location, this is one of the ids returned by [ReachPlanService.ListPlannableLocations][google.ads.googleads.v10.services.ReachPlanService.ListPlannableLocations].
        currencyCode - Required. Currency code. Three-character ISO 4217 currency code.
        budgetMicros - Required. Total budget. Amount in micros. One million is equivalent to one unit.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • generateProductMixIdeas

        public final GenerateProductMixIdeasResponse generateProductMixIdeas​(GenerateProductMixIdeasRequest request)
        Generates a product mix ideas given a set of preferences. This method helps the advertiser to obtain a good mix of ad formats and budget allocations based on its preferences.

        List of thrown errors: [AuthenticationError]() [AuthorizationError]() [HeaderError]() [InternalError]() [QuotaError]() [ReachPlanError]() [RequestError]()

        Sample code:

        
         try (ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.create()) {
           GenerateProductMixIdeasRequest request =
               GenerateProductMixIdeasRequest.newBuilder()
                   .setCustomerId("customerId-1581184615")
                   .setPlannableLocationId("plannableLocationId-1266753969")
                   .setCurrencyCode("currencyCode1004773790")
                   .setBudgetMicros(933896297)
                   .setPreferences(Preferences.newBuilder().build())
                   .build();
           GenerateProductMixIdeasResponse response =
               reachPlanServiceClient.generateProductMixIdeas(request);
         }
         
        Parameters:
        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
      • generateProductMixIdeasCallable

        public final com.google.api.gax.rpc.UnaryCallable<GenerateProductMixIdeasRequest,​GenerateProductMixIdeasResponse> generateProductMixIdeasCallable()
        Generates a product mix ideas given a set of preferences. This method helps the advertiser to obtain a good mix of ad formats and budget allocations based on its preferences.

        List of thrown errors: [AuthenticationError]() [AuthorizationError]() [HeaderError]() [InternalError]() [QuotaError]() [ReachPlanError]() [RequestError]()

        Sample code:

        
         try (ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.create()) {
           GenerateProductMixIdeasRequest request =
               GenerateProductMixIdeasRequest.newBuilder()
                   .setCustomerId("customerId-1581184615")
                   .setPlannableLocationId("plannableLocationId-1266753969")
                   .setCurrencyCode("currencyCode1004773790")
                   .setBudgetMicros(933896297)
                   .setPreferences(Preferences.newBuilder().build())
                   .build();
           ApiFuture<GenerateProductMixIdeasResponse> future =
               reachPlanServiceClient.generateProductMixIdeasCallable().futureCall(request);
           // Do something.
           GenerateProductMixIdeasResponse response = future.get();
         }
         
      • generateReachForecast

        public final GenerateReachForecastResponse generateReachForecast​(java.lang.String customerId,
                                                                         CampaignDuration campaignDuration,
                                                                         java.util.List<PlannedProduct> plannedProducts)
        Generates a reach forecast for a given targeting / product mix.

        List of thrown errors: [AuthenticationError]() [AuthorizationError]() [FieldError]() [HeaderError]() [InternalError]() [QuotaError]() [RangeError]() [ReachPlanError]() [RequestError]()

        Sample code:

        
         try (ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.create()) {
           String customerId = "customerId-1581184615";
           CampaignDuration campaignDuration = CampaignDuration.newBuilder().build();
           List<PlannedProduct> plannedProducts = new ArrayList<>();
           GenerateReachForecastResponse response =
               reachPlanServiceClient.generateReachForecast(
                   customerId, campaignDuration, plannedProducts);
         }
         
        Parameters:
        customerId - Required. The ID of the customer.
        campaignDuration - Required. Campaign duration.
        plannedProducts - Required. The products to be forecast. The max number of allowed planned products is 15.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • generateReachForecast

        public final GenerateReachForecastResponse generateReachForecast​(GenerateReachForecastRequest request)
        Generates a reach forecast for a given targeting / product mix.

        List of thrown errors: [AuthenticationError]() [AuthorizationError]() [FieldError]() [HeaderError]() [InternalError]() [QuotaError]() [RangeError]() [ReachPlanError]() [RequestError]()

        Sample code:

        
         try (ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.create()) {
           GenerateReachForecastRequest request =
               GenerateReachForecastRequest.newBuilder()
                   .setCustomerId("customerId-1581184615")
                   .setCurrencyCode("currencyCode1004773790")
                   .setCampaignDuration(CampaignDuration.newBuilder().build())
                   .setCookieFrequencyCap(-1372585004)
                   .setCookieFrequencyCapSetting(FrequencyCap.newBuilder().build())
                   .setMinEffectiveFrequency(-1801725097)
                   .setEffectiveFrequencyLimit(EffectiveFrequencyLimit.newBuilder().build())
                   .setTargeting(Targeting.newBuilder().build())
                   .addAllPlannedProducts(new ArrayList<PlannedProduct>())
                   .build();
           GenerateReachForecastResponse response =
               reachPlanServiceClient.generateReachForecast(request);
         }
         
        Parameters:
        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
      • generateReachForecastCallable

        public final com.google.api.gax.rpc.UnaryCallable<GenerateReachForecastRequest,​GenerateReachForecastResponse> generateReachForecastCallable()
        Generates a reach forecast for a given targeting / product mix.

        List of thrown errors: [AuthenticationError]() [AuthorizationError]() [FieldError]() [HeaderError]() [InternalError]() [QuotaError]() [RangeError]() [ReachPlanError]() [RequestError]()

        Sample code:

        
         try (ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.create()) {
           GenerateReachForecastRequest request =
               GenerateReachForecastRequest.newBuilder()
                   .setCustomerId("customerId-1581184615")
                   .setCurrencyCode("currencyCode1004773790")
                   .setCampaignDuration(CampaignDuration.newBuilder().build())
                   .setCookieFrequencyCap(-1372585004)
                   .setCookieFrequencyCapSetting(FrequencyCap.newBuilder().build())
                   .setMinEffectiveFrequency(-1801725097)
                   .setEffectiveFrequencyLimit(EffectiveFrequencyLimit.newBuilder().build())
                   .setTargeting(Targeting.newBuilder().build())
                   .addAllPlannedProducts(new ArrayList<PlannedProduct>())
                   .build();
           ApiFuture<GenerateReachForecastResponse> future =
               reachPlanServiceClient.generateReachForecastCallable().futureCall(request);
           // Do something.
           GenerateReachForecastResponse response = future.get();
         }
         
      • close

        public final void close()
        Specified by:
        close in interface java.lang.AutoCloseable
      • shutdown

        public void shutdown()
        Specified by:
        shutdown in interface com.google.api.gax.core.BackgroundResource
      • isShutdown

        public boolean isShutdown()
        Specified by:
        isShutdown in interface com.google.api.gax.core.BackgroundResource
      • isTerminated

        public boolean isTerminated()
        Specified by:
        isTerminated in interface com.google.api.gax.core.BackgroundResource
      • shutdownNow

        public void shutdownNow()
        Specified by:
        shutdownNow in interface com.google.api.gax.core.BackgroundResource
      • awaitTermination

        public boolean awaitTermination​(long duration,
                                        java.util.concurrent.TimeUnit unit)
                                 throws java.lang.InterruptedException
        Specified by:
        awaitTermination in interface com.google.api.gax.core.BackgroundResource
        Throws:
        java.lang.InterruptedException