Search in sources :

Example 56 with Document

use of com.ibm.cloud.cloudant.v1.model.Document in project cloudant-java-sdk by IBM.

the class Cloudant method postRevsDiff.

/**
 * Query the document revisions and possible ancestors missing from the database.
 *
 * The replicator is the primary user of this operation. After receiving a set of new revision IDs from the source
 * database, the replicator sends this set to the destination database's `_revs_diff` to find out which of them
 * already exists there. It can then avoid fetching and sending already-known document bodies.
 *
 * @param postRevsDiffOptions the {@link PostRevsDiffOptions} containing the options for the call
 * @return a {@link ServiceCall} with a result of type {@link Map}
 */
public ServiceCall<Map<String, RevsDiff>> postRevsDiff(PostRevsDiffOptions postRevsDiffOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(postRevsDiffOptions, "postRevsDiffOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("db", postRevsDiffOptions.db());
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_revs_diff", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postRevsDiff");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    builder.bodyContent(com.ibm.cloud.sdk.core.util.GsonSingleton.getGsonWithoutPrettyPrinting().toJson(postRevsDiffOptions.documentRevisions()), "application/json");
    ResponseConverter<Map<String, RevsDiff>> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Map<String, RevsDiff>>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RevsDiff(com.ibm.cloud.cloudant.v1.model.RevsDiff) RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)32 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)30 Document (com.ibm.cloud.cloudant.v1.model.Document)22 DocumentResult (com.ibm.cloud.cloudant.v1.model.DocumentResult)20 ArrayList (java.util.ArrayList)16 Test (org.testng.annotations.Test)12 Attachment (com.ibm.cloud.cloudant.v1.model.Attachment)10 DocumentRevisionStatus (com.ibm.cloud.cloudant.v1.model.DocumentRevisionStatus)10 Revisions (com.ibm.cloud.cloudant.v1.model.Revisions)10 DesignDocument (com.ibm.cloud.cloudant.v1.model.DesignDocument)9 ReplicationDocument (com.ibm.cloud.cloudant.v1.model.ReplicationDocument)9 SchedulerDocument (com.ibm.cloud.cloudant.v1.model.SchedulerDocument)9 JsonObject (com.google.gson.JsonObject)8 AllDocsResult (com.ibm.cloud.cloudant.v1.model.AllDocsResult)6 BulkGetQueryDocument (com.ibm.cloud.cloudant.v1.model.BulkGetQueryDocument)6 BulkGetResultDocument (com.ibm.cloud.cloudant.v1.model.BulkGetResultDocument)6 MockResponse (okhttp3.mockwebserver.MockResponse)6 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 PostDocumentOptions (com.ibm.cloud.cloudant.v1.model.PostDocumentOptions)5