use of com.ibm.watson.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.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class ConversationServiceIT method testCreateWorkspace.
/**
* Test createWorkspace.
*/
@Test
public void testCreateWorkspace() {
// gotta be unique
String workspaceName = "API Test " + UUID.randomUUID().toString();
String workspaceDescription = "Description of " + workspaceName;
String workspaceLanguage = "en";
// metadata
Map<String, Object> workspaceMetadata = new HashMap<String, Object>();
String metadataValue = "value for " + workspaceName;
workspaceMetadata.put("key", metadataValue);
// intents
List<CreateIntent> workspaceIntents = new ArrayList<CreateIntent>();
// gotta be unique
String intentName = "Hello" + UUID.randomUUID().toString();
String intentDescription = "Description of " + intentName;
String intentExample = "Example of " + intentName;
List<CreateExample> intentExamples = new ArrayList<CreateExample>();
intentExamples.add(new CreateExample.Builder().text(intentExample).build());
workspaceIntents.add(new CreateIntent.Builder().intent(intentName).description(intentDescription).examples(intentExamples).build());
// entities
List<CreateEntity> workspaceEntities = new ArrayList<CreateEntity>();
// gotta be unique
String entityName = "Hello" + UUID.randomUUID().toString();
String entityDescription = "Description of " + entityName;
String entitySource = "Source for " + entityName;
String entityValue = "Value of " + entityName;
String entityValueSynonym = "Synonym for Value of " + entityName;
List<CreateValue> entityValues = new ArrayList<CreateValue>();
entityValues.add(new CreateValue.Builder().value(entityValue).addSynonym(entityValueSynonym).build());
workspaceEntities.add(new CreateEntity.Builder().entity(entityName).description(entityDescription).values(entityValues).build());
// counterexamples
List<CreateCounterexample> workspaceCounterExamples = new ArrayList<CreateCounterexample>();
String counterExampleText = "Counterexample for " + workspaceName;
workspaceCounterExamples.add(new CreateCounterexample.Builder().text(counterExampleText).build());
CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder().name(workspaceName).description(workspaceDescription).language(workspaceLanguage).metadata(workspaceMetadata).intents(workspaceIntents).entities(workspaceEntities).counterexamples(workspaceCounterExamples).build();
String workspaceId = null;
try {
Workspace response = service.createWorkspace(createOptions).execute();
assertNotNull(response);
assertNotNull(response.getWorkspaceId());
workspaceId = response.getWorkspaceId();
assertNotNull(response.getName());
assertEquals(response.getName(), workspaceName);
assertNotNull(response.getDescription());
assertEquals(response.getDescription(), workspaceDescription);
assertNotNull(response.getLanguage());
assertEquals(response.getLanguage(), workspaceLanguage);
// metadata
assertNotNull(response.getMetadata());
assertNotNull(response.getMetadata().get("key"));
assertEquals(response.getMetadata().get("key"), metadataValue);
GetWorkspaceOptions getOptions = new GetWorkspaceOptions.Builder(workspaceId).export(true).build();
WorkspaceExport exResponse = service.getWorkspace(getOptions).execute();
assertNotNull(exResponse);
// intents
assertNotNull(exResponse.getIntents());
assertTrue(exResponse.getIntents().size() == 1);
assertNotNull(exResponse.getIntents().get(0).getIntentName());
assertEquals(exResponse.getIntents().get(0).getIntentName(), intentName);
assertNotNull(exResponse.getIntents().get(0).getDescription());
assertEquals(exResponse.getIntents().get(0).getDescription(), intentDescription);
assertNotNull(exResponse.getIntents().get(0).getExamples());
assertTrue(exResponse.getIntents().get(0).getExamples().size() == 1);
assertNotNull(exResponse.getIntents().get(0).getExamples().get(0));
assertNotNull(exResponse.getIntents().get(0).getExamples().get(0).getExampleText());
assertEquals(exResponse.getIntents().get(0).getExamples().get(0).getExampleText(), intentExample);
// entities
assertNotNull(exResponse.getEntities());
assertTrue(exResponse.getEntities().size() == 1);
assertNotNull(exResponse.getEntities().get(0).getEntityName());
assertEquals(exResponse.getEntities().get(0).getEntityName(), entityName);
assertNotNull(exResponse.getEntities().get(0).getDescription());
assertEquals(exResponse.getEntities().get(0).getDescription(), entityDescription);
assertNotNull(exResponse.getEntities().get(0).getValues());
assertTrue(exResponse.getEntities().get(0).getValues().size() == 1);
assertNotNull(exResponse.getEntities().get(0).getValues().get(0).getValueText());
assertEquals(exResponse.getEntities().get(0).getValues().get(0).getValueText(), entityValue);
assertNotNull(exResponse.getEntities().get(0).getValues().get(0).getSynonyms());
assertTrue(exResponse.getEntities().get(0).getValues().get(0).getSynonyms().size() == 1);
assertEquals(exResponse.getEntities().get(0).getValues().get(0).getSynonyms().get(0), entityValueSynonym);
// counterexamples
assertNotNull(exResponse.getCounterexamples());
assertTrue(exResponse.getCounterexamples().size() == 1);
assertNotNull(exResponse.getCounterexamples().get(0).getText());
assertEquals(exResponse.getCounterexamples().get(0).getText(), counterExampleText);
} catch (Exception ex) {
fail(ex.getMessage());
} finally {
// Clean up
if (workspaceId != null) {
DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build();
service.deleteWorkspace(deleteOptions).execute();
}
}
}
use of com.ibm.watson.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class AssistantTest method testGetWorkspaceWOptions.
// Test the getWorkspace operation with a valid options model parameter
@Test
public void testGetWorkspaceWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"video\", \"source\": \"source\", \"title\": \"title\", \"description\": \"description\", \"channels\": [{\"channel\": \"chat\"}], \"channel_options\": {\"mapKey\": \"anyValue\"}, \"alt_text\": \"altText\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}}, \"metadata\": {\"mapKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"learning_opt_out\": false, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"mapKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}}, \"status\": \"Non Existent\", \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}]}";
String getWorkspacePath = "/v1/workspaces/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the GetWorkspaceOptions model
GetWorkspaceOptions getWorkspaceOptionsModel = new GetWorkspaceOptions.Builder().workspaceId("testString").export(false).includeAudit(false).sort("stable").build();
// Invoke getWorkspace() with a valid options model and verify the result
Response<Workspace> response = assistantService.getWorkspace(getWorkspaceOptionsModel).execute();
assertNotNull(response);
Workspace responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "GET");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getWorkspacePath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(false));
assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false));
assertEquals(query.get("sort"), "stable");
}
use of com.ibm.watson.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class AssistantTest method testUpdateWorkspaceWOptions.
// Test the updateWorkspace operation with a valid options model parameter
@Test
public void testUpdateWorkspaceWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"video\", \"source\": \"source\", \"title\": \"title\", \"description\": \"description\", \"channels\": [{\"channel\": \"chat\"}], \"channel_options\": {\"mapKey\": \"anyValue\"}, \"alt_text\": \"altText\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"context\": {\"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}}, \"metadata\": {\"mapKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"learning_opt_out\": false, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"mapKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}}, \"status\": \"Non Existent\", \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}]}";
String updateWorkspacePath = "/v1/workspaces/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ResponseGenericChannel model
ResponseGenericChannel responseGenericChannelModel = new ResponseGenericChannel.Builder().channel("chat").build();
// Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo model
DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo dialogNodeOutputGenericModel = new DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.Builder().responseType("video").source("testString").title("testString").description("testString").channels(new java.util.ArrayList<ResponseGenericChannel>(java.util.Arrays.asList(responseGenericChannelModel))).channelOptions(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).altText("testString").build();
// Construct an instance of the DialogNodeOutputModifiers model
DialogNodeOutputModifiers dialogNodeOutputModifiersModel = new DialogNodeOutputModifiers.Builder().overwrite(true).build();
// Construct an instance of the DialogNodeOutput model
DialogNodeOutput dialogNodeOutputModel = new DialogNodeOutput.Builder().generic(new java.util.ArrayList<DialogNodeOutputGeneric>(java.util.Arrays.asList(dialogNodeOutputGenericModel))).integrations(new java.util.HashMap<String, Map<String, Object>>() {
{
put("foo", new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
});
}
}).modifiers(dialogNodeOutputModifiersModel).add("foo", "testString").build();
// Construct an instance of the DialogNodeContext model
DialogNodeContext dialogNodeContextModel = new DialogNodeContext.Builder().integrations(new java.util.HashMap<String, Map<String, Object>>() {
{
put("foo", new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
});
}
}).add("foo", "testString").build();
// Construct an instance of the DialogNodeNextStep model
DialogNodeNextStep dialogNodeNextStepModel = new DialogNodeNextStep.Builder().behavior("get_user_input").dialogNode("testString").selector("condition").build();
// Construct an instance of the DialogNodeAction model
DialogNodeAction dialogNodeActionModel = new DialogNodeAction.Builder().name("testString").type("client").parameters(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).resultVariable("testString").credentials("testString").build();
// Construct an instance of the DialogNode model
DialogNode dialogNodeModel = new DialogNode.Builder().dialogNode("testString").description("testString").conditions("testString").parent("testString").previousSibling("testString").output(dialogNodeOutputModel).context(dialogNodeContextModel).metadata(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).nextStep(dialogNodeNextStepModel).title("testString").type("standard").eventName("focus").variable("testString").actions(new java.util.ArrayList<DialogNodeAction>(java.util.Arrays.asList(dialogNodeActionModel))).digressIn("not_available").digressOut("allow_returning").digressOutSlots("not_allowed").userLabel("testString").disambiguationOptOut(false).build();
// Construct an instance of the Counterexample model
Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build();
// Construct an instance of the WorkspaceSystemSettingsTooling model
WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build();
// Construct an instance of the WorkspaceSystemSettingsDisambiguation model
WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = new WorkspaceSystemSettingsDisambiguation.Builder().prompt("testString").noneOfTheAbovePrompt("testString").enabled(false).sensitivity("auto").randomize(true).maxSuggestions(Long.valueOf("1")).suggestionTextPolicy("testString").build();
// Construct an instance of the WorkspaceSystemSettingsSystemEntities model
WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build();
// Construct an instance of the WorkspaceSystemSettingsOffTopic model
WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build();
// Construct an instance of the WorkspaceSystemSettings model
WorkspaceSystemSettings workspaceSystemSettingsModel = new WorkspaceSystemSettings.Builder().tooling(workspaceSystemSettingsToolingModel).disambiguation(workspaceSystemSettingsDisambiguationModel).humanAgentAssist(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).spellingSuggestions(false).spellingAutoCorrect(false).systemEntities(workspaceSystemSettingsSystemEntitiesModel).offTopic(workspaceSystemSettingsOffTopicModel).add("foo", "testString").build();
// Construct an instance of the WebhookHeader model
WebhookHeader webhookHeaderModel = new WebhookHeader.Builder().name("testString").value("testString").build();
// Construct an instance of the Webhook model
Webhook webhookModel = new Webhook.Builder().url("testString").name("testString").headers(new java.util.ArrayList<WebhookHeader>(java.util.Arrays.asList(webhookHeaderModel))).build();
// Construct an instance of the Mention model
Mention mentionModel = new Mention.Builder().entity("testString").location(new java.util.ArrayList<Long>(java.util.Arrays.asList(Long.valueOf("26")))).build();
// Construct an instance of the Example model
Example exampleModel = new Example.Builder().text("testString").mentions(new java.util.ArrayList<Mention>(java.util.Arrays.asList(mentionModel))).build();
// Construct an instance of the CreateIntent model
CreateIntent createIntentModel = new CreateIntent.Builder().intent("testString").description("testString").examples(new java.util.ArrayList<Example>(java.util.Arrays.asList(exampleModel))).build();
// Construct an instance of the CreateValue model
CreateValue createValueModel = new CreateValue.Builder().value("testString").metadata(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).type("synonyms").synonyms(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).patterns(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).build();
// Construct an instance of the CreateEntity model
CreateEntity createEntityModel = new CreateEntity.Builder().entity("testString").description("testString").metadata(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).fuzzyMatch(true).values(new java.util.ArrayList<CreateValue>(java.util.Arrays.asList(createValueModel))).build();
// Construct an instance of the UpdateWorkspaceOptions model
UpdateWorkspaceOptions updateWorkspaceOptionsModel = new UpdateWorkspaceOptions.Builder().workspaceId("testString").name("testString").description("testString").language("testString").dialogNodes(new java.util.ArrayList<DialogNode>(java.util.Arrays.asList(dialogNodeModel))).counterexamples(new java.util.ArrayList<Counterexample>(java.util.Arrays.asList(counterexampleModel))).metadata(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).learningOptOut(false).systemSettings(workspaceSystemSettingsModel).webhooks(new java.util.ArrayList<Webhook>(java.util.Arrays.asList(webhookModel))).intents(new java.util.ArrayList<CreateIntent>(java.util.Arrays.asList(createIntentModel))).entities(new java.util.ArrayList<CreateEntity>(java.util.Arrays.asList(createEntityModel))).append(false).includeAudit(false).build();
// Invoke updateWorkspace() with a valid options model and verify the result
Response<Workspace> response = assistantService.updateWorkspace(updateWorkspaceOptionsModel).execute();
assertNotNull(response);
Workspace responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, updateWorkspacePath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
assertEquals(Boolean.valueOf(query.get("append")), Boolean.valueOf(false));
assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false));
}
use of com.ibm.watson.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Assistant method listLogs.
/**
* List log events in a workspace.
*
* <p>List the events from the log of a specific workspace.
*
* <p>This method requires Manager access.
*
* @param listLogsOptions the {@link ListLogsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link LogCollection}
*/
public ServiceCall<LogCollection> listLogs(ListLogsOptions listLogsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listLogsOptions, "listLogsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", listLogsOptions.workspaceId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/logs", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listLogs");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("version", String.valueOf(this.version));
if (listLogsOptions.sort() != null) {
builder.query("sort", String.valueOf(listLogsOptions.sort()));
}
if (listLogsOptions.filter() != null) {
builder.query("filter", String.valueOf(listLogsOptions.filter()));
}
if (listLogsOptions.pageLimit() != null) {
builder.query("page_limit", String.valueOf(listLogsOptions.pageLimit()));
}
if (listLogsOptions.cursor() != null) {
builder.query("cursor", String.valueOf(listLogsOptions.cursor()));
}
ResponseConverter<LogCollection> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<LogCollection>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations