use of com.ibm.watson.developer_cloud.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class ConversationServiceIT method testDeleteWorkspace.
/**
* Test deleteWorkspace.
*/
@Test
public void testDeleteWorkspace() {
CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder().build();
String workspaceId = null;
try {
Workspace response = service.createWorkspace(createOptions).execute();
assertNotNull(response);
assertNotNull(response.getWorkspaceId());
workspaceId = response.getWorkspaceId();
DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build();
service.deleteWorkspace(deleteOptions).execute();
GetWorkspaceOptions getOptions = new GetWorkspaceOptions.Builder(workspaceId).export(true).build();
service.getWorkspace(getOptions).execute();
} catch (Exception ex) {
// Expected result
assertTrue(ex instanceof NotFoundException);
workspaceId = null;
} finally {
// Clean up
if (workspaceId != null) {
DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build();
service.deleteWorkspace(deleteOptions).execute();
}
}
}
use of com.ibm.watson.developer_cloud.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Assistant method listDialogNodes.
/**
* List dialog nodes.
*
* List the dialog nodes for a workspace. This operation is limited to 2500 requests per 30 minutes. For more
* information, see **Rate limiting**.
*
* @param listDialogNodesOptions the {@link ListDialogNodesOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link DialogNodeCollection}
*/
public ServiceCall<DialogNodeCollection> listDialogNodes(ListDialogNodesOptions listDialogNodesOptions) {
Validator.notNull(listDialogNodesOptions, "listDialogNodesOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "dialog_nodes" };
String[] pathParameters = { listDialogNodesOptions.workspaceId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
if (listDialogNodesOptions.pageLimit() != null) {
builder.query("page_limit", String.valueOf(listDialogNodesOptions.pageLimit()));
}
if (listDialogNodesOptions.includeCount() != null) {
builder.query("include_count", String.valueOf(listDialogNodesOptions.includeCount()));
}
if (listDialogNodesOptions.sort() != null) {
builder.query("sort", listDialogNodesOptions.sort());
}
if (listDialogNodesOptions.cursor() != null) {
builder.query("cursor", listDialogNodesOptions.cursor());
}
if (listDialogNodesOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(listDialogNodesOptions.includeAudit()));
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DialogNodeCollection.class));
}
use of com.ibm.watson.developer_cloud.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Assistant method listCounterexamples.
/**
* List counterexamples.
*
* List the counterexamples for a workspace. Counterexamples are examples that have been marked as irrelevant input.
* This operation is limited to 2500 requests per 30 minutes. For more information, see **Rate limiting**.
*
* @param listCounterexamplesOptions the {@link ListCounterexamplesOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link CounterexampleCollection}
*/
public ServiceCall<CounterexampleCollection> listCounterexamples(ListCounterexamplesOptions listCounterexamplesOptions) {
Validator.notNull(listCounterexamplesOptions, "listCounterexamplesOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "counterexamples" };
String[] pathParameters = { listCounterexamplesOptions.workspaceId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
if (listCounterexamplesOptions.pageLimit() != null) {
builder.query("page_limit", String.valueOf(listCounterexamplesOptions.pageLimit()));
}
if (listCounterexamplesOptions.includeCount() != null) {
builder.query("include_count", String.valueOf(listCounterexamplesOptions.includeCount()));
}
if (listCounterexamplesOptions.sort() != null) {
builder.query("sort", listCounterexamplesOptions.sort());
}
if (listCounterexamplesOptions.cursor() != null) {
builder.query("cursor", listCounterexamplesOptions.cursor());
}
if (listCounterexamplesOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(listCounterexamplesOptions.includeAudit()));
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(CounterexampleCollection.class));
}
use of com.ibm.watson.developer_cloud.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Assistant method updateWorkspace.
/**
* Update workspace.
*
* Update an existing workspace with new or modified data. You must provide component objects defining the content of
* the updated workspace. This operation is limited to 30 request per 30 minutes. For more information, see **Rate
* limiting**.
*
* @param updateWorkspaceOptions the {@link UpdateWorkspaceOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Workspace}
*/
public ServiceCall<Workspace> updateWorkspace(UpdateWorkspaceOptions updateWorkspaceOptions) {
Validator.notNull(updateWorkspaceOptions, "updateWorkspaceOptions cannot be null");
String[] pathSegments = { "v1/workspaces" };
String[] pathParameters = { updateWorkspaceOptions.workspaceId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
if (updateWorkspaceOptions.append() != null) {
builder.query("append", String.valueOf(updateWorkspaceOptions.append()));
}
final JsonObject contentJson = new JsonObject();
if (updateWorkspaceOptions.name() != null) {
contentJson.addProperty("name", updateWorkspaceOptions.name());
}
if (updateWorkspaceOptions.description() != null) {
contentJson.addProperty("description", updateWorkspaceOptions.description());
}
if (updateWorkspaceOptions.language() != null) {
contentJson.addProperty("language", updateWorkspaceOptions.language());
}
if (updateWorkspaceOptions.intents() != null) {
contentJson.add("intents", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.intents()));
}
if (updateWorkspaceOptions.entities() != null) {
contentJson.add("entities", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.entities()));
}
if (updateWorkspaceOptions.dialogNodes() != null) {
contentJson.add("dialog_nodes", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.dialogNodes()));
}
if (updateWorkspaceOptions.counterexamples() != null) {
contentJson.add("counterexamples", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.counterexamples()));
}
if (updateWorkspaceOptions.metadata() != null) {
contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.metadata()));
}
if (updateWorkspaceOptions.learningOptOut() != null) {
contentJson.addProperty("learning_opt_out", updateWorkspaceOptions.learningOptOut());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Workspace.class));
}
use of com.ibm.watson.developer_cloud.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Assistant method createCounterexample.
/**
* Create counterexample.
*
* Add a new counterexample to a workspace. Counterexamples are examples that have been marked as irrelevant input.
* This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**.
*
* @param createCounterexampleOptions the {@link CreateCounterexampleOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Counterexample}
*/
public ServiceCall<Counterexample> createCounterexample(CreateCounterexampleOptions createCounterexampleOptions) {
Validator.notNull(createCounterexampleOptions, "createCounterexampleOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "counterexamples" };
String[] pathParameters = { createCounterexampleOptions.workspaceId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("text", createCounterexampleOptions.text());
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Counterexample.class));
}
Aggregations