com.google.cloud.discoveryengine.v1beta.EvaluationServiceClient Maven / Gradle / Ivy
Show all versions of google-cloud-discoveryengine Show documentation
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.discoveryengine.v1beta;
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.httpjson.longrunning.OperationsClient;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.discoveryengine.v1beta.stub.EvaluationServiceStub;
import com.google.cloud.discoveryengine.v1beta.stub.EvaluationServiceStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.longrunning.Operation;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* Service Description: Service for managing
* [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation]s,
*
* 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:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* EvaluationName name = EvaluationName.of("[PROJECT]", "[LOCATION]", "[EVALUATION]");
* Evaluation response = evaluationServiceClient.getEvaluation(name);
* }
* }
*
* Note: close() needs to be called on the EvaluationServiceClient 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
*
*
* GetEvaluation
* Gets a [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* getEvaluation(GetEvaluationRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* getEvaluation(EvaluationName name)
*
getEvaluation(String name)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* getEvaluationCallable()
*
*
*
*
* ListEvaluations
* Gets a list of [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation]s.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* listEvaluations(ListEvaluationsRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* listEvaluations(LocationName parent)
*
listEvaluations(String parent)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* listEvaluationsPagedCallable()
*
listEvaluationsCallable()
*
*
*
*
* CreateEvaluation
* Creates a [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
Upon creation, the evaluation will be automatically triggered and begin execution.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* createEvaluationAsync(CreateEvaluationRequest request)
*
* Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
*
* createEvaluationAsync(LocationName parent, Evaluation evaluation)
*
createEvaluationAsync(String parent, Evaluation evaluation)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* createEvaluationOperationCallable()
*
createEvaluationCallable()
*
*
*
*
* ListEvaluationResults
* Gets a list of results for a given a [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* listEvaluationResults(ListEvaluationResultsRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* listEvaluationResults(EvaluationName evaluation)
*
listEvaluationResults(String evaluation)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* listEvaluationResultsPagedCallable()
*
listEvaluationResultsCallable()
*
*
*
*
*
* 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 EvaluationServiceSettings to
* create(). For example:
*
*
To customize credentials:
*
*
{@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
* EvaluationServiceSettings evaluationServiceSettings =
* EvaluationServiceSettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* EvaluationServiceClient evaluationServiceClient =
* EvaluationServiceClient.create(evaluationServiceSettings);
* }
*
* To customize the endpoint:
*
*
{@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
* EvaluationServiceSettings evaluationServiceSettings =
* EvaluationServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
* EvaluationServiceClient evaluationServiceClient =
* EvaluationServiceClient.create(evaluationServiceSettings);
* }
*
* To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
* the wire:
*
*
{@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
* EvaluationServiceSettings evaluationServiceSettings =
* EvaluationServiceSettings.newHttpJsonBuilder().build();
* EvaluationServiceClient evaluationServiceClient =
* EvaluationServiceClient.create(evaluationServiceSettings);
* }
*
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@BetaApi
@Generated("by gapic-generator-java")
public class EvaluationServiceClient implements BackgroundResource {
private final EvaluationServiceSettings settings;
private final EvaluationServiceStub stub;
private final OperationsClient httpJsonOperationsClient;
private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of EvaluationServiceClient with default settings. */
public static final EvaluationServiceClient create() throws IOException {
return create(EvaluationServiceSettings.newBuilder().build());
}
/**
* Constructs an instance of EvaluationServiceClient, using the given settings. The channels are
* created based on the settings passed in, or defaults for any settings that are not set.
*/
public static final EvaluationServiceClient create(EvaluationServiceSettings settings)
throws IOException {
return new EvaluationServiceClient(settings);
}
/**
* Constructs an instance of EvaluationServiceClient, using the given stub for making calls. This
* is for advanced usage - prefer using create(EvaluationServiceSettings).
*/
public static final EvaluationServiceClient create(EvaluationServiceStub stub) {
return new EvaluationServiceClient(stub);
}
/**
* Constructs an instance of EvaluationServiceClient, 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.
*/
protected EvaluationServiceClient(EvaluationServiceSettings settings) throws IOException {
this.settings = settings;
this.stub = ((EvaluationServiceStubSettings) settings.getStubSettings()).createStub();
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
protected EvaluationServiceClient(EvaluationServiceStub stub) {
this.settings = null;
this.stub = stub;
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
public final EvaluationServiceSettings getSettings() {
return settings;
}
public EvaluationServiceStub getStub() {
return stub;
}
/**
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
public final com.google.longrunning.OperationsClient getOperationsClient() {
return operationsClient;
}
/**
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
@BetaApi
public final OperationsClient getHttpJsonOperationsClient() {
return httpJsonOperationsClient;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
*
Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* EvaluationName name = EvaluationName.of("[PROJECT]", "[LOCATION]", "[EVALUATION]");
* Evaluation response = evaluationServiceClient.getEvaluation(name);
* }
* }
*
* @param name Required. Full resource name of
* [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation], such as
* `projects/{project}/locations/{location}/evaluations/{evaluation}`.
* If the caller does not have permission to access the
* [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation], regardless of whether or not
* it exists, a PERMISSION_DENIED error is returned.
*
If the requested [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation] does not
* exist, a NOT_FOUND error is returned.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Evaluation getEvaluation(EvaluationName name) {
GetEvaluationRequest request =
GetEvaluationRequest.newBuilder().setName(name == null ? null : name.toString()).build();
return getEvaluation(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
*
Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* String name = EvaluationName.of("[PROJECT]", "[LOCATION]", "[EVALUATION]").toString();
* Evaluation response = evaluationServiceClient.getEvaluation(name);
* }
* }
*
* @param name Required. Full resource name of
* [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation], such as
* `projects/{project}/locations/{location}/evaluations/{evaluation}`.
* If the caller does not have permission to access the
* [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation], regardless of whether or not
* it exists, a PERMISSION_DENIED error is returned.
*
If the requested [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation] does not
* exist, a NOT_FOUND error is returned.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Evaluation getEvaluation(String name) {
GetEvaluationRequest request = GetEvaluationRequest.newBuilder().setName(name).build();
return getEvaluation(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
*
Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* GetEvaluationRequest request =
* GetEvaluationRequest.newBuilder()
* .setName(EvaluationName.of("[PROJECT]", "[LOCATION]", "[EVALUATION]").toString())
* .build();
* Evaluation response = evaluationServiceClient.getEvaluation(request);
* }
* }
*
* @param 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
*/
public final Evaluation getEvaluation(GetEvaluationRequest request) {
return getEvaluationCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
* Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* GetEvaluationRequest request =
* GetEvaluationRequest.newBuilder()
* .setName(EvaluationName.of("[PROJECT]", "[LOCATION]", "[EVALUATION]").toString())
* .build();
* ApiFuture future =
* evaluationServiceClient.getEvaluationCallable().futureCall(request);
* // Do something.
* Evaluation response = future.get();
* }
* }
*/
public final UnaryCallable getEvaluationCallable() {
return stub.getEvaluationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a list of [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation]s.
*
* Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* for (Evaluation element : evaluationServiceClient.listEvaluations(parent).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*
* @param parent Required. The parent location resource name, such as
* `projects/{project}/locations/{location}`.
* If the caller does not have permission to list
* [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation]s under this location,
* regardless of whether or not this location exists, a `PERMISSION_DENIED` error is returned.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListEvaluationsPagedResponse listEvaluations(LocationName parent) {
ListEvaluationsRequest request =
ListEvaluationsRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.build();
return listEvaluations(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a list of [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation]s.
*
*
Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
* for (Evaluation element : evaluationServiceClient.listEvaluations(parent).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*
* @param parent Required. The parent location resource name, such as
* `projects/{project}/locations/{location}`.
* If the caller does not have permission to list
* [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation]s under this location,
* regardless of whether or not this location exists, a `PERMISSION_DENIED` error is returned.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListEvaluationsPagedResponse listEvaluations(String parent) {
ListEvaluationsRequest request = ListEvaluationsRequest.newBuilder().setParent(parent).build();
return listEvaluations(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a list of [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation]s.
*
*
Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* ListEvaluationsRequest request =
* ListEvaluationsRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* for (Evaluation element : evaluationServiceClient.listEvaluations(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*
* @param 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
*/
public final ListEvaluationsPagedResponse listEvaluations(ListEvaluationsRequest request) {
return listEvaluationsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a list of [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation]s.
*
* Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* ListEvaluationsRequest request =
* ListEvaluationsRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* ApiFuture future =
* evaluationServiceClient.listEvaluationsPagedCallable().futureCall(request);
* // Do something.
* for (Evaluation element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable
listEvaluationsPagedCallable() {
return stub.listEvaluationsPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a list of [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation]s.
*
* Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* ListEvaluationsRequest request =
* ListEvaluationsRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* while (true) {
* ListEvaluationsResponse response =
* evaluationServiceClient.listEvaluationsCallable().call(request);
* for (Evaluation element : response.getEvaluationsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* }
*/
public final UnaryCallable
listEvaluationsCallable() {
return stub.listEvaluationsCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
* Upon creation, the evaluation will be automatically triggered and begin execution.
*
*
Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* Evaluation evaluation = Evaluation.newBuilder().build();
* Evaluation response = evaluationServiceClient.createEvaluationAsync(parent, evaluation).get();
* }
* }
*
* @param parent Required. The parent resource name, such as
* `projects/{project}/locations/{location}`.
* @param evaluation Required. The [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation] to
* create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture createEvaluationAsync(
LocationName parent, Evaluation evaluation) {
CreateEvaluationRequest request =
CreateEvaluationRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setEvaluation(evaluation)
.build();
return createEvaluationAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
* Upon creation, the evaluation will be automatically triggered and begin execution.
*
*
Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
* Evaluation evaluation = Evaluation.newBuilder().build();
* Evaluation response = evaluationServiceClient.createEvaluationAsync(parent, evaluation).get();
* }
* }
*
* @param parent Required. The parent resource name, such as
* `projects/{project}/locations/{location}`.
* @param evaluation Required. The [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation] to
* create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture createEvaluationAsync(
String parent, Evaluation evaluation) {
CreateEvaluationRequest request =
CreateEvaluationRequest.newBuilder().setParent(parent).setEvaluation(evaluation).build();
return createEvaluationAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
* Upon creation, the evaluation will be automatically triggered and begin execution.
*
*
Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* CreateEvaluationRequest request =
* CreateEvaluationRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setEvaluation(Evaluation.newBuilder().build())
* .build();
* Evaluation response = evaluationServiceClient.createEvaluationAsync(request).get();
* }
* }
*
* @param 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
*/
public final OperationFuture createEvaluationAsync(
CreateEvaluationRequest request) {
return createEvaluationOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
* Upon creation, the evaluation will be automatically triggered and begin execution.
*
*
Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* CreateEvaluationRequest request =
* CreateEvaluationRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setEvaluation(Evaluation.newBuilder().build())
* .build();
* OperationFuture future =
* evaluationServiceClient.createEvaluationOperationCallable().futureCall(request);
* // Do something.
* Evaluation response = future.get();
* }
* }
*/
public final OperationCallable
createEvaluationOperationCallable() {
return stub.createEvaluationOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
* Upon creation, the evaluation will be automatically triggered and begin execution.
*
*
Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* CreateEvaluationRequest request =
* CreateEvaluationRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setEvaluation(Evaluation.newBuilder().build())
* .build();
* ApiFuture future =
* evaluationServiceClient.createEvaluationCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable createEvaluationCallable() {
return stub.createEvaluationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a list of results for a given a
* [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
* Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* EvaluationName evaluation = EvaluationName.of("[PROJECT]", "[LOCATION]", "[EVALUATION]");
* for (ListEvaluationResultsResponse.EvaluationResult element :
* evaluationServiceClient.listEvaluationResults(evaluation).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*
* @param evaluation Required. The evaluation resource name, such as
* `projects/{project}/locations/{location}/evaluations/{evaluation}`.
* If the caller does not have permission to list [EvaluationResult][] under this
* evaluation, regardless of whether or not this evaluation set exists, a `PERMISSION_DENIED`
* error is returned.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListEvaluationResultsPagedResponse listEvaluationResults(EvaluationName evaluation) {
ListEvaluationResultsRequest request =
ListEvaluationResultsRequest.newBuilder()
.setEvaluation(evaluation == null ? null : evaluation.toString())
.build();
return listEvaluationResults(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a list of results for a given a
* [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
*
Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* String evaluation = EvaluationName.of("[PROJECT]", "[LOCATION]", "[EVALUATION]").toString();
* for (ListEvaluationResultsResponse.EvaluationResult element :
* evaluationServiceClient.listEvaluationResults(evaluation).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*
* @param evaluation Required. The evaluation resource name, such as
* `projects/{project}/locations/{location}/evaluations/{evaluation}`.
* If the caller does not have permission to list [EvaluationResult][] under this
* evaluation, regardless of whether or not this evaluation set exists, a `PERMISSION_DENIED`
* error is returned.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListEvaluationResultsPagedResponse listEvaluationResults(String evaluation) {
ListEvaluationResultsRequest request =
ListEvaluationResultsRequest.newBuilder().setEvaluation(evaluation).build();
return listEvaluationResults(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a list of results for a given a
* [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
*
Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* ListEvaluationResultsRequest request =
* ListEvaluationResultsRequest.newBuilder()
* .setEvaluation(
* EvaluationName.of("[PROJECT]", "[LOCATION]", "[EVALUATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* for (ListEvaluationResultsResponse.EvaluationResult element :
* evaluationServiceClient.listEvaluationResults(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*
* @param 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
*/
public final ListEvaluationResultsPagedResponse listEvaluationResults(
ListEvaluationResultsRequest request) {
return listEvaluationResultsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a list of results for a given a
* [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
* Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* ListEvaluationResultsRequest request =
* ListEvaluationResultsRequest.newBuilder()
* .setEvaluation(
* EvaluationName.of("[PROJECT]", "[LOCATION]", "[EVALUATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* ApiFuture future =
* evaluationServiceClient.listEvaluationResultsPagedCallable().futureCall(request);
* // Do something.
* for (ListEvaluationResultsResponse.EvaluationResult element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable
listEvaluationResultsPagedCallable() {
return stub.listEvaluationResultsPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets a list of results for a given a
* [Evaluation][google.cloud.discoveryengine.v1beta.Evaluation].
*
* Sample code:
*
*
{@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 (EvaluationServiceClient evaluationServiceClient = EvaluationServiceClient.create()) {
* ListEvaluationResultsRequest request =
* ListEvaluationResultsRequest.newBuilder()
* .setEvaluation(
* EvaluationName.of("[PROJECT]", "[LOCATION]", "[EVALUATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* while (true) {
* ListEvaluationResultsResponse response =
* evaluationServiceClient.listEvaluationResultsCallable().call(request);
* for (ListEvaluationResultsResponse.EvaluationResult element :
* response.getEvaluationResultsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* }
*/
public final UnaryCallable
listEvaluationResultsCallable() {
return stub.listEvaluationResultsCallable();
}
@Override
public final void close() {
stub.close();
}
@Override
public void shutdown() {
stub.shutdown();
}
@Override
public boolean isShutdown() {
return stub.isShutdown();
}
@Override
public boolean isTerminated() {
return stub.isTerminated();
}
@Override
public void shutdownNow() {
stub.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return stub.awaitTermination(duration, unit);
}
public static class ListEvaluationsPagedResponse
extends AbstractPagedListResponse<
ListEvaluationsRequest,
ListEvaluationsResponse,
Evaluation,
ListEvaluationsPage,
ListEvaluationsFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListEvaluationsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListEvaluationsPagedResponse(input),
MoreExecutors.directExecutor());
}
private ListEvaluationsPagedResponse(ListEvaluationsPage page) {
super(page, ListEvaluationsFixedSizeCollection.createEmptyCollection());
}
}
public static class ListEvaluationsPage
extends AbstractPage<
ListEvaluationsRequest, ListEvaluationsResponse, Evaluation, ListEvaluationsPage> {
private ListEvaluationsPage(
PageContext context,
ListEvaluationsResponse response) {
super(context, response);
}
private static ListEvaluationsPage createEmptyPage() {
return new ListEvaluationsPage(null, null);
}
@Override
protected ListEvaluationsPage createPage(
PageContext context,
ListEvaluationsResponse response) {
return new ListEvaluationsPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListEvaluationsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListEvaluationsRequest,
ListEvaluationsResponse,
Evaluation,
ListEvaluationsPage,
ListEvaluationsFixedSizeCollection> {
private ListEvaluationsFixedSizeCollection(
List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListEvaluationsFixedSizeCollection createEmptyCollection() {
return new ListEvaluationsFixedSizeCollection(null, 0);
}
@Override
protected ListEvaluationsFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListEvaluationsFixedSizeCollection(pages, collectionSize);
}
}
public static class ListEvaluationResultsPagedResponse
extends AbstractPagedListResponse<
ListEvaluationResultsRequest,
ListEvaluationResultsResponse,
ListEvaluationResultsResponse.EvaluationResult,
ListEvaluationResultsPage,
ListEvaluationResultsFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext<
ListEvaluationResultsRequest,
ListEvaluationResultsResponse,
ListEvaluationResultsResponse.EvaluationResult>
context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListEvaluationResultsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListEvaluationResultsPagedResponse(input),
MoreExecutors.directExecutor());
}
private ListEvaluationResultsPagedResponse(ListEvaluationResultsPage page) {
super(page, ListEvaluationResultsFixedSizeCollection.createEmptyCollection());
}
}
public static class ListEvaluationResultsPage
extends AbstractPage<
ListEvaluationResultsRequest,
ListEvaluationResultsResponse,
ListEvaluationResultsResponse.EvaluationResult,
ListEvaluationResultsPage> {
private ListEvaluationResultsPage(
PageContext<
ListEvaluationResultsRequest,
ListEvaluationResultsResponse,
ListEvaluationResultsResponse.EvaluationResult>
context,
ListEvaluationResultsResponse response) {
super(context, response);
}
private static ListEvaluationResultsPage createEmptyPage() {
return new ListEvaluationResultsPage(null, null);
}
@Override
protected ListEvaluationResultsPage createPage(
PageContext<
ListEvaluationResultsRequest,
ListEvaluationResultsResponse,
ListEvaluationResultsResponse.EvaluationResult>
context,
ListEvaluationResultsResponse response) {
return new ListEvaluationResultsPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext<
ListEvaluationResultsRequest,
ListEvaluationResultsResponse,
ListEvaluationResultsResponse.EvaluationResult>
context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListEvaluationResultsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListEvaluationResultsRequest,
ListEvaluationResultsResponse,
ListEvaluationResultsResponse.EvaluationResult,
ListEvaluationResultsPage,
ListEvaluationResultsFixedSizeCollection> {
private ListEvaluationResultsFixedSizeCollection(
List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListEvaluationResultsFixedSizeCollection createEmptyCollection() {
return new ListEvaluationResultsFixedSizeCollection(null, 0);
}
@Override
protected ListEvaluationResultsFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListEvaluationResultsFixedSizeCollection(pages, collectionSize);
}
}
}