use of com.ibm.cloud.cloudant.v1.Cloudant in project cloudant-java-sdk by IBM.
the class Cloudant method postViewQueries.
/**
* Multi-query a MapReduce view.
*
* This operation runs multiple specified view queries against the view function from the specified design document.
*
* @param postViewQueriesOptions the {@link PostViewQueriesOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link ViewQueriesResult}
*/
public ServiceCall<ViewQueriesResult> postViewQueries(PostViewQueriesOptions postViewQueriesOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postViewQueriesOptions, "postViewQueriesOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", postViewQueriesOptions.db());
pathParamsMap.put("ddoc", postViewQueriesOptions.ddoc());
pathParamsMap.put("view", postViewQueriesOptions.view());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_design/{ddoc}/_view/{view}/queries", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postViewQueries");
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("queries", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewQueriesOptions.queries()));
builder.bodyJson(contentJson);
ResponseConverter<ViewQueriesResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ViewQueriesResult>() {
}.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 deleteAttachment.
/**
* Delete an attachment.
*
* Deletes the attachment with the filename, `{attachment_name}`, from the specified doc. You must supply the `rev`
* query parameter or `If-Match` header with the current revision to delete the attachment.
*
* @param deleteAttachmentOptions the {@link DeleteAttachmentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link DocumentResult}
*/
public ServiceCall<DocumentResult> deleteAttachment(DeleteAttachmentOptions deleteAttachmentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteAttachmentOptions, "deleteAttachmentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", deleteAttachmentOptions.db());
pathParamsMap.put("doc_id", deleteAttachmentOptions.docId());
pathParamsMap.put("attachment_name", deleteAttachmentOptions.attachmentName());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/{doc_id}/{attachment_name}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteAttachment");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (deleteAttachmentOptions.ifMatch() != null) {
builder.header("If-Match", deleteAttachmentOptions.ifMatch());
}
if (deleteAttachmentOptions.rev() != null) {
builder.query("rev", String.valueOf(deleteAttachmentOptions.rev()));
}
if (deleteAttachmentOptions.batch() != null) {
builder.query("batch", String.valueOf(deleteAttachmentOptions.batch()));
}
ResponseConverter<DocumentResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DocumentResult>() {
}.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 getSearchInfo.
/**
* Retrieve information about a search index.
*
* Retrieve search index metadata information, such as the size of the index on disk.
*
* @param getSearchInfoOptions the {@link GetSearchInfoOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link SearchInfoResult}
*/
public ServiceCall<SearchInfoResult> getSearchInfo(GetSearchInfoOptions getSearchInfoOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getSearchInfoOptions, "getSearchInfoOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", getSearchInfoOptions.db());
pathParamsMap.put("ddoc", getSearchInfoOptions.ddoc());
pathParamsMap.put("index", getSearchInfoOptions.index());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_design/{ddoc}/_search_info/{index}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSearchInfo");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<SearchInfoResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SearchInfoResult>() {
}.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 getCurrentThroughputInformation.
/**
* Retrieve the current provisioned throughput capacity consumption.
*
* View the current consumption of provisioned throughput capacity for an IBM Cloudant instance. The current
* consumption shows the quantities of reads, writes, and global queries conducted against the instance for a given
* second.
*
* @param getCurrentThroughputInformationOptions the {@link GetCurrentThroughputInformationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link CurrentThroughputInformation}
*/
public ServiceCall<CurrentThroughputInformation> getCurrentThroughputInformation(GetCurrentThroughputInformationOptions getCurrentThroughputInformationOptions) {
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/current/throughput"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCurrentThroughputInformation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<CurrentThroughputInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<CurrentThroughputInformation>() {
}.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 getActiveTasks.
/**
* Retrieve list of running tasks.
*
* Lists running tasks, including the task type, name, status, and process ID. The result includes a JSON array of the
* currently running tasks, with each task described as a single object. Depending on the operation type, the set of
* response object fields might be different.
*
* @param getActiveTasksOptions the {@link GetActiveTasksOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link List}
*/
public ServiceCall<List<ActiveTask>> getActiveTasks(GetActiveTasksOptions getActiveTasksOptions) {
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_active_tasks"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getActiveTasks");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<List<ActiveTask>> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<List<ActiveTask>>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations