use of com.ibm.watson.assistant.v1.model.Synonym in project java-sdk by watson-developer-cloud.
the class Assistant method getSynonym.
/**
* Get entity value synonym.
*
* <p>Get information about a synonym of an entity value.
*
* @param getSynonymOptions the {@link GetSynonymOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Synonym}
*/
public ServiceCall<Synonym> getSynonym(GetSynonymOptions getSynonymOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getSynonymOptions, "getSynonymOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", getSynonymOptions.workspaceId());
pathParamsMap.put("entity", getSynonymOptions.entity());
pathParamsMap.put("value", getSynonymOptions.value());
pathParamsMap.put("synonym", getSynonymOptions.synonym());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getSynonym");
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 (getSynonymOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(getSynonymOptions.includeAudit()));
}
ResponseConverter<Synonym> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Synonym>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.assistant.v1.model.Synonym in project java-sdk by watson-developer-cloud.
the class Assistant method updateSynonym.
/**
* Update entity value synonym.
*
* <p>Update an existing entity value synonym with new text.
*
* <p>If you want to update multiple synonyms with a single API call, consider using the **[Update
* entity](#update-entity)** or **[Update entity value](#update-entity-value)** method instead.
*
* @param updateSynonymOptions the {@link UpdateSynonymOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a result of type {@link Synonym}
*/
public ServiceCall<Synonym> updateSynonym(UpdateSynonymOptions updateSynonymOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateSynonymOptions, "updateSynonymOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", updateSynonymOptions.workspaceId());
pathParamsMap.put("entity", updateSynonymOptions.entity());
pathParamsMap.put("value", updateSynonymOptions.value());
pathParamsMap.put("synonym", updateSynonymOptions.synonym());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateSynonym");
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 (updateSynonymOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(updateSynonymOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
if (updateSynonymOptions.newSynonym() != null) {
contentJson.addProperty("synonym", updateSynonymOptions.newSynonym());
}
builder.bodyJson(contentJson);
ResponseConverter<Synonym> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Synonym>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations