use of com.ibm.watson.assistant.v1.model.UpdateWorkspaceOptions in project java-sdk by watson-developer-cloud.
the class Assistant method updateWorkspace.
/**
* Update workspace.
*
* <p>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 result of type {@link Workspace}
*/
public ServiceCall<Workspace> updateWorkspace(UpdateWorkspaceOptions updateWorkspaceOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateWorkspaceOptions, "updateWorkspaceOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", updateWorkspaceOptions.workspaceId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateWorkspace");
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 (updateWorkspaceOptions.append() != null) {
builder.query("append", String.valueOf(updateWorkspaceOptions.append()));
}
if (updateWorkspaceOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(updateWorkspaceOptions.includeAudit()));
}
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.dialogNodes() != null) {
contentJson.add("dialog_nodes", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.dialogNodes()));
}
if (updateWorkspaceOptions.counterexamples() != null) {
contentJson.add("counterexamples", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.counterexamples()));
}
if (updateWorkspaceOptions.metadata() != null) {
contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.metadata()));
}
if (updateWorkspaceOptions.learningOptOut() != null) {
contentJson.addProperty("learning_opt_out", updateWorkspaceOptions.learningOptOut());
}
if (updateWorkspaceOptions.systemSettings() != null) {
contentJson.add("system_settings", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.systemSettings()));
}
if (updateWorkspaceOptions.webhooks() != null) {
contentJson.add("webhooks", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.webhooks()));
}
if (updateWorkspaceOptions.intents() != null) {
contentJson.add("intents", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.intents()));
}
if (updateWorkspaceOptions.entities() != null) {
contentJson.add("entities", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.entities()));
}
builder.bodyJson(contentJson);
ResponseConverter<Workspace> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Workspace>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations