Search in sources :

Example 1 with UpdateTrainingExampleOptions

use of com.ibm.watson.developer_cloud.discovery.v1.model.UpdateTrainingExampleOptions in project java-sdk by watson-developer-cloud.

the class Discovery method updateTrainingExample.

/**
 * Changes the label or cross reference query for this training example.
 *
 * @param updateTrainingExampleOptions the {@link UpdateTrainingExampleOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link TrainingExample}
 */
public ServiceCall<TrainingExample> updateTrainingExample(UpdateTrainingExampleOptions updateTrainingExampleOptions) {
    Validator.notNull(updateTrainingExampleOptions, "updateTrainingExampleOptions cannot be null");
    String[] pathSegments = { "v1/environments", "collections", "training_data", "examples" };
    String[] pathParameters = { updateTrainingExampleOptions.environmentId(), updateTrainingExampleOptions.collectionId(), updateTrainingExampleOptions.queryId(), updateTrainingExampleOptions.exampleId() };
    RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    final JsonObject contentJson = new JsonObject();
    if (updateTrainingExampleOptions.crossReference() != null) {
        contentJson.addProperty("cross_reference", updateTrainingExampleOptions.crossReference());
    }
    if (updateTrainingExampleOptions.relevance() != null) {
        contentJson.addProperty("relevance", updateTrainingExampleOptions.relevance());
    }
    builder.bodyJson(contentJson);
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingExample.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) TrainingExample(com.ibm.watson.developer_cloud.discovery.v1.model.TrainingExample) JsonObject(com.google.gson.JsonObject)

Aggregations

JsonObject (com.google.gson.JsonObject)1 TrainingExample (com.ibm.watson.developer_cloud.discovery.v1.model.TrainingExample)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1