use of com.ibm.cloud.cloudant.v1.model.Document 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.model.Document 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.model.Document in project cloudant-java-sdk by IBM.
the class Cloudant method getDocument.
/**
* Retrieve a document.
*
* Returns document with the specified `doc_id` from the specified database. Unless you request a specific revision,
* the latest revision of the document is always returned.
*
* @param getDocumentOptions the {@link GetDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Document}
*/
public ServiceCall<Document> getDocument(GetDocumentOptions getDocumentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getDocumentOptions, "getDocumentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", getDocumentOptions.db());
pathParamsMap.put("doc_id", getDocumentOptions.docId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getDocumentOptions.ifNoneMatch() != null) {
builder.header("If-None-Match", getDocumentOptions.ifNoneMatch());
}
if (getDocumentOptions.attachments() != null) {
builder.query("attachments", String.valueOf(getDocumentOptions.attachments()));
}
if (getDocumentOptions.attEncodingInfo() != null) {
builder.query("att_encoding_info", String.valueOf(getDocumentOptions.attEncodingInfo()));
}
if (getDocumentOptions.conflicts() != null) {
builder.query("conflicts", String.valueOf(getDocumentOptions.conflicts()));
}
if (getDocumentOptions.deletedConflicts() != null) {
builder.query("deleted_conflicts", String.valueOf(getDocumentOptions.deletedConflicts()));
}
if (getDocumentOptions.latest() != null) {
builder.query("latest", String.valueOf(getDocumentOptions.latest()));
}
if (getDocumentOptions.localSeq() != null) {
builder.query("local_seq", String.valueOf(getDocumentOptions.localSeq()));
}
if (getDocumentOptions.meta() != null) {
builder.query("meta", String.valueOf(getDocumentOptions.meta()));
}
if (getDocumentOptions.rev() != null) {
builder.query("rev", String.valueOf(getDocumentOptions.rev()));
}
if (getDocumentOptions.revs() != null) {
builder.query("revs", String.valueOf(getDocumentOptions.revs()));
}
if (getDocumentOptions.revsInfo() != null) {
builder.query("revs_info", String.valueOf(getDocumentOptions.revsInfo()));
}
ResponseConverter<Document> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Document>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.Document in project cloudant-java-sdk by IBM.
the class Cloudant method putLocalDocument.
/**
* Create or modify a local document.
*
* Stores the specified local document. The semantics are identical to storing a standard document in the specified
* database, except that the document is not replicated.
*
* @param putLocalDocumentOptions the {@link PutLocalDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link DocumentResult}
*/
public ServiceCall<DocumentResult> putLocalDocument(PutLocalDocumentOptions putLocalDocumentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(putLocalDocumentOptions, "putLocalDocumentOptions cannot be null");
if (putLocalDocumentOptions.document() != null && putLocalDocumentOptions.contentType() == null) {
putLocalDocumentOptions = putLocalDocumentOptions.newBuilder().contentType("application/json").build();
}
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", putLocalDocumentOptions.db());
pathParamsMap.put("doc_id", putLocalDocumentOptions.docId());
RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_local/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putLocalDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (putLocalDocumentOptions.contentType() != null) {
builder.header("Content-Type", putLocalDocumentOptions.contentType());
}
if (putLocalDocumentOptions.batch() != null) {
builder.query("batch", String.valueOf(putLocalDocumentOptions.batch()));
}
builder.bodyContent(putLocalDocumentOptions.contentType(), putLocalDocumentOptions.document(), null, putLocalDocumentOptions.body());
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.model.Document in project cloudant-java-sdk by IBM.
the class Cloudant method getReplicationDocument.
/**
* Retrieve a replication document.
*
* Retrieves a replication document from the `_replicator` database to view the configuration of the replication. The
* status of the replication is no longer recorded in the document but can be checked via the replication scheduler.
*
* @param getReplicationDocumentOptions the {@link GetReplicationDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link ReplicationDocument}
*/
public ServiceCall<ReplicationDocument> getReplicationDocument(GetReplicationDocumentOptions getReplicationDocumentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getReplicationDocumentOptions, "getReplicationDocumentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("doc_id", getReplicationDocumentOptions.docId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getReplicationDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getReplicationDocumentOptions.ifNoneMatch() != null) {
builder.header("If-None-Match", getReplicationDocumentOptions.ifNoneMatch());
}
if (getReplicationDocumentOptions.attachments() != null) {
builder.query("attachments", String.valueOf(getReplicationDocumentOptions.attachments()));
}
if (getReplicationDocumentOptions.attEncodingInfo() != null) {
builder.query("att_encoding_info", String.valueOf(getReplicationDocumentOptions.attEncodingInfo()));
}
if (getReplicationDocumentOptions.conflicts() != null) {
builder.query("conflicts", String.valueOf(getReplicationDocumentOptions.conflicts()));
}
if (getReplicationDocumentOptions.deletedConflicts() != null) {
builder.query("deleted_conflicts", String.valueOf(getReplicationDocumentOptions.deletedConflicts()));
}
if (getReplicationDocumentOptions.latest() != null) {
builder.query("latest", String.valueOf(getReplicationDocumentOptions.latest()));
}
if (getReplicationDocumentOptions.localSeq() != null) {
builder.query("local_seq", String.valueOf(getReplicationDocumentOptions.localSeq()));
}
if (getReplicationDocumentOptions.meta() != null) {
builder.query("meta", String.valueOf(getReplicationDocumentOptions.meta()));
}
if (getReplicationDocumentOptions.rev() != null) {
builder.query("rev", String.valueOf(getReplicationDocumentOptions.rev()));
}
if (getReplicationDocumentOptions.revs() != null) {
builder.query("revs", String.valueOf(getReplicationDocumentOptions.revs()));
}
if (getReplicationDocumentOptions.revsInfo() != null) {
builder.query("revs_info", String.valueOf(getReplicationDocumentOptions.revsInfo()));
}
ResponseConverter<ReplicationDocument> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ReplicationDocument>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations