use of com.ibm.cloud.cloudant.v1.Cloudant in project cloudant-java-sdk by IBM.
the class Cloudant method postSearch.
/**
* Query a search index.
*
* Search indexes, which are defined in design documents, allow databases to be queried by using Lucene Query Parser
* Syntax. An index function defines a search index, similar to a map function in MapReduce views. The index function
* decides what data to index and what data to store in the index. The advantage of using the HTTP `POST` method is
* that the query is submitted as a JSON object in the request body. This avoids the limitations of passing query
* options as URL query parameters of a `GET` request.
*
* @param postSearchOptions the {@link PostSearchOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link SearchResult}
*/
public ServiceCall<SearchResult> postSearch(PostSearchOptions postSearchOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postSearchOptions, "postSearchOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", postSearchOptions.db());
pathParamsMap.put("ddoc", postSearchOptions.ddoc());
pathParamsMap.put("index", postSearchOptions.index());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_design/{ddoc}/_search/{index}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postSearch");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("query", postSearchOptions.query());
if (postSearchOptions.bookmark() != null) {
contentJson.addProperty("bookmark", postSearchOptions.bookmark());
}
if (postSearchOptions.highlightFields() != null) {
contentJson.add("highlight_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.highlightFields()));
}
if (postSearchOptions.highlightNumber() != null) {
contentJson.addProperty("highlight_number", postSearchOptions.highlightNumber());
}
if (postSearchOptions.highlightPostTag() != null) {
contentJson.addProperty("highlight_post_tag", postSearchOptions.highlightPostTag());
}
if (postSearchOptions.highlightPreTag() != null) {
contentJson.addProperty("highlight_pre_tag", postSearchOptions.highlightPreTag());
}
if (postSearchOptions.highlightSize() != null) {
contentJson.addProperty("highlight_size", postSearchOptions.highlightSize());
}
if (postSearchOptions.includeDocs() != null) {
contentJson.addProperty("include_docs", postSearchOptions.includeDocs());
}
if (postSearchOptions.includeFields() != null) {
contentJson.add("include_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.includeFields()));
}
if (postSearchOptions.limit() != null) {
contentJson.addProperty("limit", postSearchOptions.limit());
}
if (postSearchOptions.sort() != null) {
contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.sort()));
}
if (postSearchOptions.stale() != null) {
contentJson.addProperty("stale", postSearchOptions.stale());
}
if (postSearchOptions.counts() != null) {
contentJson.add("counts", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.counts()));
}
if (postSearchOptions.drilldown() != null) {
contentJson.add("drilldown", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.drilldown()));
}
if (postSearchOptions.groupField() != null) {
contentJson.addProperty("group_field", postSearchOptions.groupField());
}
if (postSearchOptions.groupLimit() != null) {
contentJson.addProperty("group_limit", postSearchOptions.groupLimit());
}
if (postSearchOptions.groupSort() != null) {
contentJson.add("group_sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.groupSort()));
}
if (postSearchOptions.ranges() != null) {
contentJson.add("ranges", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.ranges()));
}
builder.bodyJson(contentJson);
ResponseConverter<SearchResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SearchResult>() {
}.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 getSchedulerDocument.
/**
* Retrieve a replication scheduler document.
*
* Retrieves information about a replication document from the replicator database. The endpoint returns the document
* ID, database, replication ID, source and target, and other information.
*
* @param getSchedulerDocumentOptions the {@link GetSchedulerDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link SchedulerDocument}
*/
public ServiceCall<SchedulerDocument> getSchedulerDocument(GetSchedulerDocumentOptions getSchedulerDocumentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getSchedulerDocumentOptions, "getSchedulerDocumentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("doc_id", getSchedulerDocumentOptions.docId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/docs/_replicator/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<SchedulerDocument> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SchedulerDocument>() {
}.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 postActivityTrackerEvents.
/**
* Modify Activity Tracker events configuration.
*
* Configure event types that are being sent to IBM Cloud Activity Tracker for the IBM Cloudant instance.
*
* @param postActivityTrackerEventsOptions the {@link PostActivityTrackerEventsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Ok}
*/
public ServiceCall<Ok> postActivityTrackerEvents(PostActivityTrackerEventsOptions postActivityTrackerEventsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postActivityTrackerEventsOptions, "postActivityTrackerEventsOptions cannot be null");
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/activity_tracker/events"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postActivityTrackerEvents");
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("types", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postActivityTrackerEventsOptions.types()));
builder.bodyJson(contentJson);
ResponseConverter<Ok> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Ok>() {
}.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 putCapacityThroughputConfiguration.
/**
* Update the target provisioned throughput capacity.
*
* Sets the target provisioned throughput capacity for an IBM Cloudant instance. When target capacity is changed, the
* current capacity asynchronously changes to meet the target capacity.
*
* @param putCapacityThroughputConfigurationOptions the {@link PutCapacityThroughputConfigurationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link CapacityThroughputInformation}
*/
public ServiceCall<CapacityThroughputInformation> putCapacityThroughputConfiguration(PutCapacityThroughputConfigurationOptions putCapacityThroughputConfigurationOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(putCapacityThroughputConfigurationOptions, "putCapacityThroughputConfigurationOptions cannot be null");
RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/capacity/throughput"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putCapacityThroughputConfiguration");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("blocks", putCapacityThroughputConfigurationOptions.blocks());
builder.bodyJson(contentJson);
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 getSecurity.
/**
* Retrieve database permissions information.
*
* See who has permission to read, write, and manage the database. The credentials you use to log in to the dashboard
* automatically include `_admin` permissions to all databases you create. Everyone and everything else, including
* users you share databases with and API keys you create, must be given a permission level explicitly.
*
* @param getSecurityOptions the {@link GetSecurityOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Security}
*/
public ServiceCall<Security> getSecurity(GetSecurityOptions getSecurityOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getSecurityOptions, "getSecurityOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", getSecurityOptions.db());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_security", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSecurity");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<Security> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Security>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations