Search in sources :

Example 1 with DeleteAgentRequest

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

the class ITSystemTest method tearDown.

@AfterClass
public static void tearDown() {
    /* delete version */
    DeleteVersionRequest deleteVersionRequest = DeleteVersionRequest.newBuilder().setName(versionName).build();
    versionsClient.deleteVersion(deleteVersionRequest);
    versionsClient.close();
    /* delete transition route groups */
    DeleteTransitionRouteGroupRequest deleteTransitionRouteGroupRequest = DeleteTransitionRouteGroupRequest.newBuilder().setName(transitionRouteGroupName).build();
    transitionRouteGroupsClient.deleteTransitionRouteGroup(deleteTransitionRouteGroupRequest);
    transitionRouteGroupsClient.close();
    /* delete session */
    sessionsClient.close();
    /* delete pages */
    DeletePageRequest deletePageRequest = DeletePageRequest.newBuilder().setName(pageName).build();
    pagesClient.deletePage(deletePageRequest);
    pagesClient.close();
    /* delete intents */
    DeleteIntentRequest deleteIntentRequest = DeleteIntentRequest.newBuilder().setName(intentsName).build();
    intentsClient.deleteIntent(deleteIntentRequest);
    intentsClient.close();
    /* delete flows */
    DeleteFlowRequest deleteFlowRequest = DeleteFlowRequest.newBuilder().setName(flowName).build();
    flowsClient.deleteFlow(deleteFlowRequest);
    DeleteFlowRequest deleteTrainFlowRequest = DeleteFlowRequest.newBuilder().setName(trainFlowName).build();
    flowsClient.deleteFlow(deleteTrainFlowRequest);
    flowsClient.close();
    /* delete entity types */
    DeleteEntityTypeRequest deleteEntityTypeRequest = DeleteEntityTypeRequest.newBuilder().setName(entityTypesName).build();
    entityTypesClient.deleteEntityType(deleteEntityTypeRequest);
    entityTypesClient.close();
    /* delete agents */
    DeleteAgentRequest deleteAgentRequest = DeleteAgentRequest.newBuilder().setName(agentName).build();
    agentsClient.deleteAgent(deleteAgentRequest);
    agentsClient.close();
}
Also used : DeleteFlowRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteFlowRequest) DeleteTransitionRouteGroupRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteTransitionRouteGroupRequest) DeletePageRequest(com.google.cloud.dialogflow.cx.v3beta1.DeletePageRequest) DeleteEntityTypeRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteEntityTypeRequest) DeleteAgentRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteAgentRequest) DeleteVersionRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteVersionRequest) DeleteIntentRequest(com.google.cloud.dialogflow.cx.v3beta1.DeleteIntentRequest) AfterClass(org.junit.AfterClass)

Example 2 with DeleteAgentRequest

use of com.google.cloud.dialogflow.cx.v3beta1.DeleteAgentRequest 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

DeleteAgentRequest (com.google.cloud.dialogflow.cx.v3beta1.DeleteAgentRequest)2 Agent (com.google.cloud.dialogflow.cx.v3beta1.Agent)1 DeleteEntityTypeRequest (com.google.cloud.dialogflow.cx.v3beta1.DeleteEntityTypeRequest)1 DeleteFlowRequest (com.google.cloud.dialogflow.cx.v3beta1.DeleteFlowRequest)1 DeleteIntentRequest (com.google.cloud.dialogflow.cx.v3beta1.DeleteIntentRequest)1 DeletePageRequest (com.google.cloud.dialogflow.cx.v3beta1.DeletePageRequest)1 DeleteTransitionRouteGroupRequest (com.google.cloud.dialogflow.cx.v3beta1.DeleteTransitionRouteGroupRequest)1 DeleteVersionRequest (com.google.cloud.dialogflow.cx.v3beta1.DeleteVersionRequest)1 RestoreAgentRequest (com.google.cloud.dialogflow.cx.v3beta1.RestoreAgentRequest)1 Empty (com.google.protobuf.Empty)1 Struct (com.google.protobuf.Struct)1 AfterClass (org.junit.AfterClass)1 Test (org.junit.Test)1