use of com.ibm.watson.developer_cloud.discovery.v1.model.UpdateConfigurationOptions in project java-sdk by watson-developer-cloud.
the class Discovery method updateConfiguration.
/**
* Update a configuration.
*
* Replaces an existing configuration. * Completely replaces the original configuration. * The `configuration_id`,
* `updated`, and `created` fields are accepted in the request, but they are ignored, and an error is not generated.
* It is also acceptable for users to submit an updated configuration with none of the three properties. * Documents
* are processed with a snapshot of the configuration as it was at the time the document was submitted to be ingested.
* This means that already submitted documents will not see any updates made to the configuration.
*
* @param updateConfigurationOptions the {@link UpdateConfigurationOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Configuration}
*/
public ServiceCall<Configuration> updateConfiguration(UpdateConfigurationOptions updateConfigurationOptions) {
Validator.notNull(updateConfigurationOptions, "updateConfigurationOptions cannot be null");
String[] pathSegments = { "v1/environments", "configurations" };
String[] pathParameters = { updateConfigurationOptions.environmentId(), updateConfigurationOptions.configurationId() };
RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
final JsonObject contentJson = new JsonObject();
if (updateConfigurationOptions.name() != null) {
contentJson.addProperty("name", updateConfigurationOptions.name());
}
if (updateConfigurationOptions.description() != null) {
contentJson.addProperty("description", updateConfigurationOptions.description());
}
if (updateConfigurationOptions.conversions() != null) {
contentJson.add("conversions", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions.conversions()));
}
if (updateConfigurationOptions.enrichments() != null) {
contentJson.add("enrichments", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions.enrichments()));
}
if (updateConfigurationOptions.normalizations() != null) {
contentJson.add("normalizations", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions.normalizations()));
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Configuration.class));
}
Aggregations