@Generated(value="by gapic-generator") @BetaApi public class AgentsClient extends Object implements com.google.api.gax.core.BackgroundResource
After you create an agent, you can add [Intents][google.cloud.dialogflow.v2beta1.Intents], [Contexts][google.cloud.dialogflow.v2beta1.Contexts], [Entity Types][google.cloud.dialogflow.v2beta1.EntityTypes], [Webhooks][google.cloud.dialogflow.v2beta1.WebhookRequest], and so on to manage the flow of a conversation and match user input to predefined intents and actions.
You can create an agent using both Dialogflow Standard Edition and Dialogflow Enterprise Edition. For details, see [Dialogflow Editions](https://cloud.google.com/dialogflow/docs/editions).
You can save your agent for backup or versioning by exporting the agent by using the [ExportAgent][google.cloud.dialogflow.v2beta1.Agents.ExportAgent] method. You can import a saved agent by using the [ImportAgent][google.cloud.dialogflow.v2beta1.Agents.ImportAgent] method.
Dialogflow provides several [prebuilt agents](https://cloud.google.com/dialogflow/docs/agents-prebuilt) for common conversation scenarios such as determining a date and time, converting currency, and so on.
For more information about agents, see the [Dialogflow documentation](https://cloud.google.com/dialogflow/docs/agents-overview).
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (AgentsClient agentsClient = AgentsClient.create()) {
Agent agent = Agent.newBuilder().build();
Agent response = agentsClient.setAgent(agent);
}
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().
The surface of this class includes several types of Java methods for each of the API's methods:
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:
AgentsSettings agentsSettings =
AgentsSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
AgentsClient agentsClient =
AgentsClient.create(agentsSettings);
To customize the endpoint:
AgentsSettings agentsSettings =
AgentsSettings.newBuilder().setEndpoint(myEndpoint).build();
AgentsClient agentsClient =
AgentsClient.create(agentsSettings);
Modifier and Type | Class and Description |
---|---|
static class |
AgentsClient.SearchAgentsFixedSizeCollection |
static class |
AgentsClient.SearchAgentsPage |
static class |
AgentsClient.SearchAgentsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
AgentsClient(AgentsSettings settings)
Constructs an instance of AgentsClient, using the given settings.
|
protected |
AgentsClient(AgentsStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static AgentsClient |
create()
Constructs an instance of AgentsClient with default settings.
|
static AgentsClient |
create(AgentsSettings settings)
Constructs an instance of AgentsClient, using the given settings.
|
static AgentsClient |
create(AgentsStub stub)
Constructs an instance of AgentsClient, using the given stub for making calls.
|
void |
deleteAgent(DeleteAgentRequest request)
Deletes the specified agent.
|
void |
deleteAgent(ProjectName parent)
Deletes the specified agent.
|
void |
deleteAgent(String parent)
Deletes the specified agent.
|
com.google.api.gax.rpc.UnaryCallable<DeleteAgentRequest,Empty> |
deleteAgentCallable()
Deletes the specified agent.
|
com.google.api.gax.longrunning.OperationFuture<ExportAgentResponse,Struct> |
exportAgentAsync(ExportAgentRequest request)
Exports the specified agent to a ZIP file.
|
com.google.api.gax.longrunning.OperationFuture<ExportAgentResponse,Struct> |
exportAgentAsync(ProjectName parent)
Exports the specified agent to a ZIP file.
|
com.google.api.gax.longrunning.OperationFuture<ExportAgentResponse,Struct> |
exportAgentAsync(String parent)
Exports the specified agent to a ZIP file.
|
com.google.api.gax.rpc.UnaryCallable<ExportAgentRequest,com.google.longrunning.Operation> |
exportAgentCallable()
Exports the specified agent to a ZIP file.
|
com.google.api.gax.rpc.OperationCallable<ExportAgentRequest,ExportAgentResponse,Struct> |
exportAgentOperationCallable()
Exports the specified agent to a ZIP file.
|
Agent |
getAgent(GetAgentRequest request)
Retrieves the specified agent.
|
Agent |
getAgent(ProjectName parent)
Retrieves the specified agent.
|
Agent |
getAgent(String parent)
Retrieves the specified agent.
|
com.google.api.gax.rpc.UnaryCallable<GetAgentRequest,Agent> |
getAgentCallable()
Retrieves the specified agent.
|
com.google.longrunning.OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
AgentsSettings |
getSettings() |
AgentsStub |
getStub() |
com.google.api.gax.longrunning.OperationFuture<Empty,Struct> |
importAgentAsync(ImportAgentRequest request)
Imports the specified agent from a ZIP file.
|
com.google.api.gax.rpc.UnaryCallable<ImportAgentRequest,com.google.longrunning.Operation> |
importAgentCallable()
Imports the specified agent from a ZIP file.
|
com.google.api.gax.rpc.OperationCallable<ImportAgentRequest,Empty,Struct> |
importAgentOperationCallable()
Imports the specified agent from a ZIP file.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
com.google.api.gax.longrunning.OperationFuture<Empty,Struct> |
restoreAgentAsync(RestoreAgentRequest request)
Restores the specified agent from a ZIP file.
|
com.google.api.gax.rpc.UnaryCallable<RestoreAgentRequest,com.google.longrunning.Operation> |
restoreAgentCallable()
Restores the specified agent from a ZIP file.
|
com.google.api.gax.rpc.OperationCallable<RestoreAgentRequest,Empty,Struct> |
restoreAgentOperationCallable()
Restores the specified agent from a ZIP file.
|
AgentsClient.SearchAgentsPagedResponse |
searchAgents(ProjectName parent)
Returns the list of agents.
|
AgentsClient.SearchAgentsPagedResponse |
searchAgents(SearchAgentsRequest request)
Returns the list of agents.
|
AgentsClient.SearchAgentsPagedResponse |
searchAgents(String parent)
Returns the list of agents.
|
com.google.api.gax.rpc.UnaryCallable<SearchAgentsRequest,SearchAgentsResponse> |
searchAgentsCallable()
Returns the list of agents.
|
com.google.api.gax.rpc.UnaryCallable<SearchAgentsRequest,AgentsClient.SearchAgentsPagedResponse> |
searchAgentsPagedCallable()
Returns the list of agents.
|
Agent |
setAgent(Agent agent)
Creates/updates the specified agent.
|
Agent |
setAgent(SetAgentRequest request)
Creates/updates the specified agent.
|
com.google.api.gax.rpc.UnaryCallable<SetAgentRequest,Agent> |
setAgentCallable()
Creates/updates the specified agent.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.api.gax.longrunning.OperationFuture<Empty,Struct> |
trainAgentAsync(ProjectName parent)
Trains the specified agent.
|
com.google.api.gax.longrunning.OperationFuture<Empty,Struct> |
trainAgentAsync(String parent)
Trains the specified agent.
|
com.google.api.gax.longrunning.OperationFuture<Empty,Struct> |
trainAgentAsync(TrainAgentRequest request)
Trains the specified agent.
|
com.google.api.gax.rpc.UnaryCallable<TrainAgentRequest,com.google.longrunning.Operation> |
trainAgentCallable()
Trains the specified agent.
|
com.google.api.gax.rpc.OperationCallable<TrainAgentRequest,Empty,Struct> |
trainAgentOperationCallable()
Trains the specified agent.
|
protected AgentsClient(AgentsSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected AgentsClient(AgentsStub stub)
public static final AgentsClient create() throws IOException
IOException
public static final AgentsClient create(AgentsSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final AgentsClient create(AgentsStub stub)
public final AgentsSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public AgentsStub getStub()
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.longrunning.OperationsClient getOperationsClient()
public final Agent setAgent(Agent agent)
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
Agent agent = Agent.newBuilder().build();
Agent response = agentsClient.setAgent(agent);
}
agent
- Required. The agent to update.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Agent setAgent(SetAgentRequest request)
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
Agent agent = Agent.newBuilder().build();
SetAgentRequest request = SetAgentRequest.newBuilder()
.setAgent(agent)
.build();
Agent response = agentsClient.setAgent(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<SetAgentRequest,Agent> setAgentCallable()
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
Agent agent = Agent.newBuilder().build();
SetAgentRequest request = SetAgentRequest.newBuilder()
.setAgent(agent)
.build();
ApiFuture<Agent> future = agentsClient.setAgentCallable().futureCall(request);
// Do something
Agent response = future.get();
}
public final void deleteAgent(ProjectName parent)
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
agentsClient.deleteAgent(parent);
}
parent
- Required. The project that the agent to delete is associated with. Format:
`projects/<Project ID>`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final void deleteAgent(String parent)
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
agentsClient.deleteAgent(parent.toString());
}
parent
- Required. The project that the agent to delete is associated with. Format:
`projects/<Project ID>`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final void deleteAgent(DeleteAgentRequest request)
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
DeleteAgentRequest request = DeleteAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
agentsClient.deleteAgent(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeleteAgentRequest,Empty> deleteAgentCallable()
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
DeleteAgentRequest request = DeleteAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<Void> future = agentsClient.deleteAgentCallable().futureCall(request);
// Do something
future.get();
}
public final Agent getAgent(ProjectName parent)
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Agent response = agentsClient.getAgent(parent);
}
parent
- Required. The project that the agent to fetch is associated with. Format:
`projects/<Project ID>`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Agent getAgent(String parent)
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Agent response = agentsClient.getAgent(parent.toString());
}
parent
- Required. The project that the agent to fetch is associated with. Format:
`projects/<Project ID>`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Agent getAgent(GetAgentRequest request)
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
GetAgentRequest request = GetAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
Agent response = agentsClient.getAgent(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetAgentRequest,Agent> getAgentCallable()
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
GetAgentRequest request = GetAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<Agent> future = agentsClient.getAgentCallable().futureCall(request);
// Do something
Agent response = future.get();
}
public final AgentsClient.SearchAgentsPagedResponse searchAgents(ProjectName parent)
Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id "-". Refer to [List Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections).
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (Agent element : agentsClient.searchAgents(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The project to list agents from. Format: `projects/<Project ID or
'-'>`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final AgentsClient.SearchAgentsPagedResponse searchAgents(String parent)
Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id "-". Refer to [List Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections).
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (Agent element : agentsClient.searchAgents(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The project to list agents from. Format: `projects/<Project ID or
'-'>`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final AgentsClient.SearchAgentsPagedResponse searchAgents(SearchAgentsRequest request)
Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id "-". Refer to [List Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections).
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
SearchAgentsRequest request = SearchAgentsRequest.newBuilder()
.setParent(parent.toString())
.build();
for (Agent element : agentsClient.searchAgents(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<SearchAgentsRequest,AgentsClient.SearchAgentsPagedResponse> searchAgentsPagedCallable()
Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id "-". Refer to [List Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections).
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
SearchAgentsRequest request = SearchAgentsRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<SearchAgentsPagedResponse> future = agentsClient.searchAgentsPagedCallable().futureCall(request);
// Do something
for (Agent element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<SearchAgentsRequest,SearchAgentsResponse> searchAgentsCallable()
Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id "-". Refer to [List Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections).
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
SearchAgentsRequest request = SearchAgentsRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
SearchAgentsResponse response = agentsClient.searchAgentsCallable().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;
}
}
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Empty,Struct> trainAgentAsync(ProjectName parent)
Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
agentsClient.trainAgentAsync(parent).get();
}
parent
- Required. The project that the agent to train is associated with. Format:
`projects/<Project ID>`.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Empty,Struct> trainAgentAsync(String parent)
Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
agentsClient.trainAgentAsync(parent.toString()).get();
}
parent
- Required. The project that the agent to train is associated with. Format:
`projects/<Project ID>`.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Empty,Struct> trainAgentAsync(TrainAgentRequest request)
Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
TrainAgentRequest request = TrainAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
agentsClient.trainAgentAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final com.google.api.gax.rpc.OperationCallable<TrainAgentRequest,Empty,Struct> trainAgentOperationCallable()
Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
TrainAgentRequest request = TrainAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
OperationFuture<Empty, Struct> future = agentsClient.trainAgentOperationCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<TrainAgentRequest,com.google.longrunning.Operation> trainAgentCallable()
Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
TrainAgentRequest request = TrainAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<Operation> future = agentsClient.trainAgentCallable().futureCall(request);
// Do something
future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<ExportAgentResponse,Struct> exportAgentAsync(ProjectName parent)
Operation <response: [ExportAgentResponse][google.cloud.dialogflow.v2beta1.ExportAgentResponse]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ExportAgentResponse response = agentsClient.exportAgentAsync(parent).get();
}
parent
- Required. The project that the agent to export is associated with. Format:
`projects/<Project ID>`.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<ExportAgentResponse,Struct> exportAgentAsync(String parent)
Operation <response: [ExportAgentResponse][google.cloud.dialogflow.v2beta1.ExportAgentResponse]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ExportAgentResponse response = agentsClient.exportAgentAsync(parent.toString()).get();
}
parent
- Required. The project that the agent to export is associated with. Format:
`projects/<Project ID>`.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<ExportAgentResponse,Struct> exportAgentAsync(ExportAgentRequest request)
Operation <response: [ExportAgentResponse][google.cloud.dialogflow.v2beta1.ExportAgentResponse]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ExportAgentRequest request = ExportAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
ExportAgentResponse response = agentsClient.exportAgentAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final com.google.api.gax.rpc.OperationCallable<ExportAgentRequest,ExportAgentResponse,Struct> exportAgentOperationCallable()
Operation <response: [ExportAgentResponse][google.cloud.dialogflow.v2beta1.ExportAgentResponse]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ExportAgentRequest request = ExportAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
OperationFuture<ExportAgentResponse, Struct> future = agentsClient.exportAgentOperationCallable().futureCall(request);
// Do something
ExportAgentResponse response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<ExportAgentRequest,com.google.longrunning.Operation> exportAgentCallable()
Operation <response: [ExportAgentResponse][google.cloud.dialogflow.v2beta1.ExportAgentResponse]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ExportAgentRequest request = ExportAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<Operation> future = agentsClient.exportAgentCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Empty,Struct> importAgentAsync(ImportAgentRequest request)
Uploads new intents and entity types without deleting the existing ones. Intents and entity types with the same name are replaced with the new versions from ImportAgentRequest.
Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ImportAgentRequest request = ImportAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
agentsClient.importAgentAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final com.google.api.gax.rpc.OperationCallable<ImportAgentRequest,Empty,Struct> importAgentOperationCallable()
Uploads new intents and entity types without deleting the existing ones. Intents and entity types with the same name are replaced with the new versions from ImportAgentRequest.
Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ImportAgentRequest request = ImportAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
OperationFuture<Empty, Struct> future = agentsClient.importAgentOperationCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<ImportAgentRequest,com.google.longrunning.Operation> importAgentCallable()
Uploads new intents and entity types without deleting the existing ones. Intents and entity types with the same name are replaced with the new versions from ImportAgentRequest.
Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ImportAgentRequest request = ImportAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<Operation> future = agentsClient.importAgentCallable().futureCall(request);
// Do something
future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Empty,Struct> restoreAgentAsync(RestoreAgentRequest request)
Replaces the current agent version with a new one. All the intents and entity types in the older version are deleted.
Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
RestoreAgentRequest request = RestoreAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
agentsClient.restoreAgentAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final com.google.api.gax.rpc.OperationCallable<RestoreAgentRequest,Empty,Struct> restoreAgentOperationCallable()
Replaces the current agent version with a new one. All the intents and entity types in the older version are deleted.
Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
RestoreAgentRequest request = RestoreAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
OperationFuture<Empty, Struct> future = agentsClient.restoreAgentOperationCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<RestoreAgentRequest,com.google.longrunning.Operation> restoreAgentCallable()
Replaces the current agent version with a new one. All the intents and entity types in the older version are deleted.
Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
RestoreAgentRequest request = RestoreAgentRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<Operation> future = agentsClient.restoreAgentCallable().futureCall(request);
// Do something
future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.