use of com.ibm.cloud.sdk.core.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method deleteValue.
/**
* Delete entity value.
*
* <p>Delete a value from an entity.
*
* @param deleteValueOptions the {@link DeleteValueOptions} containing the options for the call
* @return a {@link ServiceCall} with a void result
*/
public ServiceCall<Void> deleteValue(DeleteValueOptions deleteValueOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteValueOptions, "deleteValueOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", deleteValueOptions.workspaceId());
pathParamsMap.put("entity", deleteValueOptions.entity());
pathParamsMap.put("value", deleteValueOptions.value());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteValue");
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));
ResponseConverter<Void> responseConverter = ResponseConverterUtils.getVoid();
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 createWorkspace.
/**
* Create workspace.
*
* <p>Create a workspace based on component objects. You must provide workspace components
* defining the content of the new workspace.
*
* @param createWorkspaceOptions the {@link CreateWorkspaceOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a result of type {@link Workspace}
*/
public ServiceCall<Workspace> createWorkspace(CreateWorkspaceOptions createWorkspaceOptions) {
boolean skipBody = false;
if (createWorkspaceOptions == null) {
createWorkspaceOptions = new CreateWorkspaceOptions.Builder().build();
skipBody = true;
}
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createWorkspace");
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 (createWorkspaceOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(createWorkspaceOptions.includeAudit()));
}
if (!skipBody) {
final JsonObject contentJson = new JsonObject();
if (createWorkspaceOptions.name() != null) {
contentJson.addProperty("name", createWorkspaceOptions.name());
}
if (createWorkspaceOptions.description() != null) {
contentJson.addProperty("description", createWorkspaceOptions.description());
}
if (createWorkspaceOptions.language() != null) {
contentJson.addProperty("language", createWorkspaceOptions.language());
}
if (createWorkspaceOptions.dialogNodes() != null) {
contentJson.add("dialog_nodes", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.dialogNodes()));
}
if (createWorkspaceOptions.counterexamples() != null) {
contentJson.add("counterexamples", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.counterexamples()));
}
if (createWorkspaceOptions.metadata() != null) {
contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.metadata()));
}
if (createWorkspaceOptions.learningOptOut() != null) {
contentJson.addProperty("learning_opt_out", createWorkspaceOptions.learningOptOut());
}
if (createWorkspaceOptions.systemSettings() != null) {
contentJson.add("system_settings", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.systemSettings()));
}
if (createWorkspaceOptions.webhooks() != null) {
contentJson.add("webhooks", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.webhooks()));
}
if (createWorkspaceOptions.intents() != null) {
contentJson.add("intents", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.intents()));
}
if (createWorkspaceOptions.entities() != null) {
contentJson.add("entities", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.entities()));
}
builder.bodyJson(contentJson);
}
ResponseConverter<Workspace> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Workspace>() {
}.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 updateDialogNodeNullable.
/**
* 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 UpdateDialogNodeNullableOptions the {@link UpdateDialogNodeNullableOptions} containing
* the options for the call
* @return a {@link ServiceCall} with a result of type {@link DialogNode}
*/
public ServiceCall<DialogNode> updateDialogNodeNullable(UpdateDialogNodeNullableOptions UpdateDialogNodeNullableOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(UpdateDialogNodeNullableOptions, "UpdateDialogNodeNullableOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", UpdateDialogNodeNullableOptions.workspaceId());
pathParamsMap.put("dialog_node", UpdateDialogNodeNullableOptions.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", "testUpdateDialogNode");
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 (UpdateDialogNodeNullableOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(UpdateDialogNodeNullableOptions.includeAudit()));
}
builder.bodyContent(com.ibm.cloud.sdk.core.util.GsonSingleton.getGsonWithSerializeNulls().toJson(UpdateDialogNodeNullableOptions.body()), "application/json");
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 createValue.
/**
* Create entity value.
*
* <p>Create a new value for an entity.
*
* <p>If you want to create multiple entity values with a single API call, consider using the
* **[Update entity](#update-entity)** method instead.
*
* @param createValueOptions the {@link CreateValueOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Value}
*/
public ServiceCall<Value> createValue(CreateValueOptions createValueOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createValueOptions, "createValueOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", createValueOptions.workspaceId());
pathParamsMap.put("entity", createValueOptions.entity());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/values", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createValue");
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 (createValueOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(createValueOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("value", createValueOptions.value());
if (createValueOptions.metadata() != null) {
contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createValueOptions.metadata()));
}
if (createValueOptions.type() != null) {
contentJson.addProperty("type", createValueOptions.type());
}
if (createValueOptions.synonyms() != null) {
contentJson.add("synonyms", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createValueOptions.synonyms()));
}
if (createValueOptions.patterns() != null) {
contentJson.add("patterns", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createValueOptions.patterns()));
}
builder.bodyJson(contentJson);
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 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);
}
Aggregations