Search in sources :

Example 26 with RequestBuilder

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));
}
Also used : Classifiers(com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifiers) RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder)

Example 27 with RequestBuilder

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));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) Classifier(com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier)

Example 28 with RequestBuilder

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));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) AnalysisResults(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalysisResults) JsonObject(com.google.gson.JsonObject)

Example 29 with RequestBuilder

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());
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder)

Example 30 with RequestBuilder

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));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) JsonObject(com.google.gson.JsonObject) Workspace(com.ibm.watson.developer_cloud.conversation.v1.model.Workspace)

Aggregations

RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)206 JsonObject (com.google.gson.JsonObject)60 MultipartBody (okhttp3.MultipartBody)10 RequestBody (okhttp3.RequestBody)10 Counterexample (com.ibm.watson.developer_cloud.assistant.v1.model.Counterexample)3 DialogNode (com.ibm.watson.developer_cloud.assistant.v1.model.DialogNode)3 Example (com.ibm.watson.developer_cloud.assistant.v1.model.Example)3 Synonym (com.ibm.watson.developer_cloud.assistant.v1.model.Synonym)3 Counterexample (com.ibm.watson.developer_cloud.conversation.v1.model.Counterexample)3 DialogNode (com.ibm.watson.developer_cloud.conversation.v1.model.DialogNode)3 Example (com.ibm.watson.developer_cloud.conversation.v1.model.Example)3 Synonym (com.ibm.watson.developer_cloud.conversation.v1.model.Synonym)3 Collection (com.ibm.watson.developer_cloud.discovery.v1.model.Collection)3 Configuration (com.ibm.watson.developer_cloud.discovery.v1.model.Configuration)3 Environment (com.ibm.watson.developer_cloud.discovery.v1.model.Environment)3 Entity (com.ibm.watson.developer_cloud.assistant.v1.model.Entity)2 Intent (com.ibm.watson.developer_cloud.assistant.v1.model.Intent)2 LogCollection (com.ibm.watson.developer_cloud.assistant.v1.model.LogCollection)2 Value (com.ibm.watson.developer_cloud.assistant.v1.model.Value)2 Workspace (com.ibm.watson.developer_cloud.assistant.v1.model.Workspace)2