use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class VisualRecognition method listClassifiers.
/**
* Retrieve a list of classifiers.
*
* @param listClassifiersOptions the {@link ListClassifiersOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Classifiers}
*/
public ServiceCall<Classifiers> listClassifiers(ListClassifiersOptions listClassifiersOptions) {
String[] pathSegments = { "v3/classifiers" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query(VERSION, versionDate);
if (listClassifiersOptions != null) {
if (listClassifiersOptions.verbose() != null) {
builder.query("verbose", String.valueOf(listClassifiersOptions.verbose()));
}
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifiers.class));
}
use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class VisualRecognition method getClassifier.
/**
* Retrieve classifier details.
*
* Retrieve information about a custom classifier.
*
* @param getClassifierOptions the {@link GetClassifierOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Classifier}
*/
public ServiceCall<Classifier> getClassifier(GetClassifierOptions getClassifierOptions) {
Validator.notNull(getClassifierOptions, "getClassifierOptions cannot be null");
String[] pathSegments = { "v3/classifiers" };
String[] pathParameters = { getClassifierOptions.classifierId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class));
}
use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class NaturalLanguageUnderstanding method analyze.
/**
* Analyze text, HTML, or a public webpage.
*
* Analyzes text, HTML, or a public webpage with one or more text analysis features.
*
* @param analyzeOptions the {@link AnalyzeOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link AnalysisResults}
*/
public ServiceCall<AnalysisResults> analyze(AnalyzeOptions analyzeOptions) {
Validator.notNull(analyzeOptions, "analyzeOptions cannot be null");
String[] pathSegments = { "v1/analyze" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query(VERSION, versionDate);
final JsonObject contentJson = new JsonObject();
if (analyzeOptions.text() != null) {
contentJson.addProperty("text", analyzeOptions.text());
}
if (analyzeOptions.html() != null) {
contentJson.addProperty("html", analyzeOptions.html());
}
if (analyzeOptions.url() != null) {
contentJson.addProperty("url", analyzeOptions.url());
}
contentJson.add("features", GsonSingleton.getGson().toJsonTree(analyzeOptions.features()));
if (analyzeOptions.clean() != null) {
contentJson.addProperty("clean", analyzeOptions.clean());
}
if (analyzeOptions.xpath() != null) {
contentJson.addProperty("xpath", analyzeOptions.xpath());
}
if (analyzeOptions.fallbackToRaw() != null) {
contentJson.addProperty("fallback_to_raw", analyzeOptions.fallbackToRaw());
}
if (analyzeOptions.returnAnalyzedText() != null) {
contentJson.addProperty("return_analyzed_text", analyzeOptions.returnAnalyzedText());
}
if (analyzeOptions.language() != null) {
contentJson.addProperty("language", analyzeOptions.language());
}
if (analyzeOptions.limitTextCharacters() != null) {
contentJson.addProperty("limit_text_characters", analyzeOptions.limitTextCharacters());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(AnalysisResults.class));
}
use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class VisualRecognition method getCoreMlModel.
/**
* Retrieve a Core ML model of a classifier.
*
* Download a Core ML model file (.mlmodel) of a custom classifier that returns <tt>\"core_ml_enabled\": true</tt> in
* the classifier details.
*
* @param getCoreMlModelOptions the {@link GetCoreMlModelOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link InputStream}
*/
public ServiceCall<InputStream> getCoreMlModel(GetCoreMlModelOptions getCoreMlModelOptions) {
Validator.notNull(getCoreMlModelOptions, "getCoreMlModelOptions cannot be null");
String[] pathSegments = { "v3/classifiers", "core_ml_model" };
String[] pathParameters = { getCoreMlModelOptions.classifierId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getInputStream());
}
use of com.ibm.watson.developer_cloud.http.RequestBuilder in project java-sdk by watson-developer-cloud.
the class Conversation method updateWorkspace.
/**
* Update workspace.
*
* Update an existing workspace with new or modified data. You must provide component objects defining the content of
* the updated workspace.
*
* @param updateWorkspaceOptions the {@link UpdateWorkspaceOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Workspace}
*/
public ServiceCall<Workspace> updateWorkspace(UpdateWorkspaceOptions updateWorkspaceOptions) {
Validator.notNull(updateWorkspaceOptions, "updateWorkspaceOptions cannot be null");
String[] pathSegments = { "v1/workspaces" };
String[] pathParameters = { updateWorkspaceOptions.workspaceId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
if (updateWorkspaceOptions.append() != null) {
builder.query("append", String.valueOf(updateWorkspaceOptions.append()));
}
final JsonObject contentJson = new JsonObject();
if (updateWorkspaceOptions.name() != null) {
contentJson.addProperty("name", updateWorkspaceOptions.name());
}
if (updateWorkspaceOptions.description() != null) {
contentJson.addProperty("description", updateWorkspaceOptions.description());
}
if (updateWorkspaceOptions.language() != null) {
contentJson.addProperty("language", updateWorkspaceOptions.language());
}
if (updateWorkspaceOptions.intents() != null) {
contentJson.add("intents", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.intents()));
}
if (updateWorkspaceOptions.entities() != null) {
contentJson.add("entities", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.entities()));
}
if (updateWorkspaceOptions.dialogNodes() != null) {
contentJson.add("dialog_nodes", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.dialogNodes()));
}
if (updateWorkspaceOptions.counterexamples() != null) {
contentJson.add("counterexamples", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.counterexamples()));
}
if (updateWorkspaceOptions.metadata() != null) {
contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.metadata()));
}
if (updateWorkspaceOptions.learningOptOut() != null) {
contentJson.addProperty("learning_opt_out", updateWorkspaceOptions.learningOptOut());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Workspace.class));
}
Aggregations