@Generated(value="by GAPIC v0.0.5") @BetaApi public class AgentsClient extends Object implements com.google.api.gax.core.BackgroundResource
Refer to [documentation](https://dialogflow.com/docs/agents) for more details # about agents.
Standard methods.
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()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Agent response = agentsClient.getAgent(parent);
}
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 | 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.
|
com.google.api.gax.longrunning.OperationFuture<com.google.cloud.dialogflow.v2beta1.ExportAgentResponse,com.google.protobuf.Struct> |
exportAgentAsync(com.google.cloud.dialogflow.v2beta1.ExportAgentRequest request)
Exports the specified agent to a ZIP file.
|
com.google.api.gax.longrunning.OperationFuture<com.google.cloud.dialogflow.v2beta1.ExportAgentResponse,com.google.protobuf.Struct> |
exportAgentAsync(com.google.cloud.dialogflow.v2beta1.ProjectName parent)
Exports the specified agent to a ZIP file.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.ExportAgentRequest,com.google.longrunning.Operation> |
exportAgentCallable()
Exports the specified agent to a ZIP file.
|
com.google.api.gax.rpc.OperationCallable<com.google.cloud.dialogflow.v2beta1.ExportAgentRequest,com.google.cloud.dialogflow.v2beta1.ExportAgentResponse,com.google.protobuf.Struct> |
exportAgentOperationCallable()
Exports the specified agent to a ZIP file.
|
com.google.cloud.dialogflow.v2beta1.Agent |
getAgent(com.google.cloud.dialogflow.v2beta1.ProjectName parent)
Retrieves the specified agent.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.GetAgentRequest,com.google.cloud.dialogflow.v2beta1.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<com.google.protobuf.Empty,com.google.protobuf.Struct> |
importAgentAsync(com.google.cloud.dialogflow.v2beta1.ImportAgentRequest request)
Imports the specified agent from a ZIP file.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.ImportAgentRequest,com.google.longrunning.Operation> |
importAgentCallable()
Imports the specified agent from a ZIP file.
|
com.google.api.gax.rpc.OperationCallable<com.google.cloud.dialogflow.v2beta1.ImportAgentRequest,com.google.protobuf.Empty,com.google.protobuf.Struct> |
importAgentOperationCallable()
Imports the specified agent from a ZIP file.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.protobuf.Struct> |
restoreAgentAsync(com.google.cloud.dialogflow.v2beta1.RestoreAgentRequest request)
Restores the specified agent from a ZIP file.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.RestoreAgentRequest,com.google.longrunning.Operation> |
restoreAgentCallable()
Restores the specified agent from a ZIP file.
|
com.google.api.gax.rpc.OperationCallable<com.google.cloud.dialogflow.v2beta1.RestoreAgentRequest,com.google.protobuf.Empty,com.google.protobuf.Struct> |
restoreAgentOperationCallable()
Restores the specified agent from a ZIP file.
|
PagedResponseWrappers.SearchAgentsPagedResponse |
searchAgents(com.google.cloud.dialogflow.v2beta1.ProjectName parent)
Returns the list of agents.
|
PagedResponseWrappers.SearchAgentsPagedResponse |
searchAgents(com.google.cloud.dialogflow.v2beta1.SearchAgentsRequest request)
Returns the list of agents.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.SearchAgentsRequest,com.google.cloud.dialogflow.v2beta1.SearchAgentsResponse> |
searchAgentsCallable()
Returns the list of agents.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.SearchAgentsRequest,PagedResponseWrappers.SearchAgentsPagedResponse> |
searchAgentsPagedCallable()
Returns the list of agents.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.protobuf.Struct> |
trainAgentAsync(com.google.cloud.dialogflow.v2beta1.ProjectName parent)
Trains the specified agent.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.TrainAgentRequest,com.google.longrunning.Operation> |
trainAgentCallable()
Trains the specified agent.
|
com.google.api.gax.rpc.OperationCallable<com.google.cloud.dialogflow.v2beta1.TrainAgentRequest,com.google.protobuf.Empty,com.google.protobuf.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
IOExceptionpublic 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()
public final com.google.longrunning.OperationsClient getOperationsClient()
public final com.google.cloud.dialogflow.v2beta1.Agent getAgent(com.google.cloud.dialogflow.v2beta1.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 com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.GetAgentRequest,com.google.cloud.dialogflow.v2beta1.Agent> getAgentCallable()
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
GetAgentRequest request = GetAgentRequest.newBuilder()
.setParentWithProjectName(parent)
.build();
ApiFuture<Agent> future = agentsClient.getAgentCallable().futureCall(request);
// Do something
Agent response = future.get();
}
public final PagedResponseWrappers.SearchAgentsPagedResponse searchAgents(com.google.cloud.dialogflow.v2beta1.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 PagedResponseWrappers.SearchAgentsPagedResponse searchAgents(com.google.cloud.dialogflow.v2beta1.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()
.setParentWithProjectName(parent)
.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<com.google.cloud.dialogflow.v2beta1.SearchAgentsRequest,PagedResponseWrappers.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()
.setParentWithProjectName(parent)
.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<com.google.cloud.dialogflow.v2beta1.SearchAgentsRequest,com.google.cloud.dialogflow.v2beta1.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()
.setParentWithProjectName(parent)
.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;
}
}
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.protobuf.Struct> trainAgentAsync(com.google.cloud.dialogflow.v2beta1.ProjectName parent)
Operation<response: google.protobuf.Empty, metadata: google.protobuf.Struct>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Empty response = 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 failspublic final com.google.api.gax.rpc.OperationCallable<com.google.cloud.dialogflow.v2beta1.TrainAgentRequest,com.google.protobuf.Empty,com.google.protobuf.Struct> trainAgentOperationCallable()
Operation<response: google.protobuf.Empty, metadata: google.protobuf.Struct>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
TrainAgentRequest request = TrainAgentRequest.newBuilder()
.setParentWithProjectName(parent)
.build();
OperationFuture<Operation> future = agentsClient.trainAgentOperationCallable().futureCall(request);
// Do something
Empty response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.TrainAgentRequest,com.google.longrunning.Operation> trainAgentCallable()
Operation<response: google.protobuf.Empty, metadata: google.protobuf.Struct>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
TrainAgentRequest request = TrainAgentRequest.newBuilder()
.setParentWithProjectName(parent)
.build();
ApiFuture<Operation> future = agentsClient.trainAgentCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.cloud.dialogflow.v2beta1.ExportAgentResponse,com.google.protobuf.Struct> exportAgentAsync(com.google.cloud.dialogflow.v2beta1.ProjectName parent)
Operation<response: ExportAgentResponse, metadata: google.protobuf.Struct>
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 failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.cloud.dialogflow.v2beta1.ExportAgentResponse,com.google.protobuf.Struct> exportAgentAsync(com.google.cloud.dialogflow.v2beta1.ExportAgentRequest request)
Operation<response: ExportAgentResponse, metadata: google.protobuf.Struct>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ExportAgentRequest request = ExportAgentRequest.newBuilder()
.setParentWithProjectName(parent)
.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 failspublic final com.google.api.gax.rpc.OperationCallable<com.google.cloud.dialogflow.v2beta1.ExportAgentRequest,com.google.cloud.dialogflow.v2beta1.ExportAgentResponse,com.google.protobuf.Struct> exportAgentOperationCallable()
Operation<response: ExportAgentResponse, metadata: google.protobuf.Struct>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ExportAgentRequest request = ExportAgentRequest.newBuilder()
.setParentWithProjectName(parent)
.build();
OperationFuture<Operation> future = agentsClient.exportAgentOperationCallable().futureCall(request);
// Do something
ExportAgentResponse response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.ExportAgentRequest,com.google.longrunning.Operation> exportAgentCallable()
Operation<response: ExportAgentResponse, metadata: google.protobuf.Struct>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ExportAgentRequest request = ExportAgentRequest.newBuilder()
.setParentWithProjectName(parent)
.build();
ApiFuture<Operation> future = agentsClient.exportAgentCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.protobuf.Struct> importAgentAsync(com.google.cloud.dialogflow.v2beta1.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, metadata: google.protobuf.Struct>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ImportAgentRequest request = ImportAgentRequest.newBuilder()
.setParentWithProjectName(parent)
.build();
Empty response = 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 failspublic final com.google.api.gax.rpc.OperationCallable<com.google.cloud.dialogflow.v2beta1.ImportAgentRequest,com.google.protobuf.Empty,com.google.protobuf.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, metadata: google.protobuf.Struct>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ImportAgentRequest request = ImportAgentRequest.newBuilder()
.setParentWithProjectName(parent)
.build();
OperationFuture<Operation> future = agentsClient.importAgentOperationCallable().futureCall(request);
// Do something
Empty response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.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, metadata: google.protobuf.Struct>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ImportAgentRequest request = ImportAgentRequest.newBuilder()
.setParentWithProjectName(parent)
.build();
ApiFuture<Operation> future = agentsClient.importAgentCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.protobuf.Struct> restoreAgentAsync(com.google.cloud.dialogflow.v2beta1.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, metadata: google.protobuf.Struct>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
RestoreAgentRequest request = RestoreAgentRequest.newBuilder()
.setParentWithProjectName(parent)
.build();
Empty response = 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 failspublic final com.google.api.gax.rpc.OperationCallable<com.google.cloud.dialogflow.v2beta1.RestoreAgentRequest,com.google.protobuf.Empty,com.google.protobuf.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, metadata: google.protobuf.Struct>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
RestoreAgentRequest request = RestoreAgentRequest.newBuilder()
.setParentWithProjectName(parent)
.build();
OperationFuture<Operation> future = agentsClient.restoreAgentOperationCallable().futureCall(request);
// Do something
Empty response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.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, metadata: google.protobuf.Struct>
Sample code:
try (AgentsClient agentsClient = AgentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
RestoreAgentRequest request = RestoreAgentRequest.newBuilder()
.setParentWithProjectName(parent)
.build();
ApiFuture<Operation> future = agentsClient.restoreAgentCallable().futureCall(request);
// Do something
future.get();
}
public final void close()
throws Exception
close in interface AutoCloseableExceptionpublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2017 Google. All rights reserved.