Search in sources :

Example 41 with Synonym

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) Synonym(com.ibm.watson.assistant.v1.model.Synonym)

Example 42 with Synonym

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) Synonym(com.ibm.watson.assistant.v1.model.Synonym)

Aggregations

MockResponse (okhttp3.mockwebserver.MockResponse)17 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)17 Test (org.testng.annotations.Test)17 Test (org.junit.Test)16 Synonym (com.ibm.watson.assistant.v1.model.Synonym)11 NotFoundException (com.ibm.watson.developer_cloud.service.exception.NotFoundException)10 Synonym (com.ibm.watson.developer_cloud.assistant.v1.model.Synonym)8 Synonym (com.ibm.watson.developer_cloud.conversation.v1.model.Synonym)8 CreateEntityOptions (com.ibm.watson.assistant.v1.model.CreateEntityOptions)7 CreateSynonymOptions (com.ibm.watson.assistant.v1.model.CreateSynonymOptions)7 CreateValue (com.ibm.watson.assistant.v1.model.CreateValue)7 CreateValueOptions (com.ibm.watson.assistant.v1.model.CreateValueOptions)7 DeleteSynonymOptions (com.ibm.watson.assistant.v1.model.DeleteSynonymOptions)7 HashMap (java.util.HashMap)7 JsonObject (com.google.gson.JsonObject)6 NotFoundException (com.ibm.cloud.sdk.core.service.exception.NotFoundException)6 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)6 CreateEntity (com.ibm.watson.assistant.v1.model.CreateEntity)5 CreateEntityOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntityOptions)5 CreateSynonymOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateSynonymOptions)5