use of com.ibm.watson.assistant.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class Assistant method updateEntity.
/**
* Update entity.
*
* <p>Update an existing entity with new or modified data. You must provide component objects
* defining the content of the updated entity.
*
* <p>If you want to update multiple entities with a single API call, consider using the **[Update
* workspace](#update-workspace)** method instead.
*
* @param updateEntityOptions the {@link UpdateEntityOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Entity}
*/
public ServiceCall<Entity> updateEntity(UpdateEntityOptions updateEntityOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateEntityOptions, "updateEntityOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", updateEntityOptions.workspaceId());
pathParamsMap.put("entity", updateEntityOptions.entity());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateEntity");
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 (updateEntityOptions.append() != null) {
builder.query("append", String.valueOf(updateEntityOptions.append()));
}
if (updateEntityOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(updateEntityOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
if (updateEntityOptions.newEntity() != null) {
contentJson.addProperty("entity", updateEntityOptions.newEntity());
}
if (updateEntityOptions.newDescription() != null) {
contentJson.addProperty("description", updateEntityOptions.newDescription());
}
if (updateEntityOptions.newMetadata() != null) {
contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateEntityOptions.newMetadata()));
}
if (updateEntityOptions.newFuzzyMatch() != null) {
contentJson.addProperty("fuzzy_match", updateEntityOptions.newFuzzyMatch());
}
if (updateEntityOptions.newValues() != null) {
contentJson.add("values", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateEntityOptions.newValues()));
}
builder.bodyJson(contentJson);
ResponseConverter<Entity> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Entity>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.assistant.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class Assistant method updateValue.
/**
* Update entity value.
*
* <p>Update an existing entity value with new or modified data. You must provide component
* objects defining the content of the updated entity value.
*
* <p>If you want to update multiple entity values with a single API call, consider using the
* **[Update entity](#update-entity)** method instead.
*
* @param updateValueOptions the {@link UpdateValueOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Value}
*/
public ServiceCall<Value> updateValue(UpdateValueOptions updateValueOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateValueOptions, "updateValueOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", updateValueOptions.workspaceId());
pathParamsMap.put("entity", updateValueOptions.entity());
pathParamsMap.put("value", updateValueOptions.value());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateValue");
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 (updateValueOptions.append() != null) {
builder.query("append", String.valueOf(updateValueOptions.append()));
}
if (updateValueOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(updateValueOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
if (updateValueOptions.newValue() != null) {
contentJson.addProperty("value", updateValueOptions.newValue());
}
if (updateValueOptions.newMetadata() != null) {
contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateValueOptions.newMetadata()));
}
if (updateValueOptions.newType() != null) {
contentJson.addProperty("type", updateValueOptions.newType());
}
if (updateValueOptions.newSynonyms() != null) {
contentJson.add("synonyms", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateValueOptions.newSynonyms()));
}
if (updateValueOptions.newPatterns() != null) {
contentJson.add("patterns", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateValueOptions.newPatterns()));
}
builder.bodyJson(contentJson);
ResponseConverter<Value> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Value>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.assistant.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class Assistant method getEntity.
/**
* Get entity.
*
* <p>Get information about an entity, optionally including all entity content.
*
* @param getEntityOptions the {@link GetEntityOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Entity}
*/
public ServiceCall<Entity> getEntity(GetEntityOptions getEntityOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getEntityOptions, "getEntityOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", getEntityOptions.workspaceId());
pathParamsMap.put("entity", getEntityOptions.entity());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getEntity");
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 (getEntityOptions.export() != null) {
builder.query("export", String.valueOf(getEntityOptions.export()));
}
if (getEntityOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(getEntityOptions.includeAudit()));
}
ResponseConverter<Entity> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Entity>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.assistant.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class Assistant method listSynonyms.
/**
* List entity value synonyms.
*
* <p>List the synonyms for an entity value.
*
* @param listSynonymsOptions the {@link ListSynonymsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link SynonymCollection}
*/
public ServiceCall<SynonymCollection> listSynonyms(ListSynonymsOptions listSynonymsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listSynonymsOptions, "listSynonymsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", listSynonymsOptions.workspaceId());
pathParamsMap.put("entity", listSynonymsOptions.entity());
pathParamsMap.put("value", listSynonymsOptions.value());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listSynonyms");
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 (listSynonymsOptions.pageLimit() != null) {
builder.query("page_limit", String.valueOf(listSynonymsOptions.pageLimit()));
}
if (listSynonymsOptions.includeCount() != null) {
builder.query("include_count", String.valueOf(listSynonymsOptions.includeCount()));
}
if (listSynonymsOptions.sort() != null) {
builder.query("sort", String.valueOf(listSynonymsOptions.sort()));
}
if (listSynonymsOptions.cursor() != null) {
builder.query("cursor", String.valueOf(listSynonymsOptions.cursor()));
}
if (listSynonymsOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(listSynonymsOptions.includeAudit()));
}
ResponseConverter<SynonymCollection> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SynonymCollection>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.assistant.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class Assistant method createEntity.
/**
* Create entity.
*
* <p>Create a new entity, or enable a system entity.
*
* <p>If you want to create multiple entities with a single API call, consider using the **[Update
* workspace](#update-workspace)** method instead.
*
* @param createEntityOptions the {@link CreateEntityOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Entity}
*/
public ServiceCall<Entity> createEntity(CreateEntityOptions createEntityOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createEntityOptions, "createEntityOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", createEntityOptions.workspaceId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createEntity");
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 (createEntityOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(createEntityOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("entity", createEntityOptions.entity());
if (createEntityOptions.description() != null) {
contentJson.addProperty("description", createEntityOptions.description());
}
if (createEntityOptions.metadata() != null) {
contentJson.add("metadata", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createEntityOptions.metadata()));
}
if (createEntityOptions.fuzzyMatch() != null) {
contentJson.addProperty("fuzzy_match", createEntityOptions.fuzzyMatch());
}
if (createEntityOptions.values() != null) {
contentJson.add("values", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createEntityOptions.values()));
}
builder.bodyJson(contentJson);
ResponseConverter<Entity> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Entity>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations