@Generated(value="by GAPIC v0.0.5") @BetaApi public class IntentsClient extends Object implements com.google.api.gax.core.BackgroundResource
Refer to [documentation](https://dialogflow.com/docs/intents) for more # details about agent intents.
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 (IntentsClient intentsClient = IntentsClient.create()) {
IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
Intent response = intentsClient.getIntent(name);
}
Note: close() needs to be called on the intentsClient 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 IntentsSettings to create(). For example:
To customize credentials:
IntentsSettings intentsSettings =
IntentsSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
IntentsClient intentsClient =
IntentsClient.create(intentsSettings);
To customize the endpoint:
IntentsSettings intentsSettings =
IntentsSettings.newBuilder().setEndpoint(myEndpoint).build();
IntentsClient intentsClient =
IntentsClient.create(intentsSettings);
| Modifier | Constructor and Description |
|---|---|
protected |
IntentsClient(IntentsSettings settings)
Constructs an instance of IntentsClient, using the given settings.
|
protected |
IntentsClient(IntentsStub stub) |
protected IntentsClient(IntentsSettings settings) throws IOException
IOException@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected IntentsClient(IntentsStub stub)
public static final IntentsClient create() throws IOException
IOExceptionpublic static final IntentsClient create(IntentsSettings settings) throws IOException
IOException@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final IntentsClient create(IntentsStub stub)
public final IntentsSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public IntentsStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
public final PagedResponseWrappers.ListIntentsPagedResponse listIntents(com.google.cloud.dialogflow.v2beta1.ProjectAgentName parent)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
for (Intent element : intentsClient.listIntents(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The agent to list all intents from. Format: `projects/<Project
ID>/agent`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final PagedResponseWrappers.ListIntentsPagedResponse listIntents(com.google.cloud.dialogflow.v2beta1.ProjectAgentName parent, String languageCode)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
String languageCode = "";
for (Intent element : intentsClient.listIntents(parent, languageCode).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The agent to list all intents from. Format: `projects/<Project
ID>/agent`.languageCode - Optional. The language to list training phrases, parameters and rich
messages for. If not specified, the agent's default language is used. [More than a dozen
languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages
must be enabled in the agent before they can be used.com.google.api.gax.rpc.ApiException - if the remote call failspublic final PagedResponseWrappers.ListIntentsPagedResponse listIntents(com.google.cloud.dialogflow.v2beta1.ListIntentsRequest request)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
ListIntentsRequest request = ListIntentsRequest.newBuilder()
.setParentWithProjectAgentName(parent)
.build();
for (Intent element : intentsClient.listIntents(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.ListIntentsRequest,PagedResponseWrappers.ListIntentsPagedResponse> listIntentsPagedCallable()
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
ListIntentsRequest request = ListIntentsRequest.newBuilder()
.setParentWithProjectAgentName(parent)
.build();
ApiFuture<ListIntentsPagedResponse> future = intentsClient.listIntentsPagedCallable().futureCall(request);
// Do something
for (Intent element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.ListIntentsRequest,com.google.cloud.dialogflow.v2beta1.ListIntentsResponse> listIntentsCallable()
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
ListIntentsRequest request = ListIntentsRequest.newBuilder()
.setParentWithProjectAgentName(parent)
.build();
while (true) {
ListIntentsResponse response = intentsClient.listIntentsCallable().call(request);
for (Intent element : response.getIntentsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.cloud.dialogflow.v2beta1.Intent getIntent(com.google.cloud.dialogflow.v2beta1.IntentName name)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
Intent response = intentsClient.getIntent(name);
}
name - Required. The name of the intent. Format: `projects/<Project
ID>/agent/intents/<Intent ID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.cloud.dialogflow.v2beta1.Intent getIntent(com.google.cloud.dialogflow.v2beta1.IntentName name, String languageCode)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
String languageCode = "";
Intent response = intentsClient.getIntent(name, languageCode);
}
name - Required. The name of the intent. Format: `projects/<Project
ID>/agent/intents/<Intent ID>`.languageCode - Optional. The language to retrieve training phrases, parameters and rich
messages for. If not specified, the agent's default language is used. [More than a dozen
languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages
must be enabled in the agent, before they can be used.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.cloud.dialogflow.v2beta1.Intent getIntent(com.google.cloud.dialogflow.v2beta1.GetIntentRequest request)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
GetIntentRequest request = GetIntentRequest.newBuilder()
.setNameWithIntentName(name)
.build();
Intent response = intentsClient.getIntent(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<com.google.cloud.dialogflow.v2beta1.GetIntentRequest,com.google.cloud.dialogflow.v2beta1.Intent> getIntentCallable()
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
GetIntentRequest request = GetIntentRequest.newBuilder()
.setNameWithIntentName(name)
.build();
ApiFuture<Intent> future = intentsClient.getIntentCallable().futureCall(request);
// Do something
Intent response = future.get();
}
public final com.google.cloud.dialogflow.v2beta1.Intent createIntent(com.google.cloud.dialogflow.v2beta1.ProjectAgentName parent, com.google.cloud.dialogflow.v2beta1.Intent intent)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
Intent intent = Intent.newBuilder().build();
Intent response = intentsClient.createIntent(parent, intent);
}
parent - Required. The agent to create a intent for. Format: `projects/<Project
ID>/agent`.intent - Required. The intent to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.cloud.dialogflow.v2beta1.Intent createIntent(com.google.cloud.dialogflow.v2beta1.ProjectAgentName parent, com.google.cloud.dialogflow.v2beta1.Intent intent, String languageCode)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
Intent intent = Intent.newBuilder().build();
String languageCode = "";
Intent response = intentsClient.createIntent(parent, intent, languageCode);
}
parent - Required. The agent to create a intent for. Format: `projects/<Project
ID>/agent`.intent - Required. The intent to create.languageCode - Optional. The language of training phrases, parameters and rich messages
defined in `intent`. If not specified, the agent's default language is used. [More than a
dozen languages](https://dialogflow.com/docs/reference/language) are supported. Note:
languages must be enabled in the agent, before they can be used.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.cloud.dialogflow.v2beta1.Intent createIntent(com.google.cloud.dialogflow.v2beta1.CreateIntentRequest request)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
Intent intent = Intent.newBuilder().build();
CreateIntentRequest request = CreateIntentRequest.newBuilder()
.setParentWithProjectAgentName(parent)
.setIntent(intent)
.build();
Intent response = intentsClient.createIntent(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<com.google.cloud.dialogflow.v2beta1.CreateIntentRequest,com.google.cloud.dialogflow.v2beta1.Intent> createIntentCallable()
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
Intent intent = Intent.newBuilder().build();
CreateIntentRequest request = CreateIntentRequest.newBuilder()
.setParentWithProjectAgentName(parent)
.setIntent(intent)
.build();
ApiFuture<Intent> future = intentsClient.createIntentCallable().futureCall(request);
// Do something
Intent response = future.get();
}
public final com.google.cloud.dialogflow.v2beta1.Intent updateIntent(com.google.cloud.dialogflow.v2beta1.Intent intent, String languageCode)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
Intent intent = Intent.newBuilder().build();
String languageCode = "";
Intent response = intentsClient.updateIntent(intent, languageCode);
}
intent - Required. The intent to update. Format: `projects/<Project
ID>/agent/intents/<Intent ID>`.languageCode - Optional. The language of training phrases, parameters and rich messages
defined in `intent`. If not specified, the agent's default language is used. [More than a
dozen languages](https://dialogflow.com/docs/reference/language) are supported. Note:
languages must be enabled in the agent, before they can be used.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.cloud.dialogflow.v2beta1.Intent updateIntent(com.google.cloud.dialogflow.v2beta1.Intent intent, String languageCode, com.google.protobuf.FieldMask updateMask)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
Intent intent = Intent.newBuilder().build();
String languageCode = "";
FieldMask updateMask = FieldMask.newBuilder().build();
Intent response = intentsClient.updateIntent(intent, languageCode, updateMask);
}
intent - Required. The intent to update. Format: `projects/<Project
ID>/agent/intents/<Intent ID>`.languageCode - Optional. The language of training phrases, parameters and rich messages
defined in `intent`. If not specified, the agent's default language is used. [More than a
dozen languages](https://dialogflow.com/docs/reference/language) are supported. Note:
languages must be enabled in the agent, before they can be used.updateMask - Optional. The mask to control which fields get updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.cloud.dialogflow.v2beta1.Intent updateIntent(com.google.cloud.dialogflow.v2beta1.UpdateIntentRequest request)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
Intent intent = Intent.newBuilder().build();
String languageCode = "";
UpdateIntentRequest request = UpdateIntentRequest.newBuilder()
.setIntent(intent)
.setLanguageCode(languageCode)
.build();
Intent response = intentsClient.updateIntent(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<com.google.cloud.dialogflow.v2beta1.UpdateIntentRequest,com.google.cloud.dialogflow.v2beta1.Intent> updateIntentCallable()
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
Intent intent = Intent.newBuilder().build();
String languageCode = "";
UpdateIntentRequest request = UpdateIntentRequest.newBuilder()
.setIntent(intent)
.setLanguageCode(languageCode)
.build();
ApiFuture<Intent> future = intentsClient.updateIntentCallable().futureCall(request);
// Do something
Intent response = future.get();
}
public final void deleteIntent(com.google.cloud.dialogflow.v2beta1.IntentName name)
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
intentsClient.deleteIntent(name);
}
name - Required. The name of the intent to delete. Format: `projects/<Project
ID>/agent/intents/<Intent ID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.DeleteIntentRequest,com.google.protobuf.Empty> deleteIntentCallable()
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
DeleteIntentRequest request = DeleteIntentRequest.newBuilder()
.setNameWithIntentName(name)
.build();
ApiFuture<Void> future = intentsClient.deleteIntentCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse,com.google.protobuf.Struct> batchUpdateIntentsAsync(com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsRequest request)
Operation<response: BatchUpdateIntentsResponse>
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
AgentName parent = AgentName.of("[PROJECT]", "[AGENT]");
String languageCode = "";
BatchUpdateIntentsRequest request = BatchUpdateIntentsRequest.newBuilder()
.setParentWithAgentName(parent)
.setLanguageCode(languageCode)
.build();
BatchUpdateIntentsResponse response = intentsClient.batchUpdateIntentsAsync(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.BatchUpdateIntentsRequest,com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse,com.google.protobuf.Struct> batchUpdateIntentsOperationCallable()
Operation<response: BatchUpdateIntentsResponse>
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
AgentName parent = AgentName.of("[PROJECT]", "[AGENT]");
String languageCode = "";
BatchUpdateIntentsRequest request = BatchUpdateIntentsRequest.newBuilder()
.setParentWithAgentName(parent)
.setLanguageCode(languageCode)
.build();
OperationFuture<Operation> future = intentsClient.batchUpdateIntentsOperationCallable().futureCall(request);
// Do something
BatchUpdateIntentsResponse response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsRequest,com.google.longrunning.Operation> batchUpdateIntentsCallable()
Operation<response: BatchUpdateIntentsResponse>
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
AgentName parent = AgentName.of("[PROJECT]", "[AGENT]");
String languageCode = "";
BatchUpdateIntentsRequest request = BatchUpdateIntentsRequest.newBuilder()
.setParentWithAgentName(parent)
.setLanguageCode(languageCode)
.build();
ApiFuture<Operation> future = intentsClient.batchUpdateIntentsCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.protobuf.Struct> batchDeleteIntentsAsync(com.google.cloud.dialogflow.v2beta1.ProjectName parent, List<com.google.cloud.dialogflow.v2beta1.Intent> intents)
Operation<response: google.protobuf.Empty>
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
List<Intent> intents = new ArrayList<>();
Empty response = intentsClient.batchDeleteIntentsAsync(parent, intents).get();
}
parent - Required. The name of the agent to delete all entities types for. Format:
`projects/<Project ID>/agent`.intents - Required. The collection of intents to delete. Only intent `name` must be filled
in.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.protobuf.Struct> batchDeleteIntentsAsync(com.google.cloud.dialogflow.v2beta1.BatchDeleteIntentsRequest request)
Operation<response: google.protobuf.Empty>
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
List<Intent> intents = new ArrayList<>();
BatchDeleteIntentsRequest request = BatchDeleteIntentsRequest.newBuilder()
.setParentWithProjectName(parent)
.addAllIntents(intents)
.build();
Empty response = intentsClient.batchDeleteIntentsAsync(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.BatchDeleteIntentsRequest,com.google.protobuf.Empty,com.google.protobuf.Struct> batchDeleteIntentsOperationCallable()
Operation<response: google.protobuf.Empty>
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
List<Intent> intents = new ArrayList<>();
BatchDeleteIntentsRequest request = BatchDeleteIntentsRequest.newBuilder()
.setParentWithProjectName(parent)
.addAllIntents(intents)
.build();
OperationFuture<Operation> future = intentsClient.batchDeleteIntentsOperationCallable().futureCall(request);
// Do something
Empty response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.dialogflow.v2beta1.BatchDeleteIntentsRequest,com.google.longrunning.Operation> batchDeleteIntentsCallable()
Operation<response: google.protobuf.Empty>
Sample code:
try (IntentsClient intentsClient = IntentsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
List<Intent> intents = new ArrayList<>();
BatchDeleteIntentsRequest request = BatchDeleteIntentsRequest.newBuilder()
.setParentWithProjectName(parent)
.addAllIntents(intents)
.build();
ApiFuture<Operation> future = intentsClient.batchDeleteIntentsCallable().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.