use of com.ibm.watson.assistant.v1.model.UpdateIntentOptions in project java-sdk by watson-developer-cloud.
the class Assistant method updateIntent.
/**
* Update intent.
*
* <p>Update an existing intent with new or modified data. You must provide component objects
* defining the content of the updated intent.
*
* <p>If you want to update multiple intents with a single API call, consider using the **[Update
* workspace](#update-workspace)** method instead.
*
* @param updateIntentOptions the {@link UpdateIntentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Intent}
*/
public ServiceCall<Intent> updateIntent(UpdateIntentOptions updateIntentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateIntentOptions, "updateIntentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", updateIntentOptions.workspaceId());
pathParamsMap.put("intent", updateIntentOptions.intent());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateIntent");
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 (updateIntentOptions.append() != null) {
builder.query("append", String.valueOf(updateIntentOptions.append()));
}
if (updateIntentOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(updateIntentOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
if (updateIntentOptions.newIntent() != null) {
contentJson.addProperty("intent", updateIntentOptions.newIntent());
}
if (updateIntentOptions.newDescription() != null) {
contentJson.addProperty("description", updateIntentOptions.newDescription());
}
if (updateIntentOptions.newExamples() != null) {
contentJson.add("examples", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateIntentOptions.newExamples()));
}
builder.bodyJson(contentJson);
ResponseConverter<Intent> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Intent>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations