use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method getCounterexample.
/**
* Get counterexample.
*
* <p>Get information about a counterexample. Counterexamples are examples that have been marked
* as irrelevant input.
*
* @param getCounterexampleOptions the {@link GetCounterexampleOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link Counterexample}
*/
public ServiceCall<Counterexample> getCounterexample(GetCounterexampleOptions getCounterexampleOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getCounterexampleOptions, "getCounterexampleOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", getCounterexampleOptions.workspaceId());
pathParamsMap.put("text", getCounterexampleOptions.text());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples/{text}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getCounterexample");
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 (getCounterexampleOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(getCounterexampleOptions.includeAudit()));
}
ResponseConverter<Counterexample> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Counterexample>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method createSynonym.
/**
* Create entity value synonym.
*
* <p>Add a new synonym to an entity value.
*
* <p>If you want to create multiple synonyms with a single API call, consider using the **[Update
* entity](#update-entity)** or **[Update entity value](#update-entity-value)** method instead.
*
* @param createSynonymOptions the {@link CreateSynonymOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a result of type {@link Synonym}
*/
public ServiceCall<Synonym> createSynonym(CreateSynonymOptions createSynonymOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createSynonymOptions, "createSynonymOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", createSynonymOptions.workspaceId());
pathParamsMap.put("entity", createSynonymOptions.entity());
pathParamsMap.put("value", createSynonymOptions.value());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createSynonym");
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 (createSynonymOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(createSynonymOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("synonym", createSynonymOptions.synonym());
builder.bodyJson(contentJson);
ResponseConverter<Synonym> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Synonym>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method createDialogNode.
/**
* Create dialog node.
*
* <p>Create a new dialog node.
*
* <p>If you want to create multiple dialog nodes with a single API call, consider using the
* **[Update workspace](#update-workspace)** method instead.
*
* @param createDialogNodeOptions the {@link CreateDialogNodeOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link DialogNode}
*/
public ServiceCall<DialogNode> createDialogNode(CreateDialogNodeOptions createDialogNodeOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createDialogNodeOptions, "createDialogNodeOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", createDialogNodeOptions.workspaceId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/dialog_nodes", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createDialogNode");
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 (createDialogNodeOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(createDialogNodeOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("dialog_node", createDialogNodeOptions.dialogNode());
if (createDialogNodeOptions.description() != null) {
contentJson.addProperty("description", createDialogNodeOptions.description());
}
if (createDialogNodeOptions.conditions() != null) {
contentJson.addProperty("conditions", createDialogNodeOptions.conditions());
}
if (createDialogNodeOptions.parent() != null) {
contentJson.addProperty("parent", createDialogNodeOptions.parent());
}
if (createDialogNodeOptions.previousSibling() != null) {
contentJson.addProperty("previous_sibling", createDialogNodeOptions.previousSibling());
}
if (createDialogNodeOptions.output() != null) {
contentJson.add("output", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.output()));
}
if (createDialogNodeOptions.context() != null) {
contentJson.add("context", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.context()));
}
if (createDialogNodeOptions.metadata() != null) {
contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.metadata()));
}
if (createDialogNodeOptions.nextStep() != null) {
contentJson.add("next_step", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.nextStep()));
}
if (createDialogNodeOptions.title() != null) {
contentJson.addProperty("title", createDialogNodeOptions.title());
}
if (createDialogNodeOptions.type() != null) {
contentJson.addProperty("type", createDialogNodeOptions.type());
}
if (createDialogNodeOptions.eventName() != null) {
contentJson.addProperty("event_name", createDialogNodeOptions.eventName());
}
if (createDialogNodeOptions.variable() != null) {
contentJson.addProperty("variable", createDialogNodeOptions.variable());
}
if (createDialogNodeOptions.actions() != null) {
contentJson.add("actions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.actions()));
}
if (createDialogNodeOptions.digressIn() != null) {
contentJson.addProperty("digress_in", createDialogNodeOptions.digressIn());
}
if (createDialogNodeOptions.digressOut() != null) {
contentJson.addProperty("digress_out", createDialogNodeOptions.digressOut());
}
if (createDialogNodeOptions.digressOutSlots() != null) {
contentJson.addProperty("digress_out_slots", createDialogNodeOptions.digressOutSlots());
}
if (createDialogNodeOptions.userLabel() != null) {
contentJson.addProperty("user_label", createDialogNodeOptions.userLabel());
}
if (createDialogNodeOptions.disambiguationOptOut() != null) {
contentJson.addProperty("disambiguation_opt_out", createDialogNodeOptions.disambiguationOptOut());
}
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.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method getValue.
/**
* Get entity value.
*
* <p>Get information about an entity value.
*
* @param getValueOptions the {@link GetValueOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Value}
*/
public ServiceCall<Value> getValue(GetValueOptions getValueOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getValueOptions, "getValueOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", getValueOptions.workspaceId());
pathParamsMap.put("entity", getValueOptions.entity());
pathParamsMap.put("value", getValueOptions.value());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getValue");
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 (getValueOptions.export() != null) {
builder.query("export", String.valueOf(getValueOptions.export()));
}
if (getValueOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(getValueOptions.includeAudit()));
}
ResponseConverter<Value> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Value>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method getWorkspace.
/**
* Get information about a workspace.
*
* <p>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 result of type {@link Workspace}
*/
public ServiceCall<Workspace> getWorkspace(GetWorkspaceOptions getWorkspaceOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getWorkspaceOptions, "getWorkspaceOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", getWorkspaceOptions.workspaceId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getWorkspace");
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 (getWorkspaceOptions.export() != null) {
builder.query("export", String.valueOf(getWorkspaceOptions.export()));
}
if (getWorkspaceOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(getWorkspaceOptions.includeAudit()));
}
if (getWorkspaceOptions.sort() != null) {
builder.query("sort", String.valueOf(getWorkspaceOptions.sort()));
}
ResponseConverter<Workspace> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Workspace>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations