use of com.ibm.watson.assistant.v1.model.Example in project java-sdk by watson-developer-cloud.
the class Assistant method updateExample.
/**
* Update user input example.
*
* <p>Update the text of a user input example.
*
* <p>If you want to update multiple examples with a single API call, consider using the **[Update
* intent](#update-intent)** method instead.
*
* @param updateExampleOptions the {@link UpdateExampleOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a result of type {@link Example}
*/
public ServiceCall<Example> updateExample(UpdateExampleOptions updateExampleOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateExampleOptions, "updateExampleOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", updateExampleOptions.workspaceId());
pathParamsMap.put("intent", updateExampleOptions.intent());
pathParamsMap.put("text", updateExampleOptions.text());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}/examples/{text}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateExample");
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 (updateExampleOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(updateExampleOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
if (updateExampleOptions.newText() != null) {
contentJson.addProperty("text", updateExampleOptions.newText());
}
if (updateExampleOptions.newMentions() != null) {
contentJson.add("mentions", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateExampleOptions.newMentions()));
}
builder.bodyJson(contentJson);
ResponseConverter<Example> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Example>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations