Class ExperimentServiceClient

java.lang.Object
com.google.ads.googleads.v18.services.ExperimentServiceClient
All Implemented Interfaces:
com.google.api.gax.core.BackgroundResource, AutoCloseable

@Generated("by gapic-generator-java") public class ExperimentServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
Service Description: Service to manage experiments.

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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
   String customerId = "customerId-1581184615";
   List<ExperimentOperation> operations = new ArrayList<>();
   MutateExperimentsResponse response =
       experimentServiceClient.mutateExperiments(customerId, operations);
 }
 

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

MutateExperiments

Creates, updates, or removes experiments. Operation statuses are returned.

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

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

  • mutateExperiments(MutateExperimentsRequest request)

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

  • mutateExperiments(String customerId, List<ExperimentOperation> operations)

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

  • mutateExperimentsCallable()

EndExperiment

Immediately ends an experiment, changing the experiment's scheduled end date and without waiting for end of day. End date is updated to be the time of the request.

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

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

  • endExperiment(EndExperimentRequest request)

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

  • endExperiment(ExperimentName experiment)

  • endExperiment(String experiment)

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

  • endExperimentCallable()

ListExperimentAsyncErrors

Returns all errors that occurred during the last Experiment update (either scheduling or promotion). Supports standard list paging.

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

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

  • listExperimentAsyncErrors(ListExperimentAsyncErrorsRequest request)

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

  • listExperimentAsyncErrors(ExperimentName resourceName)

  • listExperimentAsyncErrors(String resourceName)

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

  • listExperimentAsyncErrorsPagedCallable()

  • listExperimentAsyncErrorsCallable()

GraduateExperiment

Graduates an experiment to a full campaign.

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

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

  • graduateExperiment(GraduateExperimentRequest request)

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

  • graduateExperiment(ExperimentName experiment, List<CampaignBudgetMapping> campaignBudgetMappings)

  • graduateExperiment(String experiment, List<CampaignBudgetMapping> campaignBudgetMappings)

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

  • graduateExperimentCallable()

ScheduleExperiment

Schedule an experiment. The in design campaign will be converted into a real campaign (called the experiment campaign) that will begin serving ads if successfully created.

The experiment is scheduled immediately with status INITIALIZING. This method returns a long running operation that tracks the forking of the in design campaign. If the forking fails, a list of errors can be retrieved using the ListExperimentAsyncErrors method. The operation's metadata will be a string containing the resource name of the created experiment.

List of thrown errors: [AuthenticationError]() [AuthorizationError]() [ExperimentError]() [DatabaseError]() [DateError]() [DateRangeError]() [FieldError]() [HeaderError]() [InternalError]() [QuotaError]() [RangeError]() [RequestError]()

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

  • scheduleExperimentAsync(ScheduleExperimentRequest request)

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

  • scheduleExperimentAsync(ExperimentName resourceName)

  • scheduleExperimentAsync(String resourceName)

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

  • scheduleExperimentOperationCallable()

  • scheduleExperimentCallable()

PromoteExperiment

Promotes the trial campaign thus applying changes in the trial campaign to the base campaign. This method returns a long running operation that tracks the promotion of the experiment campaign. If it fails, a list of errors can be retrieved using the ListExperimentAsyncErrors method. The operation's metadata will be a string containing the resource name of the created experiment.

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

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

  • promoteExperimentAsync(PromoteExperimentRequest request)

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

  • promoteExperimentAsync(ExperimentName resourceName)

  • promoteExperimentAsync(String resourceName)

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

  • promoteExperimentOperationCallable()

  • promoteExperimentCallable()

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 ExperimentServiceSettings 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
 ExperimentServiceSettings experimentServiceSettings =
     ExperimentServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ExperimentServiceClient experimentServiceClient =
     ExperimentServiceClient.create(experimentServiceSettings);
 

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
 ExperimentServiceSettings experimentServiceSettings =
     ExperimentServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 ExperimentServiceClient experimentServiceClient =
     ExperimentServiceClient.create(experimentServiceSettings);
 

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

  • Constructor Details

    • ExperimentServiceClient

      protected ExperimentServiceClient(ExperimentServiceSettings settings) throws IOException
      Constructs an instance of ExperimentServiceClient, 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:
      IOException
    • ExperimentServiceClient

      protected ExperimentServiceClient(ExperimentServiceStub stub)
  • Method Details

    • create

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

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

      public static final ExperimentServiceClient create(ExperimentServiceStub stub)
      Constructs an instance of ExperimentServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ExperimentServiceSettings).
    • getSettings

      public final ExperimentServiceSettings getSettings()
    • getStub

      public ExperimentServiceStub getStub()
    • getOperationsClient

      public final com.google.longrunning.OperationsClient getOperationsClient()
      Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
    • mutateExperiments

      public final MutateExperimentsResponse mutateExperiments(String customerId, List<ExperimentOperation> operations)
      Creates, updates, or removes experiments. Operation statuses are returned.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         String customerId = "customerId-1581184615";
         List<ExperimentOperation> operations = new ArrayList<>();
         MutateExperimentsResponse response =
             experimentServiceClient.mutateExperiments(customerId, operations);
       }
       
      Parameters:
      customerId - Required. The ID of the customer whose experiments are being modified.
      operations - Required. The list of operations to perform on individual experiments.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • mutateExperiments

      public final MutateExperimentsResponse mutateExperiments(MutateExperimentsRequest request)
      Creates, updates, or removes experiments. Operation statuses are returned.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         MutateExperimentsRequest request =
             MutateExperimentsRequest.newBuilder()
                 .setCustomerId("customerId-1581184615")
                 .addAllOperations(new ArrayList<ExperimentOperation>())
                 .setPartialFailure(true)
                 .setValidateOnly(true)
                 .build();
         MutateExperimentsResponse response = experimentServiceClient.mutateExperiments(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
    • mutateExperimentsCallable

      public final com.google.api.gax.rpc.UnaryCallable<MutateExperimentsRequest,MutateExperimentsResponse> mutateExperimentsCallable()
      Creates, updates, or removes experiments. Operation statuses are returned.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         MutateExperimentsRequest request =
             MutateExperimentsRequest.newBuilder()
                 .setCustomerId("customerId-1581184615")
                 .addAllOperations(new ArrayList<ExperimentOperation>())
                 .setPartialFailure(true)
                 .setValidateOnly(true)
                 .build();
         ApiFuture<MutateExperimentsResponse> future =
             experimentServiceClient.mutateExperimentsCallable().futureCall(request);
         // Do something.
         MutateExperimentsResponse response = future.get();
       }
       
    • endExperiment

      public final void endExperiment(ExperimentName experiment)
      Immediately ends an experiment, changing the experiment's scheduled end date and without waiting for end of day. End date is updated to be the time of the request.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         ExperimentName experiment = ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]");
         experimentServiceClient.endExperiment(experiment);
       }
       
      Parameters:
      experiment - Required. The resource name of the campaign experiment to end.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • endExperiment

      public final void endExperiment(String experiment)
      Immediately ends an experiment, changing the experiment's scheduled end date and without waiting for end of day. End date is updated to be the time of the request.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         String experiment = ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString();
         experimentServiceClient.endExperiment(experiment);
       }
       
      Parameters:
      experiment - Required. The resource name of the campaign experiment to end.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • endExperiment

      public final void endExperiment(EndExperimentRequest request)
      Immediately ends an experiment, changing the experiment's scheduled end date and without waiting for end of day. End date is updated to be the time of the request.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         EndExperimentRequest request =
             EndExperimentRequest.newBuilder()
                 .setExperiment(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .setValidateOnly(true)
                 .build();
         experimentServiceClient.endExperiment(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
    • endExperimentCallable

      public final com.google.api.gax.rpc.UnaryCallable<EndExperimentRequest,com.google.protobuf.Empty> endExperimentCallable()
      Immediately ends an experiment, changing the experiment's scheduled end date and without waiting for end of day. End date is updated to be the time of the request.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         EndExperimentRequest request =
             EndExperimentRequest.newBuilder()
                 .setExperiment(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .setValidateOnly(true)
                 .build();
         ApiFuture<Empty> future = experimentServiceClient.endExperimentCallable().futureCall(request);
         // Do something.
         future.get();
       }
       
    • listExperimentAsyncErrors

      public final ExperimentServiceClient.ListExperimentAsyncErrorsPagedResponse listExperimentAsyncErrors(ExperimentName resourceName)
      Returns all errors that occurred during the last Experiment update (either scheduling or promotion). Supports standard list paging.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         ExperimentName resourceName = ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]");
         for (Status element :
             experimentServiceClient.listExperimentAsyncErrors(resourceName).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      resourceName - Required. The name of the experiment from which to retrieve the async errors.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • listExperimentAsyncErrors

      public final ExperimentServiceClient.ListExperimentAsyncErrorsPagedResponse listExperimentAsyncErrors(String resourceName)
      Returns all errors that occurred during the last Experiment update (either scheduling or promotion). Supports standard list paging.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         String resourceName = ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString();
         for (Status element :
             experimentServiceClient.listExperimentAsyncErrors(resourceName).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      resourceName - Required. The name of the experiment from which to retrieve the async errors.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • listExperimentAsyncErrors

      Returns all errors that occurred during the last Experiment update (either scheduling or promotion). Supports standard list paging.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         ListExperimentAsyncErrorsRequest request =
             ListExperimentAsyncErrorsRequest.newBuilder()
                 .setResourceName(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .setPageToken("pageToken873572522")
                 .setPageSize(883849137)
                 .build();
         for (Status element :
             experimentServiceClient.listExperimentAsyncErrors(request).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      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
    • listExperimentAsyncErrorsPagedCallable

      public final com.google.api.gax.rpc.UnaryCallable<ListExperimentAsyncErrorsRequest,ExperimentServiceClient.ListExperimentAsyncErrorsPagedResponse> listExperimentAsyncErrorsPagedCallable()
      Returns all errors that occurred during the last Experiment update (either scheduling or promotion). Supports standard list paging.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         ListExperimentAsyncErrorsRequest request =
             ListExperimentAsyncErrorsRequest.newBuilder()
                 .setResourceName(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .setPageToken("pageToken873572522")
                 .setPageSize(883849137)
                 .build();
         ApiFuture<Status> future =
             experimentServiceClient.listExperimentAsyncErrorsPagedCallable().futureCall(request);
         // Do something.
         for (Status element : future.get().iterateAll()) {
           // doThingsWith(element);
         }
       }
       
    • listExperimentAsyncErrorsCallable

      public final com.google.api.gax.rpc.UnaryCallable<ListExperimentAsyncErrorsRequest,ListExperimentAsyncErrorsResponse> listExperimentAsyncErrorsCallable()
      Returns all errors that occurred during the last Experiment update (either scheduling or promotion). Supports standard list paging.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         ListExperimentAsyncErrorsRequest request =
             ListExperimentAsyncErrorsRequest.newBuilder()
                 .setResourceName(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .setPageToken("pageToken873572522")
                 .setPageSize(883849137)
                 .build();
         while (true) {
           ListExperimentAsyncErrorsResponse response =
               experimentServiceClient.listExperimentAsyncErrorsCallable().call(request);
           for (Status element : response.getErrorsList()) {
             // doThingsWith(element);
           }
           String nextPageToken = response.getNextPageToken();
           if (!Strings.isNullOrEmpty(nextPageToken)) {
             request = request.toBuilder().setPageToken(nextPageToken).build();
           } else {
             break;
           }
         }
       }
       
    • graduateExperiment

      public final void graduateExperiment(ExperimentName experiment, List<CampaignBudgetMapping> campaignBudgetMappings)
      Graduates an experiment to a full campaign.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         ExperimentName experiment = ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]");
         List<CampaignBudgetMapping> campaignBudgetMappings = new ArrayList<>();
         experimentServiceClient.graduateExperiment(experiment, campaignBudgetMappings);
       }
       
      Parameters:
      experiment - Required. The experiment to be graduated.
      campaignBudgetMappings - Required. List of campaign budget mappings for graduation. Each campaign that appears here will graduate, and will be assigned a new budget that is paired with it in the mapping. The maximum size is one.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • graduateExperiment

      public final void graduateExperiment(String experiment, List<CampaignBudgetMapping> campaignBudgetMappings)
      Graduates an experiment to a full campaign.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         String experiment = ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString();
         List<CampaignBudgetMapping> campaignBudgetMappings = new ArrayList<>();
         experimentServiceClient.graduateExperiment(experiment, campaignBudgetMappings);
       }
       
      Parameters:
      experiment - Required. The experiment to be graduated.
      campaignBudgetMappings - Required. List of campaign budget mappings for graduation. Each campaign that appears here will graduate, and will be assigned a new budget that is paired with it in the mapping. The maximum size is one.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • graduateExperiment

      public final void graduateExperiment(GraduateExperimentRequest request)
      Graduates an experiment to a full campaign.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         GraduateExperimentRequest request =
             GraduateExperimentRequest.newBuilder()
                 .setExperiment(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .addAllCampaignBudgetMappings(new ArrayList<CampaignBudgetMapping>())
                 .setValidateOnly(true)
                 .build();
         experimentServiceClient.graduateExperiment(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
    • graduateExperimentCallable

      public final com.google.api.gax.rpc.UnaryCallable<GraduateExperimentRequest,com.google.protobuf.Empty> graduateExperimentCallable()
      Graduates an experiment to a full campaign.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         GraduateExperimentRequest request =
             GraduateExperimentRequest.newBuilder()
                 .setExperiment(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .addAllCampaignBudgetMappings(new ArrayList<CampaignBudgetMapping>())
                 .setValidateOnly(true)
                 .build();
         ApiFuture<Empty> future =
             experimentServiceClient.graduateExperimentCallable().futureCall(request);
         // Do something.
         future.get();
       }
       
    • scheduleExperimentAsync

      public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,ScheduleExperimentMetadata> scheduleExperimentAsync(ExperimentName resourceName)
      Schedule an experiment. The in design campaign will be converted into a real campaign (called the experiment campaign) that will begin serving ads if successfully created.

      The experiment is scheduled immediately with status INITIALIZING. This method returns a long running operation that tracks the forking of the in design campaign. If the forking fails, a list of errors can be retrieved using the ListExperimentAsyncErrors method. The operation's metadata will be a string containing the resource name of the created experiment.

      List of thrown errors: [AuthenticationError]() [AuthorizationError]() [ExperimentError]() [DatabaseError]() [DateError]() [DateRangeError]() [FieldError]() [HeaderError]() [InternalError]() [QuotaError]() [RangeError]() [RequestError]()

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         ExperimentName resourceName = ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]");
         experimentServiceClient.scheduleExperimentAsync(resourceName).get();
       }
       
      Parameters:
      resourceName - Required. The scheduled experiment.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • scheduleExperimentAsync

      public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,ScheduleExperimentMetadata> scheduleExperimentAsync(String resourceName)
      Schedule an experiment. The in design campaign will be converted into a real campaign (called the experiment campaign) that will begin serving ads if successfully created.

      The experiment is scheduled immediately with status INITIALIZING. This method returns a long running operation that tracks the forking of the in design campaign. If the forking fails, a list of errors can be retrieved using the ListExperimentAsyncErrors method. The operation's metadata will be a string containing the resource name of the created experiment.

      List of thrown errors: [AuthenticationError]() [AuthorizationError]() [ExperimentError]() [DatabaseError]() [DateError]() [DateRangeError]() [FieldError]() [HeaderError]() [InternalError]() [QuotaError]() [RangeError]() [RequestError]()

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         String resourceName = ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString();
         experimentServiceClient.scheduleExperimentAsync(resourceName).get();
       }
       
      Parameters:
      resourceName - Required. The scheduled experiment.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • scheduleExperimentAsync

      public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,ScheduleExperimentMetadata> scheduleExperimentAsync(ScheduleExperimentRequest request)
      Schedule an experiment. The in design campaign will be converted into a real campaign (called the experiment campaign) that will begin serving ads if successfully created.

      The experiment is scheduled immediately with status INITIALIZING. This method returns a long running operation that tracks the forking of the in design campaign. If the forking fails, a list of errors can be retrieved using the ListExperimentAsyncErrors method. The operation's metadata will be a string containing the resource name of the created experiment.

      List of thrown errors: [AuthenticationError]() [AuthorizationError]() [ExperimentError]() [DatabaseError]() [DateError]() [DateRangeError]() [FieldError]() [HeaderError]() [InternalError]() [QuotaError]() [RangeError]() [RequestError]()

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         ScheduleExperimentRequest request =
             ScheduleExperimentRequest.newBuilder()
                 .setResourceName(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .setValidateOnly(true)
                 .build();
         experimentServiceClient.scheduleExperimentAsync(request).get();
       }
       
      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
    • scheduleExperimentOperationCallable

      public final com.google.api.gax.rpc.OperationCallable<ScheduleExperimentRequest,com.google.protobuf.Empty,ScheduleExperimentMetadata> scheduleExperimentOperationCallable()
      Schedule an experiment. The in design campaign will be converted into a real campaign (called the experiment campaign) that will begin serving ads if successfully created.

      The experiment is scheduled immediately with status INITIALIZING. This method returns a long running operation that tracks the forking of the in design campaign. If the forking fails, a list of errors can be retrieved using the ListExperimentAsyncErrors method. The operation's metadata will be a string containing the resource name of the created experiment.

      List of thrown errors: [AuthenticationError]() [AuthorizationError]() [ExperimentError]() [DatabaseError]() [DateError]() [DateRangeError]() [FieldError]() [HeaderError]() [InternalError]() [QuotaError]() [RangeError]() [RequestError]()

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         ScheduleExperimentRequest request =
             ScheduleExperimentRequest.newBuilder()
                 .setResourceName(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .setValidateOnly(true)
                 .build();
         OperationFuture<Empty, ScheduleExperimentMetadata> future =
             experimentServiceClient.scheduleExperimentOperationCallable().futureCall(request);
         // Do something.
         future.get();
       }
       
    • scheduleExperimentCallable

      public final com.google.api.gax.rpc.UnaryCallable<ScheduleExperimentRequest,com.google.longrunning.Operation> scheduleExperimentCallable()
      Schedule an experiment. The in design campaign will be converted into a real campaign (called the experiment campaign) that will begin serving ads if successfully created.

      The experiment is scheduled immediately with status INITIALIZING. This method returns a long running operation that tracks the forking of the in design campaign. If the forking fails, a list of errors can be retrieved using the ListExperimentAsyncErrors method. The operation's metadata will be a string containing the resource name of the created experiment.

      List of thrown errors: [AuthenticationError]() [AuthorizationError]() [ExperimentError]() [DatabaseError]() [DateError]() [DateRangeError]() [FieldError]() [HeaderError]() [InternalError]() [QuotaError]() [RangeError]() [RequestError]()

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         ScheduleExperimentRequest request =
             ScheduleExperimentRequest.newBuilder()
                 .setResourceName(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .setValidateOnly(true)
                 .build();
         ApiFuture<Operation> future =
             experimentServiceClient.scheduleExperimentCallable().futureCall(request);
         // Do something.
         future.get();
       }
       
    • promoteExperimentAsync

      public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,PromoteExperimentMetadata> promoteExperimentAsync(ExperimentName resourceName)
      Promotes the trial campaign thus applying changes in the trial campaign to the base campaign. This method returns a long running operation that tracks the promotion of the experiment campaign. If it fails, a list of errors can be retrieved using the ListExperimentAsyncErrors method. The operation's metadata will be a string containing the resource name of the created experiment.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         ExperimentName resourceName = ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]");
         experimentServiceClient.promoteExperimentAsync(resourceName).get();
       }
       
      Parameters:
      resourceName - Required. The resource name of the experiment to promote.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • promoteExperimentAsync

      public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,PromoteExperimentMetadata> promoteExperimentAsync(String resourceName)
      Promotes the trial campaign thus applying changes in the trial campaign to the base campaign. This method returns a long running operation that tracks the promotion of the experiment campaign. If it fails, a list of errors can be retrieved using the ListExperimentAsyncErrors method. The operation's metadata will be a string containing the resource name of the created experiment.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         String resourceName = ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString();
         experimentServiceClient.promoteExperimentAsync(resourceName).get();
       }
       
      Parameters:
      resourceName - Required. The resource name of the experiment to promote.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • promoteExperimentAsync

      public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,PromoteExperimentMetadata> promoteExperimentAsync(PromoteExperimentRequest request)
      Promotes the trial campaign thus applying changes in the trial campaign to the base campaign. This method returns a long running operation that tracks the promotion of the experiment campaign. If it fails, a list of errors can be retrieved using the ListExperimentAsyncErrors method. The operation's metadata will be a string containing the resource name of the created experiment.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         PromoteExperimentRequest request =
             PromoteExperimentRequest.newBuilder()
                 .setResourceName(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .setValidateOnly(true)
                 .build();
         experimentServiceClient.promoteExperimentAsync(request).get();
       }
       
      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
    • promoteExperimentOperationCallable

      public final com.google.api.gax.rpc.OperationCallable<PromoteExperimentRequest,com.google.protobuf.Empty,PromoteExperimentMetadata> promoteExperimentOperationCallable()
      Promotes the trial campaign thus applying changes in the trial campaign to the base campaign. This method returns a long running operation that tracks the promotion of the experiment campaign. If it fails, a list of errors can be retrieved using the ListExperimentAsyncErrors method. The operation's metadata will be a string containing the resource name of the created experiment.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         PromoteExperimentRequest request =
             PromoteExperimentRequest.newBuilder()
                 .setResourceName(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .setValidateOnly(true)
                 .build();
         OperationFuture<Empty, PromoteExperimentMetadata> future =
             experimentServiceClient.promoteExperimentOperationCallable().futureCall(request);
         // Do something.
         future.get();
       }
       
    • promoteExperimentCallable

      public final com.google.api.gax.rpc.UnaryCallable<PromoteExperimentRequest,com.google.longrunning.Operation> promoteExperimentCallable()
      Promotes the trial campaign thus applying changes in the trial campaign to the base campaign. This method returns a long running operation that tracks the promotion of the experiment campaign. If it fails, a list of errors can be retrieved using the ListExperimentAsyncErrors method. The operation's metadata will be a string containing the resource name of the created experiment.

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

      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 (ExperimentServiceClient experimentServiceClient = ExperimentServiceClient.create()) {
         PromoteExperimentRequest request =
             PromoteExperimentRequest.newBuilder()
                 .setResourceName(ExperimentName.of("[CUSTOMER_ID]", "[TRIAL_ID]").toString())
                 .setValidateOnly(true)
                 .build();
         ApiFuture<Operation> future =
             experimentServiceClient.promoteExperimentCallable().futureCall(request);
         // Do something.
         future.get();
       }
       
    • close

      public final void close()
      Specified by:
      close in interface 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, TimeUnit unit) throws InterruptedException
      Specified by:
      awaitTermination in interface com.google.api.gax.core.BackgroundResource
      Throws:
      InterruptedException