use of com.ibm.watson.discovery.v2.model.CollectionDetails in project java-sdk by watson-developer-cloud.
the class Discovery method updateCollection.
/**
* Update a collection.
*
* <p>Updates the specified collection's name, description, and enrichments.
*
* @param updateCollectionOptions the {@link UpdateCollectionOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link CollectionDetails}
*/
public ServiceCall<CollectionDetails> updateCollection(UpdateCollectionOptions updateCollectionOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateCollectionOptions, "updateCollectionOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("project_id", updateCollectionOptions.projectId());
pathParamsMap.put("collection_id", updateCollectionOptions.collectionId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/projects/{project_id}/collections/{collection_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "updateCollection");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("version", String.valueOf(this.version));
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.enrichments() != null) {
contentJson.add("enrichments", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateCollectionOptions.enrichments()));
}
builder.bodyJson(contentJson);
ResponseConverter<CollectionDetails> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<CollectionDetails>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations