Search in sources :

Example 1 with ExportAgentRequest

use of com.google.cloud.dialogflow.cx.v3.ExportAgentRequest in project java-dialogflow-cx by googleapis.

the class ITSystemTest method exportAgentTest.

@Test
public void exportAgentTest() throws ExecutionException, InterruptedException {
    ExportAgentRequest request = ExportAgentRequest.newBuilder().setName(agentName).build();
    ExportAgentResponse exportAgentResponse = agentsClient.exportAgentAsync(request).get();
    assertNotNull(exportAgentResponse.getAgentContent());
    assertTrue(exportAgentResponse.getAgentContent().toStringUtf8().contains(agentName));
}
Also used : ExportAgentRequest(com.google.cloud.dialogflow.cx.v3beta1.ExportAgentRequest) ExportAgentResponse(com.google.cloud.dialogflow.cx.v3beta1.ExportAgentResponse) Test(org.junit.Test)

Example 2 with ExportAgentRequest

use of com.google.cloud.dialogflow.cx.v3.ExportAgentRequest in project java-dialogflow-cx by googleapis.

the class ExportAgent method exportAgent.

public static void exportAgent(String projectId, String agentId, String location) throws IOException, InterruptedException, ExecutionException {
    // Sets the api endpoint to specified location
    String apiEndpoint = String.format("%s-dialogflow.googleapis.com:443", location);
    AgentsSettings agentsSettings = AgentsSettings.newBuilder().setEndpoint(apiEndpoint).build();
    try (AgentsClient agentsClient = AgentsClient.create(agentsSettings)) {
        ExportAgentRequest request = ExportAgentRequest.newBuilder().setName(AgentName.of(projectId, location, agentId).toString()).build();
        // Returns a future of the operation
        OperationFuture<ExportAgentResponse, Struct> future = agentsClient.exportAgentOperationCallable().futureCall(request);
        // get the export agent response after the operation is completed
        ExportAgentResponse response = future.get();
        System.out.println(response);
    }
}
Also used : AgentsSettings(com.google.cloud.dialogflow.cx.v3.AgentsSettings) AgentsClient(com.google.cloud.dialogflow.cx.v3.AgentsClient) ExportAgentRequest(com.google.cloud.dialogflow.cx.v3.ExportAgentRequest) ExportAgentResponse(com.google.cloud.dialogflow.cx.v3.ExportAgentResponse) Struct(com.google.protobuf.Struct)

Aggregations

AgentsClient (com.google.cloud.dialogflow.cx.v3.AgentsClient)1 AgentsSettings (com.google.cloud.dialogflow.cx.v3.AgentsSettings)1 ExportAgentRequest (com.google.cloud.dialogflow.cx.v3.ExportAgentRequest)1 ExportAgentResponse (com.google.cloud.dialogflow.cx.v3.ExportAgentResponse)1 ExportAgentRequest (com.google.cloud.dialogflow.cx.v3beta1.ExportAgentRequest)1 ExportAgentResponse (com.google.cloud.dialogflow.cx.v3beta1.ExportAgentResponse)1 Struct (com.google.protobuf.Struct)1 Test (org.junit.Test)1