use of com.ibm.cloud.cloudant.v1.model.PostBulkGetOptions in project cloudant-java-sdk by IBM.
the class Cloudant method postBulkGet.
/**
* Bulk query revision information for multiple documents.
*
* Fetch specific revisions or revision histories for multiple documents in bulk as replicators do.
*
* @param postBulkGetOptions the {@link PostBulkGetOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link BulkGetResult}
*/
public ServiceCall<BulkGetResult> postBulkGet(PostBulkGetOptions postBulkGetOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postBulkGetOptions, "postBulkGetOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", postBulkGetOptions.db());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_bulk_get", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postBulkGet");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (postBulkGetOptions.attachments() != null) {
builder.query("attachments", String.valueOf(postBulkGetOptions.attachments()));
}
if (postBulkGetOptions.attEncodingInfo() != null) {
builder.query("att_encoding_info", String.valueOf(postBulkGetOptions.attEncodingInfo()));
}
if (postBulkGetOptions.latest() != null) {
builder.query("latest", String.valueOf(postBulkGetOptions.latest()));
}
if (postBulkGetOptions.revs() != null) {
builder.query("revs", String.valueOf(postBulkGetOptions.revs()));
}
final JsonObject contentJson = new JsonObject();
contentJson.add("docs", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postBulkGetOptions.docs()));
builder.bodyJson(contentJson);
ResponseConverter<BulkGetResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<BulkGetResult>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations