use of com.ibm.watson.developer_cloud.conversation.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class ConversationTest method testSendMessageWithNullWorkspaceId.
/**
* Negative - Test message with null workspace id.
*
* @throws InterruptedException the interrupted exception
*/
@Test(expected = IllegalArgumentException.class)
public void testSendMessageWithNullWorkspaceId() throws InterruptedException {
String text = "I'd like to get insurance to for my home";
InputData input = new InputData.Builder(text).build();
MessageOptions options = new MessageOptions.Builder().input(input).alternateIntents(true).build();
service.message(options).execute();
}
use of com.ibm.watson.developer_cloud.conversation.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Conversation 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.
*
* @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.conversation.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Conversation method getWorkspace.
/**
* Get information about a workspace.
*
* Get information about a workspace, optionally including all workspace content.
*
* @param getWorkspaceOptions the {@link GetWorkspaceOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link WorkspaceExport}
*/
public ServiceCall<WorkspaceExport> getWorkspace(GetWorkspaceOptions getWorkspaceOptions) {
Validator.notNull(getWorkspaceOptions, "getWorkspaceOptions cannot be null");
String[] pathSegments = { "v1/workspaces" };
String[] pathParameters = { getWorkspaceOptions.workspaceId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
if (getWorkspaceOptions.export() != null) {
builder.query("export", String.valueOf(getWorkspaceOptions.export()));
}
if (getWorkspaceOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(getWorkspaceOptions.includeAudit()));
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(WorkspaceExport.class));
}
use of com.ibm.watson.developer_cloud.conversation.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Conversation method listLogs.
/**
* List log events in a workspace.
*
* List log events in a specific workspace.
*
* @param listLogsOptions the {@link ListLogsOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link LogCollection}
*/
public ServiceCall<LogCollection> listLogs(ListLogsOptions listLogsOptions) {
Validator.notNull(listLogsOptions, "listLogsOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "logs" };
String[] pathParameters = { listLogsOptions.workspaceId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
if (listLogsOptions.sort() != null) {
builder.query("sort", listLogsOptions.sort());
}
if (listLogsOptions.filter() != null) {
builder.query("filter", listLogsOptions.filter());
}
if (listLogsOptions.pageLimit() != null) {
builder.query("page_limit", String.valueOf(listLogsOptions.pageLimit()));
}
if (listLogsOptions.cursor() != null) {
builder.query("cursor", listLogsOptions.cursor());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(LogCollection.class));
}
use of com.ibm.watson.developer_cloud.conversation.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Conversation method listIntents.
/**
* List intents.
*
* List the intents for a workspace.
*
* @param listIntentsOptions the {@link ListIntentsOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link IntentCollection}
*/
public ServiceCall<IntentCollection> listIntents(ListIntentsOptions listIntentsOptions) {
Validator.notNull(listIntentsOptions, "listIntentsOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "intents" };
String[] pathParameters = { listIntentsOptions.workspaceId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
if (listIntentsOptions.export() != null) {
builder.query("export", String.valueOf(listIntentsOptions.export()));
}
if (listIntentsOptions.pageLimit() != null) {
builder.query("page_limit", String.valueOf(listIntentsOptions.pageLimit()));
}
if (listIntentsOptions.includeCount() != null) {
builder.query("include_count", String.valueOf(listIntentsOptions.includeCount()));
}
if (listIntentsOptions.sort() != null) {
builder.query("sort", listIntentsOptions.sort());
}
if (listIntentsOptions.cursor() != null) {
builder.query("cursor", listIntentsOptions.cursor());
}
if (listIntentsOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(listIntentsOptions.includeAudit()));
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IntentCollection.class));
}
Aggregations