use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method listIntents.
/**
* List intents.
*
* List the intents for a workspace. With **export**=`false`, this operation is limited to 2000 requests per 30
* minutes. With **export**=`true`, the limit is 400 requests per 30 minutes. For more information, see **Rate
* limiting**.
*
* @param listIntentsOptions the {@link ListIntentsOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link IntentCollection}
*/
public ServiceCall<IntentCollection> listIntents(ListIntentsOptions listIntentsOptions) {
Validator.notNull(listIntentsOptions, "listIntentsOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "intents" };
String[] pathParameters = { listIntentsOptions.workspaceId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
if (listIntentsOptions.export() != null) {
builder.query("export", String.valueOf(listIntentsOptions.export()));
}
if (listIntentsOptions.pageLimit() != null) {
builder.query("page_limit", String.valueOf(listIntentsOptions.pageLimit()));
}
if (listIntentsOptions.includeCount() != null) {
builder.query("include_count", String.valueOf(listIntentsOptions.includeCount()));
}
if (listIntentsOptions.sort() != null) {
builder.query("sort", listIntentsOptions.sort());
}
if (listIntentsOptions.cursor() != null) {
builder.query("cursor", listIntentsOptions.cursor());
}
if (listIntentsOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(listIntentsOptions.includeAudit()));
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IntentCollection.class));
}
use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method createWorkspace.
/**
* Create workspace.
*
* Create a workspace based on component objects. You must provide workspace components defining the content of the
* new workspace. This operation is limited to 30 requests per 30 minutes. For more information, see **Rate
* limiting**.
*
* @param createWorkspaceOptions the {@link CreateWorkspaceOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Workspace}
*/
public ServiceCall<Workspace> createWorkspace(CreateWorkspaceOptions createWorkspaceOptions) {
String[] pathSegments = { "v1/workspaces" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query(VERSION, versionDate);
if (createWorkspaceOptions != null) {
final JsonObject contentJson = new JsonObject();
if (createWorkspaceOptions.name() != null) {
contentJson.addProperty("name", createWorkspaceOptions.name());
}
if (createWorkspaceOptions.description() != null) {
contentJson.addProperty("description", createWorkspaceOptions.description());
}
if (createWorkspaceOptions.language() != null) {
contentJson.addProperty("language", createWorkspaceOptions.language());
}
if (createWorkspaceOptions.intents() != null) {
contentJson.add("intents", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.intents()));
}
if (createWorkspaceOptions.entities() != null) {
contentJson.add("entities", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.entities()));
}
if (createWorkspaceOptions.dialogNodes() != null) {
contentJson.add("dialog_nodes", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.dialogNodes()));
}
if (createWorkspaceOptions.counterexamples() != null) {
contentJson.add("counterexamples", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.counterexamples()));
}
if (createWorkspaceOptions.metadata() != null) {
contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.metadata()));
}
if (createWorkspaceOptions.learningOptOut() != null) {
contentJson.addProperty("learning_opt_out", createWorkspaceOptions.learningOptOut());
}
builder.bodyJson(contentJson);
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Workspace.class));
}
use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method updateIntent.
/**
* Update intent.
*
* Update an existing intent with new or modified data. You must provide component objects defining the content of the
* updated intent. This operation is limited to 2000 requests per 30 minutes. For more information, see **Rate
* limiting**.
*
* @param updateIntentOptions the {@link UpdateIntentOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Intent}
*/
public ServiceCall<Intent> updateIntent(UpdateIntentOptions updateIntentOptions) {
Validator.notNull(updateIntentOptions, "updateIntentOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "intents" };
String[] pathParameters = { updateIntentOptions.workspaceId(), updateIntentOptions.intent() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
final JsonObject contentJson = new JsonObject();
if (updateIntentOptions.newIntent() != null) {
contentJson.addProperty("intent", updateIntentOptions.newIntent());
}
if (updateIntentOptions.newExamples() != null) {
contentJson.add("examples", GsonSingleton.getGson().toJsonTree(updateIntentOptions.newExamples()));
}
if (updateIntentOptions.newDescription() != null) {
contentJson.addProperty("description", updateIntentOptions.newDescription());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Intent.class));
}
use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method updateEntity.
/**
* Update entity.
*
* Update an existing entity with new or modified data. You must provide component objects defining the content of the
* updated entity. This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate
* limiting**.
*
* @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.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Assistant method createSynonym.
/**
* Add entity value synonym.
*
* Add a new synonym to an entity value. This operation is limited to 1000 requests per 30 minutes. For more
* information, see **Rate limiting**.
*
* @param createSynonymOptions the {@link CreateSynonymOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Synonym}
*/
public ServiceCall<Synonym> createSynonym(CreateSynonymOptions createSynonymOptions) {
Validator.notNull(createSynonymOptions, "createSynonymOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "entities", "values", "synonyms" };
String[] pathParameters = { createSynonymOptions.workspaceId(), createSynonymOptions.entity(), createSynonymOptions.value() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("synonym", createSynonymOptions.synonym());
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class));
}
Aggregations