use of com.ibm.cloud.cloudant.v1.Cloudant in project cloudant-java-sdk by IBM.
the class Cloudant method postSearchAnalyze.
/**
* Query tokenization of sample text.
*
* Returns the results of analyzer tokenization of the provided sample text. This endpoint can be used for testing
* analyzer tokenization.
*
* @param postSearchAnalyzeOptions the {@link PostSearchAnalyzeOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link SearchAnalyzeResult}
*/
public ServiceCall<SearchAnalyzeResult> postSearchAnalyze(PostSearchAnalyzeOptions postSearchAnalyzeOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postSearchAnalyzeOptions, "postSearchAnalyzeOptions cannot be null");
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_search_analyze"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postSearchAnalyze");
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("analyzer", postSearchAnalyzeOptions.analyzer());
contentJson.addProperty("text", postSearchAnalyzeOptions.text());
builder.bodyJson(contentJson);
ResponseConverter<SearchAnalyzeResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SearchAnalyzeResult>() {
}.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 getGeo.
/**
* Query a geospatial index.
*
* Executes a query against the requested geospatial index from the specified design document.
*
* @param getGeoOptions the {@link GetGeoOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link GeoResult}
*/
public ServiceCall<GeoResult> getGeo(GetGeoOptions getGeoOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getGeoOptions, "getGeoOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", getGeoOptions.db());
pathParamsMap.put("ddoc", getGeoOptions.ddoc());
pathParamsMap.put("index", getGeoOptions.index());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_design/{ddoc}/_geo/{index}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getGeo");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getGeoOptions.bbox() != null) {
builder.query("bbox", String.valueOf(getGeoOptions.bbox()));
}
if (getGeoOptions.bookmark() != null) {
builder.query("bookmark", String.valueOf(getGeoOptions.bookmark()));
}
if (getGeoOptions.format() != null) {
builder.query("format", String.valueOf(getGeoOptions.format()));
}
if (getGeoOptions.g() != null) {
builder.query("g", String.valueOf(getGeoOptions.g()));
}
if (getGeoOptions.includeDocs() != null) {
builder.query("include_docs", String.valueOf(getGeoOptions.includeDocs()));
}
if (getGeoOptions.lat() != null) {
builder.query("lat", String.valueOf(getGeoOptions.lat()));
}
if (getGeoOptions.limit() != null) {
builder.query("limit", String.valueOf(getGeoOptions.limit()));
}
if (getGeoOptions.lon() != null) {
builder.query("lon", String.valueOf(getGeoOptions.lon()));
}
if (getGeoOptions.nearest() != null) {
builder.query("nearest", String.valueOf(getGeoOptions.nearest()));
}
if (getGeoOptions.radius() != null) {
builder.query("radius", String.valueOf(getGeoOptions.radius()));
}
if (getGeoOptions.rangex() != null) {
builder.query("rangex", String.valueOf(getGeoOptions.rangex()));
}
if (getGeoOptions.rangey() != null) {
builder.query("rangey", String.valueOf(getGeoOptions.rangey()));
}
if (getGeoOptions.relation() != null) {
builder.query("relation", String.valueOf(getGeoOptions.relation()));
}
if (getGeoOptions.skip() != null) {
builder.query("skip", String.valueOf(getGeoOptions.skip()));
}
if (getGeoOptions.stale() != null) {
builder.query("stale", String.valueOf(getGeoOptions.stale()));
}
ResponseConverter<GeoResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<GeoResult>() {
}.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 postView.
/**
* Query a MapReduce view.
*
* This operation queries the specified MapReduce view of the specified design document. By default, the map and
* reduce functions of the view are run to update the view before returning the response. 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 postViewOptions the {@link PostViewOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link ViewResult}
*/
public ServiceCall<ViewResult> postView(PostViewOptions postViewOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postViewOptions, "postViewOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", postViewOptions.db());
pathParamsMap.put("ddoc", postViewOptions.ddoc());
pathParamsMap.put("view", postViewOptions.view());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_design/{ddoc}/_view/{view}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postView");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (postViewOptions.attEncodingInfo() != null) {
contentJson.addProperty("att_encoding_info", postViewOptions.attEncodingInfo());
}
if (postViewOptions.attachments() != null) {
contentJson.addProperty("attachments", postViewOptions.attachments());
}
if (postViewOptions.conflicts() != null) {
contentJson.addProperty("conflicts", postViewOptions.conflicts());
}
if (postViewOptions.descending() != null) {
contentJson.addProperty("descending", postViewOptions.descending());
}
if (postViewOptions.includeDocs() != null) {
contentJson.addProperty("include_docs", postViewOptions.includeDocs());
}
if (postViewOptions.inclusiveEnd() != null) {
contentJson.addProperty("inclusive_end", postViewOptions.inclusiveEnd());
}
if (postViewOptions.limit() != null) {
contentJson.addProperty("limit", postViewOptions.limit());
}
if (postViewOptions.skip() != null) {
contentJson.addProperty("skip", postViewOptions.skip());
}
if (postViewOptions.updateSeq() != null) {
contentJson.addProperty("update_seq", postViewOptions.updateSeq());
}
if (postViewOptions.endkey() != null) {
contentJson.add("endkey", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.endkey()));
}
if (postViewOptions.endkeyDocid() != null) {
contentJson.addProperty("endkey_docid", postViewOptions.endkeyDocid());
}
if (postViewOptions.group() != null) {
contentJson.addProperty("group", postViewOptions.group());
}
if (postViewOptions.groupLevel() != null) {
contentJson.addProperty("group_level", postViewOptions.groupLevel());
}
if (postViewOptions.key() != null) {
contentJson.add("key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.key()));
}
if (postViewOptions.keys() != null) {
contentJson.add("keys", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.keys()));
}
if (postViewOptions.reduce() != null) {
contentJson.addProperty("reduce", postViewOptions.reduce());
}
if (postViewOptions.stable() != null) {
contentJson.addProperty("stable", postViewOptions.stable());
}
if (postViewOptions.startkey() != null) {
contentJson.add("startkey", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.startkey()));
}
if (postViewOptions.startkeyDocid() != null) {
contentJson.addProperty("startkey_docid", postViewOptions.startkeyDocid());
}
if (postViewOptions.update() != null) {
contentJson.addProperty("update", postViewOptions.update());
}
builder.bodyJson(contentJson);
ResponseConverter<ViewResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ViewResult>() {
}.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 postPartitionAllDocs.
/**
* Query a list of all documents in a database partition.
*
* Queries the primary index (all document IDs). The results that match the query parameters are returned in a JSON
* object, including a list of matching documents with basic contents, such as the ID and revision. When no query
* parameters are specified, results for all documents in the database partition are returned. Optionally, document
* content or additional metadata can be included in the response.
*
* @param postPartitionAllDocsOptions the {@link PostPartitionAllDocsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link AllDocsResult}
*/
public ServiceCall<AllDocsResult> postPartitionAllDocs(PostPartitionAllDocsOptions postPartitionAllDocsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionAllDocsOptions, "postPartitionAllDocsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", postPartitionAllDocsOptions.db());
pathParamsMap.put("partition_key", postPartitionAllDocsOptions.partitionKey());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_all_docs", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionAllDocs");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (postPartitionAllDocsOptions.attEncodingInfo() != null) {
contentJson.addProperty("att_encoding_info", postPartitionAllDocsOptions.attEncodingInfo());
}
if (postPartitionAllDocsOptions.attachments() != null) {
contentJson.addProperty("attachments", postPartitionAllDocsOptions.attachments());
}
if (postPartitionAllDocsOptions.conflicts() != null) {
contentJson.addProperty("conflicts", postPartitionAllDocsOptions.conflicts());
}
if (postPartitionAllDocsOptions.descending() != null) {
contentJson.addProperty("descending", postPartitionAllDocsOptions.descending());
}
if (postPartitionAllDocsOptions.includeDocs() != null) {
contentJson.addProperty("include_docs", postPartitionAllDocsOptions.includeDocs());
}
if (postPartitionAllDocsOptions.inclusiveEnd() != null) {
contentJson.addProperty("inclusive_end", postPartitionAllDocsOptions.inclusiveEnd());
}
if (postPartitionAllDocsOptions.limit() != null) {
contentJson.addProperty("limit", postPartitionAllDocsOptions.limit());
}
if (postPartitionAllDocsOptions.skip() != null) {
contentJson.addProperty("skip", postPartitionAllDocsOptions.skip());
}
if (postPartitionAllDocsOptions.updateSeq() != null) {
contentJson.addProperty("update_seq", postPartitionAllDocsOptions.updateSeq());
}
if (postPartitionAllDocsOptions.endkey() != null) {
contentJson.addProperty("endkey", postPartitionAllDocsOptions.endkey());
}
if (postPartitionAllDocsOptions.key() != null) {
contentJson.addProperty("key", postPartitionAllDocsOptions.key());
}
if (postPartitionAllDocsOptions.keys() != null) {
contentJson.add("keys", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionAllDocsOptions.keys()));
}
if (postPartitionAllDocsOptions.startkey() != null) {
contentJson.addProperty("startkey", postPartitionAllDocsOptions.startkey());
}
builder.bodyJson(contentJson);
ResponseConverter<AllDocsResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<AllDocsResult>() {
}.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 postChanges.
/**
* Query the database document changes feed.
*
* Requests the database changes feed in the same way as `GET /{db}/_changes` does. It is widely used with the
* `filter` query parameter because it allows one to pass more information to the filter.
*
* @param postChangesOptions the {@link PostChangesOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link ChangesResult}
*/
public ServiceCall<ChangesResult> postChanges(PostChangesOptions postChangesOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postChangesOptions, "postChangesOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", postChangesOptions.db());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_changes", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postChanges");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (postChangesOptions.lastEventId() != null) {
builder.header("Last-Event-ID", postChangesOptions.lastEventId());
}
if (postChangesOptions.attEncodingInfo() != null) {
builder.query("att_encoding_info", String.valueOf(postChangesOptions.attEncodingInfo()));
}
if (postChangesOptions.attachments() != null) {
builder.query("attachments", String.valueOf(postChangesOptions.attachments()));
}
if (postChangesOptions.conflicts() != null) {
builder.query("conflicts", String.valueOf(postChangesOptions.conflicts()));
}
if (postChangesOptions.descending() != null) {
builder.query("descending", String.valueOf(postChangesOptions.descending()));
}
if (postChangesOptions.feed() != null) {
builder.query("feed", String.valueOf(postChangesOptions.feed()));
}
if (postChangesOptions.filter() != null) {
builder.query("filter", String.valueOf(postChangesOptions.filter()));
}
if (postChangesOptions.heartbeat() != null) {
builder.query("heartbeat", String.valueOf(postChangesOptions.heartbeat()));
}
if (postChangesOptions.includeDocs() != null) {
builder.query("include_docs", String.valueOf(postChangesOptions.includeDocs()));
}
if (postChangesOptions.limit() != null) {
builder.query("limit", String.valueOf(postChangesOptions.limit()));
}
if (postChangesOptions.seqInterval() != null) {
builder.query("seq_interval", String.valueOf(postChangesOptions.seqInterval()));
}
if (postChangesOptions.since() != null) {
builder.query("since", String.valueOf(postChangesOptions.since()));
}
if (postChangesOptions.style() != null) {
builder.query("style", String.valueOf(postChangesOptions.style()));
}
if (postChangesOptions.timeout() != null) {
builder.query("timeout", String.valueOf(postChangesOptions.timeout()));
}
if (postChangesOptions.view() != null) {
builder.query("view", String.valueOf(postChangesOptions.view()));
}
final JsonObject contentJson = new JsonObject();
if (postChangesOptions.docIds() != null) {
contentJson.add("doc_ids", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postChangesOptions.docIds()));
}
if (postChangesOptions.fields() != null) {
contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postChangesOptions.fields()));
}
if (postChangesOptions.selector() != null) {
contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postChangesOptions.selector()));
}
builder.bodyJson(contentJson);
ResponseConverter<ChangesResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ChangesResult>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations