use of com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient in project java-dialogflow by googleapis.
the class CreateDocumentTest method tearDown.
@After
public void tearDown() throws IOException {
// Delete the created knowledge base
try (KnowledgeBasesClient client = KnowledgeBasesClient.create()) {
DeleteKnowledgeBaseRequest request = DeleteKnowledgeBaseRequest.newBuilder().setName(knowledgeBaseName).setForce(true).build();
client.deleteKnowledgeBase(request);
}
System.setOut(null);
}
use of com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient in project java-dialogflow by googleapis.
the class CreateKnowledgeBaseTest method tearDown.
@After
public void tearDown() throws IOException {
if (knowledgeBaseName == null) {
return;
}
// Delete the created knowledge base
try (KnowledgeBasesClient client = KnowledgeBasesClient.create()) {
DeleteKnowledgeBaseRequest request = DeleteKnowledgeBaseRequest.newBuilder().setName(knowledgeBaseName).setForce(true).build();
client.deleteKnowledgeBase(request);
}
System.setOut(originalOutputStream);
}
use of com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient in project java-dialogflow by googleapis.
the class KnowledgeBaseManagement method createKnowledgeBase.
// Create a Knowledge base
public static void createKnowledgeBase(String projectId, String location, String displayName) throws ApiException, IOException {
// Instantiates a client
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
KnowledgeBase targetKnowledgeBase = KnowledgeBase.newBuilder().setDisplayName(displayName).build();
LocationName parent = LocationName.of(projectId, location);
KnowledgeBase createdKnowledgeBase = knowledgeBasesClient.createKnowledgeBase(parent, targetKnowledgeBase);
System.out.println("====================");
System.out.format("Knowledgebase created:\n");
System.out.format("Display Name: %s\n", createdKnowledgeBase.getDisplayName());
System.out.format("Name: %s\n", createdKnowledgeBase.getName());
}
}
use of com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient in project java-dialogflow by googleapis.
the class CreateDocumentTest method setUp.
@Before
public void setUp() throws IOException {
// Create a knowledge base for the document
try (KnowledgeBasesClient client = KnowledgeBasesClient.create()) {
KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().setDisplayName(KNOWLEDGE_DISPLAY_NAME).build();
ProjectName projectName = ProjectName.of(PROJECT_ID);
KnowledgeBase response = client.createKnowledgeBase(projectName, knowledgeBase);
// Save the full name for deletion
knowledgeBaseName = response.getName();
}
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
System.setOut(out);
}
Aggregations