use of com.ibm.watson.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Assistant method listCounterexamples.
/**
* List counterexamples.
*
* <p>List the counterexamples for a workspace. Counterexamples are examples that have been marked
* as irrelevant input.
*
* @param listCounterexamplesOptions the {@link ListCounterexamplesOptions} containing the options
* for the call
* @return a {@link ServiceCall} with a result of type {@link CounterexampleCollection}
*/
public ServiceCall<CounterexampleCollection> listCounterexamples(ListCounterexamplesOptions listCounterexamplesOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listCounterexamplesOptions, "listCounterexamplesOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", listCounterexamplesOptions.workspaceId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listCounterexamples");
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 (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", String.valueOf(listCounterexamplesOptions.sort()));
}
if (listCounterexamplesOptions.cursor() != null) {
builder.query("cursor", String.valueOf(listCounterexamplesOptions.cursor()));
}
if (listCounterexamplesOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(listCounterexamplesOptions.includeAudit()));
}
ResponseConverter<CounterexampleCollection> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<CounterexampleCollection>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Assistant method updateDialogNode.
/**
* Update dialog node.
*
* <p>Update an existing dialog node with new or modified data.
*
* <p>If you want to update multiple dialog nodes with a single API call, consider using the
* **[Update workspace](#update-workspace)** method instead.
*
* @param updateDialogNodeOptions the {@link UpdateDialogNodeOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link DialogNode}
*/
public ServiceCall<DialogNode> updateDialogNode(UpdateDialogNodeOptions updateDialogNodeOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateDialogNodeOptions, "updateDialogNodeOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", updateDialogNodeOptions.workspaceId());
pathParamsMap.put("dialog_node", updateDialogNodeOptions.dialogNode());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateDialogNode");
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 (updateDialogNodeOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(updateDialogNodeOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
if (updateDialogNodeOptions.newDialogNode() != null) {
contentJson.addProperty("dialog_node", updateDialogNodeOptions.newDialogNode());
}
if (updateDialogNodeOptions.newDescription() != null) {
contentJson.addProperty("description", updateDialogNodeOptions.newDescription());
}
if (updateDialogNodeOptions.newConditions() != null) {
contentJson.addProperty("conditions", updateDialogNodeOptions.newConditions());
}
if (updateDialogNodeOptions.newParent() != null) {
contentJson.addProperty("parent", updateDialogNodeOptions.newParent());
}
if (updateDialogNodeOptions.newPreviousSibling() != null) {
contentJson.addProperty("previous_sibling", updateDialogNodeOptions.newPreviousSibling());
}
if (updateDialogNodeOptions.newOutput() != null) {
contentJson.add("output", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newOutput()));
}
if (updateDialogNodeOptions.newContext() != null) {
contentJson.add("context", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newContext()));
}
if (updateDialogNodeOptions.newMetadata() != null) {
contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newMetadata()));
}
if (updateDialogNodeOptions.newNextStep() != null) {
contentJson.add("next_step", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newNextStep()));
}
if (updateDialogNodeOptions.newTitle() != null) {
contentJson.addProperty("title", updateDialogNodeOptions.newTitle());
}
if (updateDialogNodeOptions.newType() != null) {
contentJson.addProperty("type", updateDialogNodeOptions.newType());
}
if (updateDialogNodeOptions.newEventName() != null) {
contentJson.addProperty("event_name", updateDialogNodeOptions.newEventName());
}
if (updateDialogNodeOptions.newVariable() != null) {
contentJson.addProperty("variable", updateDialogNodeOptions.newVariable());
}
if (updateDialogNodeOptions.newActions() != null) {
contentJson.add("actions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newActions()));
}
if (updateDialogNodeOptions.newDigressIn() != null) {
contentJson.addProperty("digress_in", updateDialogNodeOptions.newDigressIn());
}
if (updateDialogNodeOptions.newDigressOut() != null) {
contentJson.addProperty("digress_out", updateDialogNodeOptions.newDigressOut());
}
if (updateDialogNodeOptions.newDigressOutSlots() != null) {
contentJson.addProperty("digress_out_slots", updateDialogNodeOptions.newDigressOutSlots());
}
if (updateDialogNodeOptions.newUserLabel() != null) {
contentJson.addProperty("user_label", updateDialogNodeOptions.newUserLabel());
}
if (updateDialogNodeOptions.newDisambiguationOptOut() != null) {
contentJson.addProperty("disambiguation_opt_out", updateDialogNodeOptions.newDisambiguationOptOut());
}
builder.bodyJson(contentJson);
ResponseConverter<DialogNode> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DialogNode>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Assistant method updateEntity.
/**
* Update entity.
*
* <p>Update an existing entity with new or modified data. You must provide component objects
* defining the content of the updated entity.
*
* <p>If you want to update multiple entities with a single API call, consider using the **[Update
* workspace](#update-workspace)** method instead.
*
* @param updateEntityOptions the {@link UpdateEntityOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Entity}
*/
public ServiceCall<Entity> updateEntity(UpdateEntityOptions updateEntityOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateEntityOptions, "updateEntityOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", updateEntityOptions.workspaceId());
pathParamsMap.put("entity", updateEntityOptions.entity());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateEntity");
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 (updateEntityOptions.append() != null) {
builder.query("append", String.valueOf(updateEntityOptions.append()));
}
if (updateEntityOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(updateEntityOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
if (updateEntityOptions.newEntity() != null) {
contentJson.addProperty("entity", updateEntityOptions.newEntity());
}
if (updateEntityOptions.newDescription() != null) {
contentJson.addProperty("description", updateEntityOptions.newDescription());
}
if (updateEntityOptions.newMetadata() != null) {
contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateEntityOptions.newMetadata()));
}
if (updateEntityOptions.newFuzzyMatch() != null) {
contentJson.addProperty("fuzzy_match", updateEntityOptions.newFuzzyMatch());
}
if (updateEntityOptions.newValues() != null) {
contentJson.add("values", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateEntityOptions.newValues()));
}
builder.bodyJson(contentJson);
ResponseConverter<Entity> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Entity>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Assistant method createCounterexample.
/**
* Create counterexample.
*
* <p>Add a new counterexample to a workspace. Counterexamples are examples that have been marked
* as irrelevant input.
*
* <p>If you want to add multiple counterexamples with a single API call, consider using the
* **[Update workspace](#update-workspace)** method instead.
*
* @param createCounterexampleOptions the {@link CreateCounterexampleOptions} containing the
* options for the call
* @return a {@link ServiceCall} with a result of type {@link Counterexample}
*/
public ServiceCall<Counterexample> createCounterexample(CreateCounterexampleOptions createCounterexampleOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createCounterexampleOptions, "createCounterexampleOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", createCounterexampleOptions.workspaceId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createCounterexample");
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 (createCounterexampleOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(createCounterexampleOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("text", createCounterexampleOptions.text());
builder.bodyJson(contentJson);
ResponseConverter<Counterexample> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Counterexample>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.assistant.v1.model.Workspace in project java-sdk by watson-developer-cloud.
the class Assistant method createEntity.
/**
* Create entity.
*
* <p>Create a new entity, or enable a system entity.
*
* <p>If you want to create multiple entities with a single API call, consider using the **[Update
* workspace](#update-workspace)** method instead.
*
* @param createEntityOptions the {@link CreateEntityOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Entity}
*/
public ServiceCall<Entity> createEntity(CreateEntityOptions createEntityOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createEntityOptions, "createEntityOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", createEntityOptions.workspaceId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createEntity");
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 (createEntityOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(createEntityOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("entity", createEntityOptions.entity());
if (createEntityOptions.description() != null) {
contentJson.addProperty("description", createEntityOptions.description());
}
if (createEntityOptions.metadata() != null) {
contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createEntityOptions.metadata()));
}
if (createEntityOptions.fuzzyMatch() != null) {
contentJson.addProperty("fuzzy_match", createEntityOptions.fuzzyMatch());
}
if (createEntityOptions.values() != null) {
contentJson.add("values", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createEntityOptions.values()));
}
builder.bodyJson(contentJson);
ResponseConverter<Entity> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Entity>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations