Search in sources :

Example 1 with RestoreAgentRequest

use of com.google.cloud.dialogflow.cx.v3beta1.RestoreAgentRequest in project java-dialogflow-cx by googleapis.

the class ITSystemTest method restoreAgentTest.

@Test
public void restoreAgentTest() throws ExecutionException, InterruptedException {
    Agent agent = Agent.newBuilder().setDisplayName("test_agent_" + UUID.randomUUID().toString()).setDescription(DESCRIPTION).setTimeZone(AGENT_TIME_ZONE).setDefaultLanguageCode(DEFAULT_LANGUAGE_CODE).setEnableStackdriverLogging(true).setEnableSpellCorrection(true).build();
    Agent response = agentsClient.createAgent(PARENT, agent);
    String agentName = response.getName();
    try {
        /* Replaces the current agent with a new one. Note that all existing resources in agent (e.g.
       * intents, entity types, flows) will be removed
       */
        RestoreAgentRequest restoreAgentRequest = RestoreAgentRequest.newBuilder().setName(agentName).build();
        OperationFuture<Empty, Struct> operationFuture = agentsClient.restoreAgentAsync(restoreAgentRequest);
        assertNotEquals(agentName, operationFuture.getName());
    } finally {
        DeleteAgentRequest deleteAgentRequest = DeleteAgentRequest.newBuilder().setName(agentName).build();
        agentsClient.deleteAgent(deleteAgentRequest);
    }
}
Also used : Agent(com.google.cloud.dialogflow.cx.v3beta1.Agent) Empty(com.google.protobuf.Empty) DeleteAgentRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteAgentRequest) RestoreAgentRequest(com.google.cloud.dialogflow.cx.v3beta1.RestoreAgentRequest) Struct(com.google.protobuf.Struct) Test(org.junit.Test)

Aggregations

Agent (com.google.cloud.dialogflow.cx.v3beta1.Agent)1 DeleteAgentRequest (com.google.cloud.dialogflow.cx.v3beta1.DeleteAgentRequest)1 RestoreAgentRequest (com.google.cloud.dialogflow.cx.v3beta1.RestoreAgentRequest)1 Empty (com.google.protobuf.Empty)1 Struct (com.google.protobuf.Struct)1 Test (org.junit.Test)1