use of com.ibm.watson.developer_cloud.discovery.v1.model.UpdateCollectionOptions in project java-sdk by watson-developer-cloud.
the class Discovery method updateCollection.
/**
* Update a collection.
*
* @param updateCollectionOptions the {@link UpdateCollectionOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Collection}
*/
public ServiceCall<Collection> updateCollection(UpdateCollectionOptions updateCollectionOptions) {
Validator.notNull(updateCollectionOptions, "updateCollectionOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections" };
String[] pathParameters = { updateCollectionOptions.environmentId(), updateCollectionOptions.collectionId() };
RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
final JsonObject contentJson = new JsonObject();
if (updateCollectionOptions.name() != null) {
contentJson.addProperty("name", updateCollectionOptions.name());
}
if (updateCollectionOptions.description() != null) {
contentJson.addProperty("description", updateCollectionOptions.description());
}
if (updateCollectionOptions.configurationId() != null) {
contentJson.addProperty("configuration_id", updateCollectionOptions.configurationId());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class));
}
Aggregations