use of com.ibm.watson.developer_cloud.conversation.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class Conversation method getEntity.
/**
* Get entity.
*
* 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 response type of {@link EntityExport}
*/
public ServiceCall<EntityExport> getEntity(GetEntityOptions getEntityOptions) {
Validator.notNull(getEntityOptions, "getEntityOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "entities" };
String[] pathParameters = { getEntityOptions.workspaceId(), getEntityOptions.entity() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
if (getEntityOptions.export() != null) {
builder.query("export", String.valueOf(getEntityOptions.export()));
}
if (getEntityOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(getEntityOptions.includeAudit()));
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(EntityExport.class));
}
use of com.ibm.watson.developer_cloud.conversation.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class Conversation method updateValue.
/**
* Update entity value.
*
* Update the content of a value for an entity.
*
* @param updateValueOptions the {@link UpdateValueOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Value}
*/
public ServiceCall<Value> updateValue(UpdateValueOptions updateValueOptions) {
Validator.notNull(updateValueOptions, "updateValueOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "entities", "values" };
String[] pathParameters = { updateValueOptions.workspaceId(), updateValueOptions.entity(), updateValueOptions.value() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
final JsonObject contentJson = new JsonObject();
if (updateValueOptions.newSynonyms() != null) {
contentJson.add("synonyms", GsonSingleton.getGson().toJsonTree(updateValueOptions.newSynonyms()));
}
if (updateValueOptions.valueType() != null) {
contentJson.addProperty("type", updateValueOptions.valueType());
}
if (updateValueOptions.newMetadata() != null) {
contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateValueOptions.newMetadata()));
}
if (updateValueOptions.newPatterns() != null) {
contentJson.add("patterns", GsonSingleton.getGson().toJsonTree(updateValueOptions.newPatterns()));
}
if (updateValueOptions.newValue() != null) {
contentJson.addProperty("value", updateValueOptions.newValue());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Value.class));
}
use of com.ibm.watson.developer_cloud.conversation.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class Conversation method updateEntity.
/**
* Update entity.
*
* Update an existing entity with new or modified data.
*
* @param updateEntityOptions the {@link UpdateEntityOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Entity}
*/
public ServiceCall<Entity> updateEntity(UpdateEntityOptions updateEntityOptions) {
Validator.notNull(updateEntityOptions, "updateEntityOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "entities" };
String[] pathParameters = { updateEntityOptions.workspaceId(), updateEntityOptions.entity() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
final JsonObject contentJson = new JsonObject();
if (updateEntityOptions.newFuzzyMatch() != null) {
contentJson.addProperty("fuzzy_match", updateEntityOptions.newFuzzyMatch());
}
if (updateEntityOptions.newEntity() != null) {
contentJson.addProperty("entity", updateEntityOptions.newEntity());
}
if (updateEntityOptions.newMetadata() != null) {
contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateEntityOptions.newMetadata()));
}
if (updateEntityOptions.newValues() != null) {
contentJson.add("values", GsonSingleton.getGson().toJsonTree(updateEntityOptions.newValues()));
}
if (updateEntityOptions.newDescription() != null) {
contentJson.addProperty("description", updateEntityOptions.newDescription());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Entity.class));
}
use of com.ibm.watson.developer_cloud.conversation.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class Conversation method getSynonym.
/**
* Get entity value synonym.
*
* Get information about a synonym for an entity value.
*
* @param getSynonymOptions the {@link GetSynonymOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Synonym}
*/
public ServiceCall<Synonym> getSynonym(GetSynonymOptions getSynonymOptions) {
Validator.notNull(getSynonymOptions, "getSynonymOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" };
String[] pathParameters = { getSynonymOptions.workspaceId(), getSynonymOptions.entity(), getSynonymOptions.value(), getSynonymOptions.synonym() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
if (getSynonymOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(getSynonymOptions.includeAudit()));
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class));
}
use of com.ibm.watson.developer_cloud.conversation.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class Assistant method createEntity.
/**
* Create entity.
*
* Create a new entity. This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate
* limiting**.
*
* @param createEntityOptions the {@link CreateEntityOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Entity}
*/
public ServiceCall<Entity> createEntity(CreateEntityOptions createEntityOptions) {
Validator.notNull(createEntityOptions, "createEntityOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "entities" };
String[] pathParameters = { createEntityOptions.workspaceId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
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", GsonSingleton.getGson().toJsonTree(createEntityOptions.metadata()));
}
if (createEntityOptions.values() != null) {
contentJson.add("values", GsonSingleton.getGson().toJsonTree(createEntityOptions.values()));
}
if (createEntityOptions.fuzzyMatch() != null) {
contentJson.addProperty("fuzzy_match", createEntityOptions.fuzzyMatch());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Entity.class));
}
Aggregations