
com.google.cloud.dialogflow.cx.v3.AgentsClient Maven / Gradle / Ivy
/*
* 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.dialogflow.cx.v3;
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.dialogflow.cx.v3.stub.AgentsStub;
import com.google.cloud.dialogflow.cx.v3.stub.AgentsStubSettings;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.cloud.location.Location;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.longrunning.Operation;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import com.google.protobuf.Struct;
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 [Agents][google.cloud.dialogflow.cx.v3.Agent].
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* AgentName name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
* Agent response = agentsClient.getAgent(name);
* }
* }
*
* Note: close() needs to be called on the AgentsClient 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
*
*
* ListAgents
* Returns the list of all agents in the specified location.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* listAgents(ListAgentsRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* listAgents(LocationName parent)
*
listAgents(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.
*
* listAgentsPagedCallable()
*
listAgentsCallable()
*
*
*
*
* GetAgent
* Retrieves the specified agent.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* getAgent(GetAgentRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* getAgent(AgentName name)
*
getAgent(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.
*
* getAgentCallable()
*
*
*
*
* CreateAgent
* Creates an agent in the specified location.
*
Note: You should always train flows prior to sending them queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* createAgent(CreateAgentRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* createAgent(LocationName parent, Agent agent)
*
createAgent(String parent, Agent agent)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* createAgentCallable()
*
*
*
*
* UpdateAgent
* Updates the specified agent.
*
Note: You should always train flows prior to sending them queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* updateAgent(UpdateAgentRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* updateAgent(Agent agent, FieldMask updateMask)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* updateAgentCallable()
*
*
*
*
* DeleteAgent
* Deletes the specified agent.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* deleteAgent(DeleteAgentRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* deleteAgent(AgentName name)
*
deleteAgent(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.
*
* deleteAgentCallable()
*
*
*
*
* ExportAgent
* Exports the specified agent to a binary file.
*
This method is a [long-running operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The returned `Operation` type has the following method-specific fields:
*
- `metadata`: An empty [Struct message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - `response`: [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse]
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* exportAgentAsync(ExportAgentRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* exportAgentOperationCallable()
*
exportAgentCallable()
*
*
*
*
* RestoreAgent
* Restores the specified agent from a binary file.
*
Replaces the current agent with a new one. Note that all existing resources in agent (e.g. intents, entity types, flows) will be removed.
*
This method is a [long-running operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The returned `Operation` type has the following method-specific fields:
*
- `metadata`: An empty [Struct message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - `response`: An [Empty message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
*
Note: You should always train flows prior to sending them queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* restoreAgentAsync(RestoreAgentRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* restoreAgentOperationCallable()
*
restoreAgentCallable()
*
*
*
*
* ValidateAgent
* Validates the specified agent and creates or updates validation results. The agent in draft version is validated. Please call this API after the training is completed to get the complete validation results.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* validateAgent(ValidateAgentRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* validateAgentCallable()
*
*
*
*
* GetAgentValidationResult
* Gets the latest agent validation result. Agent validation is performed when ValidateAgent is called.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* getAgentValidationResult(GetAgentValidationResultRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* getAgentValidationResult(AgentValidationResultName name)
*
getAgentValidationResult(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.
*
* getAgentValidationResultCallable()
*
*
*
*
* GetGenerativeSettings
* Gets the generative settings for the agent.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* getGenerativeSettings(GetGenerativeSettingsRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* getGenerativeSettings(AgentGenerativeSettingsName name, String languageCode)
*
getGenerativeSettings(String name, String languageCode)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* getGenerativeSettingsCallable()
*
*
*
*
* UpdateGenerativeSettings
* Updates the generative settings for the agent.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* updateGenerativeSettings(UpdateGenerativeSettingsRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* updateGenerativeSettings(GenerativeSettings generativeSettings, FieldMask updateMask)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* updateGenerativeSettingsCallable()
*
*
*
*
* ListLocations
* Lists information about the supported locations for this service.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* listLocations(ListLocationsRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* listLocationsPagedCallable()
*
listLocationsCallable()
*
*
*
*
* GetLocation
* Gets information about a location.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* getLocation(GetLocationRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* getLocationCallable()
*
*
*
*
*
* 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 AgentsSettings 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
* AgentsSettings agentsSettings =
* AgentsSettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* AgentsClient agentsClient = AgentsClient.create(agentsSettings);
* }
*
* 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
* AgentsSettings agentsSettings = AgentsSettings.newBuilder().setEndpoint(myEndpoint).build();
* AgentsClient agentsClient = AgentsClient.create(agentsSettings);
* }
*
* 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
* AgentsSettings agentsSettings = AgentsSettings.newHttpJsonBuilder().build();
* AgentsClient agentsClient = AgentsClient.create(agentsSettings);
* }
*
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class AgentsClient implements BackgroundResource {
private final AgentsSettings settings;
private final AgentsStub stub;
private final OperationsClient httpJsonOperationsClient;
private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of AgentsClient with default settings. */
public static final AgentsClient create() throws IOException {
return create(AgentsSettings.newBuilder().build());
}
/**
* Constructs an instance of AgentsClient, 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 AgentsClient create(AgentsSettings settings) throws IOException {
return new AgentsClient(settings);
}
/**
* Constructs an instance of AgentsClient, using the given stub for making calls. This is for
* advanced usage - prefer using create(AgentsSettings).
*/
public static final AgentsClient create(AgentsStub stub) {
return new AgentsClient(stub);
}
/**
* Constructs an instance of AgentsClient, 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 AgentsClient(AgentsSettings settings) throws IOException {
this.settings = settings;
this.stub = ((AgentsStubSettings) settings.getStubSettings()).createStub();
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
protected AgentsClient(AgentsStub 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 AgentsSettings getSettings() {
return settings;
}
public AgentsStub 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.
/**
* Returns the list of all agents in the specified location.
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* for (Agent element : agentsClient.listAgents(parent).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*
* @param parent Required. The location to list all agents for. Format:
* `projects/<ProjectID>/locations/<LocationID>`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListAgentsPagedResponse listAgents(LocationName parent) {
ListAgentsRequest request =
ListAgentsRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build();
return listAgents(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns the list of all agents in the specified location.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
* for (Agent element : agentsClient.listAgents(parent).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*
* @param parent Required. The location to list all agents for. Format:
* `projects/<ProjectID>/locations/<LocationID>`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListAgentsPagedResponse listAgents(String parent) {
ListAgentsRequest request = ListAgentsRequest.newBuilder().setParent(parent).build();
return listAgents(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns the list of all agents in the specified location.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* ListAgentsRequest request =
* ListAgentsRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* for (Agent element : agentsClient.listAgents(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 ListAgentsPagedResponse listAgents(ListAgentsRequest request) {
return listAgentsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns the list of all agents in the specified location.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* ListAgentsRequest request =
* ListAgentsRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* ApiFuture future = agentsClient.listAgentsPagedCallable().futureCall(request);
* // Do something.
* for (Agent element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable listAgentsPagedCallable() {
return stub.listAgentsPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns the list of all agents in the specified location.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* ListAgentsRequest request =
* ListAgentsRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* while (true) {
* ListAgentsResponse response = agentsClient.listAgentsCallable().call(request);
* for (Agent element : response.getAgentsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* }
*/
public final UnaryCallable listAgentsCallable() {
return stub.listAgentsCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Retrieves the specified agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* AgentName name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
* Agent response = agentsClient.getAgent(name);
* }
* }
*
* @param name Required. The name of the agent. Format:
* `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Agent getAgent(AgentName name) {
GetAgentRequest request =
GetAgentRequest.newBuilder().setName(name == null ? null : name.toString()).build();
return getAgent(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Retrieves the specified agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* String name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
* Agent response = agentsClient.getAgent(name);
* }
* }
*
* @param name Required. The name of the agent. Format:
* `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Agent getAgent(String name) {
GetAgentRequest request = GetAgentRequest.newBuilder().setName(name).build();
return getAgent(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Retrieves the specified agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* GetAgentRequest request =
* GetAgentRequest.newBuilder()
* .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .build();
* Agent response = agentsClient.getAgent(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 Agent getAgent(GetAgentRequest request) {
return getAgentCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Retrieves the specified agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* GetAgentRequest request =
* GetAgentRequest.newBuilder()
* .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .build();
* ApiFuture future = agentsClient.getAgentCallable().futureCall(request);
* // Do something.
* Agent response = future.get();
* }
* }
*/
public final UnaryCallable getAgentCallable() {
return stub.getAgentCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates an agent in the specified location.
*
* Note: You should always train flows prior to sending them queries. See the [training
* documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* Agent agent = Agent.newBuilder().build();
* Agent response = agentsClient.createAgent(parent, agent);
* }
* }
*
* @param parent Required. The location to create a agent for. Format:
* `projects/<ProjectID>/locations/<LocationID>`.
* @param agent Required. The agent to create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Agent createAgent(LocationName parent, Agent agent) {
CreateAgentRequest request =
CreateAgentRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setAgent(agent)
.build();
return createAgent(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates an agent in the specified location.
*
* Note: You should always train flows prior to sending them queries. See the [training
* documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
* Agent agent = Agent.newBuilder().build();
* Agent response = agentsClient.createAgent(parent, agent);
* }
* }
*
* @param parent Required. The location to create a agent for. Format:
* `projects/<ProjectID>/locations/<LocationID>`.
* @param agent Required. The agent to create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Agent createAgent(String parent, Agent agent) {
CreateAgentRequest request =
CreateAgentRequest.newBuilder().setParent(parent).setAgent(agent).build();
return createAgent(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates an agent in the specified location.
*
* Note: You should always train flows prior to sending them queries. See the [training
* documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* CreateAgentRequest request =
* CreateAgentRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setAgent(Agent.newBuilder().build())
* .build();
* Agent response = agentsClient.createAgent(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 Agent createAgent(CreateAgentRequest request) {
return createAgentCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates an agent in the specified location.
*
* Note: You should always train flows prior to sending them queries. See the [training
* documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* CreateAgentRequest request =
* CreateAgentRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setAgent(Agent.newBuilder().build())
* .build();
* ApiFuture future = agentsClient.createAgentCallable().futureCall(request);
* // Do something.
* Agent response = future.get();
* }
* }
*/
public final UnaryCallable createAgentCallable() {
return stub.createAgentCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates the specified agent.
*
* Note: You should always train flows prior to sending them queries. See the [training
* documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* Agent agent = Agent.newBuilder().build();
* FieldMask updateMask = FieldMask.newBuilder().build();
* Agent response = agentsClient.updateAgent(agent, updateMask);
* }
* }
*
* @param agent Required. The agent to update.
* @param updateMask The mask to control which fields get updated. If the mask is not present, all
* fields will be updated.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Agent updateAgent(Agent agent, FieldMask updateMask) {
UpdateAgentRequest request =
UpdateAgentRequest.newBuilder().setAgent(agent).setUpdateMask(updateMask).build();
return updateAgent(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates the specified agent.
*
* Note: You should always train flows prior to sending them queries. See the [training
* documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* UpdateAgentRequest request =
* UpdateAgentRequest.newBuilder()
* .setAgent(Agent.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* Agent response = agentsClient.updateAgent(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 Agent updateAgent(UpdateAgentRequest request) {
return updateAgentCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates the specified agent.
*
* Note: You should always train flows prior to sending them queries. See the [training
* documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* UpdateAgentRequest request =
* UpdateAgentRequest.newBuilder()
* .setAgent(Agent.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* ApiFuture future = agentsClient.updateAgentCallable().futureCall(request);
* // Do something.
* Agent response = future.get();
* }
* }
*/
public final UnaryCallable updateAgentCallable() {
return stub.updateAgentCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the specified agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* AgentName name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
* agentsClient.deleteAgent(name);
* }
* }
*
* @param name Required. The name of the agent to delete. Format:
* `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteAgent(AgentName name) {
DeleteAgentRequest request =
DeleteAgentRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteAgent(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the specified agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* String name = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
* agentsClient.deleteAgent(name);
* }
* }
*
* @param name Required. The name of the agent to delete. Format:
* `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteAgent(String name) {
DeleteAgentRequest request = DeleteAgentRequest.newBuilder().setName(name).build();
deleteAgent(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the specified agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* DeleteAgentRequest request =
* DeleteAgentRequest.newBuilder()
* .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .build();
* agentsClient.deleteAgent(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 void deleteAgent(DeleteAgentRequest request) {
deleteAgentCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the specified agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* DeleteAgentRequest request =
* DeleteAgentRequest.newBuilder()
* .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .build();
* ApiFuture future = agentsClient.deleteAgentCallable().futureCall(request);
* // Do something.
* future.get();
* }
* }
*/
public final UnaryCallable deleteAgentCallable() {
return stub.deleteAgentCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Exports the specified agent to a binary file.
*
* This method is a [long-running
* operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
* returned `Operation` type has the following method-specific fields:
*
*
- `metadata`: An empty [Struct
* message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
* - `response`: [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse]
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* ExportAgentRequest request =
* ExportAgentRequest.newBuilder()
* .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .setAgentUri("agentUri1469149223")
* .setEnvironment(
* EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]")
* .toString())
* .setGitDestination(ExportAgentRequest.GitDestination.newBuilder().build())
* .setIncludeBigqueryExportSettings(true)
* .build();
* ExportAgentResponse response = agentsClient.exportAgentAsync(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 exportAgentAsync(
ExportAgentRequest request) {
return exportAgentOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Exports the specified agent to a binary file.
*
* This method is a [long-running
* operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
* returned `Operation` type has the following method-specific fields:
*
*
- `metadata`: An empty [Struct
* message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
* - `response`: [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse]
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* ExportAgentRequest request =
* ExportAgentRequest.newBuilder()
* .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .setAgentUri("agentUri1469149223")
* .setEnvironment(
* EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]")
* .toString())
* .setGitDestination(ExportAgentRequest.GitDestination.newBuilder().build())
* .setIncludeBigqueryExportSettings(true)
* .build();
* OperationFuture future =
* agentsClient.exportAgentOperationCallable().futureCall(request);
* // Do something.
* ExportAgentResponse response = future.get();
* }
* }
*/
public final OperationCallable
exportAgentOperationCallable() {
return stub.exportAgentOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Exports the specified agent to a binary file.
*
* This method is a [long-running
* operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
* returned `Operation` type has the following method-specific fields:
*
*
- `metadata`: An empty [Struct
* message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
* - `response`: [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse]
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* ExportAgentRequest request =
* ExportAgentRequest.newBuilder()
* .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .setAgentUri("agentUri1469149223")
* .setEnvironment(
* EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]")
* .toString())
* .setGitDestination(ExportAgentRequest.GitDestination.newBuilder().build())
* .setIncludeBigqueryExportSettings(true)
* .build();
* ApiFuture future = agentsClient.exportAgentCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable exportAgentCallable() {
return stub.exportAgentCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Restores the specified agent from a binary file.
*
* Replaces the current agent with a new one. Note that all existing resources in agent (e.g.
* intents, entity types, flows) will be removed.
*
*
This method is a [long-running
* operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
* returned `Operation` type has the following method-specific fields:
*
*
- `metadata`: An empty [Struct
* message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
* - `response`: An [Empty
* message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
*
*
Note: You should always train flows prior to sending them queries. See the [training
* documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* RestoreAgentRequest request =
* RestoreAgentRequest.newBuilder()
* .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .build();
* agentsClient.restoreAgentAsync(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 restoreAgentAsync(RestoreAgentRequest request) {
return restoreAgentOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Restores the specified agent from a binary file.
*
* Replaces the current agent with a new one. Note that all existing resources in agent (e.g.
* intents, entity types, flows) will be removed.
*
*
This method is a [long-running
* operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
* returned `Operation` type has the following method-specific fields:
*
*
- `metadata`: An empty [Struct
* message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
* - `response`: An [Empty
* message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
*
*
Note: You should always train flows prior to sending them queries. See the [training
* documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* RestoreAgentRequest request =
* RestoreAgentRequest.newBuilder()
* .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .build();
* OperationFuture future =
* agentsClient.restoreAgentOperationCallable().futureCall(request);
* // Do something.
* future.get();
* }
* }
*/
public final OperationCallable
restoreAgentOperationCallable() {
return stub.restoreAgentOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Restores the specified agent from a binary file.
*
* Replaces the current agent with a new one. Note that all existing resources in agent (e.g.
* intents, entity types, flows) will be removed.
*
*
This method is a [long-running
* operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The
* returned `Operation` type has the following method-specific fields:
*
*
- `metadata`: An empty [Struct
* message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
* - `response`: An [Empty
* message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)
*
*
Note: You should always train flows prior to sending them queries. See the [training
* documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).
*
*
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 (AgentsClient agentsClient = AgentsClient.create()) {
* RestoreAgentRequest request =
* RestoreAgentRequest.newBuilder()
* .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .build();
* ApiFuture future = agentsClient.restoreAgentCallable().futureCall(request);
* // Do something.
* future.get();
* }
* }
*/
public final UnaryCallable restoreAgentCallable() {
return stub.restoreAgentCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Validates the specified agent and creates or updates validation results. The agent in draft
* version is validated. Please call this API after the training is completed to get the complete
* validation results.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* ValidateAgentRequest request =
* ValidateAgentRequest.newBuilder()
* .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .setLanguageCode("languageCode-2092349083")
* .build();
* AgentValidationResult response = agentsClient.validateAgent(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 AgentValidationResult validateAgent(ValidateAgentRequest request) {
return validateAgentCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Validates the specified agent and creates or updates validation results. The agent in draft
* version is validated. Please call this API after the training is completed to get the complete
* validation results.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* ValidateAgentRequest request =
* ValidateAgentRequest.newBuilder()
* .setName(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .setLanguageCode("languageCode-2092349083")
* .build();
* ApiFuture future =
* agentsClient.validateAgentCallable().futureCall(request);
* // Do something.
* AgentValidationResult response = future.get();
* }
* }
*/
public final UnaryCallable validateAgentCallable() {
return stub.validateAgentCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the latest agent validation result. Agent validation is performed when ValidateAgent is
* called.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* AgentValidationResultName name =
* AgentValidationResultName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
* AgentValidationResult response = agentsClient.getAgentValidationResult(name);
* }
* }
*
* @param name Required. The agent name. Format:
* `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/validationResult`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AgentValidationResult getAgentValidationResult(AgentValidationResultName name) {
GetAgentValidationResultRequest request =
GetAgentValidationResultRequest.newBuilder()
.setName(name == null ? null : name.toString())
.build();
return getAgentValidationResult(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the latest agent validation result. Agent validation is performed when ValidateAgent is
* called.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* String name = AgentValidationResultName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
* AgentValidationResult response = agentsClient.getAgentValidationResult(name);
* }
* }
*
* @param name Required. The agent name. Format:
* `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/validationResult`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AgentValidationResult getAgentValidationResult(String name) {
GetAgentValidationResultRequest request =
GetAgentValidationResultRequest.newBuilder().setName(name).build();
return getAgentValidationResult(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the latest agent validation result. Agent validation is performed when ValidateAgent is
* called.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* GetAgentValidationResultRequest request =
* GetAgentValidationResultRequest.newBuilder()
* .setName(
* AgentValidationResultName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .setLanguageCode("languageCode-2092349083")
* .build();
* AgentValidationResult response = agentsClient.getAgentValidationResult(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 AgentValidationResult getAgentValidationResult(
GetAgentValidationResultRequest request) {
return getAgentValidationResultCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the latest agent validation result. Agent validation is performed when ValidateAgent is
* called.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* GetAgentValidationResultRequest request =
* GetAgentValidationResultRequest.newBuilder()
* .setName(
* AgentValidationResultName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .setLanguageCode("languageCode-2092349083")
* .build();
* ApiFuture future =
* agentsClient.getAgentValidationResultCallable().futureCall(request);
* // Do something.
* AgentValidationResult response = future.get();
* }
* }
*/
public final UnaryCallable
getAgentValidationResultCallable() {
return stub.getAgentValidationResultCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the generative settings for the agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* AgentGenerativeSettingsName name =
* AgentGenerativeSettingsName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
* String languageCode = "languageCode-2092349083";
* GenerativeSettings response = agentsClient.getGenerativeSettings(name, languageCode);
* }
* }
*
* @param name Required. Format:
* `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/generativeSettings`.
* @param languageCode Required. Language code of the generative settings.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final GenerativeSettings getGenerativeSettings(
AgentGenerativeSettingsName name, String languageCode) {
GetGenerativeSettingsRequest request =
GetGenerativeSettingsRequest.newBuilder()
.setName(name == null ? null : name.toString())
.setLanguageCode(languageCode)
.build();
return getGenerativeSettings(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the generative settings for the agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* String name = AgentGenerativeSettingsName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
* String languageCode = "languageCode-2092349083";
* GenerativeSettings response = agentsClient.getGenerativeSettings(name, languageCode);
* }
* }
*
* @param name Required. Format:
* `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/generativeSettings`.
* @param languageCode Required. Language code of the generative settings.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final GenerativeSettings getGenerativeSettings(String name, String languageCode) {
GetGenerativeSettingsRequest request =
GetGenerativeSettingsRequest.newBuilder()
.setName(name)
.setLanguageCode(languageCode)
.build();
return getGenerativeSettings(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the generative settings for the agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* GetGenerativeSettingsRequest request =
* GetGenerativeSettingsRequest.newBuilder()
* .setName(
* AgentGenerativeSettingsName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .setLanguageCode("languageCode-2092349083")
* .build();
* GenerativeSettings response = agentsClient.getGenerativeSettings(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 GenerativeSettings getGenerativeSettings(GetGenerativeSettingsRequest request) {
return getGenerativeSettingsCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the generative settings for the agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* GetGenerativeSettingsRequest request =
* GetGenerativeSettingsRequest.newBuilder()
* .setName(
* AgentGenerativeSettingsName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
* .setLanguageCode("languageCode-2092349083")
* .build();
* ApiFuture future =
* agentsClient.getGenerativeSettingsCallable().futureCall(request);
* // Do something.
* GenerativeSettings response = future.get();
* }
* }
*/
public final UnaryCallable
getGenerativeSettingsCallable() {
return stub.getGenerativeSettingsCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates the generative settings for the agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* GenerativeSettings generativeSettings = GenerativeSettings.newBuilder().build();
* FieldMask updateMask = FieldMask.newBuilder().build();
* GenerativeSettings response =
* agentsClient.updateGenerativeSettings(generativeSettings, updateMask);
* }
* }
*
* @param generativeSettings Required. Generative settings to update.
* @param updateMask Optional. The mask to control which fields get updated. If the mask is not
* present, all fields will be updated.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final GenerativeSettings updateGenerativeSettings(
GenerativeSettings generativeSettings, FieldMask updateMask) {
UpdateGenerativeSettingsRequest request =
UpdateGenerativeSettingsRequest.newBuilder()
.setGenerativeSettings(generativeSettings)
.setUpdateMask(updateMask)
.build();
return updateGenerativeSettings(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates the generative settings for the agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* UpdateGenerativeSettingsRequest request =
* UpdateGenerativeSettingsRequest.newBuilder()
* .setGenerativeSettings(GenerativeSettings.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* GenerativeSettings response = agentsClient.updateGenerativeSettings(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 GenerativeSettings updateGenerativeSettings(
UpdateGenerativeSettingsRequest request) {
return updateGenerativeSettingsCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates the generative settings for the agent.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* UpdateGenerativeSettingsRequest request =
* UpdateGenerativeSettingsRequest.newBuilder()
* .setGenerativeSettings(GenerativeSettings.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* ApiFuture future =
* agentsClient.updateGenerativeSettingsCallable().futureCall(request);
* // Do something.
* GenerativeSettings response = future.get();
* }
* }
*/
public final UnaryCallable
updateGenerativeSettingsCallable() {
return stub.updateGenerativeSettingsCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* ListLocationsRequest request =
* ListLocationsRequest.newBuilder()
* .setName("name3373707")
* .setFilter("filter-1274492040")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* for (Location element : agentsClient.listLocations(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 ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
return listLocationsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* ListLocationsRequest request =
* ListLocationsRequest.newBuilder()
* .setName("name3373707")
* .setFilter("filter-1274492040")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* ApiFuture future = agentsClient.listLocationsPagedCallable().futureCall(request);
* // Do something.
* for (Location element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable
listLocationsPagedCallable() {
return stub.listLocationsPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* ListLocationsRequest request =
* ListLocationsRequest.newBuilder()
* .setName("name3373707")
* .setFilter("filter-1274492040")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* while (true) {
* ListLocationsResponse response = agentsClient.listLocationsCallable().call(request);
* for (Location element : response.getLocationsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* }
*/
public final UnaryCallable listLocationsCallable() {
return stub.listLocationsCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets information about a location.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
* Location response = agentsClient.getLocation(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 Location getLocation(GetLocationRequest request) {
return getLocationCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets information about a location.
*
* 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 (AgentsClient agentsClient = AgentsClient.create()) {
* GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
* ApiFuture future = agentsClient.getLocationCallable().futureCall(request);
* // Do something.
* Location response = future.get();
* }
* }
*/
public final UnaryCallable getLocationCallable() {
return stub.getLocationCallable();
}
@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 ListAgentsPagedResponse
extends AbstractPagedListResponse<
ListAgentsRequest,
ListAgentsResponse,
Agent,
ListAgentsPage,
ListAgentsFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListAgentsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage, input -> new ListAgentsPagedResponse(input), MoreExecutors.directExecutor());
}
private ListAgentsPagedResponse(ListAgentsPage page) {
super(page, ListAgentsFixedSizeCollection.createEmptyCollection());
}
}
public static class ListAgentsPage
extends AbstractPage {
private ListAgentsPage(
PageContext context,
ListAgentsResponse response) {
super(context, response);
}
private static ListAgentsPage createEmptyPage() {
return new ListAgentsPage(null, null);
}
@Override
protected ListAgentsPage createPage(
PageContext context,
ListAgentsResponse response) {
return new ListAgentsPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListAgentsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListAgentsRequest,
ListAgentsResponse,
Agent,
ListAgentsPage,
ListAgentsFixedSizeCollection> {
private ListAgentsFixedSizeCollection(List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListAgentsFixedSizeCollection createEmptyCollection() {
return new ListAgentsFixedSizeCollection(null, 0);
}
@Override
protected ListAgentsFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListAgentsFixedSizeCollection(pages, collectionSize);
}
}
public static class ListLocationsPagedResponse
extends AbstractPagedListResponse<
ListLocationsRequest,
ListLocationsResponse,
Location,
ListLocationsPage,
ListLocationsFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListLocationsPagedResponse(input),
MoreExecutors.directExecutor());
}
private ListLocationsPagedResponse(ListLocationsPage page) {
super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
}
}
public static class ListLocationsPage
extends AbstractPage<
ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
private ListLocationsPage(
PageContext context,
ListLocationsResponse response) {
super(context, response);
}
private static ListLocationsPage createEmptyPage() {
return new ListLocationsPage(null, null);
}
@Override
protected ListLocationsPage createPage(
PageContext context,
ListLocationsResponse response) {
return new ListLocationsPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListLocationsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListLocationsRequest,
ListLocationsResponse,
Location,
ListLocationsPage,
ListLocationsFixedSizeCollection> {
private ListLocationsFixedSizeCollection(List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListLocationsFixedSizeCollection createEmptyCollection() {
return new ListLocationsFixedSizeCollection(null, 0);
}
@Override
protected ListLocationsFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListLocationsFixedSizeCollection(pages, collectionSize);
}
}
}