use of com.google.cloud.dialogflow.cx.v3beta1.AgentName in project java-dialogflow by googleapis.
the class IntentManagement method listIntents.
// [START dialogflow_list_intents]
/**
* List intents
*
* @param projectId Project/Agent Id.
* @return Intents found.
*/
public static List<Intent> listIntents(String projectId) throws ApiException, IOException {
List<Intent> intents = Lists.newArrayList();
// Instantiates a client
try (IntentsClient intentsClient = IntentsClient.create()) {
// Set the project agent name using the projectID (my-project-id)
AgentName parent = AgentName.of(projectId);
// Performs the list intents request
for (Intent intent : intentsClient.listIntents(parent).iterateAll()) {
System.out.println("====================");
System.out.format("Intent name: '%s'\n", intent.getName());
System.out.format("Intent display name: '%s'\n", intent.getDisplayName());
System.out.format("Action: '%s'\n", intent.getAction());
System.out.format("Root followup intent: '%s'\n", intent.getRootFollowupIntentName());
System.out.format("Parent followup intent: '%s'\n", intent.getParentFollowupIntentName());
System.out.format("Input contexts:\n");
for (String inputContextName : intent.getInputContextNamesList()) {
System.out.format("\tName: %s\n", inputContextName);
}
System.out.format("Output contexts:\n");
for (Context outputContext : intent.getOutputContextsList()) {
System.out.format("\tName: %s\n", outputContext.getName());
}
intents.add(intent);
}
}
return intents;
}
use of com.google.cloud.dialogflow.cx.v3beta1.AgentName in project java-dialogflow-cx by googleapis.
the class FlowsClientTest method listFlowsTest.
@Test
public void listFlowsTest() throws Exception {
Flow responsesElement = Flow.newBuilder().build();
ListFlowsResponse expectedResponse = ListFlowsResponse.newBuilder().setNextPageToken("").addAllFlows(Arrays.asList(responsesElement)).build();
mockFlows.addResponse(expectedResponse);
AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
ListFlowsPagedResponse pagedListResponse = client.listFlows(parent);
List<Flow> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getFlowsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockFlows.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListFlowsRequest actualRequest = ((ListFlowsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.cx.v3beta1.AgentName in project java-dialogflow-cx by googleapis.
the class IntentsClientTest method listIntentsTest.
@Test
public void listIntentsTest() throws Exception {
Intent responsesElement = Intent.newBuilder().build();
ListIntentsResponse expectedResponse = ListIntentsResponse.newBuilder().setNextPageToken("").addAllIntents(Arrays.asList(responsesElement)).build();
mockIntents.addResponse(expectedResponse);
AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
ListIntentsPagedResponse pagedListResponse = client.listIntents(parent);
List<Intent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getIntentsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockIntents.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListIntentsRequest actualRequest = ((ListIntentsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.cx.v3beta1.AgentName in project java-dialogflow-cx by googleapis.
the class EnvironmentsClientTest method listEnvironmentsTest.
@Test
public void listEnvironmentsTest() throws Exception {
Environment responsesElement = Environment.newBuilder().build();
ListEnvironmentsResponse expectedResponse = ListEnvironmentsResponse.newBuilder().setNextPageToken("").addAllEnvironments(Arrays.asList(responsesElement)).build();
mockEnvironments.addResponse(expectedResponse);
AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
ListEnvironmentsPagedResponse pagedListResponse = client.listEnvironments(parent);
List<Environment> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getEnvironmentsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockEnvironments.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListEnvironmentsRequest actualRequest = ((ListEnvironmentsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.cx.v3beta1.AgentName in project java-dialogflow-cx by googleapis.
the class EntityTypesClientTest method listEntityTypesTest.
@Test
public void listEntityTypesTest() throws Exception {
EntityType responsesElement = EntityType.newBuilder().build();
ListEntityTypesResponse expectedResponse = ListEntityTypesResponse.newBuilder().setNextPageToken("").addAllEntityTypes(Arrays.asList(responsesElement)).build();
mockEntityTypes.addResponse(expectedResponse);
AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
ListEntityTypesPagedResponse pagedListResponse = client.listEntityTypes(parent);
List<EntityType> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getEntityTypesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockEntityTypes.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListEntityTypesRequest actualRequest = ((ListEntityTypesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations