Class RecommendationServiceClient
- java.lang.Object
-
- com.google.ads.googleads.v14.services.RecommendationServiceClient
-
- All Implemented Interfaces:
com.google.api.gax.core.BackgroundResource,java.lang.AutoCloseable
@Generated("by gapic-generator-java") public class RecommendationServiceClient extends java.lang.Object implements com.google.api.gax.core.BackgroundResourceService Description: Service to manage recommendations.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 (RecommendationServiceClient recommendationServiceClient = RecommendationServiceClient.create()) { String customerId = "customerId-1581184615"; List<ApplyRecommendationOperation> operations = new ArrayList<>(); ApplyRecommendationResponse response = recommendationServiceClient.applyRecommendation(customerId, operations); }Note: close() needs to be called on the RecommendationServiceClient 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 ApplyRecommendation
Applies given recommendations with corresponding apply parameters.
List of thrown errors: [AuthenticationError]() [AuthorizationError]() [DatabaseError]() [FieldError]() [HeaderError]() [InternalError]() [MutateError]() [QuotaError]() [RecommendationError]() [RequestError]() [UrlFieldError]()
Request object method variants only take one parameter, a request object, which must be constructed before the call.
applyRecommendation(ApplyRecommendationRequest request)
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
applyRecommendation(String customerId, List<ApplyRecommendationOperation> operations)
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
applyRecommendationCallable()
DismissRecommendation
Dismisses given recommendations.
List of thrown errors: [AuthenticationError]() [AuthorizationError]() [HeaderError]() [InternalError]() [QuotaError]() [RecommendationError]() [RequestError]()
Request object method variants only take one parameter, a request object, which must be constructed before the call.
dismissRecommendation(DismissRecommendationRequest request)
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
dismissRecommendation(String customerId, List<DismissRecommendationRequest.DismissRecommendationOperation> operations)
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
dismissRecommendationCallable()
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 RecommendationServiceSettings 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 RecommendationServiceSettings recommendationServiceSettings = RecommendationServiceSettings.newBuilder() .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) .build(); RecommendationServiceClient recommendationServiceClient = RecommendationServiceClient.create(recommendationServiceSettings);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 RecommendationServiceSettings recommendationServiceSettings = RecommendationServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); RecommendationServiceClient recommendationServiceClient = RecommendationServiceClient.create(recommendationServiceSettings);Please refer to the GitHub repository's samples for more quickstart code snippets.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRecommendationServiceClient(RecommendationServiceSettings settings)Constructs an instance of RecommendationServiceClient, using the given settings.protectedRecommendationServiceClient(RecommendationServiceStub stub)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ApplyRecommendationResponseapplyRecommendation(ApplyRecommendationRequest request)Applies given recommendations with corresponding apply parameters.ApplyRecommendationResponseapplyRecommendation(java.lang.String customerId, java.util.List<ApplyRecommendationOperation> operations)Applies given recommendations with corresponding apply parameters.com.google.api.gax.rpc.UnaryCallable<ApplyRecommendationRequest,ApplyRecommendationResponse>applyRecommendationCallable()Applies given recommendations with corresponding apply parameters.booleanawaitTermination(long duration, java.util.concurrent.TimeUnit unit)voidclose()static RecommendationServiceClientcreate()Constructs an instance of RecommendationServiceClient with default settings.static RecommendationServiceClientcreate(RecommendationServiceSettings settings)Constructs an instance of RecommendationServiceClient, using the given settings.static RecommendationServiceClientcreate(RecommendationServiceStub stub)Constructs an instance of RecommendationServiceClient, using the given stub for making calls.DismissRecommendationResponsedismissRecommendation(DismissRecommendationRequest request)Dismisses given recommendations.DismissRecommendationResponsedismissRecommendation(java.lang.String customerId, java.util.List<DismissRecommendationRequest.DismissRecommendationOperation> operations)Dismisses given recommendations.com.google.api.gax.rpc.UnaryCallable<DismissRecommendationRequest,DismissRecommendationResponse>dismissRecommendationCallable()Dismisses given recommendations.RecommendationServiceSettingsgetSettings()RecommendationServiceStubgetStub()booleanisShutdown()booleanisTerminated()voidshutdown()voidshutdownNow()
-
-
-
Constructor Detail
-
RecommendationServiceClient
protected RecommendationServiceClient(RecommendationServiceSettings settings) throws java.io.IOException
Constructs an instance of RecommendationServiceClient, 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
-
RecommendationServiceClient
protected RecommendationServiceClient(RecommendationServiceStub stub)
-
-
Method Detail
-
create
public static final RecommendationServiceClient create() throws java.io.IOException
Constructs an instance of RecommendationServiceClient with default settings.- Throws:
java.io.IOException
-
create
public static final RecommendationServiceClient create(RecommendationServiceSettings settings) throws java.io.IOException
Constructs an instance of RecommendationServiceClient, 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
public static final RecommendationServiceClient create(RecommendationServiceStub stub)
Constructs an instance of RecommendationServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(RecommendationServiceSettings).
-
getSettings
public final RecommendationServiceSettings getSettings()
-
getStub
public RecommendationServiceStub getStub()
-
applyRecommendation
public final ApplyRecommendationResponse applyRecommendation(java.lang.String customerId, java.util.List<ApplyRecommendationOperation> operations)
Applies given recommendations with corresponding apply parameters.List of thrown errors: [AuthenticationError]() [AuthorizationError]() [DatabaseError]() [FieldError]() [HeaderError]() [InternalError]() [MutateError]() [QuotaError]() [RecommendationError]() [RequestError]() [UrlFieldError]()
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 (RecommendationServiceClient recommendationServiceClient = RecommendationServiceClient.create()) { String customerId = "customerId-1581184615"; List<ApplyRecommendationOperation> operations = new ArrayList<>(); ApplyRecommendationResponse response = recommendationServiceClient.applyRecommendation(customerId, operations); }- Parameters:
customerId- Required. The ID of the customer with the recommendation.operations- Required. The list of operations to apply recommendations. If partial_failure=false all recommendations should be of the same type There is a limit of 100 operations per request.- Throws:
com.google.api.gax.rpc.ApiException- if the remote call fails
-
applyRecommendation
public final ApplyRecommendationResponse applyRecommendation(ApplyRecommendationRequest request)
Applies given recommendations with corresponding apply parameters.List of thrown errors: [AuthenticationError]() [AuthorizationError]() [DatabaseError]() [FieldError]() [HeaderError]() [InternalError]() [MutateError]() [QuotaError]() [RecommendationError]() [RequestError]() [UrlFieldError]()
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 (RecommendationServiceClient recommendationServiceClient = RecommendationServiceClient.create()) { ApplyRecommendationRequest request = ApplyRecommendationRequest.newBuilder() .setCustomerId("customerId-1581184615") .addAllOperations(new ArrayList<ApplyRecommendationOperation>()) .setPartialFailure(true) .build(); ApplyRecommendationResponse response = recommendationServiceClient.applyRecommendation(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
-
applyRecommendationCallable
public final com.google.api.gax.rpc.UnaryCallable<ApplyRecommendationRequest,ApplyRecommendationResponse> applyRecommendationCallable()
Applies given recommendations with corresponding apply parameters.List of thrown errors: [AuthenticationError]() [AuthorizationError]() [DatabaseError]() [FieldError]() [HeaderError]() [InternalError]() [MutateError]() [QuotaError]() [RecommendationError]() [RequestError]() [UrlFieldError]()
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 (RecommendationServiceClient recommendationServiceClient = RecommendationServiceClient.create()) { ApplyRecommendationRequest request = ApplyRecommendationRequest.newBuilder() .setCustomerId("customerId-1581184615") .addAllOperations(new ArrayList<ApplyRecommendationOperation>()) .setPartialFailure(true) .build(); ApiFuture<ApplyRecommendationResponse> future = recommendationServiceClient.applyRecommendationCallable().futureCall(request); // Do something. ApplyRecommendationResponse response = future.get(); }
-
dismissRecommendation
public final DismissRecommendationResponse dismissRecommendation(java.lang.String customerId, java.util.List<DismissRecommendationRequest.DismissRecommendationOperation> operations)
Dismisses given recommendations.List of thrown errors: [AuthenticationError]() [AuthorizationError]() [HeaderError]() [InternalError]() [QuotaError]() [RecommendationError]() [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 (RecommendationServiceClient recommendationServiceClient = RecommendationServiceClient.create()) { String customerId = "customerId-1581184615"; List<DismissRecommendationRequest.DismissRecommendationOperation> operations = new ArrayList<>(); DismissRecommendationResponse response = recommendationServiceClient.dismissRecommendation(customerId, operations); }- Parameters:
customerId- Required. The ID of the customer with the recommendation.operations- Required. The list of operations to dismiss recommendations. If partial_failure=false all recommendations should be of the same type There is a limit of 100 operations per request.- Throws:
com.google.api.gax.rpc.ApiException- if the remote call fails
-
dismissRecommendation
public final DismissRecommendationResponse dismissRecommendation(DismissRecommendationRequest request)
Dismisses given recommendations.List of thrown errors: [AuthenticationError]() [AuthorizationError]() [HeaderError]() [InternalError]() [QuotaError]() [RecommendationError]() [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 (RecommendationServiceClient recommendationServiceClient = RecommendationServiceClient.create()) { DismissRecommendationRequest request = DismissRecommendationRequest.newBuilder() .setCustomerId("customerId-1581184615") .addAllOperations( new ArrayList<DismissRecommendationRequest.DismissRecommendationOperation>()) .setPartialFailure(true) .build(); DismissRecommendationResponse response = recommendationServiceClient.dismissRecommendation(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
-
dismissRecommendationCallable
public final com.google.api.gax.rpc.UnaryCallable<DismissRecommendationRequest,DismissRecommendationResponse> dismissRecommendationCallable()
Dismisses given recommendations.List of thrown errors: [AuthenticationError]() [AuthorizationError]() [HeaderError]() [InternalError]() [QuotaError]() [RecommendationError]() [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 (RecommendationServiceClient recommendationServiceClient = RecommendationServiceClient.create()) { DismissRecommendationRequest request = DismissRecommendationRequest.newBuilder() .setCustomerId("customerId-1581184615") .addAllOperations( new ArrayList<DismissRecommendationRequest.DismissRecommendationOperation>()) .setPartialFailure(true) .build(); ApiFuture<DismissRecommendationResponse> future = recommendationServiceClient.dismissRecommendationCallable().futureCall(request); // Do something. DismissRecommendationResponse response = future.get(); }
-
close
public final void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfacecom.google.api.gax.core.BackgroundResource
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdownin interfacecom.google.api.gax.core.BackgroundResource
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminatedin interfacecom.google.api.gax.core.BackgroundResource
-
shutdownNow
public void shutdownNow()
- Specified by:
shutdownNowin interfacecom.google.api.gax.core.BackgroundResource
-
awaitTermination
public boolean awaitTermination(long duration, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException- Specified by:
awaitTerminationin interfacecom.google.api.gax.core.BackgroundResource- Throws:
java.lang.InterruptedException
-
-