use of com.ibm.cloud.cloudant.v1.Cloudant 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);
}
use of com.ibm.cloud.cloudant.v1.Cloudant in project cloudant-java-sdk by IBM.
the class Cloudant method postExplain.
/**
* Retrieve information about which index is used for a query.
*
* Shows which index is being used by the query. Parameters are the same as the [`_find`
* endpoint](#query-an-index-by-using-selector-syntax).
*
* @param postExplainOptions the {@link PostExplainOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link ExplainResult}
*/
public ServiceCall<ExplainResult> postExplain(PostExplainOptions postExplainOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postExplainOptions, "postExplainOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", postExplainOptions.db());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_explain", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postExplain");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postExplainOptions.selector()));
if (postExplainOptions.bookmark() != null) {
contentJson.addProperty("bookmark", postExplainOptions.bookmark());
}
if (postExplainOptions.conflicts() != null) {
contentJson.addProperty("conflicts", postExplainOptions.conflicts());
}
if (postExplainOptions.executionStats() != null) {
contentJson.addProperty("execution_stats", postExplainOptions.executionStats());
}
if (postExplainOptions.fields() != null) {
contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postExplainOptions.fields()));
}
if (postExplainOptions.limit() != null) {
contentJson.addProperty("limit", postExplainOptions.limit());
}
if (postExplainOptions.skip() != null) {
contentJson.addProperty("skip", postExplainOptions.skip());
}
if (postExplainOptions.sort() != null) {
contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postExplainOptions.sort()));
}
if (postExplainOptions.stable() != null) {
contentJson.addProperty("stable", postExplainOptions.stable());
}
if (postExplainOptions.update() != null) {
contentJson.addProperty("update", postExplainOptions.update());
}
if (postExplainOptions.useIndex() != null) {
contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postExplainOptions.useIndex()));
}
if (postExplainOptions.r() != null) {
contentJson.addProperty("r", postExplainOptions.r());
}
builder.bodyJson(contentJson);
ResponseConverter<ExplainResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ExplainResult>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.Cloudant in project cloudant-java-sdk by IBM.
the class Cloudant method getCapacityThroughputInformation.
/**
* Retrieve provisioned throughput capacity information.
*
* View the amount of provisioned throughput capacity that is allocated to an IBM Cloudant instance and what is the
* target provisioned throughput capacity.
*
* @param getCapacityThroughputInformationOptions the {@link GetCapacityThroughputInformationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link CapacityThroughputInformation}
*/
public ServiceCall<CapacityThroughputInformation> getCapacityThroughputInformation(GetCapacityThroughputInformationOptions getCapacityThroughputInformationOptions) {
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/capacity/throughput"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCapacityThroughputInformation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<CapacityThroughputInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<CapacityThroughputInformation>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.Cloudant in project cloudant-java-sdk by IBM.
the class Cloudant method getUpInformation.
/**
* Retrieve information about whether the server is up.
*
* Confirms that the server is up, running, and ready to respond to requests. If `maintenance_mode` is `true` or
* `nolb`, the endpoint returns a 404 response.
*
* @param getUpInformationOptions the {@link GetUpInformationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link UpInformation}
*/
public ServiceCall<UpInformation> getUpInformation(GetUpInformationOptions getUpInformationOptions) {
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_up"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getUpInformation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<UpInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<UpInformation>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.Cloudant in project cloudant-java-sdk by IBM.
the class Cloudant method getDbUpdates.
/**
* Retrieve change events for all databases.
*
* Lists changes to databases, like a global changes feed. Types of changes include updating the database and creating
* or deleting a database. Like the changes feed, the feed is not guaranteed to return changes in the correct order
* and might repeat changes. Polling modes for this method work like polling modes for the changes feed.
* **Note: This endpoint requires _admin or _db_updates role and is only available on dedicated clusters.**.
*
* @param getDbUpdatesOptions the {@link GetDbUpdatesOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link DbUpdates}
*/
public ServiceCall<DbUpdates> getDbUpdates(GetDbUpdatesOptions getDbUpdatesOptions) {
if (getDbUpdatesOptions == null) {
getDbUpdatesOptions = new GetDbUpdatesOptions.Builder().build();
}
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_db_updates"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getDbUpdates");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getDbUpdatesOptions.feed() != null) {
builder.query("feed", String.valueOf(getDbUpdatesOptions.feed()));
}
if (getDbUpdatesOptions.heartbeat() != null) {
builder.query("heartbeat", String.valueOf(getDbUpdatesOptions.heartbeat()));
}
if (getDbUpdatesOptions.timeout() != null) {
builder.query("timeout", String.valueOf(getDbUpdatesOptions.timeout()));
}
if (getDbUpdatesOptions.since() != null) {
builder.query("since", String.valueOf(getDbUpdatesOptions.since()));
}
ResponseConverter<DbUpdates> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DbUpdates>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations