From 033e5625b36db12708236a60196b866b4a8535ae Mon Sep 17 00:00:00 2001 From: cloudant-sdks-automation <71659186+cloudant-sdks-automation@users.noreply.github.com> Date: Thu, 29 Oct 2026 14:48:21 +0000 Subject: [PATCH] feat(generated): add WireMock stub for POST /{db}/_index_info Generated SDK source code using: - Generator version 3.117.2 - Specification version 1.0.0-dev0.1.41 - Automation (cloudant-sdks) version bf0dbc2 --- .../com/ibm/cloud/cloudant/v1/Cloudant.java | 3818 ++++++++-------- .../v1/model/DesignDocumentViewIndex.java | 2 +- .../cloudant/v1/model/IndexInfoResult.java | 82 + .../v1/model/PostIndexInfoOptions.java | 516 +++ .../v1/model/ReplicationDatabaseAuth.java | 28 +- .../v1/model/ReplicationDatabaseAuthIBM.java | 104 + .../model/ReplicationDatabaseAuthIBMIam.java | 106 + .../v1/model/ReplicationDatabaseAuthIam.java | 2 +- .../v1/model/ReplicationDocument.java | 50 + .../cloudant/v1/model/SearchIndexInfo.java | 13 + .../v1/model/SearchIndexInformation.java | 124 + .../cloudant/v1/model/UpdatesPending.java | 51 +- .../v1/model/ViewIndexInformation.java | 126 + .../com/ibm/cloud/cloudant/v1/CloudantIT.java | 418 +- .../ibm/cloud/cloudant/v1/CloudantTest.java | 4057 +++++++++-------- .../v1/model/IndexInfoResultTest.java | 46 + .../v1/model/PostIndexInfoOptionsTest.java | 73 + .../v1/model/PostReplicatorOptionsTest.java | 16 + .../PutReplicationDocumentOptionsTest.java | 16 + .../ReplicationDatabaseAuthIBMIamTest.java | 51 + .../model/ReplicationDatabaseAuthIBMTest.java | 57 + .../v1/model/ReplicationDatabaseAuthTest.java | 15 + .../v1/model/ReplicationDatabaseTest.java | 14 + .../v1/model/ReplicationDocumentTest.java | 17 + .../v1/model/SearchIndexInfoTest.java | 2 + .../v1/model/SearchIndexInformationTest.java | 46 + .../v1/model/SearchInfoResultTest.java | 1 + .../cloudant/v1/model/UpdatesPendingTest.java | 3 + .../v1/model/ViewIndexInformationTest.java | 47 + stubs/gen-its-mappings.json | 97 + 30 files changed, 5959 insertions(+), 4039 deletions(-) create mode 100644 modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/IndexInfoResult.java create mode 100644 modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/PostIndexInfoOptions.java create mode 100644 modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBM.java create mode 100644 modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBMIam.java create mode 100644 modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInformation.java create mode 100644 modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ViewIndexInformation.java create mode 100644 modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/IndexInfoResultTest.java create mode 100644 modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/PostIndexInfoOptionsTest.java create mode 100644 modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBMIamTest.java create mode 100644 modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBMTest.java create mode 100644 modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInformationTest.java create mode 100644 modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ViewIndexInformationTest.java diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/Cloudant.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/Cloudant.java index d7aa9b774..afb140928 100644 --- a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/Cloudant.java +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/Cloudant.java @@ -84,6 +84,7 @@ import com.ibm.cloud.cloudant.v1.model.HeadSchedulerDocumentOptions; import com.ibm.cloud.cloudant.v1.model.HeadSchedulerJobOptions; import com.ibm.cloud.cloudant.v1.model.HeadUpInformationOptions; +import com.ibm.cloud.cloudant.v1.model.IndexInfoResult; import com.ibm.cloud.cloudant.v1.model.IndexResult; import com.ibm.cloud.cloudant.v1.model.IndexesInformation; import com.ibm.cloud.cloudant.v1.model.MembershipInformation; @@ -102,6 +103,7 @@ import com.ibm.cloud.cloudant.v1.model.PostDocumentOptions; import com.ibm.cloud.cloudant.v1.model.PostExplainOptions; import com.ibm.cloud.cloudant.v1.model.PostFindOptions; +import com.ibm.cloud.cloudant.v1.model.PostIndexInfoOptions; import com.ibm.cloud.cloudant.v1.model.PostIndexOptions; import com.ibm.cloud.cloudant.v1.model.PostPartitionAllDocsOptions; import com.ibm.cloud.cloudant.v1.model.PostPartitionExplainOptions; @@ -1844,1426 +1846,1086 @@ public ServiceCall postDesignDocsQueries(PostDesignDocsQue } /** - * Query a MapReduce view. + * Retrieve HTTP headers about whether the server is up. * - * 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. + * Retrieves the HTTP headers about whether the server is up. * - * @param postViewOptions the {@link PostViewOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link ViewResult} + * @param headUpInformationOptions the {@link HeadUpInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall postView(PostViewOptions postViewOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postViewOptions, - "postViewOptions cannot be null"); - Map pathParamsMap = new HashMap(); - 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postView"); + public ServiceCall headUpInformation(HeadUpInformationOptions headUpInformationOptions) { + RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_up")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headUpInformation"); for (Entry 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("end_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.endKey())); - } - if (postViewOptions.endKeyDocId() != null) { - contentJson.addProperty("end_key_doc_id", 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("start_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.startKey())); - } - if (postViewOptions.startKeyDocId() != null) { - contentJson.addProperty("start_key_doc_id", postViewOptions.startKeyDocId()); - } - if (postViewOptions.update() != null) { - contentJson.addProperty("update", postViewOptions.update()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } /** - * Query a MapReduce view as stream. + * Retrieve HTTP headers about whether the server is up. * - * 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. + * Retrieves the HTTP headers about whether the server is up. * - * @param postViewOptions the {@link PostViewOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link InputStream} + * @return a {@link ServiceCall} with a void result */ - public ServiceCall postViewAsStream(PostViewOptions postViewOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postViewOptions, - "postViewOptions cannot be null"); - Map pathParamsMap = new HashMap(); - 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postViewAsStream"); - for (Entry 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("end_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.endKey())); - } - if (postViewOptions.endKeyDocId() != null) { - contentJson.addProperty("end_key_doc_id", 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("start_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.startKey())); - } - if (postViewOptions.startKeyDocId() != null) { - contentJson.addProperty("start_key_doc_id", postViewOptions.startKeyDocId()); - } - if (postViewOptions.update() != null) { - contentJson.addProperty("update", postViewOptions.update()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); - return createServiceCall(builder.build(), responseConverter); + public ServiceCall headUpInformation() { + return headUpInformation(null); } /** - * Multi-query a MapReduce view. + * Retrieve list of running tasks. * - * This operation runs multiple specified view queries against the view function from the specified design document. + * 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 postViewQueriesOptions the {@link PostViewQueriesOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link ViewQueriesResult} + * @param getActiveTasksOptions the {@link GetActiveTasksOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link List} */ - public ServiceCall postViewQueries(PostViewQueriesOptions postViewQueriesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postViewQueriesOptions, - "postViewQueriesOptions cannot be null"); - Map pathParamsMap = new HashMap(); - 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postViewQueries"); + public ServiceCall> getActiveTasks(GetActiveTasksOptions getActiveTasksOptions) { + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_active_tasks")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getActiveTasks"); for (Entry 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 responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter> responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken>() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Multi-query a MapReduce view as stream. + * Retrieve list of running tasks. * - * This operation runs multiple specified view queries against the view function from the specified design document. + * 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 postViewQueriesOptions the {@link PostViewQueriesOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link InputStream} + * @return a {@link ServiceCall} with a result of type {@link List} */ - public ServiceCall postViewQueriesAsStream(PostViewQueriesOptions postViewQueriesOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postViewQueriesOptions, - "postViewQueriesOptions cannot be null"); - Map pathParamsMap = new HashMap(); - 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postViewQueriesAsStream"); + public ServiceCall> getActiveTasks() { + return getActiveTasks(null); + } + + /** + * Retrieve activity tracking events information. + * + * Check event types sent to IBM Cloud Activity Tracker Event Routing for the IBM Cloudant instance. + * + * @param getActivityTrackerEventsOptions the {@link GetActivityTrackerEventsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ActivityTrackerEvents} + */ + public ServiceCall getActivityTrackerEvents(GetActivityTrackerEventsOptions getActivityTrackerEventsOptions) { + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/activity_tracker/events")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getActivityTrackerEvents"); for (Entry 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 responseConverter = ResponseConverterUtils.getInputStream(); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve information about a database partition. + * Retrieve activity tracking events information. * - * Given a partition key, return the database name, sizes, partition, doc count, and doc delete count. + * Check event types sent to IBM Cloud Activity Tracker Event Routing for the IBM Cloudant instance. * - * @param getPartitionInformationOptions the {@link GetPartitionInformationOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link PartitionInformation} + * @return a {@link ServiceCall} with a result of type {@link ActivityTrackerEvents} */ - public ServiceCall getPartitionInformation(GetPartitionInformationOptions getPartitionInformationOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getPartitionInformationOptions, - "getPartitionInformationOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", getPartitionInformationOptions.db()); - pathParamsMap.put("partition_key", getPartitionInformationOptions.partitionKey()); - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getPartitionInformation"); + public ServiceCall getActivityTrackerEvents() { + return getActivityTrackerEvents(null); + } + + /** + * Modify activity tracking events configuration. + * + * Configure event types sent to IBM Cloud Activity Tracker Event Routing 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 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postActivityTrackerEvents"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + final JsonObject contentJson = new JsonObject(); + contentJson.add("types", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postActivityTrackerEventsOptions.types())); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Query a list of all documents in a database partition. + * Retrieve maximum allowed database count. * - * 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. + * Retrieves the maximum number of databases currently allowed in the instance. * - * @param postPartitionAllDocsOptions the {@link PostPartitionAllDocsOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link AllDocsResult} + * @param getCapacityDatabasesInformationOptions the {@link GetCapacityDatabasesInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link CapacityDatabasesInformation} */ - public ServiceCall postPartitionAllDocs(PostPartitionAllDocsOptions postPartitionAllDocsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionAllDocsOptions, - "postPartitionAllDocsOptions cannot be null"); - Map pathParamsMap = new HashMap(); - 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionAllDocs"); + public ServiceCall getCapacityDatabasesInformation(GetCapacityDatabasesInformationOptions getCapacityDatabasesInformationOptions) { + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/capacity/databases")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCapacityDatabasesInformation"); for (Entry 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("end_key", 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("start_key", postPartitionAllDocsOptions.startKey()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Query a list of all documents in a database partition as stream. + * Retrieve maximum allowed database count. * - * 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. + * Retrieves the maximum number of databases currently allowed in the instance. * - * @param postPartitionAllDocsOptions the {@link PostPartitionAllDocsOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link InputStream} + * @return a {@link ServiceCall} with a result of type {@link CapacityDatabasesInformation} */ - public ServiceCall postPartitionAllDocsAsStream(PostPartitionAllDocsOptions postPartitionAllDocsOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionAllDocsOptions, - "postPartitionAllDocsOptions cannot be null"); - Map pathParamsMap = new HashMap(); - 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionAllDocsAsStream"); + public ServiceCall getCapacityDatabasesInformation() { + return getCapacityDatabasesInformation(null); + } + + /** + * Retrieve current database count. + * + * Retrieves the current number of databases that exist in the instance. + * + * @param getCurrentDatabasesInformationOptions the {@link GetCurrentDatabasesInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link CurrentDatabasesInformation} + */ + public ServiceCall getCurrentDatabasesInformation(GetCurrentDatabasesInformationOptions getCurrentDatabasesInformationOptions) { + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/current/databases")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCurrentDatabasesInformation"); for (Entry 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("end_key", 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("start_key", postPartitionAllDocsOptions.startKey()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Query a database partition search index. + * Retrieve current database count. * - * Partitioned Search indexes, which are defined in design documents, allow partition databases to be queried by using - * Lucene Query Parser Syntax. Search indexes are defined by an index function, similar to a map function in MapReduce - * views. The index function decides what data to index and store in the index. + * Retrieves the current number of databases that exist in the instance. * + * @return a {@link ServiceCall} with a result of type {@link CurrentDatabasesInformation} + */ + public ServiceCall getCurrentDatabasesInformation() { + return getCurrentDatabasesInformation(null); + } + + /** + * Retrieve the current provisioned throughput capacity consumption. * - * Before using read the - * [FAQs](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-database-partitioning#partition-querying) to understand - * the limitations and appropriate use cases. + * 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 postPartitionSearchOptions the {@link PostPartitionSearchOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link SearchResult} + * @param getCurrentThroughputInformationOptions the {@link GetCurrentThroughputInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link CurrentThroughputInformation} */ - public ServiceCall postPartitionSearch(PostPartitionSearchOptions postPartitionSearchOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionSearchOptions, - "postPartitionSearchOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", postPartitionSearchOptions.db()); - pathParamsMap.put("partition_key", postPartitionSearchOptions.partitionKey()); - pathParamsMap.put("ddoc", postPartitionSearchOptions.ddoc()); - pathParamsMap.put("index", postPartitionSearchOptions.index()); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_design/{ddoc}/_search/{index}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionSearch"); + public ServiceCall getCurrentThroughputInformation(GetCurrentThroughputInformationOptions getCurrentThroughputInformationOptions) { + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/current/throughput")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCurrentThroughputInformation"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("query", postPartitionSearchOptions.query()); - if (postPartitionSearchOptions.bookmark() != null) { - contentJson.addProperty("bookmark", postPartitionSearchOptions.bookmark()); - } - if (postPartitionSearchOptions.highlightFields() != null) { - contentJson.add("highlight_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionSearchOptions.highlightFields())); - } - if (postPartitionSearchOptions.highlightNumber() != null) { - contentJson.addProperty("highlight_number", postPartitionSearchOptions.highlightNumber()); - } - if (postPartitionSearchOptions.highlightPostTag() != null) { - contentJson.addProperty("highlight_post_tag", postPartitionSearchOptions.highlightPostTag()); - } - if (postPartitionSearchOptions.highlightPreTag() != null) { - contentJson.addProperty("highlight_pre_tag", postPartitionSearchOptions.highlightPreTag()); - } - if (postPartitionSearchOptions.highlightSize() != null) { - contentJson.addProperty("highlight_size", postPartitionSearchOptions.highlightSize()); - } - if (postPartitionSearchOptions.includeDocs() != null) { - contentJson.addProperty("include_docs", postPartitionSearchOptions.includeDocs()); - } - if (postPartitionSearchOptions.includeFields() != null) { - contentJson.add("include_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionSearchOptions.includeFields())); - } - if (postPartitionSearchOptions.limit() != null) { - contentJson.addProperty("limit", postPartitionSearchOptions.limit()); - } - if (postPartitionSearchOptions.sort() != null) { - contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionSearchOptions.sort())); - } - if (postPartitionSearchOptions.stale() != null) { - contentJson.addProperty("stale", postPartitionSearchOptions.stale()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Query a database partition search index as stream. + * Retrieve the current provisioned throughput capacity consumption. * - * Partitioned Search indexes, which are defined in design documents, allow partition databases to be queried by using - * Lucene Query Parser Syntax. Search indexes are defined by an index function, similar to a map function in MapReduce - * views. The index function decides what data to index and store in the index. + * 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. * + * @return a {@link ServiceCall} with a result of type {@link CurrentThroughputInformation} + */ + public ServiceCall getCurrentThroughputInformation() { + return getCurrentThroughputInformation(null); + } + + /** + * Retrieve cluster membership information. * - * Before using read the - * [FAQs](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-database-partitioning#partition-querying) to understand - * the limitations and appropriate use cases. + * Displays the nodes that are part of the cluster as `cluster_nodes`. The field, `all_nodes`, displays all nodes this + * node knows about, including the ones that are part of the cluster. This endpoint is useful when you set up a + * cluster. * - * @param postPartitionSearchOptions the {@link PostPartitionSearchOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link InputStream} + * @param getMembershipInformationOptions the {@link GetMembershipInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link MembershipInformation} */ - public ServiceCall postPartitionSearchAsStream(PostPartitionSearchOptions postPartitionSearchOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionSearchOptions, - "postPartitionSearchOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", postPartitionSearchOptions.db()); - pathParamsMap.put("partition_key", postPartitionSearchOptions.partitionKey()); - pathParamsMap.put("ddoc", postPartitionSearchOptions.ddoc()); - pathParamsMap.put("index", postPartitionSearchOptions.index()); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_design/{ddoc}/_search/{index}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionSearchAsStream"); + public ServiceCall getMembershipInformation(GetMembershipInformationOptions getMembershipInformationOptions) { + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_membership")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getMembershipInformation"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("query", postPartitionSearchOptions.query()); - if (postPartitionSearchOptions.bookmark() != null) { - contentJson.addProperty("bookmark", postPartitionSearchOptions.bookmark()); - } - if (postPartitionSearchOptions.highlightFields() != null) { - contentJson.add("highlight_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionSearchOptions.highlightFields())); - } - if (postPartitionSearchOptions.highlightNumber() != null) { - contentJson.addProperty("highlight_number", postPartitionSearchOptions.highlightNumber()); - } - if (postPartitionSearchOptions.highlightPostTag() != null) { - contentJson.addProperty("highlight_post_tag", postPartitionSearchOptions.highlightPostTag()); - } - if (postPartitionSearchOptions.highlightPreTag() != null) { - contentJson.addProperty("highlight_pre_tag", postPartitionSearchOptions.highlightPreTag()); - } - if (postPartitionSearchOptions.highlightSize() != null) { - contentJson.addProperty("highlight_size", postPartitionSearchOptions.highlightSize()); - } - if (postPartitionSearchOptions.includeDocs() != null) { - contentJson.addProperty("include_docs", postPartitionSearchOptions.includeDocs()); - } - if (postPartitionSearchOptions.includeFields() != null) { - contentJson.add("include_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionSearchOptions.includeFields())); - } - if (postPartitionSearchOptions.limit() != null) { - contentJson.addProperty("limit", postPartitionSearchOptions.limit()); - } - if (postPartitionSearchOptions.sort() != null) { - contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionSearchOptions.sort())); - } - if (postPartitionSearchOptions.stale() != null) { - contentJson.addProperty("stale", postPartitionSearchOptions.stale()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Query a database partition MapReduce view function. + * Retrieve cluster membership information. * - * Runs the specified view function from the specified design document. Unlike `GET /{db}/_design/{ddoc}/_view/{view}` - * for accessing views, the POST method supports the specification of explicit keys to be retrieved from the view - * results. The remainder of the POST view functionality is identical to the `GET /{db}/_design/{ddoc}/_view/{view}` - * API. + * Displays the nodes that are part of the cluster as `cluster_nodes`. The field, `all_nodes`, displays all nodes this + * node knows about, including the ones that are part of the cluster. This endpoint is useful when you set up a + * cluster. * + * @return a {@link ServiceCall} with a result of type {@link MembershipInformation} + */ + public ServiceCall getMembershipInformation() { + return getMembershipInformation(null); + } + + /** + * Retrieve information about whether the server is up. * - * Before using read the - * [FAQs](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-database-partitioning#partition-querying) to understand - * the limitations and appropriate use cases. + * Confirms that the server is up, running, and ready to respond to requests. If the cluster is unavailable the + * endpoint returns a `503` response code. * - * @param postPartitionViewOptions the {@link PostPartitionViewOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link ViewResult} + * **Tip:** The authentication for this endpoint is only enforced when using IAM. + * + * @param getUpInformationOptions the {@link GetUpInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link UpInformation} */ - public ServiceCall postPartitionView(PostPartitionViewOptions postPartitionViewOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionViewOptions, - "postPartitionViewOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", postPartitionViewOptions.db()); - pathParamsMap.put("partition_key", postPartitionViewOptions.partitionKey()); - pathParamsMap.put("ddoc", postPartitionViewOptions.ddoc()); - pathParamsMap.put("view", postPartitionViewOptions.view()); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_design/{ddoc}/_view/{view}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionView"); + public ServiceCall getUpInformation(GetUpInformationOptions getUpInformationOptions) { + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_up")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getUpInformation"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (postPartitionViewOptions.attEncodingInfo() != null) { - contentJson.addProperty("att_encoding_info", postPartitionViewOptions.attEncodingInfo()); - } - if (postPartitionViewOptions.attachments() != null) { - contentJson.addProperty("attachments", postPartitionViewOptions.attachments()); - } - if (postPartitionViewOptions.conflicts() != null) { - contentJson.addProperty("conflicts", postPartitionViewOptions.conflicts()); - } - if (postPartitionViewOptions.descending() != null) { - contentJson.addProperty("descending", postPartitionViewOptions.descending()); - } - if (postPartitionViewOptions.includeDocs() != null) { - contentJson.addProperty("include_docs", postPartitionViewOptions.includeDocs()); - } - if (postPartitionViewOptions.inclusiveEnd() != null) { - contentJson.addProperty("inclusive_end", postPartitionViewOptions.inclusiveEnd()); - } - if (postPartitionViewOptions.limit() != null) { - contentJson.addProperty("limit", postPartitionViewOptions.limit()); - } - if (postPartitionViewOptions.skip() != null) { - contentJson.addProperty("skip", postPartitionViewOptions.skip()); - } - if (postPartitionViewOptions.updateSeq() != null) { - contentJson.addProperty("update_seq", postPartitionViewOptions.updateSeq()); - } - if (postPartitionViewOptions.endKey() != null) { - contentJson.add("end_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.endKey())); - } - if (postPartitionViewOptions.endKeyDocId() != null) { - contentJson.addProperty("end_key_doc_id", postPartitionViewOptions.endKeyDocId()); - } - if (postPartitionViewOptions.group() != null) { - contentJson.addProperty("group", postPartitionViewOptions.group()); - } - if (postPartitionViewOptions.groupLevel() != null) { - contentJson.addProperty("group_level", postPartitionViewOptions.groupLevel()); - } - if (postPartitionViewOptions.key() != null) { - contentJson.add("key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.key())); - } - if (postPartitionViewOptions.keys() != null) { - contentJson.add("keys", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.keys())); - } - if (postPartitionViewOptions.reduce() != null) { - contentJson.addProperty("reduce", postPartitionViewOptions.reduce()); - } - if (postPartitionViewOptions.startKey() != null) { - contentJson.add("start_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.startKey())); - } - if (postPartitionViewOptions.startKeyDocId() != null) { - contentJson.addProperty("start_key_doc_id", postPartitionViewOptions.startKeyDocId()); - } - if (postPartitionViewOptions.update() != null) { - contentJson.addProperty("update", postPartitionViewOptions.update()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Query a database partition MapReduce view function as stream. - * - * Runs the specified view function from the specified design document. Unlike `GET /{db}/_design/{ddoc}/_view/{view}` - * for accessing views, the POST method supports the specification of explicit keys to be retrieved from the view - * results. The remainder of the POST view functionality is identical to the `GET /{db}/_design/{ddoc}/_view/{view}` - * API. + * Retrieve information about whether the server is up. + * + * Confirms that the server is up, running, and ready to respond to requests. If the cluster is unavailable the + * endpoint returns a `503` response code. + * + * **Tip:** The authentication for this endpoint is only enforced when using IAM. + * + * @return a {@link ServiceCall} with a result of type {@link UpInformation} + */ + public ServiceCall getUpInformation() { + return getUpInformation(null); + } + + /** + * Retrieve index status for all design documents. * + * **EXPERIMENTAL** Returns index status grouped by type for all design documents in the database or a filtered + * subset. Results are grouped into `view_indexes` and `search_indexes`. Each entry identifies the index by its design + * document and, for search indexes, its `name`. Use a `keys` array in the request body to select design documents by + * ID. Use this endpoint to verify whether a database's indexes are fully built, for example before switching traffic + * to a replica. * - * Before using read the - * [FAQs](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-database-partitioning#partition-querying) to understand - * the limitations and appropriate use cases. - * - * @param postPartitionViewOptions the {@link PostPartitionViewOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link InputStream} + * @param postIndexInfoOptions the {@link PostIndexInfoOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link IndexInfoResult} */ - public ServiceCall postPartitionViewAsStream(PostPartitionViewOptions postPartitionViewOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionViewOptions, - "postPartitionViewOptions cannot be null"); + public ServiceCall postIndexInfo(PostIndexInfoOptions postIndexInfoOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postIndexInfoOptions, + "postIndexInfoOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", postPartitionViewOptions.db()); - pathParamsMap.put("partition_key", postPartitionViewOptions.partitionKey()); - pathParamsMap.put("ddoc", postPartitionViewOptions.ddoc()); - pathParamsMap.put("view", postPartitionViewOptions.view()); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_design/{ddoc}/_view/{view}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionViewAsStream"); + pathParamsMap.put("db", postIndexInfoOptions.db()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_index_info", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postIndexInfo"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - if (postPartitionViewOptions.attEncodingInfo() != null) { - contentJson.addProperty("att_encoding_info", postPartitionViewOptions.attEncodingInfo()); - } - if (postPartitionViewOptions.attachments() != null) { - contentJson.addProperty("attachments", postPartitionViewOptions.attachments()); - } - if (postPartitionViewOptions.conflicts() != null) { - contentJson.addProperty("conflicts", postPartitionViewOptions.conflicts()); - } - if (postPartitionViewOptions.descending() != null) { - contentJson.addProperty("descending", postPartitionViewOptions.descending()); - } - if (postPartitionViewOptions.includeDocs() != null) { - contentJson.addProperty("include_docs", postPartitionViewOptions.includeDocs()); - } - if (postPartitionViewOptions.inclusiveEnd() != null) { - contentJson.addProperty("inclusive_end", postPartitionViewOptions.inclusiveEnd()); + if (postIndexInfoOptions.attEncodingInfo() != null) { + contentJson.addProperty("att_encoding_info", postIndexInfoOptions.attEncodingInfo()); } - if (postPartitionViewOptions.limit() != null) { - contentJson.addProperty("limit", postPartitionViewOptions.limit()); + if (postIndexInfoOptions.attachments() != null) { + contentJson.addProperty("attachments", postIndexInfoOptions.attachments()); } - if (postPartitionViewOptions.skip() != null) { - contentJson.addProperty("skip", postPartitionViewOptions.skip()); + if (postIndexInfoOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postIndexInfoOptions.conflicts()); } - if (postPartitionViewOptions.updateSeq() != null) { - contentJson.addProperty("update_seq", postPartitionViewOptions.updateSeq()); + if (postIndexInfoOptions.descending() != null) { + contentJson.addProperty("descending", postIndexInfoOptions.descending()); } - if (postPartitionViewOptions.endKey() != null) { - contentJson.add("end_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.endKey())); + if (postIndexInfoOptions.includeDocs() != null) { + contentJson.addProperty("include_docs", postIndexInfoOptions.includeDocs()); } - if (postPartitionViewOptions.endKeyDocId() != null) { - contentJson.addProperty("end_key_doc_id", postPartitionViewOptions.endKeyDocId()); + if (postIndexInfoOptions.inclusiveEnd() != null) { + contentJson.addProperty("inclusive_end", postIndexInfoOptions.inclusiveEnd()); } - if (postPartitionViewOptions.group() != null) { - contentJson.addProperty("group", postPartitionViewOptions.group()); + if (postIndexInfoOptions.limit() != null) { + contentJson.addProperty("limit", postIndexInfoOptions.limit()); } - if (postPartitionViewOptions.groupLevel() != null) { - contentJson.addProperty("group_level", postPartitionViewOptions.groupLevel()); + if (postIndexInfoOptions.skip() != null) { + contentJson.addProperty("skip", postIndexInfoOptions.skip()); } - if (postPartitionViewOptions.key() != null) { - contentJson.add("key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.key())); + if (postIndexInfoOptions.updateSeq() != null) { + contentJson.addProperty("update_seq", postIndexInfoOptions.updateSeq()); } - if (postPartitionViewOptions.keys() != null) { - contentJson.add("keys", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.keys())); + if (postIndexInfoOptions.endKey() != null) { + contentJson.addProperty("end_key", postIndexInfoOptions.endKey()); } - if (postPartitionViewOptions.reduce() != null) { - contentJson.addProperty("reduce", postPartitionViewOptions.reduce()); + if (postIndexInfoOptions.key() != null) { + contentJson.addProperty("key", postIndexInfoOptions.key()); } - if (postPartitionViewOptions.startKey() != null) { - contentJson.add("start_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.startKey())); + if (postIndexInfoOptions.keys() != null) { + contentJson.add("keys", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postIndexInfoOptions.keys())); } - if (postPartitionViewOptions.startKeyDocId() != null) { - contentJson.addProperty("start_key_doc_id", postPartitionViewOptions.startKeyDocId()); + if (postIndexInfoOptions.startKey() != null) { + contentJson.addProperty("start_key", postIndexInfoOptions.startKey()); } - if (postPartitionViewOptions.update() != null) { - contentJson.addProperty("update", postPartitionViewOptions.update()); + if (postIndexInfoOptions.type() != null) { + contentJson.add("type", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postIndexInfoOptions.type())); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve information about which partition index is used for a query. + * Query a MapReduce view. * - * Shows which index is being used by the query. Parameters are the same as the - * [`/{db}/_partition/{partition_key}/_find` endpoint](#postpartitionfind-queries). + * 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 postPartitionExplainOptions the {@link PostPartitionExplainOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link ExplainResult} + * @param postViewOptions the {@link PostViewOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ViewResult} */ - public ServiceCall postPartitionExplain(PostPartitionExplainOptions postPartitionExplainOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionExplainOptions, - "postPartitionExplainOptions cannot be null"); + public ServiceCall postView(PostViewOptions postViewOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postViewOptions, + "postViewOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", postPartitionExplainOptions.db()); - pathParamsMap.put("partition_key", postPartitionExplainOptions.partitionKey()); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_explain", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionExplain"); + 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postView"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionExplainOptions.selector())); - if (postPartitionExplainOptions.allowFallback() != null) { - contentJson.addProperty("allow_fallback", postPartitionExplainOptions.allowFallback()); + if (postViewOptions.attEncodingInfo() != null) { + contentJson.addProperty("att_encoding_info", postViewOptions.attEncodingInfo()); } - if (postPartitionExplainOptions.bookmark() != null) { - contentJson.addProperty("bookmark", postPartitionExplainOptions.bookmark()); + if (postViewOptions.attachments() != null) { + contentJson.addProperty("attachments", postViewOptions.attachments()); } - if (postPartitionExplainOptions.conflicts() != null) { - contentJson.addProperty("conflicts", postPartitionExplainOptions.conflicts()); + if (postViewOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postViewOptions.conflicts()); } - if (postPartitionExplainOptions.executionStats() != null) { - contentJson.addProperty("execution_stats", postPartitionExplainOptions.executionStats()); + if (postViewOptions.descending() != null) { + contentJson.addProperty("descending", postViewOptions.descending()); } - if (postPartitionExplainOptions.fields() != null) { - contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionExplainOptions.fields())); + if (postViewOptions.includeDocs() != null) { + contentJson.addProperty("include_docs", postViewOptions.includeDocs()); } - if (postPartitionExplainOptions.limit() != null) { - contentJson.addProperty("limit", postPartitionExplainOptions.limit()); + if (postViewOptions.inclusiveEnd() != null) { + contentJson.addProperty("inclusive_end", postViewOptions.inclusiveEnd()); } - if (postPartitionExplainOptions.skip() != null) { - contentJson.addProperty("skip", postPartitionExplainOptions.skip()); + if (postViewOptions.limit() != null) { + contentJson.addProperty("limit", postViewOptions.limit()); } - if (postPartitionExplainOptions.sort() != null) { - contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionExplainOptions.sort())); + if (postViewOptions.skip() != null) { + contentJson.addProperty("skip", postViewOptions.skip()); } - if (postPartitionExplainOptions.stable() != null) { - contentJson.addProperty("stable", postPartitionExplainOptions.stable()); + if (postViewOptions.updateSeq() != null) { + contentJson.addProperty("update_seq", postViewOptions.updateSeq()); } - if (postPartitionExplainOptions.update() != null) { - contentJson.addProperty("update", postPartitionExplainOptions.update()); + if (postViewOptions.endKey() != null) { + contentJson.add("end_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.endKey())); } - if (postPartitionExplainOptions.useIndex() != null) { - contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionExplainOptions.useIndex())); + if (postViewOptions.endKeyDocId() != null) { + contentJson.addProperty("end_key_doc_id", 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("start_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.startKey())); + } + if (postViewOptions.startKeyDocId() != null) { + contentJson.addProperty("start_key_doc_id", postViewOptions.startKeyDocId()); + } + if (postViewOptions.update() != null) { + contentJson.addProperty("update", postViewOptions.update()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Query a database partition index by using selector syntax. - * - * Query documents by using a declarative JSON querying syntax. It's best practice to create an appropriate index for - * all fields in selector by using the `_index` endpoint. - * - * Queries without an appropriate backing index by default fallback to using the built-in `_all_docs` index. This - * isn't recommended because it has a significant performance impact causing a full scan of the partition with each - * request. In this case the response body includes a warning field recommending the creation of an index. - * - * To avoid the fallback behavior set the `allow_fallback` option to `false` and the server responds with a `400` - * status code if no suitable index exists. If you want to use only a specific index for your query set - * `allow_fallback` to `false` and set the `use_index` option. + * Query a MapReduce view as stream. * - * Before using read the - * [FAQs](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-database-partitioning#partition-querying) to understand - * the limitations and appropriate use cases. + * 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 postPartitionFindOptions the {@link PostPartitionFindOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link FindResult} + * @param postViewOptions the {@link PostViewOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ - public ServiceCall postPartitionFind(PostPartitionFindOptions postPartitionFindOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionFindOptions, - "postPartitionFindOptions cannot be null"); + public ServiceCall postViewAsStream(PostViewOptions postViewOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postViewOptions, + "postViewOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", postPartitionFindOptions.db()); - pathParamsMap.put("partition_key", postPartitionFindOptions.partitionKey()); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_find", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionFind"); + 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postViewAsStream"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.selector())); - if (postPartitionFindOptions.allowFallback() != null) { - contentJson.addProperty("allow_fallback", postPartitionFindOptions.allowFallback()); + if (postViewOptions.attEncodingInfo() != null) { + contentJson.addProperty("att_encoding_info", postViewOptions.attEncodingInfo()); } - if (postPartitionFindOptions.bookmark() != null) { - contentJson.addProperty("bookmark", postPartitionFindOptions.bookmark()); + if (postViewOptions.attachments() != null) { + contentJson.addProperty("attachments", postViewOptions.attachments()); } - if (postPartitionFindOptions.conflicts() != null) { - contentJson.addProperty("conflicts", postPartitionFindOptions.conflicts()); + if (postViewOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postViewOptions.conflicts()); } - if (postPartitionFindOptions.executionStats() != null) { - contentJson.addProperty("execution_stats", postPartitionFindOptions.executionStats()); + if (postViewOptions.descending() != null) { + contentJson.addProperty("descending", postViewOptions.descending()); } - if (postPartitionFindOptions.fields() != null) { - contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.fields())); + 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("end_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.endKey())); + } + if (postViewOptions.endKeyDocId() != null) { + contentJson.addProperty("end_key_doc_id", 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 (postPartitionFindOptions.limit() != null) { - contentJson.addProperty("limit", postPartitionFindOptions.limit()); + if (postViewOptions.keys() != null) { + contentJson.add("keys", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.keys())); } - if (postPartitionFindOptions.skip() != null) { - contentJson.addProperty("skip", postPartitionFindOptions.skip()); + if (postViewOptions.reduce() != null) { + contentJson.addProperty("reduce", postViewOptions.reduce()); } - if (postPartitionFindOptions.sort() != null) { - contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.sort())); + if (postViewOptions.stable() != null) { + contentJson.addProperty("stable", postViewOptions.stable()); } - if (postPartitionFindOptions.stable() != null) { - contentJson.addProperty("stable", postPartitionFindOptions.stable()); + if (postViewOptions.startKey() != null) { + contentJson.add("start_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewOptions.startKey())); } - if (postPartitionFindOptions.update() != null) { - contentJson.addProperty("update", postPartitionFindOptions.update()); + if (postViewOptions.startKeyDocId() != null) { + contentJson.addProperty("start_key_doc_id", postViewOptions.startKeyDocId()); } - if (postPartitionFindOptions.useIndex() != null) { - contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.useIndex())); + if (postViewOptions.update() != null) { + contentJson.addProperty("update", postViewOptions.update()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); return createServiceCall(builder.build(), responseConverter); } /** - * Query a database partition index by using selector syntax as stream. - * - * Query documents by using a declarative JSON querying syntax. It's best practice to create an appropriate index for - * all fields in selector by using the `_index` endpoint. + * Multi-query a MapReduce view. * - * Queries without an appropriate backing index by default fallback to using the built-in `_all_docs` index. This - * isn't recommended because it has a significant performance impact causing a full scan of the partition with each - * request. In this case the response body includes a warning field recommending the creation of an index. + * This operation runs multiple specified view queries against the view function from the specified design document. * - * To avoid the fallback behavior set the `allow_fallback` option to `false` and the server responds with a `400` - * status code if no suitable index exists. If you want to use only a specific index for your query set - * `allow_fallback` to `false` and set the `use_index` option. + * @param postViewQueriesOptions the {@link PostViewQueriesOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ViewQueriesResult} + */ + public ServiceCall postViewQueries(PostViewQueriesOptions postViewQueriesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postViewQueriesOptions, + "postViewQueriesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postViewQueries"); + for (Entry 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 responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Multi-query a MapReduce view as stream. * - * Before using read the - * [FAQs](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-database-partitioning#partition-querying) to understand - * the limitations and appropriate use cases. + * This operation runs multiple specified view queries against the view function from the specified design document. * - * @param postPartitionFindOptions the {@link PostPartitionFindOptions} containing the options for the call + * @param postViewQueriesOptions the {@link PostViewQueriesOptions} containing the options for the call * @return a {@link ServiceCall} with a result of type {@link InputStream} */ - public ServiceCall postPartitionFindAsStream(PostPartitionFindOptions postPartitionFindOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionFindOptions, - "postPartitionFindOptions cannot be null"); + public ServiceCall postViewQueriesAsStream(PostViewQueriesOptions postViewQueriesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postViewQueriesOptions, + "postViewQueriesOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", postPartitionFindOptions.db()); - pathParamsMap.put("partition_key", postPartitionFindOptions.partitionKey()); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_find", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionFindAsStream"); + 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postViewQueriesAsStream"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.selector())); - if (postPartitionFindOptions.allowFallback() != null) { - contentJson.addProperty("allow_fallback", postPartitionFindOptions.allowFallback()); - } - if (postPartitionFindOptions.bookmark() != null) { - contentJson.addProperty("bookmark", postPartitionFindOptions.bookmark()); - } - if (postPartitionFindOptions.conflicts() != null) { - contentJson.addProperty("conflicts", postPartitionFindOptions.conflicts()); - } - if (postPartitionFindOptions.executionStats() != null) { - contentJson.addProperty("execution_stats", postPartitionFindOptions.executionStats()); - } - if (postPartitionFindOptions.fields() != null) { - contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.fields())); - } - if (postPartitionFindOptions.limit() != null) { - contentJson.addProperty("limit", postPartitionFindOptions.limit()); - } - if (postPartitionFindOptions.skip() != null) { - contentJson.addProperty("skip", postPartitionFindOptions.skip()); - } - if (postPartitionFindOptions.sort() != null) { - contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.sort())); - } - if (postPartitionFindOptions.stable() != null) { - contentJson.addProperty("stable", postPartitionFindOptions.stable()); - } - if (postPartitionFindOptions.update() != null) { - contentJson.addProperty("update", postPartitionFindOptions.update()); - } - if (postPartitionFindOptions.useIndex() != null) { - contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.useIndex())); - } + contentJson.add("queries", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postViewQueriesOptions.queries())); builder.bodyJson(contentJson); ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve information about which index is used for a query. + * Retrieve information about a database partition. * - * Shows which index is being used by the query. Parameters are the same as the [`_find` endpoint](#postfind). + * Given a partition key, return the database name, sizes, partition, doc count, and doc delete count. * - * @param postExplainOptions the {@link PostExplainOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link ExplainResult} + * @param getPartitionInformationOptions the {@link GetPartitionInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PartitionInformation} */ - public ServiceCall postExplain(PostExplainOptions postExplainOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postExplainOptions, - "postExplainOptions cannot be null"); + public ServiceCall getPartitionInformation(GetPartitionInformationOptions getPartitionInformationOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getPartitionInformationOptions, + "getPartitionInformationOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", postExplainOptions.db()); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_explain", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postExplain"); + pathParamsMap.put("db", getPartitionInformationOptions.db()); + pathParamsMap.put("partition_key", getPartitionInformationOptions.partitionKey()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getPartitionInformation"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * 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 postPartitionAllDocs(PostPartitionAllDocsOptions postPartitionAllDocsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionAllDocsOptions, + "postPartitionAllDocsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionAllDocs"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postExplainOptions.selector())); - if (postExplainOptions.allowFallback() != null) { - contentJson.addProperty("allow_fallback", postExplainOptions.allowFallback()); + if (postPartitionAllDocsOptions.attEncodingInfo() != null) { + contentJson.addProperty("att_encoding_info", postPartitionAllDocsOptions.attEncodingInfo()); } - if (postExplainOptions.bookmark() != null) { - contentJson.addProperty("bookmark", postExplainOptions.bookmark()); + if (postPartitionAllDocsOptions.attachments() != null) { + contentJson.addProperty("attachments", postPartitionAllDocsOptions.attachments()); } - if (postExplainOptions.conflicts() != null) { - contentJson.addProperty("conflicts", postExplainOptions.conflicts()); + if (postPartitionAllDocsOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postPartitionAllDocsOptions.conflicts()); } - if (postExplainOptions.executionStats() != null) { - contentJson.addProperty("execution_stats", postExplainOptions.executionStats()); + if (postPartitionAllDocsOptions.descending() != null) { + contentJson.addProperty("descending", postPartitionAllDocsOptions.descending()); } - if (postExplainOptions.fields() != null) { - contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postExplainOptions.fields())); + if (postPartitionAllDocsOptions.includeDocs() != null) { + contentJson.addProperty("include_docs", postPartitionAllDocsOptions.includeDocs()); } - if (postExplainOptions.limit() != null) { - contentJson.addProperty("limit", postExplainOptions.limit()); + if (postPartitionAllDocsOptions.inclusiveEnd() != null) { + contentJson.addProperty("inclusive_end", postPartitionAllDocsOptions.inclusiveEnd()); } - if (postExplainOptions.skip() != null) { - contentJson.addProperty("skip", postExplainOptions.skip()); + if (postPartitionAllDocsOptions.limit() != null) { + contentJson.addProperty("limit", postPartitionAllDocsOptions.limit()); } - if (postExplainOptions.sort() != null) { - contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postExplainOptions.sort())); + if (postPartitionAllDocsOptions.skip() != null) { + contentJson.addProperty("skip", postPartitionAllDocsOptions.skip()); } - if (postExplainOptions.stable() != null) { - contentJson.addProperty("stable", postExplainOptions.stable()); + if (postPartitionAllDocsOptions.updateSeq() != null) { + contentJson.addProperty("update_seq", postPartitionAllDocsOptions.updateSeq()); } - if (postExplainOptions.update() != null) { - contentJson.addProperty("update", postExplainOptions.update()); + if (postPartitionAllDocsOptions.endKey() != null) { + contentJson.addProperty("end_key", postPartitionAllDocsOptions.endKey()); } - if (postExplainOptions.useIndex() != null) { - contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postExplainOptions.useIndex())); + if (postPartitionAllDocsOptions.key() != null) { + contentJson.addProperty("key", postPartitionAllDocsOptions.key()); } - if (postExplainOptions.r() != null) { - contentJson.addProperty("r", postExplainOptions.r()); + if (postPartitionAllDocsOptions.keys() != null) { + contentJson.add("keys", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionAllDocsOptions.keys())); + } + if (postPartitionAllDocsOptions.startKey() != null) { + contentJson.addProperty("start_key", postPartitionAllDocsOptions.startKey()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Query an index by using selector syntax. - * - * Query documents by using a declarative JSON querying syntax. It's best practice to create an appropriate index for - * all fields in selector by using the `_index` endpoint. - * - * Queries without an appropriate backing index by default fallback to using the built-in `_all_docs` index. This - * isn't recommended because it has a significant performance impact causing a full scan of the database with each - * request. In this case the response body includes a warning field recommending the creation of an index. + * Query a list of all documents in a database partition as stream. * - * To avoid the fallback behavior set the `allow_fallback` option to `false` and the server responds with a `400` - * status code if no suitable index exists. If you want to use only a specific index for your query set - * `allow_fallback` to `false` and set the `use_index` option. + * 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 postFindOptions the {@link PostFindOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link FindResult} + * @param postPartitionAllDocsOptions the {@link PostPartitionAllDocsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ - public ServiceCall postFind(PostFindOptions postFindOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postFindOptions, - "postFindOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", postFindOptions.db()); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_find", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postFind"); + public ServiceCall postPartitionAllDocsAsStream(PostPartitionAllDocsOptions postPartitionAllDocsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionAllDocsOptions, + "postPartitionAllDocsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionAllDocsAsStream"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.selector())); - if (postFindOptions.allowFallback() != null) { - contentJson.addProperty("allow_fallback", postFindOptions.allowFallback()); + if (postPartitionAllDocsOptions.attEncodingInfo() != null) { + contentJson.addProperty("att_encoding_info", postPartitionAllDocsOptions.attEncodingInfo()); } - if (postFindOptions.bookmark() != null) { - contentJson.addProperty("bookmark", postFindOptions.bookmark()); + if (postPartitionAllDocsOptions.attachments() != null) { + contentJson.addProperty("attachments", postPartitionAllDocsOptions.attachments()); } - if (postFindOptions.conflicts() != null) { - contentJson.addProperty("conflicts", postFindOptions.conflicts()); + if (postPartitionAllDocsOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postPartitionAllDocsOptions.conflicts()); } - if (postFindOptions.executionStats() != null) { - contentJson.addProperty("execution_stats", postFindOptions.executionStats()); + if (postPartitionAllDocsOptions.descending() != null) { + contentJson.addProperty("descending", postPartitionAllDocsOptions.descending()); } - if (postFindOptions.fields() != null) { - contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.fields())); + if (postPartitionAllDocsOptions.includeDocs() != null) { + contentJson.addProperty("include_docs", postPartitionAllDocsOptions.includeDocs()); } - if (postFindOptions.limit() != null) { - contentJson.addProperty("limit", postFindOptions.limit()); + if (postPartitionAllDocsOptions.inclusiveEnd() != null) { + contentJson.addProperty("inclusive_end", postPartitionAllDocsOptions.inclusiveEnd()); } - if (postFindOptions.skip() != null) { - contentJson.addProperty("skip", postFindOptions.skip()); + if (postPartitionAllDocsOptions.limit() != null) { + contentJson.addProperty("limit", postPartitionAllDocsOptions.limit()); } - if (postFindOptions.sort() != null) { - contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.sort())); + if (postPartitionAllDocsOptions.skip() != null) { + contentJson.addProperty("skip", postPartitionAllDocsOptions.skip()); } - if (postFindOptions.stable() != null) { - contentJson.addProperty("stable", postFindOptions.stable()); + if (postPartitionAllDocsOptions.updateSeq() != null) { + contentJson.addProperty("update_seq", postPartitionAllDocsOptions.updateSeq()); } - if (postFindOptions.update() != null) { - contentJson.addProperty("update", postFindOptions.update()); + if (postPartitionAllDocsOptions.endKey() != null) { + contentJson.addProperty("end_key", postPartitionAllDocsOptions.endKey()); } - if (postFindOptions.useIndex() != null) { - contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.useIndex())); + if (postPartitionAllDocsOptions.key() != null) { + contentJson.addProperty("key", postPartitionAllDocsOptions.key()); } - if (postFindOptions.r() != null) { - contentJson.addProperty("r", postFindOptions.r()); + if (postPartitionAllDocsOptions.keys() != null) { + contentJson.add("keys", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionAllDocsOptions.keys())); + } + if (postPartitionAllDocsOptions.startKey() != null) { + contentJson.addProperty("start_key", postPartitionAllDocsOptions.startKey()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); return createServiceCall(builder.build(), responseConverter); } /** - * Query an index by using selector syntax as stream. + * Query a database partition search index. * - * Query documents by using a declarative JSON querying syntax. It's best practice to create an appropriate index for - * all fields in selector by using the `_index` endpoint. + * Partitioned Search indexes, which are defined in design documents, allow partition databases to be queried by using + * Lucene Query Parser Syntax. Search indexes are defined by an index function, similar to a map function in MapReduce + * views. The index function decides what data to index and store in the index. * - * Queries without an appropriate backing index by default fallback to using the built-in `_all_docs` index. This - * isn't recommended because it has a significant performance impact causing a full scan of the database with each - * request. In this case the response body includes a warning field recommending the creation of an index. * - * To avoid the fallback behavior set the `allow_fallback` option to `false` and the server responds with a `400` - * status code if no suitable index exists. If you want to use only a specific index for your query set - * `allow_fallback` to `false` and set the `use_index` option. + * Before using read the + * [FAQs](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-database-partitioning#partition-querying) to understand + * the limitations and appropriate use cases. * - * @param postFindOptions the {@link PostFindOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link InputStream} + * @param postPartitionSearchOptions the {@link PostPartitionSearchOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link SearchResult} */ - public ServiceCall postFindAsStream(PostFindOptions postFindOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postFindOptions, - "postFindOptions cannot be null"); + public ServiceCall postPartitionSearch(PostPartitionSearchOptions postPartitionSearchOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionSearchOptions, + "postPartitionSearchOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", postFindOptions.db()); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_find", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postFindAsStream"); + pathParamsMap.put("db", postPartitionSearchOptions.db()); + pathParamsMap.put("partition_key", postPartitionSearchOptions.partitionKey()); + pathParamsMap.put("ddoc", postPartitionSearchOptions.ddoc()); + pathParamsMap.put("index", postPartitionSearchOptions.index()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_design/{ddoc}/_search/{index}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionSearch"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.selector())); - if (postFindOptions.allowFallback() != null) { - contentJson.addProperty("allow_fallback", postFindOptions.allowFallback()); - } - if (postFindOptions.bookmark() != null) { - contentJson.addProperty("bookmark", postFindOptions.bookmark()); + contentJson.addProperty("query", postPartitionSearchOptions.query()); + if (postPartitionSearchOptions.bookmark() != null) { + contentJson.addProperty("bookmark", postPartitionSearchOptions.bookmark()); } - if (postFindOptions.conflicts() != null) { - contentJson.addProperty("conflicts", postFindOptions.conflicts()); + if (postPartitionSearchOptions.highlightFields() != null) { + contentJson.add("highlight_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionSearchOptions.highlightFields())); } - if (postFindOptions.executionStats() != null) { - contentJson.addProperty("execution_stats", postFindOptions.executionStats()); + if (postPartitionSearchOptions.highlightNumber() != null) { + contentJson.addProperty("highlight_number", postPartitionSearchOptions.highlightNumber()); } - if (postFindOptions.fields() != null) { - contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.fields())); + if (postPartitionSearchOptions.highlightPostTag() != null) { + contentJson.addProperty("highlight_post_tag", postPartitionSearchOptions.highlightPostTag()); } - if (postFindOptions.limit() != null) { - contentJson.addProperty("limit", postFindOptions.limit()); + if (postPartitionSearchOptions.highlightPreTag() != null) { + contentJson.addProperty("highlight_pre_tag", postPartitionSearchOptions.highlightPreTag()); } - if (postFindOptions.skip() != null) { - contentJson.addProperty("skip", postFindOptions.skip()); + if (postPartitionSearchOptions.highlightSize() != null) { + contentJson.addProperty("highlight_size", postPartitionSearchOptions.highlightSize()); } - if (postFindOptions.sort() != null) { - contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.sort())); + if (postPartitionSearchOptions.includeDocs() != null) { + contentJson.addProperty("include_docs", postPartitionSearchOptions.includeDocs()); } - if (postFindOptions.stable() != null) { - contentJson.addProperty("stable", postFindOptions.stable()); + if (postPartitionSearchOptions.includeFields() != null) { + contentJson.add("include_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionSearchOptions.includeFields())); } - if (postFindOptions.update() != null) { - contentJson.addProperty("update", postFindOptions.update()); + if (postPartitionSearchOptions.limit() != null) { + contentJson.addProperty("limit", postPartitionSearchOptions.limit()); } - if (postFindOptions.useIndex() != null) { - contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.useIndex())); + if (postPartitionSearchOptions.sort() != null) { + contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionSearchOptions.sort())); } - if (postFindOptions.r() != null) { - contentJson.addProperty("r", postFindOptions.r()); + if (postPartitionSearchOptions.stale() != null) { + contentJson.addProperty("stale", postPartitionSearchOptions.stale()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve information about all indexes. + * Query a database partition search index as stream. * - * When you make a GET request to `/db/_index`, you get a list of all the indexes using `"language":"query"` in the - * database and the primary index. In addition to the information available through this API, the indexes are stored - * in the `indexes` property of their respective design documents. + * Partitioned Search indexes, which are defined in design documents, allow partition databases to be queried by using + * Lucene Query Parser Syntax. Search indexes are defined by an index function, similar to a map function in MapReduce + * views. The index function decides what data to index and store in the index. * - * @param getIndexesInformationOptions the {@link GetIndexesInformationOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link IndexesInformation} - */ - public ServiceCall getIndexesInformation(GetIndexesInformationOptions getIndexesInformationOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getIndexesInformationOptions, - "getIndexesInformationOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", getIndexesInformationOptions.db()); - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_index", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getIndexesInformation"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Create a new index on a database. * - * Create a new index on a database. + * Before using read the + * [FAQs](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-database-partitioning#partition-querying) to understand + * the limitations and appropriate use cases. * - * @param postIndexOptions the {@link PostIndexOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link IndexResult} + * @param postPartitionSearchOptions the {@link PostPartitionSearchOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ - public ServiceCall postIndex(PostIndexOptions postIndexOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postIndexOptions, - "postIndexOptions cannot be null"); + public ServiceCall postPartitionSearchAsStream(PostPartitionSearchOptions postPartitionSearchOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionSearchOptions, + "postPartitionSearchOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", postIndexOptions.db()); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_index", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postIndex"); + pathParamsMap.put("db", postPartitionSearchOptions.db()); + pathParamsMap.put("partition_key", postPartitionSearchOptions.partitionKey()); + pathParamsMap.put("ddoc", postPartitionSearchOptions.ddoc()); + pathParamsMap.put("index", postPartitionSearchOptions.index()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_design/{ddoc}/_search/{index}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionSearchAsStream"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - contentJson.add("index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postIndexOptions.index())); - if (postIndexOptions.ddoc() != null) { - contentJson.addProperty("ddoc", postIndexOptions.ddoc()); + contentJson.addProperty("query", postPartitionSearchOptions.query()); + if (postPartitionSearchOptions.bookmark() != null) { + contentJson.addProperty("bookmark", postPartitionSearchOptions.bookmark()); } - if (postIndexOptions.name() != null) { - contentJson.addProperty("name", postIndexOptions.name()); + if (postPartitionSearchOptions.highlightFields() != null) { + contentJson.add("highlight_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionSearchOptions.highlightFields())); } - if (postIndexOptions.partitioned() != null) { - contentJson.addProperty("partitioned", postIndexOptions.partitioned()); + if (postPartitionSearchOptions.highlightNumber() != null) { + contentJson.addProperty("highlight_number", postPartitionSearchOptions.highlightNumber()); } - if (postIndexOptions.type() != null) { - contentJson.addProperty("type", postIndexOptions.type()); + if (postPartitionSearchOptions.highlightPostTag() != null) { + contentJson.addProperty("highlight_post_tag", postPartitionSearchOptions.highlightPostTag()); } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Delete an index. - * - * Delete the index functions from the design document and index files on the server. - * - * @param deleteIndexOptions the {@link DeleteIndexOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link Ok} - */ - public ServiceCall deleteIndex(DeleteIndexOptions deleteIndexOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteIndexOptions, - "deleteIndexOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", deleteIndexOptions.db()); - pathParamsMap.put("ddoc", deleteIndexOptions.ddoc()); - pathParamsMap.put("type", deleteIndexOptions.type()); - pathParamsMap.put("index", deleteIndexOptions.index()); - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_index/_design/{ddoc}/{type}/{index}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteIndex"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); + if (postPartitionSearchOptions.highlightPreTag() != null) { + contentJson.addProperty("highlight_pre_tag", postPartitionSearchOptions.highlightPreTag()); + } + if (postPartitionSearchOptions.highlightSize() != null) { + contentJson.addProperty("highlight_size", postPartitionSearchOptions.highlightSize()); + } + if (postPartitionSearchOptions.includeDocs() != null) { + contentJson.addProperty("include_docs", postPartitionSearchOptions.includeDocs()); + } + if (postPartitionSearchOptions.includeFields() != null) { + contentJson.add("include_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionSearchOptions.includeFields())); + } + if (postPartitionSearchOptions.limit() != null) { + contentJson.addProperty("limit", postPartitionSearchOptions.limit()); } - builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * 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 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postSearchAnalyze"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); + if (postPartitionSearchOptions.sort() != null) { + contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionSearchOptions.sort())); + } + if (postPartitionSearchOptions.stale() != null) { + contentJson.addProperty("stale", postPartitionSearchOptions.stale()); } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("analyzer", postSearchAnalyzeOptions.analyzer()); - contentJson.addProperty("text", postSearchAnalyzeOptions.text()); builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); return createServiceCall(builder.build(), responseConverter); } /** - * Query a search index. + * Query a database partition MapReduce view function. * - * 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. + * Runs the specified view function from the specified design document. Unlike `GET /{db}/_design/{ddoc}/_view/{view}` + * for accessing views, the POST method supports the specification of explicit keys to be retrieved from the view + * results. The remainder of the POST view functionality is identical to the `GET /{db}/_design/{ddoc}/_view/{view}` + * API. * - * @param postSearchOptions the {@link PostSearchOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link SearchResult} + * + * Before using read the + * [FAQs](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-database-partitioning#partition-querying) to understand + * the limitations and appropriate use cases. + * + * @param postPartitionViewOptions the {@link PostPartitionViewOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ViewResult} */ - public ServiceCall postSearch(PostSearchOptions postSearchOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postSearchOptions, - "postSearchOptions cannot be null"); + public ServiceCall postPartitionView(PostPartitionViewOptions postPartitionViewOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionViewOptions, + "postPartitionViewOptions cannot be null"); Map pathParamsMap = new HashMap(); - 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postSearch"); + pathParamsMap.put("db", postPartitionViewOptions.db()); + pathParamsMap.put("partition_key", postPartitionViewOptions.partitionKey()); + pathParamsMap.put("ddoc", postPartitionViewOptions.ddoc()); + pathParamsMap.put("view", postPartitionViewOptions.view()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_design/{ddoc}/_view/{view}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionView"); for (Entry 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 (postPartitionViewOptions.attEncodingInfo() != null) { + contentJson.addProperty("att_encoding_info", postPartitionViewOptions.attEncodingInfo()); } - if (postSearchOptions.highlightFields() != null) { - contentJson.add("highlight_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.highlightFields())); + if (postPartitionViewOptions.attachments() != null) { + contentJson.addProperty("attachments", postPartitionViewOptions.attachments()); } - if (postSearchOptions.highlightNumber() != null) { - contentJson.addProperty("highlight_number", postSearchOptions.highlightNumber()); + if (postPartitionViewOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postPartitionViewOptions.conflicts()); } - if (postSearchOptions.highlightPostTag() != null) { - contentJson.addProperty("highlight_post_tag", postSearchOptions.highlightPostTag()); + if (postPartitionViewOptions.descending() != null) { + contentJson.addProperty("descending", postPartitionViewOptions.descending()); } - if (postSearchOptions.highlightPreTag() != null) { - contentJson.addProperty("highlight_pre_tag", postSearchOptions.highlightPreTag()); + if (postPartitionViewOptions.includeDocs() != null) { + contentJson.addProperty("include_docs", postPartitionViewOptions.includeDocs()); } - if (postSearchOptions.highlightSize() != null) { - contentJson.addProperty("highlight_size", postSearchOptions.highlightSize()); + if (postPartitionViewOptions.inclusiveEnd() != null) { + contentJson.addProperty("inclusive_end", postPartitionViewOptions.inclusiveEnd()); } - if (postSearchOptions.includeDocs() != null) { - contentJson.addProperty("include_docs", postSearchOptions.includeDocs()); + if (postPartitionViewOptions.limit() != null) { + contentJson.addProperty("limit", postPartitionViewOptions.limit()); } - if (postSearchOptions.includeFields() != null) { - contentJson.add("include_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.includeFields())); + if (postPartitionViewOptions.skip() != null) { + contentJson.addProperty("skip", postPartitionViewOptions.skip()); } - if (postSearchOptions.limit() != null) { - contentJson.addProperty("limit", postSearchOptions.limit()); + if (postPartitionViewOptions.updateSeq() != null) { + contentJson.addProperty("update_seq", postPartitionViewOptions.updateSeq()); } - if (postSearchOptions.sort() != null) { - contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.sort())); + if (postPartitionViewOptions.endKey() != null) { + contentJson.add("end_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.endKey())); } - if (postSearchOptions.stale() != null) { - contentJson.addProperty("stale", postSearchOptions.stale()); + if (postPartitionViewOptions.endKeyDocId() != null) { + contentJson.addProperty("end_key_doc_id", postPartitionViewOptions.endKeyDocId()); } - if (postSearchOptions.counts() != null) { - contentJson.add("counts", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.counts())); + if (postPartitionViewOptions.group() != null) { + contentJson.addProperty("group", postPartitionViewOptions.group()); } - if (postSearchOptions.drilldown() != null) { - contentJson.add("drilldown", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.drilldown())); + if (postPartitionViewOptions.groupLevel() != null) { + contentJson.addProperty("group_level", postPartitionViewOptions.groupLevel()); } - if (postSearchOptions.groupField() != null) { - contentJson.addProperty("group_field", postSearchOptions.groupField()); + if (postPartitionViewOptions.key() != null) { + contentJson.add("key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.key())); } - if (postSearchOptions.groupLimit() != null) { - contentJson.addProperty("group_limit", postSearchOptions.groupLimit()); + if (postPartitionViewOptions.keys() != null) { + contentJson.add("keys", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.keys())); } - if (postSearchOptions.groupSort() != null) { - contentJson.add("group_sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.groupSort())); + if (postPartitionViewOptions.reduce() != null) { + contentJson.addProperty("reduce", postPartitionViewOptions.reduce()); } - if (postSearchOptions.ranges() != null) { - contentJson.add("ranges", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.ranges())); + if (postPartitionViewOptions.startKey() != null) { + contentJson.add("start_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.startKey())); + } + if (postPartitionViewOptions.startKeyDocId() != null) { + contentJson.addProperty("start_key_doc_id", postPartitionViewOptions.startKeyDocId()); + } + if (postPartitionViewOptions.update() != null) { + contentJson.addProperty("update", postPartitionViewOptions.update()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Query a search index as stream. + * Query a database partition MapReduce view function as stream. * - * 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. + * Runs the specified view function from the specified design document. Unlike `GET /{db}/_design/{ddoc}/_view/{view}` + * for accessing views, the POST method supports the specification of explicit keys to be retrieved from the view + * results. The remainder of the POST view functionality is identical to the `GET /{db}/_design/{ddoc}/_view/{view}` + * API. * - * @param postSearchOptions the {@link PostSearchOptions} containing the options for the call + * + * Before using read the + * [FAQs](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-database-partitioning#partition-querying) to understand + * the limitations and appropriate use cases. + * + * @param postPartitionViewOptions the {@link PostPartitionViewOptions} containing the options for the call * @return a {@link ServiceCall} with a result of type {@link InputStream} */ - public ServiceCall postSearchAsStream(PostSearchOptions postSearchOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postSearchOptions, - "postSearchOptions cannot be null"); + public ServiceCall postPartitionViewAsStream(PostPartitionViewOptions postPartitionViewOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionViewOptions, + "postPartitionViewOptions cannot be null"); Map pathParamsMap = new HashMap(); - 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postSearchAsStream"); + pathParamsMap.put("db", postPartitionViewOptions.db()); + pathParamsMap.put("partition_key", postPartitionViewOptions.partitionKey()); + pathParamsMap.put("ddoc", postPartitionViewOptions.ddoc()); + pathParamsMap.put("view", postPartitionViewOptions.view()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_design/{ddoc}/_view/{view}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionViewAsStream"); for (Entry 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 (postPartitionViewOptions.attEncodingInfo() != null) { + contentJson.addProperty("att_encoding_info", postPartitionViewOptions.attEncodingInfo()); } - if (postSearchOptions.highlightFields() != null) { - contentJson.add("highlight_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.highlightFields())); + if (postPartitionViewOptions.attachments() != null) { + contentJson.addProperty("attachments", postPartitionViewOptions.attachments()); } - if (postSearchOptions.highlightNumber() != null) { - contentJson.addProperty("highlight_number", postSearchOptions.highlightNumber()); + if (postPartitionViewOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postPartitionViewOptions.conflicts()); } - if (postSearchOptions.highlightPostTag() != null) { - contentJson.addProperty("highlight_post_tag", postSearchOptions.highlightPostTag()); + if (postPartitionViewOptions.descending() != null) { + contentJson.addProperty("descending", postPartitionViewOptions.descending()); } - if (postSearchOptions.highlightPreTag() != null) { - contentJson.addProperty("highlight_pre_tag", postSearchOptions.highlightPreTag()); + if (postPartitionViewOptions.includeDocs() != null) { + contentJson.addProperty("include_docs", postPartitionViewOptions.includeDocs()); } - if (postSearchOptions.highlightSize() != null) { - contentJson.addProperty("highlight_size", postSearchOptions.highlightSize()); + if (postPartitionViewOptions.inclusiveEnd() != null) { + contentJson.addProperty("inclusive_end", postPartitionViewOptions.inclusiveEnd()); } - if (postSearchOptions.includeDocs() != null) { - contentJson.addProperty("include_docs", postSearchOptions.includeDocs()); + if (postPartitionViewOptions.limit() != null) { + contentJson.addProperty("limit", postPartitionViewOptions.limit()); } - if (postSearchOptions.includeFields() != null) { - contentJson.add("include_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.includeFields())); + if (postPartitionViewOptions.skip() != null) { + contentJson.addProperty("skip", postPartitionViewOptions.skip()); } - if (postSearchOptions.limit() != null) { - contentJson.addProperty("limit", postSearchOptions.limit()); + if (postPartitionViewOptions.updateSeq() != null) { + contentJson.addProperty("update_seq", postPartitionViewOptions.updateSeq()); } - if (postSearchOptions.sort() != null) { - contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.sort())); + if (postPartitionViewOptions.endKey() != null) { + contentJson.add("end_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.endKey())); } - if (postSearchOptions.stale() != null) { - contentJson.addProperty("stale", postSearchOptions.stale()); + if (postPartitionViewOptions.endKeyDocId() != null) { + contentJson.addProperty("end_key_doc_id", postPartitionViewOptions.endKeyDocId()); } - if (postSearchOptions.counts() != null) { - contentJson.add("counts", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.counts())); + if (postPartitionViewOptions.group() != null) { + contentJson.addProperty("group", postPartitionViewOptions.group()); } - if (postSearchOptions.drilldown() != null) { - contentJson.add("drilldown", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.drilldown())); + if (postPartitionViewOptions.groupLevel() != null) { + contentJson.addProperty("group_level", postPartitionViewOptions.groupLevel()); } - if (postSearchOptions.groupField() != null) { - contentJson.addProperty("group_field", postSearchOptions.groupField()); + if (postPartitionViewOptions.key() != null) { + contentJson.add("key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.key())); } - if (postSearchOptions.groupLimit() != null) { - contentJson.addProperty("group_limit", postSearchOptions.groupLimit()); + if (postPartitionViewOptions.keys() != null) { + contentJson.add("keys", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.keys())); } - if (postSearchOptions.groupSort() != null) { - contentJson.add("group_sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.groupSort())); + if (postPartitionViewOptions.reduce() != null) { + contentJson.addProperty("reduce", postPartitionViewOptions.reduce()); + } + if (postPartitionViewOptions.startKey() != null) { + contentJson.add("start_key", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionViewOptions.startKey())); + } + if (postPartitionViewOptions.startKeyDocId() != null) { + contentJson.addProperty("start_key_doc_id", postPartitionViewOptions.startKeyDocId()); } - if (postSearchOptions.ranges() != null) { - contentJson.add("ranges", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.ranges())); + if (postPartitionViewOptions.update() != null) { + contentJson.addProperty("update", postPartitionViewOptions.update()); } builder.bodyJson(contentJson); ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); @@ -3271,740 +2933,886 @@ public ServiceCall postSearchAsStream(PostSearchOptions postSearchO } /** - * Retrieve information about the search index disk size. + * Retrieve information about which partition index is used for a query. * - * Retrieve size of the search index on disk. + * Shows which index is being used by the query. Parameters are the same as the + * [`/{db}/_partition/{partition_key}/_find` endpoint](#postpartitionfind-queries). * - * @param getSearchDiskSizeOptions the {@link GetSearchDiskSizeOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link SearchDiskSizeInformation} + * @param postPartitionExplainOptions the {@link PostPartitionExplainOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ExplainResult} */ - public ServiceCall getSearchDiskSize(GetSearchDiskSizeOptions getSearchDiskSizeOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getSearchDiskSizeOptions, - "getSearchDiskSizeOptions cannot be null"); + public ServiceCall postPartitionExplain(PostPartitionExplainOptions postPartitionExplainOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionExplainOptions, + "postPartitionExplainOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", getSearchDiskSizeOptions.db()); - pathParamsMap.put("ddoc", getSearchDiskSizeOptions.ddoc()); - pathParamsMap.put("index", getSearchDiskSizeOptions.index()); - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_design/{ddoc}/_search_disk_size/{index}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSearchDiskSize"); + pathParamsMap.put("db", postPartitionExplainOptions.db()); + pathParamsMap.put("partition_key", postPartitionExplainOptions.partitionKey()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_explain", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionExplain"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + final JsonObject contentJson = new JsonObject(); + contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionExplainOptions.selector())); + if (postPartitionExplainOptions.allowFallback() != null) { + contentJson.addProperty("allow_fallback", postPartitionExplainOptions.allowFallback()); + } + if (postPartitionExplainOptions.bookmark() != null) { + contentJson.addProperty("bookmark", postPartitionExplainOptions.bookmark()); + } + if (postPartitionExplainOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postPartitionExplainOptions.conflicts()); + } + if (postPartitionExplainOptions.executionStats() != null) { + contentJson.addProperty("execution_stats", postPartitionExplainOptions.executionStats()); + } + if (postPartitionExplainOptions.fields() != null) { + contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionExplainOptions.fields())); + } + if (postPartitionExplainOptions.limit() != null) { + contentJson.addProperty("limit", postPartitionExplainOptions.limit()); + } + if (postPartitionExplainOptions.skip() != null) { + contentJson.addProperty("skip", postPartitionExplainOptions.skip()); + } + if (postPartitionExplainOptions.sort() != null) { + contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionExplainOptions.sort())); + } + if (postPartitionExplainOptions.stable() != null) { + contentJson.addProperty("stable", postPartitionExplainOptions.stable()); + } + if (postPartitionExplainOptions.update() != null) { + contentJson.addProperty("update", postPartitionExplainOptions.update()); + } + if (postPartitionExplainOptions.useIndex() != null) { + contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionExplainOptions.useIndex())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve information about a search index. + * Query a database partition index by using selector syntax. * - * Retrieve search index metadata information, such as the size of the index on disk. + * Query documents by using a declarative JSON querying syntax. It's best practice to create an appropriate index for + * all fields in selector by using the `_index` endpoint. * - * @param getSearchInfoOptions the {@link GetSearchInfoOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link SearchInfoResult} - */ - public ServiceCall getSearchInfo(GetSearchInfoOptions getSearchInfoOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getSearchInfoOptions, - "getSearchInfoOptions cannot be null"); - Map pathParamsMap = new HashMap(); - 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSearchInfo"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Retrieve the HTTP headers for a persistent replication. + * Queries without an appropriate backing index by default fallback to using the built-in `_all_docs` index. This + * isn't recommended because it has a significant performance impact causing a full scan of the partition with each + * request. In this case the response body includes a warning field recommending the creation of an index. * - * Retrieves the HTTP headers containing minimal amount of information about the specified replication document from - * the `_replicator` database. The method supports the same query arguments as the `GET /_replicator/{doc_id}` - * method, but only headers like content length and the revision (ETag header) are returned. + * To avoid the fallback behavior set the `allow_fallback` option to `false` and the server responds with a `400` + * status code if no suitable index exists. If you want to use only a specific index for your query set + * `allow_fallback` to `false` and set the `use_index` option. * - * @param headReplicationDocumentOptions the {@link HeadReplicationDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a void result + * Before using read the + * [FAQs](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-database-partitioning#partition-querying) to understand + * the limitations and appropriate use cases. + * + * @param postPartitionFindOptions the {@link PostPartitionFindOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link FindResult} */ - public ServiceCall headReplicationDocument(HeadReplicationDocumentOptions headReplicationDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(headReplicationDocumentOptions, - "headReplicationDocumentOptions cannot be null"); + public ServiceCall postPartitionFind(PostPartitionFindOptions postPartitionFindOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionFindOptions, + "postPartitionFindOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("doc_id", headReplicationDocumentOptions.docId()); - RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headReplicationDocument"); + pathParamsMap.put("db", postPartitionFindOptions.db()); + pathParamsMap.put("partition_key", postPartitionFindOptions.partitionKey()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_find", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionFind"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - if (headReplicationDocumentOptions.ifNoneMatch() != null) { - builder.header("If-None-Match", headReplicationDocumentOptions.ifNoneMatch()); + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.selector())); + if (postPartitionFindOptions.allowFallback() != null) { + contentJson.addProperty("allow_fallback", postPartitionFindOptions.allowFallback()); } - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + if (postPartitionFindOptions.bookmark() != null) { + contentJson.addProperty("bookmark", postPartitionFindOptions.bookmark()); + } + if (postPartitionFindOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postPartitionFindOptions.conflicts()); + } + if (postPartitionFindOptions.executionStats() != null) { + contentJson.addProperty("execution_stats", postPartitionFindOptions.executionStats()); + } + if (postPartitionFindOptions.fields() != null) { + contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.fields())); + } + if (postPartitionFindOptions.limit() != null) { + contentJson.addProperty("limit", postPartitionFindOptions.limit()); + } + if (postPartitionFindOptions.skip() != null) { + contentJson.addProperty("skip", postPartitionFindOptions.skip()); + } + if (postPartitionFindOptions.sort() != null) { + contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.sort())); + } + if (postPartitionFindOptions.stable() != null) { + contentJson.addProperty("stable", postPartitionFindOptions.stable()); + } + if (postPartitionFindOptions.update() != null) { + contentJson.addProperty("update", postPartitionFindOptions.update()); + } + if (postPartitionFindOptions.useIndex() != null) { + contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.useIndex())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve HTTP headers for a replication scheduler document. + * Query a database partition index by using selector syntax as stream. * - * Retrieves the HTTP headers containing minimal amount of information about the specified replication scheduler - * document. Since the response body is empty, using the HEAD method is a lightweight way to check if the replication - * scheduler document exists or not. + * Query documents by using a declarative JSON querying syntax. It's best practice to create an appropriate index for + * all fields in selector by using the `_index` endpoint. * - * @param headSchedulerDocumentOptions the {@link HeadSchedulerDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a void result - */ - public ServiceCall headSchedulerDocument(HeadSchedulerDocumentOptions headSchedulerDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(headSchedulerDocumentOptions, - "headSchedulerDocumentOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("doc_id", headSchedulerDocumentOptions.docId()); - RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/docs/_replicator/{doc_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headSchedulerDocument"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); - } - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Retrieve the HTTP headers for a replication scheduler job. + * Queries without an appropriate backing index by default fallback to using the built-in `_all_docs` index. This + * isn't recommended because it has a significant performance impact causing a full scan of the partition with each + * request. In this case the response body includes a warning field recommending the creation of an index. * - * Returns the HTTP headers that contain a minimal amount of information about the specified replication task. Only - * the header information is returned. + * To avoid the fallback behavior set the `allow_fallback` option to `false` and the server responds with a `400` + * status code if no suitable index exists. If you want to use only a specific index for your query set + * `allow_fallback` to `false` and set the `use_index` option. * - * @param headSchedulerJobOptions the {@link HeadSchedulerJobOptions} containing the options for the call - * @return a {@link ServiceCall} with a void result + * Before using read the + * [FAQs](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-database-partitioning#partition-querying) to understand + * the limitations and appropriate use cases. + * + * @param postPartitionFindOptions the {@link PostPartitionFindOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ - public ServiceCall headSchedulerJob(HeadSchedulerJobOptions headSchedulerJobOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(headSchedulerJobOptions, - "headSchedulerJobOptions cannot be null"); + public ServiceCall postPartitionFindAsStream(PostPartitionFindOptions postPartitionFindOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postPartitionFindOptions, + "postPartitionFindOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("job_id", headSchedulerJobOptions.jobId()); - RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/jobs/{job_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headSchedulerJob"); + pathParamsMap.put("db", postPartitionFindOptions.db()); + pathParamsMap.put("partition_key", postPartitionFindOptions.partitionKey()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_partition/{partition_key}/_find", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postPartitionFindAsStream"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Create a persistent replication with a generated ID. - * - * Creates or modifies a document in the `_replicator` database to start a new replication or to edit an existing - * replication. - * - * @param postReplicatorOptions the {@link PostReplicatorOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link DocumentResult} - */ - public ServiceCall postReplicator(PostReplicatorOptions postReplicatorOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postReplicatorOptions, - "postReplicatorOptions cannot be null"); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postReplicator"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.selector())); + if (postPartitionFindOptions.allowFallback() != null) { + contentJson.addProperty("allow_fallback", postPartitionFindOptions.allowFallback()); + } + if (postPartitionFindOptions.bookmark() != null) { + contentJson.addProperty("bookmark", postPartitionFindOptions.bookmark()); + } + if (postPartitionFindOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postPartitionFindOptions.conflicts()); + } + if (postPartitionFindOptions.executionStats() != null) { + contentJson.addProperty("execution_stats", postPartitionFindOptions.executionStats()); } - builder.header("Accept", "application/json"); - if (postReplicatorOptions.batch() != null) { - builder.query("batch", String.valueOf(postReplicatorOptions.batch())); + if (postPartitionFindOptions.fields() != null) { + contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.fields())); } - builder.bodyContent(com.ibm.cloud.sdk.core.util.GsonSingleton.getGsonWithoutPrettyPrinting().toJson(postReplicatorOptions.replicationDocument()), "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + if (postPartitionFindOptions.limit() != null) { + contentJson.addProperty("limit", postPartitionFindOptions.limit()); + } + if (postPartitionFindOptions.skip() != null) { + contentJson.addProperty("skip", postPartitionFindOptions.skip()); + } + if (postPartitionFindOptions.sort() != null) { + contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.sort())); + } + if (postPartitionFindOptions.stable() != null) { + contentJson.addProperty("stable", postPartitionFindOptions.stable()); + } + if (postPartitionFindOptions.update() != null) { + contentJson.addProperty("update", postPartitionFindOptions.update()); + } + if (postPartitionFindOptions.useIndex() != null) { + contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postPartitionFindOptions.useIndex())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); return createServiceCall(builder.build(), responseConverter); } /** - * Cancel a persistent replication. + * Retrieve information about which index is used for a query. * - * Cancels a replication by deleting the document that describes it from the `_replicator` database. + * Shows which index is being used by the query. Parameters are the same as the [`_find` endpoint](#postfind). * - * @param deleteReplicationDocumentOptions the {@link DeleteReplicationDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link DocumentResult} + * @param postExplainOptions the {@link PostExplainOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ExplainResult} */ - public ServiceCall deleteReplicationDocument(DeleteReplicationDocumentOptions deleteReplicationDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteReplicationDocumentOptions, - "deleteReplicationDocumentOptions cannot be null"); + public ServiceCall postExplain(PostExplainOptions postExplainOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postExplainOptions, + "postExplainOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("doc_id", deleteReplicationDocumentOptions.docId()); - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteReplicationDocument"); + pathParamsMap.put("db", postExplainOptions.db()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_explain", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postExplain"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (deleteReplicationDocumentOptions.ifMatch() != null) { - builder.header("If-Match", deleteReplicationDocumentOptions.ifMatch()); + final JsonObject contentJson = new JsonObject(); + contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postExplainOptions.selector())); + if (postExplainOptions.allowFallback() != null) { + contentJson.addProperty("allow_fallback", postExplainOptions.allowFallback()); } - if (deleteReplicationDocumentOptions.batch() != null) { - builder.query("batch", String.valueOf(deleteReplicationDocumentOptions.batch())); + if (postExplainOptions.bookmark() != null) { + contentJson.addProperty("bookmark", postExplainOptions.bookmark()); } - if (deleteReplicationDocumentOptions.rev() != null) { - builder.query("rev", String.valueOf(deleteReplicationDocumentOptions.rev())); + if (postExplainOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postExplainOptions.conflicts()); } - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + if (postExplainOptions.executionStats() != null) { + contentJson.addProperty("execution_stats", postExplainOptions.executionStats()); + } + if (postExplainOptions.fields() != null) { + contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postExplainOptions.fields())); + } + if (postExplainOptions.limit() != null) { + contentJson.addProperty("limit", postExplainOptions.limit()); + } + if (postExplainOptions.skip() != null) { + contentJson.addProperty("skip", postExplainOptions.skip()); + } + if (postExplainOptions.sort() != null) { + contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postExplainOptions.sort())); + } + if (postExplainOptions.stable() != null) { + contentJson.addProperty("stable", postExplainOptions.stable()); + } + if (postExplainOptions.update() != null) { + contentJson.addProperty("update", postExplainOptions.update()); + } + if (postExplainOptions.useIndex() != null) { + contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postExplainOptions.useIndex())); + } + if (postExplainOptions.r() != null) { + contentJson.addProperty("r", postExplainOptions.r()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve the configuration for a persistent replication. + * Query an index by using selector syntax. * - * 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. + * Query documents by using a declarative JSON querying syntax. It's best practice to create an appropriate index for + * all fields in selector by using the `_index` endpoint. * - * @param getReplicationDocumentOptions the {@link GetReplicationDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link ReplicationDocument} + * Queries without an appropriate backing index by default fallback to using the built-in `_all_docs` index. This + * isn't recommended because it has a significant performance impact causing a full scan of the database with each + * request. In this case the response body includes a warning field recommending the creation of an index. + * + * To avoid the fallback behavior set the `allow_fallback` option to `false` and the server responds with a `400` + * status code if no suitable index exists. If you want to use only a specific index for your query set + * `allow_fallback` to `false` and set the `use_index` option. + * + * @param postFindOptions the {@link PostFindOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link FindResult} */ - public ServiceCall getReplicationDocument(GetReplicationDocumentOptions getReplicationDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getReplicationDocumentOptions, - "getReplicationDocumentOptions cannot be null"); + public ServiceCall postFind(PostFindOptions postFindOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postFindOptions, + "postFindOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("doc_id", getReplicationDocumentOptions.docId()); - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getReplicationDocument"); + pathParamsMap.put("db", postFindOptions.db()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_find", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postFind"); for (Entry 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()); + final JsonObject contentJson = new JsonObject(); + contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.selector())); + if (postFindOptions.allowFallback() != null) { + contentJson.addProperty("allow_fallback", postFindOptions.allowFallback()); } - if (getReplicationDocumentOptions.attachments() != null) { - builder.query("attachments", String.valueOf(getReplicationDocumentOptions.attachments())); + if (postFindOptions.bookmark() != null) { + contentJson.addProperty("bookmark", postFindOptions.bookmark()); } - if (getReplicationDocumentOptions.attEncodingInfo() != null) { - builder.query("att_encoding_info", String.valueOf(getReplicationDocumentOptions.attEncodingInfo())); + if (postFindOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postFindOptions.conflicts()); } - if (getReplicationDocumentOptions.conflicts() != null) { - builder.query("conflicts", String.valueOf(getReplicationDocumentOptions.conflicts())); + if (postFindOptions.executionStats() != null) { + contentJson.addProperty("execution_stats", postFindOptions.executionStats()); } - if (getReplicationDocumentOptions.deletedConflicts() != null) { - builder.query("deleted_conflicts", String.valueOf(getReplicationDocumentOptions.deletedConflicts())); + if (postFindOptions.fields() != null) { + contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.fields())); } - if (getReplicationDocumentOptions.latest() != null) { - builder.query("latest", String.valueOf(getReplicationDocumentOptions.latest())); + if (postFindOptions.limit() != null) { + contentJson.addProperty("limit", postFindOptions.limit()); } - if (getReplicationDocumentOptions.localSeq() != null) { - builder.query("local_seq", String.valueOf(getReplicationDocumentOptions.localSeq())); + if (postFindOptions.skip() != null) { + contentJson.addProperty("skip", postFindOptions.skip()); } - if (getReplicationDocumentOptions.meta() != null) { - builder.query("meta", String.valueOf(getReplicationDocumentOptions.meta())); + if (postFindOptions.sort() != null) { + contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.sort())); } - if (getReplicationDocumentOptions.rev() != null) { - builder.query("rev", String.valueOf(getReplicationDocumentOptions.rev())); + if (postFindOptions.stable() != null) { + contentJson.addProperty("stable", postFindOptions.stable()); } - if (getReplicationDocumentOptions.revs() != null) { - builder.query("revs", String.valueOf(getReplicationDocumentOptions.revs())); + if (postFindOptions.update() != null) { + contentJson.addProperty("update", postFindOptions.update()); } - if (getReplicationDocumentOptions.revsInfo() != null) { - builder.query("revs_info", String.valueOf(getReplicationDocumentOptions.revsInfo())); + if (postFindOptions.useIndex() != null) { + contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.useIndex())); } - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + if (postFindOptions.r() != null) { + contentJson.addProperty("r", postFindOptions.r()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Create or modify a persistent replication. + * Query an index by using selector syntax as stream. * - * Creates or modifies a document in the `_replicator` database to start a new replication or to edit an existing - * replication. + * Query documents by using a declarative JSON querying syntax. It's best practice to create an appropriate index for + * all fields in selector by using the `_index` endpoint. * - * @param putReplicationDocumentOptions the {@link PutReplicationDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link DocumentResult} + * Queries without an appropriate backing index by default fallback to using the built-in `_all_docs` index. This + * isn't recommended because it has a significant performance impact causing a full scan of the database with each + * request. In this case the response body includes a warning field recommending the creation of an index. + * + * To avoid the fallback behavior set the `allow_fallback` option to `false` and the server responds with a `400` + * status code if no suitable index exists. If you want to use only a specific index for your query set + * `allow_fallback` to `false` and set the `use_index` option. + * + * @param postFindOptions the {@link PostFindOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ - public ServiceCall putReplicationDocument(PutReplicationDocumentOptions putReplicationDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(putReplicationDocumentOptions, - "putReplicationDocumentOptions cannot be null"); + public ServiceCall postFindAsStream(PostFindOptions postFindOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postFindOptions, + "postFindOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("doc_id", putReplicationDocumentOptions.docId()); - RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putReplicationDocument"); + pathParamsMap.put("db", postFindOptions.db()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_find", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postFindAsStream"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (putReplicationDocumentOptions.ifMatch() != null) { - builder.header("If-Match", putReplicationDocumentOptions.ifMatch()); + final JsonObject contentJson = new JsonObject(); + contentJson.add("selector", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.selector())); + if (postFindOptions.allowFallback() != null) { + contentJson.addProperty("allow_fallback", postFindOptions.allowFallback()); } - if (putReplicationDocumentOptions.batch() != null) { - builder.query("batch", String.valueOf(putReplicationDocumentOptions.batch())); + if (postFindOptions.bookmark() != null) { + contentJson.addProperty("bookmark", postFindOptions.bookmark()); } - if (putReplicationDocumentOptions.newEdits() != null) { - builder.query("new_edits", String.valueOf(putReplicationDocumentOptions.newEdits())); + if (postFindOptions.conflicts() != null) { + contentJson.addProperty("conflicts", postFindOptions.conflicts()); } - if (putReplicationDocumentOptions.rev() != null) { - builder.query("rev", String.valueOf(putReplicationDocumentOptions.rev())); + if (postFindOptions.executionStats() != null) { + contentJson.addProperty("execution_stats", postFindOptions.executionStats()); } - builder.bodyContent(com.ibm.cloud.sdk.core.util.GsonSingleton.getGsonWithoutPrettyPrinting().toJson(putReplicationDocumentOptions.replicationDocument()), "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); - return createServiceCall(builder.build(), responseConverter); - } - - /** - * Retrieve replication scheduler documents. - * - * Lists replication documents, including information about all documents, even the ones in a completed or failed - * state. For each document, the endpoint returns the document ID, database, replication ID, source and target, and - * other information. - * - * @param getSchedulerDocsOptions the {@link GetSchedulerDocsOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link SchedulerDocsResult} - */ - public ServiceCall getSchedulerDocs(GetSchedulerDocsOptions getSchedulerDocsOptions) { - if (getSchedulerDocsOptions == null) { - getSchedulerDocsOptions = new GetSchedulerDocsOptions.Builder().build(); + if (postFindOptions.fields() != null) { + contentJson.add("fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.fields())); + } + if (postFindOptions.limit() != null) { + contentJson.addProperty("limit", postFindOptions.limit()); + } + if (postFindOptions.skip() != null) { + contentJson.addProperty("skip", postFindOptions.skip()); + } + if (postFindOptions.sort() != null) { + contentJson.add("sort", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.sort())); } - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/docs")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerDocs"); - for (Entry header : sdkHeaders.entrySet()) { - builder.header(header.getKey(), header.getValue()); + if (postFindOptions.stable() != null) { + contentJson.addProperty("stable", postFindOptions.stable()); } - builder.header("Accept", "application/json"); - if (getSchedulerDocsOptions.limit() != null) { - builder.query("limit", String.valueOf(getSchedulerDocsOptions.limit())); + if (postFindOptions.update() != null) { + contentJson.addProperty("update", postFindOptions.update()); } - if (getSchedulerDocsOptions.skip() != null) { - builder.query("skip", String.valueOf(getSchedulerDocsOptions.skip())); + if (postFindOptions.useIndex() != null) { + contentJson.add("use_index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postFindOptions.useIndex())); } - if (getSchedulerDocsOptions.states() != null) { - builder.query("states", RequestUtils.join(getSchedulerDocsOptions.states(), ",")); + if (postFindOptions.r() != null) { + contentJson.addProperty("r", postFindOptions.r()); } - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve replication scheduler documents. - * - * Lists replication documents, including information about all documents, even the ones in a completed or failed - * state. For each document, the endpoint returns the document ID, database, replication ID, source and target, and - * other information. - * - * @return a {@link ServiceCall} with a result of type {@link SchedulerDocsResult} - */ - public ServiceCall getSchedulerDocs() { - return getSchedulerDocs(null); - } - - /** - * Retrieve a replication scheduler document. + * Retrieve information about all indexes. * - * 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. + * When you make a GET request to `/db/_index`, you get a list of all the indexes using `"language":"query"` in the + * database and the primary index. In addition to the information available through this API, the indexes are stored + * in the `indexes` property of their respective design documents. * - * @param getSchedulerDocumentOptions the {@link GetSchedulerDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link SchedulerDocument} + * @param getIndexesInformationOptions the {@link GetIndexesInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link IndexesInformation} */ - public ServiceCall getSchedulerDocument(GetSchedulerDocumentOptions getSchedulerDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getSchedulerDocumentOptions, - "getSchedulerDocumentOptions cannot be null"); + public ServiceCall getIndexesInformation(GetIndexesInformationOptions getIndexesInformationOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getIndexesInformationOptions, + "getIndexesInformationOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("doc_id", getSchedulerDocumentOptions.docId()); - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/docs/_replicator/{doc_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerDocument"); + pathParamsMap.put("db", getIndexesInformationOptions.db()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_index", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getIndexesInformation"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve replication scheduler jobs. + * Create a new index on a database. * - * Retrieves information about replications that were created via `/_replicate` endpoint, as well as those created - * from replication documents. It doesn't include replications that completed or failed to start because replication - * documents were malformed. Each job description includes source and target information, replication ID, history of - * recent events, and other information. + * Create a new index on a database. * - * @param getSchedulerJobsOptions the {@link GetSchedulerJobsOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link SchedulerJobsResult} + * @param postIndexOptions the {@link PostIndexOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link IndexResult} */ - public ServiceCall getSchedulerJobs(GetSchedulerJobsOptions getSchedulerJobsOptions) { - if (getSchedulerJobsOptions == null) { - getSchedulerJobsOptions = new GetSchedulerJobsOptions.Builder().build(); - } - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/jobs")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerJobs"); + public ServiceCall postIndex(PostIndexOptions postIndexOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postIndexOptions, + "postIndexOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", postIndexOptions.db()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_index", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postIndex"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (getSchedulerJobsOptions.limit() != null) { - builder.query("limit", String.valueOf(getSchedulerJobsOptions.limit())); + final JsonObject contentJson = new JsonObject(); + contentJson.add("index", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postIndexOptions.index())); + if (postIndexOptions.ddoc() != null) { + contentJson.addProperty("ddoc", postIndexOptions.ddoc()); } - if (getSchedulerJobsOptions.skip() != null) { - builder.query("skip", String.valueOf(getSchedulerJobsOptions.skip())); + if (postIndexOptions.name() != null) { + contentJson.addProperty("name", postIndexOptions.name()); } - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + if (postIndexOptions.partitioned() != null) { + contentJson.addProperty("partitioned", postIndexOptions.partitioned()); + } + if (postIndexOptions.type() != null) { + contentJson.addProperty("type", postIndexOptions.type()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve replication scheduler jobs. - * - * Retrieves information about replications that were created via `/_replicate` endpoint, as well as those created - * from replication documents. It doesn't include replications that completed or failed to start because replication - * documents were malformed. Each job description includes source and target information, replication ID, history of - * recent events, and other information. - * - * @return a {@link ServiceCall} with a result of type {@link SchedulerJobsResult} - */ - public ServiceCall getSchedulerJobs() { - return getSchedulerJobs(null); - } - - /** - * Retrieve a replication scheduler job. + * Delete an index. * - * Retrieves the state of a single replication task based on its replication ID. + * Delete the index functions from the design document and index files on the server. * - * @param getSchedulerJobOptions the {@link GetSchedulerJobOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link SchedulerJob} + * @param deleteIndexOptions the {@link DeleteIndexOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link Ok} */ - public ServiceCall getSchedulerJob(GetSchedulerJobOptions getSchedulerJobOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getSchedulerJobOptions, - "getSchedulerJobOptions cannot be null"); + public ServiceCall deleteIndex(DeleteIndexOptions deleteIndexOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteIndexOptions, + "deleteIndexOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("job_id", getSchedulerJobOptions.jobId()); - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/jobs/{job_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerJob"); + pathParamsMap.put("db", deleteIndexOptions.db()); + pathParamsMap.put("ddoc", deleteIndexOptions.ddoc()); + pathParamsMap.put("type", deleteIndexOptions.type()); + pathParamsMap.put("index", deleteIndexOptions.index()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_index/_design/{ddoc}/{type}/{index}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteIndex"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve current session cookie information. + * Query tokenization of sample text. * - * Retrieves information about the authenticated user's session. + * Returns the results of analyzer tokenization of the provided sample text. This endpoint can be used for testing + * analyzer tokenization. * - * @param getSessionInformationOptions the {@link GetSessionInformationOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link SessionInformation} + * @param postSearchAnalyzeOptions the {@link PostSearchAnalyzeOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link SearchAnalyzeResult} */ - public ServiceCall getSessionInformation(GetSessionInformationOptions getSessionInformationOptions) { - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_session")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSessionInformation"); + public ServiceCall 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postSearchAnalyze"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("analyzer", postSearchAnalyzeOptions.analyzer()); + contentJson.addProperty("text", postSearchAnalyzeOptions.text()); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve current session cookie information. - * - * Retrieves information about the authenticated user's session. - * - * @return a {@link ServiceCall} with a result of type {@link SessionInformation} - */ - public ServiceCall getSessionInformation() { - return getSessionInformation(null); - } - - /** - * Generates API keys for apps or persons to enable database access. + * Query a search index. * - * Generates API keys to enable database access for a person or application, but without creating a new IBM Cloudant - * account for that person or application. An API key is a randomly generated username and password. The key is given - * the wanted access permissions for a database. + * 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 postApiKeysOptions the {@link PostApiKeysOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link ApiKeysResult} + * @param postSearchOptions the {@link PostSearchOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link SearchResult} */ - public ServiceCall postApiKeys(PostApiKeysOptions postApiKeysOptions) { - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/api_keys")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postApiKeys"); + public ServiceCall postSearch(PostSearchOptions postSearchOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postSearchOptions, + "postSearchOptions cannot be null"); + Map pathParamsMap = new HashMap(); + 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postSearch"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + 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 responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Generates API keys for apps or persons to enable database access. - * - * Generates API keys to enable database access for a person or application, but without creating a new IBM Cloudant - * account for that person or application. An API key is a randomly generated username and password. The key is given - * the wanted access permissions for a database. - * - * @return a {@link ServiceCall} with a result of type {@link ApiKeysResult} - */ - public ServiceCall postApiKeys() { - return postApiKeys(null); - } - - /** - * Modify only Cloudant related database permissions. - * - * Modify only Cloudant related permissions to database. Be careful: by removing an API key from the list, you remove - * the API key from the list of users that have access to the database. - * - * ### Note about nobody role + * Query a search index as stream. * - * The `nobody` username applies to all unauthenticated connection attempts. For example, if an application tries to - * read data from a database, but did not identify itself, the task can continue only if the `nobody` user has the - * role `_reader`. + * 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 putCloudantSecurityConfigurationOptions the {@link PutCloudantSecurityConfigurationOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link Ok} + * @param postSearchOptions the {@link PostSearchOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ - public ServiceCall putCloudantSecurityConfiguration(PutCloudantSecurityConfigurationOptions putCloudantSecurityConfigurationOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(putCloudantSecurityConfigurationOptions, - "putCloudantSecurityConfigurationOptions cannot be null"); + public ServiceCall postSearchAsStream(PostSearchOptions postSearchOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postSearchOptions, + "postSearchOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", putCloudantSecurityConfigurationOptions.db()); - RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/db/{db}/_security", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putCloudantSecurityConfiguration"); + 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postSearchAsStream"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - contentJson.add("cloudant", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putCloudantSecurityConfigurationOptions.cloudant())); - if (putCloudantSecurityConfigurationOptions.admins() != null) { - contentJson.add("admins", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putCloudantSecurityConfigurationOptions.admins())); + contentJson.addProperty("query", postSearchOptions.query()); + if (postSearchOptions.bookmark() != null) { + contentJson.addProperty("bookmark", postSearchOptions.bookmark()); } - if (putCloudantSecurityConfigurationOptions.couchdbAuthOnly() != null) { - contentJson.addProperty("couchdb_auth_only", putCloudantSecurityConfigurationOptions.couchdbAuthOnly()); + if (postSearchOptions.highlightFields() != null) { + contentJson.add("highlight_fields", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postSearchOptions.highlightFields())); } - if (putCloudantSecurityConfigurationOptions.members() != null) { - contentJson.add("members", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putCloudantSecurityConfigurationOptions.members())); + 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 responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve database permissions information. + * Retrieve information about the search index disk size. * - * 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. + * Retrieve size of the search index on disk. * - * @param getSecurityOptions the {@link GetSecurityOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link Security} + * @param getSearchDiskSizeOptions the {@link GetSearchDiskSizeOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link SearchDiskSizeInformation} */ - public ServiceCall getSecurity(GetSecurityOptions getSecurityOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getSecurityOptions, - "getSecurityOptions cannot be null"); + public ServiceCall getSearchDiskSize(GetSearchDiskSizeOptions getSearchDiskSizeOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getSearchDiskSizeOptions, + "getSearchDiskSizeOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", getSecurityOptions.db()); - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_security", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSecurity"); + pathParamsMap.put("db", getSearchDiskSizeOptions.db()); + pathParamsMap.put("ddoc", getSearchDiskSizeOptions.ddoc()); + pathParamsMap.put("index", getSearchDiskSizeOptions.index()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_design/{ddoc}/_search_disk_size/{index}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSearchDiskSize"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Modify database permissions. - * - * Modify who has permission to read, write, or manage a database. This endpoint can be used to modify both Cloudant - * and CouchDB related permissions. Be careful: by removing a Cloudant API key, a member or an admin from the list of - * users that have access permissions, you remove it from the list of users that have access to the database. - * - * ### Note about nobody role + * Retrieve information about a search index. * - * The `nobody` username applies to all unauthenticated connection attempts. For example, if an application tries to - * read data from a database, but did not identify itself, the task can continue only if the `nobody` user has the - * role `_reader`. + * Retrieve search index metadata information, such as the size of the index on disk. * - * @param putSecurityOptions the {@link PutSecurityOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link Ok} + * @param getSearchInfoOptions the {@link GetSearchInfoOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link SearchInfoResult} */ - public ServiceCall putSecurity(PutSecurityOptions putSecurityOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(putSecurityOptions, - "putSecurityOptions cannot be null"); + public ServiceCall getSearchInfo(GetSearchInfoOptions getSearchInfoOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getSearchInfoOptions, + "getSearchInfoOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", putSecurityOptions.db()); - RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_security", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putSecurity"); + 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSearchInfo"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - if (putSecurityOptions.admins() != null) { - contentJson.add("admins", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putSecurityOptions.admins())); - } - if (putSecurityOptions.cloudant() != null) { - contentJson.add("cloudant", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putSecurityOptions.cloudant())); - } - if (putSecurityOptions.couchdbAuthOnly() != null) { - contentJson.addProperty("couchdb_auth_only", putSecurityOptions.couchdbAuthOnly()); - } - if (putSecurityOptions.members() != null) { - contentJson.add("members", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putSecurityOptions.members())); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve CORS configuration information. + * Retrieve the HTTP headers for a persistent replication. * - * Lists all Cross-origin resource sharing (CORS) configuration. CORS defines a way in which the browser and the - * server interact to determine whether or not to allow the request. + * Retrieves the HTTP headers containing minimal amount of information about the specified replication document from + * the `_replicator` database. The method supports the same query arguments as the `GET /_replicator/{doc_id}` + * method, but only headers like content length and the revision (ETag header) are returned. * - * @param getCorsInformationOptions the {@link GetCorsInformationOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link CorsInformation} + * @param headReplicationDocumentOptions the {@link HeadReplicationDocumentOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall getCorsInformation(GetCorsInformationOptions getCorsInformationOptions) { - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/config/cors")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCorsInformation"); + public ServiceCall headReplicationDocument(HeadReplicationDocumentOptions headReplicationDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(headReplicationDocumentOptions, + "headReplicationDocumentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("doc_id", headReplicationDocumentOptions.docId()); + RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headReplicationDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + if (headReplicationDocumentOptions.ifNoneMatch() != null) { + builder.header("If-None-Match", headReplicationDocumentOptions.ifNoneMatch()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve CORS configuration information. + * Retrieve HTTP headers for a replication scheduler document. * - * Lists all Cross-origin resource sharing (CORS) configuration. CORS defines a way in which the browser and the - * server interact to determine whether or not to allow the request. + * Retrieves the HTTP headers containing minimal amount of information about the specified replication scheduler + * document. Since the response body is empty, using the HEAD method is a lightweight way to check if the replication + * scheduler document exists or not. * - * @return a {@link ServiceCall} with a result of type {@link CorsInformation} + * @param headSchedulerDocumentOptions the {@link HeadSchedulerDocumentOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall getCorsInformation() { - return getCorsInformation(null); + public ServiceCall headSchedulerDocument(HeadSchedulerDocumentOptions headSchedulerDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(headSchedulerDocumentOptions, + "headSchedulerDocumentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("doc_id", headSchedulerDocumentOptions.docId()); + RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/docs/_replicator/{doc_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headSchedulerDocument"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); } /** - * Modify CORS configuration. + * Retrieve the HTTP headers for a replication scheduler job. * - * Sets the CORS configuration. The configuration applies to all databases and all account level endpoints in your - * account. + * Returns the HTTP headers that contain a minimal amount of information about the specified replication task. Only + * the header information is returned. * - * @param putCorsConfigurationOptions the {@link PutCorsConfigurationOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link Ok} + * @param headSchedulerJobOptions the {@link HeadSchedulerJobOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall putCorsConfiguration(PutCorsConfigurationOptions putCorsConfigurationOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(putCorsConfigurationOptions, - "putCorsConfigurationOptions cannot be null"); - RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/config/cors")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putCorsConfiguration"); + public ServiceCall headSchedulerJob(HeadSchedulerJobOptions headSchedulerJobOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(headSchedulerJobOptions, + "headSchedulerJobOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("job_id", headSchedulerJobOptions.jobId()); + RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/jobs/{job_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headSchedulerJob"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - builder.header("Accept", "application/json"); - final JsonObject contentJson = new JsonObject(); - contentJson.add("origins", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putCorsConfigurationOptions.origins())); - if (putCorsConfigurationOptions.allowCredentials() != null) { - contentJson.addProperty("allow_credentials", putCorsConfigurationOptions.allowCredentials()); - } - if (putCorsConfigurationOptions.enableCors() != null) { - contentJson.addProperty("enable_cors", putCorsConfigurationOptions.enableCors()); - } - builder.bodyJson(contentJson); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve the HTTP headers for an attachment. + * Create a persistent replication with a generated ID. * - * Returns the HTTP headers that contain a minimal amount of information about the specified attachment. This method - * supports the same query arguments as the `GET /{db}/{doc_id}/{attachment_name}` method, but only the header - * information (including attachment size, encoding, and the MD5 hash as an ETag), is returned. + * Creates or modifies a document in the `_replicator` database to start a new replication or to edit an existing + * replication. * - * @param headAttachmentOptions the {@link HeadAttachmentOptions} containing the options for the call - * @return a {@link ServiceCall} with a void result + * @param postReplicatorOptions the {@link PostReplicatorOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentResult} */ - public ServiceCall headAttachment(HeadAttachmentOptions headAttachmentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(headAttachmentOptions, - "headAttachmentOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", headAttachmentOptions.db()); - pathParamsMap.put("doc_id", headAttachmentOptions.docId()); - pathParamsMap.put("attachment_name", headAttachmentOptions.attachmentName()); - RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/{doc_id}/{attachment_name}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headAttachment"); + public ServiceCall postReplicator(PostReplicatorOptions postReplicatorOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postReplicatorOptions, + "postReplicatorOptions cannot be null"); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postReplicator"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - if (headAttachmentOptions.ifMatch() != null) { - builder.header("If-Match", headAttachmentOptions.ifMatch()); - } - if (headAttachmentOptions.ifNoneMatch() != null) { - builder.header("If-None-Match", headAttachmentOptions.ifNoneMatch()); - } - if (headAttachmentOptions.rev() != null) { - builder.query("rev", String.valueOf(headAttachmentOptions.rev())); + builder.header("Accept", "application/json"); + if (postReplicatorOptions.batch() != null) { + builder.query("batch", String.valueOf(postReplicatorOptions.batch())); } - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + builder.bodyContent(com.ibm.cloud.sdk.core.util.GsonSingleton.getGsonWithoutPrettyPrinting().toJson(postReplicatorOptions.replicationDocument()), "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Delete an attachment. + * Cancel a persistent replication. * - * 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. + * Cancels a replication by deleting the document that describes it from the `_replicator` database. * - * @param deleteAttachmentOptions the {@link DeleteAttachmentOptions} containing the options for the call + * @param deleteReplicationDocumentOptions the {@link DeleteReplicationDocumentOptions} containing the options for the call * @return a {@link ServiceCall} with a result of type {@link DocumentResult} */ - public ServiceCall deleteAttachment(DeleteAttachmentOptions deleteAttachmentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteAttachmentOptions, - "deleteAttachmentOptions cannot be null"); + public ServiceCall deleteReplicationDocument(DeleteReplicationDocumentOptions deleteReplicationDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteReplicationDocumentOptions, + "deleteReplicationDocumentOptions cannot be null"); Map pathParamsMap = new HashMap(); - 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteAttachment"); + pathParamsMap.put("doc_id", deleteReplicationDocumentOptions.docId()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteReplicationDocument"); for (Entry 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 (deleteReplicationDocumentOptions.ifMatch() != null) { + builder.header("If-Match", deleteReplicationDocumentOptions.ifMatch()); } - if (deleteAttachmentOptions.rev() != null) { - builder.query("rev", String.valueOf(deleteAttachmentOptions.rev())); + if (deleteReplicationDocumentOptions.batch() != null) { + builder.query("batch", String.valueOf(deleteReplicationDocumentOptions.batch())); } - if (deleteAttachmentOptions.batch() != null) { - builder.query("batch", String.valueOf(deleteAttachmentOptions.batch())); + if (deleteReplicationDocumentOptions.rev() != null) { + builder.query("rev", String.valueOf(deleteReplicationDocumentOptions.rev())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); @@ -4012,414 +3820,483 @@ public ServiceCall deleteAttachment(DeleteAttachmentOptions dele } /** - * Retrieve an attachment. + * Retrieve the configuration for a persistent replication. * - * Returns the file attachment that is associated with the document. The raw data of the associated attachment is - * returned, just as if you were accessing a static file. The returned Content-Type header is the same as the content - * type set when the document attachment was submitted to the database. + * 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 getAttachmentOptions the {@link GetAttachmentOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link InputStream} + * @param getReplicationDocumentOptions the {@link GetReplicationDocumentOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ReplicationDocument} */ - public ServiceCall getAttachment(GetAttachmentOptions getAttachmentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getAttachmentOptions, - "getAttachmentOptions cannot be null"); + public ServiceCall getReplicationDocument(GetReplicationDocumentOptions getReplicationDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getReplicationDocumentOptions, + "getReplicationDocumentOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", getAttachmentOptions.db()); - pathParamsMap.put("doc_id", getAttachmentOptions.docId()); - pathParamsMap.put("attachment_name", getAttachmentOptions.attachmentName()); - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/{doc_id}/{attachment_name}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getAttachment"); + pathParamsMap.put("doc_id", getReplicationDocumentOptions.docId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getReplicationDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - if (getAttachmentOptions.accept() != null) { - builder.header("Accept", getAttachmentOptions.accept()); + builder.header("Accept", "application/json"); + if (getReplicationDocumentOptions.ifNoneMatch() != null) { + builder.header("If-None-Match", getReplicationDocumentOptions.ifNoneMatch()); } - if (getAttachmentOptions.ifMatch() != null) { - builder.header("If-Match", getAttachmentOptions.ifMatch()); + if (getReplicationDocumentOptions.attachments() != null) { + builder.query("attachments", String.valueOf(getReplicationDocumentOptions.attachments())); } - if (getAttachmentOptions.ifNoneMatch() != null) { - builder.header("If-None-Match", getAttachmentOptions.ifNoneMatch()); + if (getReplicationDocumentOptions.attEncodingInfo() != null) { + builder.query("att_encoding_info", String.valueOf(getReplicationDocumentOptions.attEncodingInfo())); } - if (getAttachmentOptions.range() != null) { - builder.header("Range", getAttachmentOptions.range()); + if (getReplicationDocumentOptions.conflicts() != null) { + builder.query("conflicts", String.valueOf(getReplicationDocumentOptions.conflicts())); } - if (getAttachmentOptions.rev() != null) { - builder.query("rev", String.valueOf(getAttachmentOptions.rev())); + if (getReplicationDocumentOptions.deletedConflicts() != null) { + builder.query("deleted_conflicts", String.valueOf(getReplicationDocumentOptions.deletedConflicts())); } - ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); + 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 responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Create or modify an attachment. + * Create or modify a persistent replication. * - * Uploads the supplied content as an attachment to the specified document. The attachment name that you provide must - * be a URL encoded string. You must supply the Content-Type header, and for an existing document, you must also - * supply either the `rev` query argument or the `If-Match` HTTP header. If you omit the revision, a new, otherwise - * empty, document is created with the provided attachment, or a conflict occurs. If the uploaded attachment uses an - * existing attachment name in the remote database, it updates the corresponding stored content of the database. Since - * you must supply the revision information to add an attachment to the document, this serves as validation to update - * the existing attachment. + * Creates or modifies a document in the `_replicator` database to start a new replication or to edit an existing + * replication. * - * @param putAttachmentOptions the {@link PutAttachmentOptions} containing the options for the call + * @param putReplicationDocumentOptions the {@link PutReplicationDocumentOptions} containing the options for the call * @return a {@link ServiceCall} with a result of type {@link DocumentResult} */ - public ServiceCall putAttachment(PutAttachmentOptions putAttachmentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(putAttachmentOptions, - "putAttachmentOptions cannot be null"); + public ServiceCall putReplicationDocument(PutReplicationDocumentOptions putReplicationDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(putReplicationDocumentOptions, + "putReplicationDocumentOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", putAttachmentOptions.db()); - pathParamsMap.put("doc_id", putAttachmentOptions.docId()); - pathParamsMap.put("attachment_name", putAttachmentOptions.attachmentName()); - RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/{doc_id}/{attachment_name}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putAttachment"); + pathParamsMap.put("doc_id", putReplicationDocumentOptions.docId()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putReplicationDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.header("Content-Type", putAttachmentOptions.contentType()); - if (putAttachmentOptions.ifMatch() != null) { - builder.header("If-Match", putAttachmentOptions.ifMatch()); + if (putReplicationDocumentOptions.ifMatch() != null) { + builder.header("If-Match", putReplicationDocumentOptions.ifMatch()); } - if (putAttachmentOptions.rev() != null) { - builder.query("rev", String.valueOf(putAttachmentOptions.rev())); + if (putReplicationDocumentOptions.batch() != null) { + builder.query("batch", String.valueOf(putReplicationDocumentOptions.batch())); } - builder.bodyContent(putAttachmentOptions.contentType(), null, - null, putAttachmentOptions.attachment()); + if (putReplicationDocumentOptions.newEdits() != null) { + builder.query("new_edits", String.valueOf(putReplicationDocumentOptions.newEdits())); + } + if (putReplicationDocumentOptions.rev() != null) { + builder.query("rev", String.valueOf(putReplicationDocumentOptions.rev())); + } + builder.bodyContent(com.ibm.cloud.sdk.core.util.GsonSingleton.getGsonWithoutPrettyPrinting().toJson(putReplicationDocumentOptions.replicationDocument()), "application/json"); ResponseConverter responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve HTTP headers for a local document. + * Retrieve replication scheduler documents. * - * Retrieves the HTTP headers containing minimal amount of information about the specified local document. Since the - * response body is empty, using the HEAD method is a lightweight way to check if the local document exists or not. + * Lists replication documents, including information about all documents, even the ones in a completed or failed + * state. For each document, the endpoint returns the document ID, database, replication ID, source and target, and + * other information. * - * @param headLocalDocumentOptions the {@link HeadLocalDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a void result + * @param getSchedulerDocsOptions the {@link GetSchedulerDocsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link SchedulerDocsResult} */ - public ServiceCall headLocalDocument(HeadLocalDocumentOptions headLocalDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(headLocalDocumentOptions, - "headLocalDocumentOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", headLocalDocumentOptions.db()); - pathParamsMap.put("doc_id", headLocalDocumentOptions.docId()); - RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_local/{doc_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headLocalDocument"); + public ServiceCall getSchedulerDocs(GetSchedulerDocsOptions getSchedulerDocsOptions) { + if (getSchedulerDocsOptions == null) { + getSchedulerDocsOptions = new GetSchedulerDocsOptions.Builder().build(); + } + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/docs")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerDocs"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - if (headLocalDocumentOptions.ifNoneMatch() != null) { - builder.header("If-None-Match", headLocalDocumentOptions.ifNoneMatch()); + builder.header("Accept", "application/json"); + if (getSchedulerDocsOptions.limit() != null) { + builder.query("limit", String.valueOf(getSchedulerDocsOptions.limit())); } - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + if (getSchedulerDocsOptions.skip() != null) { + builder.query("skip", String.valueOf(getSchedulerDocsOptions.skip())); + } + if (getSchedulerDocsOptions.states() != null) { + builder.query("states", RequestUtils.join(getSchedulerDocsOptions.states(), ",")); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Delete a local document. + * Retrieve replication scheduler documents. + * + * Lists replication documents, including information about all documents, even the ones in a completed or failed + * state. For each document, the endpoint returns the document ID, database, replication ID, source and target, and + * other information. + * + * @return a {@link ServiceCall} with a result of type {@link SchedulerDocsResult} + */ + public ServiceCall getSchedulerDocs() { + return getSchedulerDocs(null); + } + + /** + * Retrieve a replication scheduler document. * - * Deletes the specified local document. The semantics are identical to deleting a standard document in the specified - * database, except that the document is not replicated. + * 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 deleteLocalDocumentOptions the {@link DeleteLocalDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link DocumentResult} + * @param getSchedulerDocumentOptions the {@link GetSchedulerDocumentOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link SchedulerDocument} */ - public ServiceCall deleteLocalDocument(DeleteLocalDocumentOptions deleteLocalDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(deleteLocalDocumentOptions, - "deleteLocalDocumentOptions cannot be null"); + public ServiceCall getSchedulerDocument(GetSchedulerDocumentOptions getSchedulerDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getSchedulerDocumentOptions, + "getSchedulerDocumentOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", deleteLocalDocumentOptions.db()); - pathParamsMap.put("doc_id", deleteLocalDocumentOptions.docId()); - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_local/{doc_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteLocalDocument"); + pathParamsMap.put("doc_id", getSchedulerDocumentOptions.docId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/docs/_replicator/{doc_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (deleteLocalDocumentOptions.batch() != null) { - builder.query("batch", String.valueOf(deleteLocalDocumentOptions.batch())); - } - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve a local document. + * Retrieve replication scheduler jobs. * - * Retrieves the specified local document. The semantics are identical to accessing a standard document in the - * specified database, except that the document is not replicated. + * Retrieves information about replications that were created via `/_replicate` endpoint, as well as those created + * from replication documents. It doesn't include replications that completed or failed to start because replication + * documents were malformed. Each job description includes source and target information, replication ID, history of + * recent events, and other information. * - * @param getLocalDocumentOptions the {@link GetLocalDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link Document} + * @param getSchedulerJobsOptions the {@link GetSchedulerJobsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link SchedulerJobsResult} */ - public ServiceCall getLocalDocument(GetLocalDocumentOptions getLocalDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getLocalDocumentOptions, - "getLocalDocumentOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", getLocalDocumentOptions.db()); - pathParamsMap.put("doc_id", getLocalDocumentOptions.docId()); - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_local/{doc_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getLocalDocument"); + public ServiceCall getSchedulerJobs(GetSchedulerJobsOptions getSchedulerJobsOptions) { + if (getSchedulerJobsOptions == null) { + getSchedulerJobsOptions = new GetSchedulerJobsOptions.Builder().build(); + } + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/jobs")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerJobs"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - if (getLocalDocumentOptions.accept() != null) { - builder.header("Accept", getLocalDocumentOptions.accept()); - } - if (getLocalDocumentOptions.ifNoneMatch() != null) { - builder.header("If-None-Match", getLocalDocumentOptions.ifNoneMatch()); - } - if (getLocalDocumentOptions.attachments() != null) { - builder.query("attachments", String.valueOf(getLocalDocumentOptions.attachments())); - } - if (getLocalDocumentOptions.attEncodingInfo() != null) { - builder.query("att_encoding_info", String.valueOf(getLocalDocumentOptions.attEncodingInfo())); + builder.header("Accept", "application/json"); + if (getSchedulerJobsOptions.limit() != null) { + builder.query("limit", String.valueOf(getSchedulerJobsOptions.limit())); } - if (getLocalDocumentOptions.localSeq() != null) { - builder.query("local_seq", String.valueOf(getLocalDocumentOptions.localSeq())); + if (getSchedulerJobsOptions.skip() != null) { + builder.query("skip", String.valueOf(getSchedulerJobsOptions.skip())); } - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Create or modify a local document. + * Retrieve replication scheduler jobs. * - * 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. + * Retrieves information about replications that were created via `/_replicate` endpoint, as well as those created + * from replication documents. It doesn't include replications that completed or failed to start because replication + * documents were malformed. Each job description includes source and target information, replication ID, history of + * recent events, and other information. * - * @param putLocalDocumentOptions the {@link PutLocalDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link DocumentResult} + * @return a {@link ServiceCall} with a result of type {@link SchedulerJobsResult} */ - public ServiceCall putLocalDocument(PutLocalDocumentOptions putLocalDocumentOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(putLocalDocumentOptions, - "putLocalDocumentOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.isTrue((putLocalDocumentOptions.document() != null) || (putLocalDocumentOptions.body() != null), - "One of [putLocalDocumentOptions.document(), putLocalDocumentOptions.body()] must be specified"); + public ServiceCall getSchedulerJobs() { + return getSchedulerJobs(null); + } - if (putLocalDocumentOptions.document() != null && putLocalDocumentOptions.contentType() == null) { - putLocalDocumentOptions = putLocalDocumentOptions.newBuilder().contentType("application/json").build(); - } + /** + * Retrieve a replication scheduler job. + * + * Retrieves the state of a single replication task based on its replication ID. + * + * @param getSchedulerJobOptions the {@link GetSchedulerJobOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link SchedulerJob} + */ + public ServiceCall getSchedulerJob(GetSchedulerJobOptions getSchedulerJobOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getSchedulerJobOptions, + "getSchedulerJobOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", putLocalDocumentOptions.db()); - pathParamsMap.put("doc_id", putLocalDocumentOptions.docId()); - RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_local/{doc_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putLocalDocument"); + pathParamsMap.put("job_id", getSchedulerJobOptions.jobId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/jobs/{job_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerJob"); for (Entry 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 responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Query the document revisions and possible ancestors missing from the database. + * Retrieve current session cookie information. * - * 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. + * Retrieves information about the authenticated user's session. * - * @param postRevsDiffOptions the {@link PostRevsDiffOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link Map} + * @param getSessionInformationOptions the {@link GetSessionInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link SessionInformation} */ - public ServiceCall> postRevsDiff(PostRevsDiffOptions postRevsDiffOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(postRevsDiffOptions, - "postRevsDiffOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", postRevsDiffOptions.db()); - RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_revs_diff", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postRevsDiff"); + public ServiceCall getSessionInformation(GetSessionInformationOptions getSessionInformationOptions) { + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_session")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSessionInformation"); for (Entry 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> responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken>() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve shard information. + * Retrieve current session cookie information. * - * List each shard range and the corresponding replicas for a specified database. + * Retrieves information about the authenticated user's session. * - * @param getShardsInformationOptions the {@link GetShardsInformationOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link ShardsInformation} + * @return a {@link ServiceCall} with a result of type {@link SessionInformation} */ - public ServiceCall getShardsInformation(GetShardsInformationOptions getShardsInformationOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getShardsInformationOptions, - "getShardsInformationOptions cannot be null"); - Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", getShardsInformationOptions.db()); - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_shards", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getShardsInformation"); + public ServiceCall getSessionInformation() { + return getSessionInformation(null); + } + + /** + * Generates API keys for apps or persons to enable database access. + * + * Generates API keys to enable database access for a person or application, but without creating a new IBM Cloudant + * account for that person or application. An API key is a randomly generated username and password. The key is given + * the wanted access permissions for a database. + * + * @param postApiKeysOptions the {@link PostApiKeysOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ApiKeysResult} + */ + public ServiceCall postApiKeys(PostApiKeysOptions postApiKeysOptions) { + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/api_keys")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postApiKeys"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve shard information for a specific document. + * Generates API keys for apps or persons to enable database access. * - * Retrieves information about a specific shard where a particular document is stored, along with information about - * the nodes where that shard has a replica. + * Generates API keys to enable database access for a person or application, but without creating a new IBM Cloudant + * account for that person or application. An API key is a randomly generated username and password. The key is given + * the wanted access permissions for a database. * - * @param getDocumentShardsInfoOptions the {@link GetDocumentShardsInfoOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link DocumentShardInfo} + * @return a {@link ServiceCall} with a result of type {@link ApiKeysResult} */ - public ServiceCall getDocumentShardsInfo(GetDocumentShardsInfoOptions getDocumentShardsInfoOptions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(getDocumentShardsInfoOptions, - "getDocumentShardsInfoOptions cannot be null"); + public ServiceCall postApiKeys() { + return postApiKeys(null); + } + + /** + * Modify only Cloudant related database permissions. + * + * Modify only Cloudant related permissions to database. Be careful: by removing an API key from the list, you remove + * the API key from the list of users that have access to the database. + * + * ### Note about nobody role + * + * The `nobody` username applies to all unauthenticated connection attempts. For example, if an application tries to + * read data from a database, but did not identify itself, the task can continue only if the `nobody` user has the + * role `_reader`. + * + * @param putCloudantSecurityConfigurationOptions the {@link PutCloudantSecurityConfigurationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link Ok} + */ + public ServiceCall putCloudantSecurityConfiguration(PutCloudantSecurityConfigurationOptions putCloudantSecurityConfigurationOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(putCloudantSecurityConfigurationOptions, + "putCloudantSecurityConfigurationOptions cannot be null"); Map pathParamsMap = new HashMap(); - pathParamsMap.put("db", getDocumentShardsInfoOptions.db()); - pathParamsMap.put("doc_id", getDocumentShardsInfoOptions.docId()); - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_shards/{doc_id}", pathParamsMap)); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getDocumentShardsInfo"); + pathParamsMap.put("db", putCloudantSecurityConfigurationOptions.db()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/db/{db}/_security", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putCloudantSecurityConfiguration"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + final JsonObject contentJson = new JsonObject(); + contentJson.add("cloudant", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putCloudantSecurityConfigurationOptions.cloudant())); + if (putCloudantSecurityConfigurationOptions.admins() != null) { + contentJson.add("admins", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putCloudantSecurityConfigurationOptions.admins())); + } + if (putCloudantSecurityConfigurationOptions.couchdbAuthOnly() != null) { + contentJson.addProperty("couchdb_auth_only", putCloudantSecurityConfigurationOptions.couchdbAuthOnly()); + } + if (putCloudantSecurityConfigurationOptions.members() != null) { + contentJson.add("members", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putCloudantSecurityConfigurationOptions.members())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve HTTP headers about whether the server is up. + * Retrieve database permissions information. * - * Retrieves the HTTP headers about whether the server is up. + * 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 headUpInformationOptions the {@link HeadUpInformationOptions} containing the options for the call - * @return a {@link ServiceCall} with a void result + * @param getSecurityOptions the {@link GetSecurityOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link Security} */ - public ServiceCall headUpInformation(HeadUpInformationOptions headUpInformationOptions) { - RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_up")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headUpInformation"); + public ServiceCall getSecurity(GetSecurityOptions getSecurityOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getSecurityOptions, + "getSecurityOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", getSecurityOptions.db()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_security", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSecurity"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve HTTP headers about whether the server is up. + * Modify database permissions. * - * Retrieves the HTTP headers about whether the server is up. + * Modify who has permission to read, write, or manage a database. This endpoint can be used to modify both Cloudant + * and CouchDB related permissions. Be careful: by removing a Cloudant API key, a member or an admin from the list of + * users that have access permissions, you remove it from the list of users that have access to the database. * - * @return a {@link ServiceCall} with a void result - */ - public ServiceCall headUpInformation() { - return headUpInformation(null); - } - - /** - * Retrieve list of running tasks. + * ### Note about nobody role * - * 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. + * The `nobody` username applies to all unauthenticated connection attempts. For example, if an application tries to + * read data from a database, but did not identify itself, the task can continue only if the `nobody` user has the + * role `_reader`. * - * @param getActiveTasksOptions the {@link GetActiveTasksOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link List} + * @param putSecurityOptions the {@link PutSecurityOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link Ok} */ - public ServiceCall> getActiveTasks(GetActiveTasksOptions getActiveTasksOptions) { - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_active_tasks")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getActiveTasks"); + public ServiceCall putSecurity(PutSecurityOptions putSecurityOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(putSecurityOptions, + "putSecurityOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", putSecurityOptions.db()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_security", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putSecurity"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter> responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken>() { }.getType()); + final JsonObject contentJson = new JsonObject(); + if (putSecurityOptions.admins() != null) { + contentJson.add("admins", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putSecurityOptions.admins())); + } + if (putSecurityOptions.cloudant() != null) { + contentJson.add("cloudant", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putSecurityOptions.cloudant())); + } + if (putSecurityOptions.couchdbAuthOnly() != null) { + contentJson.addProperty("couchdb_auth_only", putSecurityOptions.couchdbAuthOnly()); + } + if (putSecurityOptions.members() != null) { + contentJson.add("members", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putSecurityOptions.members())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * 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. - * - * @return a {@link ServiceCall} with a result of type {@link List} - */ - public ServiceCall> getActiveTasks() { - return getActiveTasks(null); - } - - /** - * Retrieve activity tracking events information. + * Retrieve CORS configuration information. * - * Check event types sent to IBM Cloud Activity Tracker Event Routing for the IBM Cloudant instance. + * Lists all Cross-origin resource sharing (CORS) configuration. CORS defines a way in which the browser and the + * server interact to determine whether or not to allow the request. * - * @param getActivityTrackerEventsOptions the {@link GetActivityTrackerEventsOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link ActivityTrackerEvents} + * @param getCorsInformationOptions the {@link GetCorsInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link CorsInformation} */ - public ServiceCall getActivityTrackerEvents(GetActivityTrackerEventsOptions getActivityTrackerEventsOptions) { - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/activity_tracker/events")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getActivityTrackerEvents"); + public ServiceCall getCorsInformation(GetCorsInformationOptions getCorsInformationOptions) { + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/config/cors")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCorsInformation"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve activity tracking events information. + * Retrieve CORS configuration information. * - * Check event types sent to IBM Cloud Activity Tracker Event Routing for the IBM Cloudant instance. + * Lists all Cross-origin resource sharing (CORS) configuration. CORS defines a way in which the browser and the + * server interact to determine whether or not to allow the request. * - * @return a {@link ServiceCall} with a result of type {@link ActivityTrackerEvents} + * @return a {@link ServiceCall} with a result of type {@link CorsInformation} */ - public ServiceCall getActivityTrackerEvents() { - return getActivityTrackerEvents(null); + public ServiceCall getCorsInformation() { + return getCorsInformation(null); } /** - * Modify activity tracking events configuration. + * Modify CORS configuration. * - * Configure event types sent to IBM Cloud Activity Tracker Event Routing for the IBM Cloudant instance. + * Sets the CORS configuration. The configuration applies to all databases and all account level endpoints in your + * account. * - * @param postActivityTrackerEventsOptions the {@link PostActivityTrackerEventsOptions} containing the options for the call + * @param putCorsConfigurationOptions the {@link PutCorsConfigurationOptions} containing the options for the call * @return a {@link ServiceCall} with a result of type {@link Ok} */ - public ServiceCall 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postActivityTrackerEvents"); + public ServiceCall putCorsConfiguration(PutCorsConfigurationOptions putCorsConfigurationOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(putCorsConfigurationOptions, + "putCorsConfigurationOptions cannot be null"); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/config/cors")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putCorsConfiguration"); for (Entry 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())); + contentJson.add("origins", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putCorsConfigurationOptions.origins())); + if (putCorsConfigurationOptions.allowCredentials() != null) { + contentJson.addProperty("allow_credentials", putCorsConfigurationOptions.allowCredentials()); + } + if (putCorsConfigurationOptions.enableCors() != null) { + contentJson.addProperty("enable_cors", putCorsConfigurationOptions.enableCors()); + } builder.bodyJson(contentJson); ResponseConverter responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); @@ -4427,172 +4304,369 @@ public ServiceCall postActivityTrackerEvents(PostActivityTrackerEventsOption } /** - * Retrieve maximum allowed database count. + * Retrieve the HTTP headers for an attachment. * - * Retrieves the maximum number of databases currently allowed in the instance. + * Returns the HTTP headers that contain a minimal amount of information about the specified attachment. This method + * supports the same query arguments as the `GET /{db}/{doc_id}/{attachment_name}` method, but only the header + * information (including attachment size, encoding, and the MD5 hash as an ETag), is returned. * - * @param getCapacityDatabasesInformationOptions the {@link GetCapacityDatabasesInformationOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link CapacityDatabasesInformation} + * @param headAttachmentOptions the {@link HeadAttachmentOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall getCapacityDatabasesInformation(GetCapacityDatabasesInformationOptions getCapacityDatabasesInformationOptions) { - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/capacity/databases")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCapacityDatabasesInformation"); + public ServiceCall headAttachment(HeadAttachmentOptions headAttachmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(headAttachmentOptions, + "headAttachmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", headAttachmentOptions.db()); + pathParamsMap.put("doc_id", headAttachmentOptions.docId()); + pathParamsMap.put("attachment_name", headAttachmentOptions.attachmentName()); + RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/{doc_id}/{attachment_name}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headAttachment"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + if (headAttachmentOptions.ifMatch() != null) { + builder.header("If-Match", headAttachmentOptions.ifMatch()); + } + if (headAttachmentOptions.ifNoneMatch() != null) { + builder.header("If-None-Match", headAttachmentOptions.ifNoneMatch()); + } + if (headAttachmentOptions.rev() != null) { + builder.query("rev", String.valueOf(headAttachmentOptions.rev())); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * 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 deleteAttachment(DeleteAttachmentOptions deleteAttachmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteAttachmentOptions, + "deleteAttachmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + 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 sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteAttachment"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + 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 responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve maximum allowed database count. + * Retrieve an attachment. * - * Retrieves the maximum number of databases currently allowed in the instance. + * Returns the file attachment that is associated with the document. The raw data of the associated attachment is + * returned, just as if you were accessing a static file. The returned Content-Type header is the same as the content + * type set when the document attachment was submitted to the database. * - * @return a {@link ServiceCall} with a result of type {@link CapacityDatabasesInformation} + * @param getAttachmentOptions the {@link GetAttachmentOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ - public ServiceCall getCapacityDatabasesInformation() { - return getCapacityDatabasesInformation(null); + public ServiceCall getAttachment(GetAttachmentOptions getAttachmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getAttachmentOptions, + "getAttachmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", getAttachmentOptions.db()); + pathParamsMap.put("doc_id", getAttachmentOptions.docId()); + pathParamsMap.put("attachment_name", getAttachmentOptions.attachmentName()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/{doc_id}/{attachment_name}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getAttachment"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + if (getAttachmentOptions.accept() != null) { + builder.header("Accept", getAttachmentOptions.accept()); + } + if (getAttachmentOptions.ifMatch() != null) { + builder.header("If-Match", getAttachmentOptions.ifMatch()); + } + if (getAttachmentOptions.ifNoneMatch() != null) { + builder.header("If-None-Match", getAttachmentOptions.ifNoneMatch()); + } + if (getAttachmentOptions.range() != null) { + builder.header("Range", getAttachmentOptions.range()); + } + if (getAttachmentOptions.rev() != null) { + builder.query("rev", String.valueOf(getAttachmentOptions.rev())); + } + ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); + return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve current database count. + * Create or modify an attachment. * - * Retrieves the current number of databases that exist in the instance. + * Uploads the supplied content as an attachment to the specified document. The attachment name that you provide must + * be a URL encoded string. You must supply the Content-Type header, and for an existing document, you must also + * supply either the `rev` query argument or the `If-Match` HTTP header. If you omit the revision, a new, otherwise + * empty, document is created with the provided attachment, or a conflict occurs. If the uploaded attachment uses an + * existing attachment name in the remote database, it updates the corresponding stored content of the database. Since + * you must supply the revision information to add an attachment to the document, this serves as validation to update + * the existing attachment. * - * @param getCurrentDatabasesInformationOptions the {@link GetCurrentDatabasesInformationOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link CurrentDatabasesInformation} + * @param putAttachmentOptions the {@link PutAttachmentOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentResult} */ - public ServiceCall getCurrentDatabasesInformation(GetCurrentDatabasesInformationOptions getCurrentDatabasesInformationOptions) { - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/current/databases")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCurrentDatabasesInformation"); + public ServiceCall putAttachment(PutAttachmentOptions putAttachmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(putAttachmentOptions, + "putAttachmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", putAttachmentOptions.db()); + pathParamsMap.put("doc_id", putAttachmentOptions.docId()); + pathParamsMap.put("attachment_name", putAttachmentOptions.attachmentName()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/{doc_id}/{attachment_name}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putAttachment"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + builder.header("Content-Type", putAttachmentOptions.contentType()); + if (putAttachmentOptions.ifMatch() != null) { + builder.header("If-Match", putAttachmentOptions.ifMatch()); + } + if (putAttachmentOptions.rev() != null) { + builder.query("rev", String.valueOf(putAttachmentOptions.rev())); + } + builder.bodyContent(putAttachmentOptions.contentType(), null, + null, putAttachmentOptions.attachment()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve current database count. + * Retrieve HTTP headers for a local document. * - * Retrieves the current number of databases that exist in the instance. + * Retrieves the HTTP headers containing minimal amount of information about the specified local document. Since the + * response body is empty, using the HEAD method is a lightweight way to check if the local document exists or not. * - * @return a {@link ServiceCall} with a result of type {@link CurrentDatabasesInformation} + * @param headLocalDocumentOptions the {@link HeadLocalDocumentOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result */ - public ServiceCall getCurrentDatabasesInformation() { - return getCurrentDatabasesInformation(null); + public ServiceCall headLocalDocument(HeadLocalDocumentOptions headLocalDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(headLocalDocumentOptions, + "headLocalDocumentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", headLocalDocumentOptions.db()); + pathParamsMap.put("doc_id", headLocalDocumentOptions.docId()); + RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_local/{doc_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headLocalDocument"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + if (headLocalDocumentOptions.ifNoneMatch() != null) { + builder.header("If-None-Match", headLocalDocumentOptions.ifNoneMatch()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve the current provisioned throughput capacity consumption. + * Delete a local document. * - * 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. + * Deletes the specified local document. The semantics are identical to deleting a standard document in the specified + * database, except that the document is not replicated. * - * @param getCurrentThroughputInformationOptions the {@link GetCurrentThroughputInformationOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link CurrentThroughputInformation} + * @param deleteLocalDocumentOptions the {@link DeleteLocalDocumentOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentResult} */ - public ServiceCall getCurrentThroughputInformation(GetCurrentThroughputInformationOptions getCurrentThroughputInformationOptions) { - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/current/throughput")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCurrentThroughputInformation"); + public ServiceCall deleteLocalDocument(DeleteLocalDocumentOptions deleteLocalDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteLocalDocumentOptions, + "deleteLocalDocumentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", deleteLocalDocumentOptions.db()); + pathParamsMap.put("doc_id", deleteLocalDocumentOptions.docId()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_local/{doc_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteLocalDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + if (deleteLocalDocumentOptions.batch() != null) { + builder.query("batch", String.valueOf(deleteLocalDocumentOptions.batch())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve the current provisioned throughput capacity consumption. + * Retrieve a local document. * - * 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. + * Retrieves the specified local document. The semantics are identical to accessing a standard document in the + * specified database, except that the document is not replicated. * - * @return a {@link ServiceCall} with a result of type {@link CurrentThroughputInformation} + * @param getLocalDocumentOptions the {@link GetLocalDocumentOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link Document} */ - public ServiceCall getCurrentThroughputInformation() { - return getCurrentThroughputInformation(null); + public ServiceCall getLocalDocument(GetLocalDocumentOptions getLocalDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getLocalDocumentOptions, + "getLocalDocumentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", getLocalDocumentOptions.db()); + pathParamsMap.put("doc_id", getLocalDocumentOptions.docId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_local/{doc_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getLocalDocument"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + if (getLocalDocumentOptions.accept() != null) { + builder.header("Accept", getLocalDocumentOptions.accept()); + } + if (getLocalDocumentOptions.ifNoneMatch() != null) { + builder.header("If-None-Match", getLocalDocumentOptions.ifNoneMatch()); + } + if (getLocalDocumentOptions.attachments() != null) { + builder.query("attachments", String.valueOf(getLocalDocumentOptions.attachments())); + } + if (getLocalDocumentOptions.attEncodingInfo() != null) { + builder.query("att_encoding_info", String.valueOf(getLocalDocumentOptions.attEncodingInfo())); + } + if (getLocalDocumentOptions.localSeq() != null) { + builder.query("local_seq", String.valueOf(getLocalDocumentOptions.localSeq())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve cluster membership information. + * Create or modify a local document. * - * Displays the nodes that are part of the cluster as `cluster_nodes`. The field, `all_nodes`, displays all nodes this - * node knows about, including the ones that are part of the cluster. This endpoint is useful when you set up a - * cluster. + * 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 getMembershipInformationOptions the {@link GetMembershipInformationOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link MembershipInformation} + * @param putLocalDocumentOptions the {@link PutLocalDocumentOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentResult} */ - public ServiceCall getMembershipInformation(GetMembershipInformationOptions getMembershipInformationOptions) { - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_membership")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getMembershipInformation"); + public ServiceCall putLocalDocument(PutLocalDocumentOptions putLocalDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(putLocalDocumentOptions, + "putLocalDocumentOptions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.isTrue((putLocalDocumentOptions.document() != null) || (putLocalDocumentOptions.body() != null), + "One of [putLocalDocumentOptions.document(), putLocalDocumentOptions.body()] must be specified"); + + if (putLocalDocumentOptions.document() != null && putLocalDocumentOptions.contentType() == null) { + putLocalDocumentOptions = putLocalDocumentOptions.newBuilder().contentType("application/json").build(); + } + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", putLocalDocumentOptions.db()); + pathParamsMap.put("doc_id", putLocalDocumentOptions.docId()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_local/{doc_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putLocalDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + 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 responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve cluster membership information. + * Query the document revisions and possible ancestors missing from the database. * - * Displays the nodes that are part of the cluster as `cluster_nodes`. The field, `all_nodes`, displays all nodes this - * node knows about, including the ones that are part of the cluster. This endpoint is useful when you set up a - * cluster. + * 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. * - * @return a {@link ServiceCall} with a result of type {@link MembershipInformation} + * @param postRevsDiffOptions the {@link PostRevsDiffOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link Map} */ - public ServiceCall getMembershipInformation() { - return getMembershipInformation(null); + public ServiceCall> postRevsDiff(PostRevsDiffOptions postRevsDiffOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(postRevsDiffOptions, + "postRevsDiffOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", postRevsDiffOptions.db()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_revs_diff", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postRevsDiff"); + for (Entry 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> responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken>() { }.getType()); + return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve information about whether the server is up. - * - * Confirms that the server is up, running, and ready to respond to requests. If the cluster is unavailable the - * endpoint returns a `503` response code. + * Retrieve shard information. * - * **Tip:** The authentication for this endpoint is only enforced when using IAM. + * List each shard range and the corresponding replicas for a specified database. * - * @param getUpInformationOptions the {@link GetUpInformationOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link UpInformation} + * @param getShardsInformationOptions the {@link GetShardsInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ShardsInformation} */ - public ServiceCall getUpInformation(GetUpInformationOptions getUpInformationOptions) { - RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_up")); - Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getUpInformation"); + public ServiceCall getShardsInformation(GetShardsInformationOptions getShardsInformationOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getShardsInformationOptions, + "getShardsInformationOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", getShardsInformationOptions.db()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_shards", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getShardsInformation"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } /** - * Retrieve information about whether the server is up. - * - * Confirms that the server is up, running, and ready to respond to requests. If the cluster is unavailable the - * endpoint returns a `503` response code. + * Retrieve shard information for a specific document. * - * **Tip:** The authentication for this endpoint is only enforced when using IAM. + * Retrieves information about a specific shard where a particular document is stored, along with information about + * the nodes where that shard has a replica. * - * @return a {@link ServiceCall} with a result of type {@link UpInformation} + * @param getDocumentShardsInfoOptions the {@link GetDocumentShardsInfoOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DocumentShardInfo} */ - public ServiceCall getUpInformation() { - return getUpInformation(null); + public ServiceCall getDocumentShardsInfo(GetDocumentShardsInfoOptions getDocumentShardsInfoOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getDocumentShardsInfoOptions, + "getDocumentShardsInfoOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("db", getDocumentShardsInfoOptions.db()); + pathParamsMap.put("doc_id", getDocumentShardsInfoOptions.docId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_shards/{doc_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getDocumentShardsInfo"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); } } diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/DesignDocumentViewIndex.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/DesignDocumentViewIndex.java index 018896e41..f622b9274 100644 --- a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/DesignDocumentViewIndex.java +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/DesignDocumentViewIndex.java @@ -111,7 +111,7 @@ public Boolean isUpdaterRunning() { /** * Gets the updatesPending. * - * Schema for an ability to tell if view is up-to-date without querying it. + * Schema for information about pending updates for an index, calculated across all available copies of all shards. * * @return the updatesPending */ diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/IndexInfoResult.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/IndexInfoResult.java new file mode 100644 index 000000000..b8dff7af6 --- /dev/null +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/IndexInfoResult.java @@ -0,0 +1,82 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Schema for the result of an _index_info request. + */ +public class IndexInfoResult extends GenericModel { + + protected String bookmark; + @SerializedName("search_indexes") + protected List searchIndexes; + @SerializedName("total_rows") + protected Long totalRows; + @SerializedName("view_indexes") + protected List viewIndexes; + + protected IndexInfoResult() { } + + /** + * Gets the bookmark. + * + * The ID of the first design document after the current page of results. Pass this value as `start_key` to retrieve + * the next page. This field is `null` when no more design documents are available, or when the request includes a + * `keys` parameter. + * + * @return the bookmark + */ + public String getBookmark() { + return bookmark; + } + + /** + * Gets the searchIndexes. + * + * The status of each search index across the design documents in the current page of results. + * + * @return the searchIndexes + */ + public List getSearchIndexes() { + return searchIndexes; + } + + /** + * Gets the totalRows. + * + * The total number of design documents in the database. A design document can contain multiple indexes. + * + * @return the totalRows + */ + public Long getTotalRows() { + return totalRows; + } + + /** + * Gets the viewIndexes. + * + * The view index status for each design document in the current page of results. + * + * @return the viewIndexes + */ + public List getViewIndexes() { + return viewIndexes; + } +} + diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/PostIndexInfoOptions.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/PostIndexInfoOptions.java new file mode 100644 index 000000000..4fda10cf6 --- /dev/null +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/PostIndexInfoOptions.java @@ -0,0 +1,516 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The postIndexInfo options. + */ +public class PostIndexInfoOptions extends GenericModel { + + public interface Type { + /** search. */ + String SEARCH = "search"; + /** view. */ + String VIEW = "view"; + } + + protected String db; + protected Boolean attEncodingInfo; + protected Boolean attachments; + protected Boolean conflicts; + protected Boolean descending; + protected Boolean includeDocs; + protected Boolean inclusiveEnd; + protected Long limit; + protected Long skip; + protected Boolean updateSeq; + protected String endKey; + protected String key; + protected List keys; + protected String startKey; + protected List type; + + /** + * Builder. + */ + public static class Builder { + private String db; + private Boolean attEncodingInfo; + private Boolean attachments; + private Boolean conflicts; + private Boolean descending; + private Boolean includeDocs; + private Boolean inclusiveEnd; + private Long limit; + private Long skip; + private Boolean updateSeq; + private String endKey; + private String key; + private List keys; + private String startKey; + private List type; + + /** + * Instantiates a new Builder from an existing PostIndexInfoOptions instance. + * + * @param postIndexInfoOptions the instance to initialize the Builder with + */ + private Builder(PostIndexInfoOptions postIndexInfoOptions) { + this.db = postIndexInfoOptions.db; + this.attEncodingInfo = postIndexInfoOptions.attEncodingInfo; + this.attachments = postIndexInfoOptions.attachments; + this.conflicts = postIndexInfoOptions.conflicts; + this.descending = postIndexInfoOptions.descending; + this.includeDocs = postIndexInfoOptions.includeDocs; + this.inclusiveEnd = postIndexInfoOptions.inclusiveEnd; + this.limit = postIndexInfoOptions.limit; + this.skip = postIndexInfoOptions.skip; + this.updateSeq = postIndexInfoOptions.updateSeq; + this.endKey = postIndexInfoOptions.endKey; + this.key = postIndexInfoOptions.key; + this.keys = postIndexInfoOptions.keys; + this.startKey = postIndexInfoOptions.startKey; + this.type = postIndexInfoOptions.type; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param db the db + */ + public Builder(String db) { + this.db = db; + } + + /** + * Builds a PostIndexInfoOptions. + * + * @return the new PostIndexInfoOptions instance + */ + public PostIndexInfoOptions build() { + return new PostIndexInfoOptions(this); + } + + /** + * Adds a new element to keys. + * + * @param keys the new element to be added + * @return the PostIndexInfoOptions builder + */ + public Builder addKeys(String keys) { + com.ibm.cloud.sdk.core.util.Validator.notNull(keys, + "keys cannot be null"); + if (this.keys == null) { + this.keys = new ArrayList(); + } + this.keys.add(keys); + return this; + } + + /** + * Adds a new element to type. + * + * @param type the new element to be added + * @return the PostIndexInfoOptions builder + */ + public Builder addType(String type) { + com.ibm.cloud.sdk.core.util.Validator.notNull(type, + "type cannot be null"); + if (this.type == null) { + this.type = new ArrayList(); + } + this.type.add(type); + return this; + } + + /** + * Set the db. + * + * @param db the db + * @return the PostIndexInfoOptions builder + */ + public Builder db(String db) { + this.db = db; + return this; + } + + /** + * Set the attEncodingInfo. + * + * @param attEncodingInfo the attEncodingInfo + * @return the PostIndexInfoOptions builder + */ + public Builder attEncodingInfo(Boolean attEncodingInfo) { + this.attEncodingInfo = attEncodingInfo; + return this; + } + + /** + * Set the attachments. + * + * @param attachments the attachments + * @return the PostIndexInfoOptions builder + */ + public Builder attachments(Boolean attachments) { + this.attachments = attachments; + return this; + } + + /** + * Set the conflicts. + * + * @param conflicts the conflicts + * @return the PostIndexInfoOptions builder + */ + public Builder conflicts(Boolean conflicts) { + this.conflicts = conflicts; + return this; + } + + /** + * Set the descending. + * + * @param descending the descending + * @return the PostIndexInfoOptions builder + */ + public Builder descending(Boolean descending) { + this.descending = descending; + return this; + } + + /** + * Set the includeDocs. + * + * @param includeDocs the includeDocs + * @return the PostIndexInfoOptions builder + */ + public Builder includeDocs(Boolean includeDocs) { + this.includeDocs = includeDocs; + return this; + } + + /** + * Set the inclusiveEnd. + * + * @param inclusiveEnd the inclusiveEnd + * @return the PostIndexInfoOptions builder + */ + public Builder inclusiveEnd(Boolean inclusiveEnd) { + this.inclusiveEnd = inclusiveEnd; + return this; + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the PostIndexInfoOptions builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + + /** + * Set the skip. + * + * @param skip the skip + * @return the PostIndexInfoOptions builder + */ + public Builder skip(long skip) { + this.skip = skip; + return this; + } + + /** + * Set the updateSeq. + * + * @param updateSeq the updateSeq + * @return the PostIndexInfoOptions builder + */ + public Builder updateSeq(Boolean updateSeq) { + this.updateSeq = updateSeq; + return this; + } + + /** + * Set the endKey. + * + * @param endKey the endKey + * @return the PostIndexInfoOptions builder + */ + public Builder endKey(String endKey) { + this.endKey = endKey; + return this; + } + + /** + * Set the key. + * + * @param key the key + * @return the PostIndexInfoOptions builder + */ + public Builder key(String key) { + this.key = key; + return this; + } + + /** + * Set the keys. + * Existing keys will be replaced. + * + * @param keys the keys + * @return the PostIndexInfoOptions builder + */ + public Builder keys(List keys) { + this.keys = keys; + return this; + } + + /** + * Set the startKey. + * + * @param startKey the startKey + * @return the PostIndexInfoOptions builder + */ + public Builder startKey(String startKey) { + this.startKey = startKey; + return this; + } + + /** + * Set the type. + * Existing type will be replaced. + * + * @param type the type + * @return the PostIndexInfoOptions builder + */ + public Builder type(List type) { + this.type = type; + return this; + } + } + + protected PostIndexInfoOptions() { } + + protected PostIndexInfoOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.db, + "db cannot be empty"); + db = builder.db; + attEncodingInfo = builder.attEncodingInfo; + attachments = builder.attachments; + conflicts = builder.conflicts; + descending = builder.descending; + includeDocs = builder.includeDocs; + inclusiveEnd = builder.inclusiveEnd; + limit = builder.limit; + skip = builder.skip; + updateSeq = builder.updateSeq; + endKey = builder.endKey; + key = builder.key; + keys = builder.keys; + startKey = builder.startKey; + type = builder.type; + } + + /** + * New builder. + * + * @return a PostIndexInfoOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the db. + * + * Path parameter to specify the database name. + * + * @return the db + */ + public String db() { + return db; + } + + /** + * Gets the attEncodingInfo. + * + * Parameter to specify whether to include the encoding information for compressed attachments. This only applies when + * requesting documents in the response. + * + * @return the attEncodingInfo + */ + public Boolean attEncodingInfo() { + return attEncodingInfo; + } + + /** + * Gets the attachments. + * + * Parameter to specify whether to include attachment content in included document content or only the attachment + * metadata. This only applies when requesting documents in the response. + * + * @return the attachments + */ + public Boolean attachments() { + return attachments; + } + + /** + * Gets the conflicts. + * + * Parameter to specify whether to include a list of conflicted revisions in each returned document. This only applies + * when requesting documents in the response. + * + * @return the conflicts + */ + public Boolean conflicts() { + return conflicts; + } + + /** + * Gets the descending. + * + * Parameter to specify whether to return the documents in descending by key order. + * + * @return the descending + */ + public Boolean descending() { + return descending; + } + + /** + * Gets the includeDocs. + * + * Parameter to specify whether to include the full content of the documents in the response. + * + * @return the includeDocs + */ + public Boolean includeDocs() { + return includeDocs; + } + + /** + * Gets the inclusiveEnd. + * + * Parameter to specify whether to include the specified end key in the result. + * + * @return the inclusiveEnd + */ + public Boolean inclusiveEnd() { + return inclusiveEnd; + } + + /** + * Gets the limit. + * + * Parameter to specify the number of returned documents to limit the result to. + * + * @return the limit + */ + public Long limit() { + return limit; + } + + /** + * Gets the skip. + * + * Parameter to specify the number of records before starting to return the results. + * + * @return the skip + */ + public Long skip() { + return skip; + } + + /** + * Gets the updateSeq. + * + * Parameter to specify whether to include in the response an update_seq value indicating the sequence id of the + * database the view reflects. + * + * @return the updateSeq + */ + public Boolean updateSeq() { + return updateSeq; + } + + /** + * Gets the endKey. + * + * Schema for a document ID. + * + * @return the endKey + */ + public String endKey() { + return endKey; + } + + /** + * Gets the key. + * + * Schema for a document ID. + * + * @return the key + */ + public String key() { + return key; + } + + /** + * Gets the keys. + * + * Schema for a list of document IDs. + * + * @return the keys + */ + public List keys() { + return keys; + } + + /** + * Gets the startKey. + * + * Schema for a document ID. + * + * @return the startKey + */ + public String startKey() { + return startKey; + } + + /** + * Gets the type. + * + * Index types to filter results by. If omitted, the response includes all index types. + * + * @return the type + */ + public List type() { + return type; + } +} + diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuth.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuth.java index ddf5c7d8c..1f71be379 100644 --- a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuth.java +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuth.java @@ -22,6 +22,7 @@ public class ReplicationDatabaseAuth extends GenericModel { protected ReplicationDatabaseAuthBasic basic; protected ReplicationDatabaseAuthIam iam; + protected ReplicationDatabaseAuthIBM ibm; /** * Builder. @@ -29,6 +30,7 @@ public class ReplicationDatabaseAuth extends GenericModel { public static class Builder { private ReplicationDatabaseAuthBasic basic; private ReplicationDatabaseAuthIam iam; + private ReplicationDatabaseAuthIBM ibm; /** * Instantiates a new Builder from an existing ReplicationDatabaseAuth instance. @@ -38,6 +40,7 @@ public static class Builder { private Builder(ReplicationDatabaseAuth replicationDatabaseAuth) { this.basic = replicationDatabaseAuth.basic; this.iam = replicationDatabaseAuth.iam; + this.ibm = replicationDatabaseAuth.ibm; } /** @@ -76,6 +79,17 @@ public Builder iam(ReplicationDatabaseAuthIam iam) { this.iam = iam; return this; } + + /** + * Set the ibm. + * + * @param ibm the ibm + * @return the ReplicationDatabaseAuth builder + */ + public Builder ibm(ReplicationDatabaseAuthIBM ibm) { + this.ibm = ibm; + return this; + } } protected ReplicationDatabaseAuth() { } @@ -83,6 +97,7 @@ protected ReplicationDatabaseAuth() { } protected ReplicationDatabaseAuth(Builder builder) { basic = builder.basic; iam = builder.iam; + ibm = builder.ibm; } /** @@ -108,12 +123,23 @@ public ReplicationDatabaseAuthBasic basic() { /** * Gets the iam. * - * Schema for an IAM API key for replication database authentication. + * Deprecated: use the `ibm` property instead to configure IAM for replication database authentication. * * @return the iam */ public ReplicationDatabaseAuthIam iam() { return iam; } + + /** + * Gets the ibm. + * + * IBM IAM replication auth for CouchDB or Cloudant. + * + * @return the ibm + */ + public ReplicationDatabaseAuthIBM ibm() { + return ibm; + } } diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBM.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBM.java new file mode 100644 index 000000000..519f94e61 --- /dev/null +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBM.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * IBM IAM replication auth for CouchDB or Cloudant. + */ +public class ReplicationDatabaseAuthIBM extends GenericModel { + + protected ReplicationDatabaseAuthIBMIam iam; + + /** + * Builder. + */ + public static class Builder { + private ReplicationDatabaseAuthIBMIam iam; + + /** + * Instantiates a new Builder from an existing ReplicationDatabaseAuthIBM instance. + * + * @param replicationDatabaseAuthIbm the instance to initialize the Builder with + */ + private Builder(ReplicationDatabaseAuthIBM replicationDatabaseAuthIbm) { + this.iam = replicationDatabaseAuthIbm.iam; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param iam the iam + */ + public Builder(ReplicationDatabaseAuthIBMIam iam) { + this.iam = iam; + } + + /** + * Builds a ReplicationDatabaseAuthIBM. + * + * @return the new ReplicationDatabaseAuthIBM instance + */ + public ReplicationDatabaseAuthIBM build() { + return new ReplicationDatabaseAuthIBM(this); + } + + /** + * Set the iam. + * + * @param iam the iam + * @return the ReplicationDatabaseAuthIBM builder + */ + public Builder iam(ReplicationDatabaseAuthIBMIam iam) { + this.iam = iam; + return this; + } + } + + protected ReplicationDatabaseAuthIBM() { } + + protected ReplicationDatabaseAuthIBM(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.iam, + "iam cannot be null"); + iam = builder.iam; + } + + /** + * New builder. + * + * @return a ReplicationDatabaseAuthIBM builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the iam. + * + * IAM API key for replication database authentication. + * + * @return the iam + */ + public ReplicationDatabaseAuthIBMIam iam() { + return iam; + } +} + diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBMIam.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBMIam.java new file mode 100644 index 000000000..33ed2e4a8 --- /dev/null +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBMIam.java @@ -0,0 +1,106 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * IAM API key for replication database authentication. + */ +public class ReplicationDatabaseAuthIBMIam extends GenericModel { + + @SerializedName("api_key") + protected String apiKey; + + /** + * Builder. + */ + public static class Builder { + private String apiKey; + + /** + * Instantiates a new Builder from an existing ReplicationDatabaseAuthIBMIam instance. + * + * @param replicationDatabaseAuthIbmIam the instance to initialize the Builder with + */ + private Builder(ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIam) { + this.apiKey = replicationDatabaseAuthIbmIam.apiKey; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param apiKey the apiKey + */ + public Builder(String apiKey) { + this.apiKey = apiKey; + } + + /** + * Builds a ReplicationDatabaseAuthIBMIam. + * + * @return the new ReplicationDatabaseAuthIBMIam instance + */ + public ReplicationDatabaseAuthIBMIam build() { + return new ReplicationDatabaseAuthIBMIam(this); + } + + /** + * Set the apiKey. + * + * @param apiKey the apiKey + * @return the ReplicationDatabaseAuthIBMIam builder + */ + public Builder apiKey(String apiKey) { + this.apiKey = apiKey; + return this; + } + } + + protected ReplicationDatabaseAuthIBMIam() { } + + protected ReplicationDatabaseAuthIBMIam(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.apiKey, + "apiKey cannot be null"); + apiKey = builder.apiKey; + } + + /** + * New builder. + * + * @return a ReplicationDatabaseAuthIBMIam builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the apiKey. + * + * IAM API key. + * + * @return the apiKey + */ + public String apiKey() { + return apiKey; + } +} + diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIam.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIam.java index ade8c6f87..3d71fb1bb 100644 --- a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIam.java +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIam.java @@ -17,7 +17,7 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * Schema for an IAM API key for replication database authentication. + * Deprecated: use the `ibm` property instead to configure IAM for replication database authentication. */ public class ReplicationDatabaseAuthIam extends GenericModel { diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDocument.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDocument.java index ee507f4de..e6cd07fbb 100644 --- a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDocument.java +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ReplicationDocument.java @@ -29,6 +29,18 @@ */ public class ReplicationDocument extends DynamicModel { + /** + * Specify whether to compress HTTP request bodies during replication. Set to `gzip` to compress request bodies or + * `none` to disable compression. Only use `gzip` if the remote server accepts compressed requests. If unset, the + * default is determined by the server administrator. + */ + public interface RequestCompression { + /** none. */ + String NONE = "none"; + /** gzip. */ + String GZIP = "gzip"; + } + @SerializedName("_attachments") protected Map attachments; @SerializedName("_conflicts") @@ -69,6 +81,8 @@ public class ReplicationDocument extends DynamicModel { protected String owner; @SerializedName("query_params") protected Map queryParams; + @SerializedName("request_compression") + protected String requestCompression; @SerializedName("retries_per_request") protected Long retriesPerRequest; @SerializedName("selector") @@ -126,6 +140,7 @@ public static class Builder { private Long httpConnections; private String owner; private Map queryParams; + private String requestCompression; private Long retriesPerRequest; private Map selector; private String sinceSeq; @@ -168,6 +183,7 @@ private Builder(ReplicationDocument replicationDocument) { this.httpConnections = replicationDocument.httpConnections; this.owner = replicationDocument.owner; this.queryParams = replicationDocument.queryParams; + this.requestCompression = replicationDocument.requestCompression; this.retriesPerRequest = replicationDocument.retriesPerRequest; this.selector = replicationDocument.selector; this.sinceSeq = replicationDocument.sinceSeq; @@ -499,6 +515,17 @@ public Builder queryParams(Map queryParams) { return this; } + /** + * Set the requestCompression. + * + * @param requestCompression the requestCompression + * @return the ReplicationDocument builder + */ + public Builder requestCompression(String requestCompression) { + this.requestCompression = requestCompression; + return this; + } + /** * Set the retriesPerRequest. * @@ -700,6 +727,7 @@ protected ReplicationDocument(Builder builder) { httpConnections = builder.httpConnections; owner = builder.owner; queryParams = builder.queryParams; + requestCompression = builder.requestCompression; retriesPerRequest = builder.retriesPerRequest; selector = builder.selector; sinceSeq = builder.sinceSeq; @@ -1130,6 +1158,28 @@ public void setQueryParams(final Map queryParams) { this.queryParams = queryParams; } + /** + * Gets the requestCompression. + * + * Specify whether to compress HTTP request bodies during replication. Set to `gzip` to compress request bodies or + * `none` to disable compression. Only use `gzip` if the remote server accepts compressed requests. If unset, the + * default is determined by the server administrator. + * + * @return the requestCompression + */ + public String getRequestCompression() { + return this.requestCompression; + } + + /** + * Sets the requestCompression. + * + * @param requestCompression the new requestCompression + */ + public void setRequestCompression(final String requestCompression) { + this.requestCompression = requestCompression; + } + /** * Gets the retriesPerRequest. * diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInfo.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInfo.java index 386769b58..61326b21c 100644 --- a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInfo.java +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInfo.java @@ -32,6 +32,8 @@ public class SearchIndexInfo extends GenericModel { @SerializedName("pending_seq") protected Long pendingSeq; protected String signature; + @SerializedName("updates_pending") + protected UpdatesPending updatesPending; protected SearchIndexInfo() { } @@ -100,5 +102,16 @@ public Long getPendingSeq() { public String getSignature() { return signature; } + + /** + * Gets the updatesPending. + * + * Schema for information about pending updates for an index, calculated across all available copies of all shards. + * + * @return the updatesPending + */ + public UpdatesPending getUpdatesPending() { + return updatesPending; + } } diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInformation.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInformation.java new file mode 100644 index 000000000..12e1bb2f1 --- /dev/null +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInformation.java @@ -0,0 +1,124 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Schema for search index status for a named index within a design document. + */ +public class SearchIndexInformation extends GenericModel { + + protected Boolean ok; + @SerializedName("caused_by") + protected String causedBy; + protected String error; + protected String reason; + protected Long ref; + protected String ddoc; + protected SearchIndexInfo info; + protected String name; + + protected SearchIndexInformation() { } + + /** + * Gets the ok. + * + * ok. + * + * @return the ok + */ + public Boolean isOk() { + return ok; + } + + /** + * Gets the causedBy. + * + * The cause of the error (if available). + * + * @return the causedBy + */ + public String getCausedBy() { + return causedBy; + } + + /** + * Gets the error. + * + * The name of the error. + * + * @return the error + */ + public String getError() { + return error; + } + + /** + * Gets the reason. + * + * The reason the error occurred (if available). + * + * @return the reason + */ + public String getReason() { + return reason; + } + + /** + * Gets the ref. + * + * An internal error reference (if available). + * + * @return the ref + */ + public Long getRef() { + return ref; + } + + /** + * Gets the ddoc. + * + * Schema for a design document ID including a `_design/` prefix. + * + * @return the ddoc + */ + public String getDdoc() { + return ddoc; + } + + /** + * Gets the info. + * + * Schema for metadata information about a search index. + * + * @return the info + */ + public SearchIndexInfo getInfo() { + return info; + } + + /** + * Gets the name. + * + * The name of the search index. + * + * @return the name + */ + public String getName() { + return name; + } +} + diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/UpdatesPending.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/UpdatesPending.java index ca7b7296f..10262e014 100644 --- a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/UpdatesPending.java +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/UpdatesPending.java @@ -13,23 +13,65 @@ package com.ibm.cloud.cloudant.v1.model; +import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; /** - * Schema for an ability to tell if view is up-to-date without querying it. + * Schema for information about pending updates for an index, calculated across all available copies of all shards. */ public class UpdatesPending extends GenericModel { + protected Long copies; + @SerializedName("copies_expected") + protected Long copiesExpected; + protected Long maximum; protected Long minimum; protected Long preferred; protected Long total; protected UpdatesPending() { } + /** + * Gets the copies. + * + * The number of shard copies that reported an answer. Copies that are unreachable or in maintenance mode are not + * included. Compare with the `copies_expected` value. + * + * @return the copies + */ + public Long getCopies() { + return copies; + } + + /** + * Gets the copiesExpected. + * + * The expected number of shard copy responses. If `copies` is less than this value, the results might be partial and + * `maximum` might not represent the true backlog. + * + * @return the copiesExpected + */ + public Long getCopiesExpected() { + return copiesExpected; + } + + /** + * Gets the maximum. + * + * The backlog of the least up-to-date copy of each shard range. A value of `0` means the index is fully built on + * every copy. + * + * @return the maximum + */ + public Long getMaximum() { + return maximum; + } + /** * Gets the minimum. * - * Sum of shard copies with the least amount of work to do. + * The backlog of the most up-to-date copy of each shard range. A value of `0` means that at least one complete copy + * exists for every shard range. * * @return the minimum */ @@ -40,8 +82,7 @@ public Long getMinimum() { /** * Gets the preferred. * - * Sum of unique shards. This value is zero when at least one copy of every shard range is up-to-date and the view is - * able to answer a query without index building delays. + * The backlog of the preferred shard copies, which are the copies that queries are routed to by default. * * @return the preferred */ @@ -52,7 +93,7 @@ public Long getPreferred() { /** * Gets the total. * - * Sum of all shard copies. + * The total backlog across all shard copies. * * @return the total */ diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ViewIndexInformation.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ViewIndexInformation.java new file mode 100644 index 000000000..21eea3350 --- /dev/null +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/ViewIndexInformation.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Schema for view index status for a design document. + */ +public class ViewIndexInformation extends GenericModel { + + protected Boolean ok; + @SerializedName("caused_by") + protected String causedBy; + protected String error; + protected String reason; + protected Long ref; + protected String ddoc; + protected DesignDocumentViewIndex info; + protected List views; + + protected ViewIndexInformation() { } + + /** + * Gets the ok. + * + * ok. + * + * @return the ok + */ + public Boolean isOk() { + return ok; + } + + /** + * Gets the causedBy. + * + * The cause of the error (if available). + * + * @return the causedBy + */ + public String getCausedBy() { + return causedBy; + } + + /** + * Gets the error. + * + * The name of the error. + * + * @return the error + */ + public String getError() { + return error; + } + + /** + * Gets the reason. + * + * The reason the error occurred (if available). + * + * @return the reason + */ + public String getReason() { + return reason; + } + + /** + * Gets the ref. + * + * An internal error reference (if available). + * + * @return the ref + */ + public Long getRef() { + return ref; + } + + /** + * Gets the ddoc. + * + * Schema for a design document ID including a `_design/` prefix. + * + * @return the ddoc + */ + public String getDdoc() { + return ddoc; + } + + /** + * Gets the info. + * + * View index information. + * + * @return the info + */ + public DesignDocumentViewIndex getInfo() { + return info; + } + + /** + * Gets the views. + * + * The map-reduce view names in the design document. + * + * @return the views + */ + public List getViews() { + return views; + } +} + diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantIT.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantIT.java index e58e8b27f..a38b9b8c4 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantIT.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantIT.java @@ -116,6 +116,7 @@ import com.ibm.cloud.cloudant.v1.model.IndexCandidate; import com.ibm.cloud.cloudant.v1.model.IndexDefinition; import com.ibm.cloud.cloudant.v1.model.IndexField; +import com.ibm.cloud.cloudant.v1.model.IndexInfoResult; import com.ibm.cloud.cloudant.v1.model.IndexInformation; import com.ibm.cloud.cloudant.v1.model.IndexResult; import com.ibm.cloud.cloudant.v1.model.IndexTextOperatorDefaultField; @@ -141,6 +142,7 @@ import com.ibm.cloud.cloudant.v1.model.PostDocumentOptions; import com.ibm.cloud.cloudant.v1.model.PostExplainOptions; import com.ibm.cloud.cloudant.v1.model.PostFindOptions; +import com.ibm.cloud.cloudant.v1.model.PostIndexInfoOptions; import com.ibm.cloud.cloudant.v1.model.PostIndexOptions; import com.ibm.cloud.cloudant.v1.model.PostPartitionAllDocsOptions; import com.ibm.cloud.cloudant.v1.model.PostPartitionExplainOptions; @@ -167,6 +169,8 @@ import com.ibm.cloud.cloudant.v1.model.ReplicationDatabase; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuth; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthBasic; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBM; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBMIam; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIam; import com.ibm.cloud.cloudant.v1.model.ReplicationDocument; import com.ibm.cloud.cloudant.v1.model.Revisions; @@ -182,6 +186,7 @@ import com.ibm.cloud.cloudant.v1.model.SearchIndexDefinition; import com.ibm.cloud.cloudant.v1.model.SearchIndexDiskSize; import com.ibm.cloud.cloudant.v1.model.SearchIndexInfo; +import com.ibm.cloud.cloudant.v1.model.SearchIndexInformation; import com.ibm.cloud.cloudant.v1.model.SearchInfoResult; import com.ibm.cloud.cloudant.v1.model.SearchResult; import com.ibm.cloud.cloudant.v1.model.SearchResultProperties; @@ -199,6 +204,7 @@ import com.ibm.cloud.cloudant.v1.model.UpdatesPending; import com.ibm.cloud.cloudant.v1.model.UserContext; import com.ibm.cloud.cloudant.v1.model.UuidsResult; +import com.ibm.cloud.cloudant.v1.model.ViewIndexInformation; import com.ibm.cloud.cloudant.v1.model.ViewQueriesResult; import com.ibm.cloud.cloudant.v1.model.ViewQuery; import com.ibm.cloud.cloudant.v1.model.ViewResult; @@ -1465,6 +1471,220 @@ public void testPostDesignDocsQueries() throws Exception { } @Test(dependsOnMethods = { "testPostDesignDocsQueries" }) + public void testHeadUpInformation() throws Exception { + try { + HeadUpInformationOptions headUpInformationOptions = new HeadUpInformationOptions(); + + // Invoke operation + Response response = service.headUpInformation(headUpInformationOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testHeadUpInformation" }) + public void testGetActiveTasks() throws Exception { + try { + GetActiveTasksOptions getActiveTasksOptions = new GetActiveTasksOptions(); + + // Invoke operation + Response> response = service.getActiveTasks(getActiveTasksOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + List listActiveTaskResult = response.getResult(); + assertNotNull(listActiveTaskResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetActiveTasks" }) + public void testGetActivityTrackerEvents() throws Exception { + try { + GetActivityTrackerEventsOptions getActivityTrackerEventsOptions = new GetActivityTrackerEventsOptions(); + + // Invoke operation + Response response = service.getActivityTrackerEvents(getActivityTrackerEventsOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + ActivityTrackerEvents activityTrackerEventsResult = response.getResult(); + assertNotNull(activityTrackerEventsResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetActivityTrackerEvents" }) + public void testPostActivityTrackerEvents() throws Exception { + try { + PostActivityTrackerEventsOptions postActivityTrackerEventsOptions = new PostActivityTrackerEventsOptions.Builder() + .types(java.util.Arrays.asList("management", "data")) + .build(); + + // Invoke operation + Response response = service.postActivityTrackerEvents(postActivityTrackerEventsOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + Ok okResult = response.getResult(); + assertNotNull(okResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testPostActivityTrackerEvents" }) + public void testGetCapacityDatabasesInformation() throws Exception { + try { + GetCapacityDatabasesInformationOptions getCapacityDatabasesInformationOptions = new GetCapacityDatabasesInformationOptions(); + + // Invoke operation + Response response = service.getCapacityDatabasesInformation(getCapacityDatabasesInformationOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + CapacityDatabasesInformation capacityDatabasesInformationResult = response.getResult(); + assertNotNull(capacityDatabasesInformationResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetCapacityDatabasesInformation" }) + public void testGetCurrentDatabasesInformation() throws Exception { + try { + GetCurrentDatabasesInformationOptions getCurrentDatabasesInformationOptions = new GetCurrentDatabasesInformationOptions(); + + // Invoke operation + Response response = service.getCurrentDatabasesInformation(getCurrentDatabasesInformationOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + CurrentDatabasesInformation currentDatabasesInformationResult = response.getResult(); + assertNotNull(currentDatabasesInformationResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetCurrentDatabasesInformation" }) + public void testGetCurrentThroughputInformation() throws Exception { + try { + GetCurrentThroughputInformationOptions getCurrentThroughputInformationOptions = new GetCurrentThroughputInformationOptions(); + + // Invoke operation + Response response = service.getCurrentThroughputInformation(getCurrentThroughputInformationOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + CurrentThroughputInformation currentThroughputInformationResult = response.getResult(); + assertNotNull(currentThroughputInformationResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetCurrentThroughputInformation" }) + public void testGetMembershipInformation() throws Exception { + try { + GetMembershipInformationOptions getMembershipInformationOptions = new GetMembershipInformationOptions(); + + // Invoke operation + Response response = service.getMembershipInformation(getMembershipInformationOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + MembershipInformation membershipInformationResult = response.getResult(); + assertNotNull(membershipInformationResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetMembershipInformation" }) + public void testGetUpInformation() throws Exception { + try { + GetUpInformationOptions getUpInformationOptions = new GetUpInformationOptions(); + + // Invoke operation + Response response = service.getUpInformation(getUpInformationOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + UpInformation upInformationResult = response.getResult(); + assertNotNull(upInformationResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetUpInformation" }) + public void testPostIndexInfo() throws Exception { + try { + PostIndexInfoOptions postIndexInfoOptions = new PostIndexInfoOptions.Builder() + .db("testString") + .attEncodingInfo(false) + .attachments(false) + .conflicts(false) + .descending(false) + .includeDocs(false) + .inclusiveEnd(true) + .limit(Long.valueOf("0")) + .skip(Long.valueOf("0")) + .updateSeq(false) + .endKey("testString") + .key("testString") + .keys(java.util.Arrays.asList("_design/cookbook")) + .startKey("testString") + .type(java.util.Arrays.asList("search")) + .build(); + + // Invoke operation + Response response = service.postIndexInfo(postIndexInfoOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + IndexInfoResult indexInfoResultResult = response.getResult(); + assertNotNull(indexInfoResultResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testPostIndexInfo" }) public void testPostView() throws Exception { try { PostViewOptions postViewOptions = new PostViewOptions.Builder() @@ -2446,9 +2666,18 @@ public void testPostReplicator() throws Exception { .apiKey("testString") .build(); + ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIamModel = new ReplicationDatabaseAuthIBMIam.Builder() + .apiKey("testString") + .build(); + + ReplicationDatabaseAuthIBM replicationDatabaseAuthIbmModel = new ReplicationDatabaseAuthIBM.Builder() + .iam(replicationDatabaseAuthIbmIamModel) + .build(); + ReplicationDatabaseAuth replicationDatabaseAuthModel = new ReplicationDatabaseAuth.Builder() .basic(replicationDatabaseAuthBasicModel) .iam(replicationDatabaseAuthIamModel) + .ibm(replicationDatabaseAuthIbmModel) .build(); ReplicationDatabase replicationDatabaseModel = new ReplicationDatabase.Builder() @@ -2484,6 +2713,7 @@ public void testPostReplicator() throws Exception { .httpConnections(Long.valueOf("10")) .owner("testString") .queryParams(java.util.Collections.singletonMap("key1", "testString")) + .requestCompression("gzip") .retriesPerRequest(Long.valueOf("3")) .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) .sinceSeq("34-g1AAAAGjeJzLYWBgYMlgTmGQT0lKzi9KdU") @@ -2594,9 +2824,18 @@ public void testPutReplicationDocument() throws Exception { .apiKey("testString") .build(); + ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIamModel = new ReplicationDatabaseAuthIBMIam.Builder() + .apiKey("testString") + .build(); + + ReplicationDatabaseAuthIBM replicationDatabaseAuthIbmModel = new ReplicationDatabaseAuthIBM.Builder() + .iam(replicationDatabaseAuthIbmIamModel) + .build(); + ReplicationDatabaseAuth replicationDatabaseAuthModel = new ReplicationDatabaseAuth.Builder() .basic(replicationDatabaseAuthBasicModel) .iam(replicationDatabaseAuthIamModel) + .ibm(replicationDatabaseAuthIbmModel) .build(); ReplicationDatabase replicationDatabaseModel = new ReplicationDatabase.Builder() @@ -2632,6 +2871,7 @@ public void testPutReplicationDocument() throws Exception { .httpConnections(Long.valueOf("10")) .owner("testString") .queryParams(java.util.Collections.singletonMap("key1", "testString")) + .requestCompression("gzip") .retriesPerRequest(Long.valueOf("3")) .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) .sinceSeq("34-g1AAAAGjeJzLYWBgYMlgTmGQT0lKzi9KdU") @@ -3200,184 +3440,6 @@ public void testGetDocumentShardsInfo() throws Exception { } @Test(dependsOnMethods = { "testGetDocumentShardsInfo" }) - public void testHeadUpInformation() throws Exception { - try { - HeadUpInformationOptions headUpInformationOptions = new HeadUpInformationOptions(); - - // Invoke operation - Response response = service.headUpInformation(headUpInformationOptions).execute(); - // Validate response - assertNotNull(response); - assertEquals(response.getStatusCode(), 200); - } catch (ServiceResponseException e) { - fail(String.format("Service returned status code %d: %s%nError details: %s", - e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); - } - } - - @Test(dependsOnMethods = { "testHeadUpInformation" }) - public void testGetActiveTasks() throws Exception { - try { - GetActiveTasksOptions getActiveTasksOptions = new GetActiveTasksOptions(); - - // Invoke operation - Response> response = service.getActiveTasks(getActiveTasksOptions).execute(); - // Validate response - assertNotNull(response); - assertEquals(response.getStatusCode(), 200); - - List listActiveTaskResult = response.getResult(); - assertNotNull(listActiveTaskResult); - - } catch (ServiceResponseException e) { - fail(String.format("Service returned status code %d: %s%nError details: %s", - e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); - } - } - - @Test(dependsOnMethods = { "testGetActiveTasks" }) - public void testGetActivityTrackerEvents() throws Exception { - try { - GetActivityTrackerEventsOptions getActivityTrackerEventsOptions = new GetActivityTrackerEventsOptions(); - - // Invoke operation - Response response = service.getActivityTrackerEvents(getActivityTrackerEventsOptions).execute(); - // Validate response - assertNotNull(response); - assertEquals(response.getStatusCode(), 200); - - ActivityTrackerEvents activityTrackerEventsResult = response.getResult(); - assertNotNull(activityTrackerEventsResult); - - } catch (ServiceResponseException e) { - fail(String.format("Service returned status code %d: %s%nError details: %s", - e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); - } - } - - @Test(dependsOnMethods = { "testGetActivityTrackerEvents" }) - public void testPostActivityTrackerEvents() throws Exception { - try { - PostActivityTrackerEventsOptions postActivityTrackerEventsOptions = new PostActivityTrackerEventsOptions.Builder() - .types(java.util.Arrays.asList("management", "data")) - .build(); - - // Invoke operation - Response response = service.postActivityTrackerEvents(postActivityTrackerEventsOptions).execute(); - // Validate response - assertNotNull(response); - assertEquals(response.getStatusCode(), 200); - - Ok okResult = response.getResult(); - assertNotNull(okResult); - - } catch (ServiceResponseException e) { - fail(String.format("Service returned status code %d: %s%nError details: %s", - e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); - } - } - - @Test(dependsOnMethods = { "testPostActivityTrackerEvents" }) - public void testGetCapacityDatabasesInformation() throws Exception { - try { - GetCapacityDatabasesInformationOptions getCapacityDatabasesInformationOptions = new GetCapacityDatabasesInformationOptions(); - - // Invoke operation - Response response = service.getCapacityDatabasesInformation(getCapacityDatabasesInformationOptions).execute(); - // Validate response - assertNotNull(response); - assertEquals(response.getStatusCode(), 200); - - CapacityDatabasesInformation capacityDatabasesInformationResult = response.getResult(); - assertNotNull(capacityDatabasesInformationResult); - - } catch (ServiceResponseException e) { - fail(String.format("Service returned status code %d: %s%nError details: %s", - e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); - } - } - - @Test(dependsOnMethods = { "testGetCapacityDatabasesInformation" }) - public void testGetCurrentDatabasesInformation() throws Exception { - try { - GetCurrentDatabasesInformationOptions getCurrentDatabasesInformationOptions = new GetCurrentDatabasesInformationOptions(); - - // Invoke operation - Response response = service.getCurrentDatabasesInformation(getCurrentDatabasesInformationOptions).execute(); - // Validate response - assertNotNull(response); - assertEquals(response.getStatusCode(), 200); - - CurrentDatabasesInformation currentDatabasesInformationResult = response.getResult(); - assertNotNull(currentDatabasesInformationResult); - - } catch (ServiceResponseException e) { - fail(String.format("Service returned status code %d: %s%nError details: %s", - e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); - } - } - - @Test(dependsOnMethods = { "testGetCurrentDatabasesInformation" }) - public void testGetCurrentThroughputInformation() throws Exception { - try { - GetCurrentThroughputInformationOptions getCurrentThroughputInformationOptions = new GetCurrentThroughputInformationOptions(); - - // Invoke operation - Response response = service.getCurrentThroughputInformation(getCurrentThroughputInformationOptions).execute(); - // Validate response - assertNotNull(response); - assertEquals(response.getStatusCode(), 200); - - CurrentThroughputInformation currentThroughputInformationResult = response.getResult(); - assertNotNull(currentThroughputInformationResult); - - } catch (ServiceResponseException e) { - fail(String.format("Service returned status code %d: %s%nError details: %s", - e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); - } - } - - @Test(dependsOnMethods = { "testGetCurrentThroughputInformation" }) - public void testGetMembershipInformation() throws Exception { - try { - GetMembershipInformationOptions getMembershipInformationOptions = new GetMembershipInformationOptions(); - - // Invoke operation - Response response = service.getMembershipInformation(getMembershipInformationOptions).execute(); - // Validate response - assertNotNull(response); - assertEquals(response.getStatusCode(), 200); - - MembershipInformation membershipInformationResult = response.getResult(); - assertNotNull(membershipInformationResult); - - } catch (ServiceResponseException e) { - fail(String.format("Service returned status code %d: %s%nError details: %s", - e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); - } - } - - @Test(dependsOnMethods = { "testGetMembershipInformation" }) - public void testGetUpInformation() throws Exception { - try { - GetUpInformationOptions getUpInformationOptions = new GetUpInformationOptions(); - - // Invoke operation - Response response = service.getUpInformation(getUpInformationOptions).execute(); - // Validate response - assertNotNull(response); - assertEquals(response.getStatusCode(), 200); - - UpInformation upInformationResult = response.getResult(); - assertNotNull(upInformationResult); - - } catch (ServiceResponseException e) { - fail(String.format("Service returned status code %d: %s%nError details: %s", - e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); - } - } - - @Test(dependsOnMethods = { "testGetUpInformation" }) public void testDeleteDatabase() throws Exception { try { DeleteDatabaseOptions deleteDatabaseOptions = new DeleteDatabaseOptions.Builder() diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantTest.java index 63e82d547..3e89dbda8 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantTest.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantTest.java @@ -117,6 +117,7 @@ import com.ibm.cloud.cloudant.v1.model.IndexCandidate; import com.ibm.cloud.cloudant.v1.model.IndexDefinition; import com.ibm.cloud.cloudant.v1.model.IndexField; +import com.ibm.cloud.cloudant.v1.model.IndexInfoResult; import com.ibm.cloud.cloudant.v1.model.IndexInformation; import com.ibm.cloud.cloudant.v1.model.IndexResult; import com.ibm.cloud.cloudant.v1.model.IndexTextOperatorDefaultField; @@ -142,6 +143,7 @@ import com.ibm.cloud.cloudant.v1.model.PostDocumentOptions; import com.ibm.cloud.cloudant.v1.model.PostExplainOptions; import com.ibm.cloud.cloudant.v1.model.PostFindOptions; +import com.ibm.cloud.cloudant.v1.model.PostIndexInfoOptions; import com.ibm.cloud.cloudant.v1.model.PostIndexOptions; import com.ibm.cloud.cloudant.v1.model.PostPartitionAllDocsOptions; import com.ibm.cloud.cloudant.v1.model.PostPartitionExplainOptions; @@ -168,6 +170,8 @@ import com.ibm.cloud.cloudant.v1.model.ReplicationDatabase; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuth; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthBasic; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBM; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBMIam; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIam; import com.ibm.cloud.cloudant.v1.model.ReplicationDocument; import com.ibm.cloud.cloudant.v1.model.Revisions; @@ -183,6 +187,7 @@ import com.ibm.cloud.cloudant.v1.model.SearchIndexDefinition; import com.ibm.cloud.cloudant.v1.model.SearchIndexDiskSize; import com.ibm.cloud.cloudant.v1.model.SearchIndexInfo; +import com.ibm.cloud.cloudant.v1.model.SearchIndexInformation; import com.ibm.cloud.cloudant.v1.model.SearchInfoResult; import com.ibm.cloud.cloudant.v1.model.SearchResult; import com.ibm.cloud.cloudant.v1.model.SearchResultProperties; @@ -200,6 +205,7 @@ import com.ibm.cloud.cloudant.v1.model.UpdatesPending; import com.ibm.cloud.cloudant.v1.model.UserContext; import com.ibm.cloud.cloudant.v1.model.UuidsResult; +import com.ibm.cloud.cloudant.v1.model.ViewIndexInformation; import com.ibm.cloud.cloudant.v1.model.ViewQueriesResult; import com.ibm.cloud.cloudant.v1.model.ViewQuery; import com.ibm.cloud.cloudant.v1.model.ViewResult; @@ -2538,7 +2544,7 @@ public void testPutDesignDocumentNoOptions() throws Throwable { @Test public void testGetDesignDocumentInformationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"name\": \"name\", \"view_index\": {\"collator_versions\": [\"collatorVersions\"], \"compact_running\": true, \"language\": \"language\", \"signature\": \"signature\", \"sizes\": {\"active\": 0, \"external\": 0, \"file\": 0}, \"updater_running\": true, \"updates_pending\": {\"minimum\": 0, \"preferred\": 0, \"total\": 0}, \"waiting_clients\": 0, \"waiting_commit\": false}}"; + String mockResponseBody = "{\"name\": \"name\", \"view_index\": {\"collator_versions\": [\"collatorVersions\"], \"compact_running\": true, \"language\": \"language\", \"signature\": \"signature\", \"sizes\": {\"active\": 0, \"external\": 0, \"file\": 0}, \"updater_running\": true, \"updates_pending\": {\"copies\": 0, \"copies_expected\": 0, \"maximum\": 0, \"minimum\": 0, \"preferred\": 0, \"total\": 0}, \"waiting_clients\": 0, \"waiting_commit\": false}}"; String getDesignDocumentInformationPath = "/testString/_design/testString/_info"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -2720,280 +2726,152 @@ public void testPostDesignDocsQueriesNoOptions() throws Throwable { cloudantService.postDesignDocsQueries(null).execute(); } - // Test the postView operation with a valid options model parameter + // Test the headUpInformation operation with a valid options model parameter @Test - public void testPostViewWOptions() throws Throwable { + public void testHeadUpInformationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"total_rows\": 0, \"update_seq\": \"updateSeq\", \"rows\": [{\"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0, \"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"id\": \"id\", \"key\": \"anyValue\", \"value\": \"anyValue\"}]}"; - String postViewPath = "/testString/_design/testString/_view/testString"; + String mockResponseBody = ""; + String headUpInformationPath = "/_up"; server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostViewOptions model - PostViewOptions postViewOptionsModel = new PostViewOptions.Builder() - .db("testString") - .ddoc("testString") - .view("testString") - .attEncodingInfo(false) - .attachments(false) - .conflicts(false) - .descending(false) - .includeDocs(true) - .inclusiveEnd(true) - .limit(Long.valueOf("10")) - .skip(Long.valueOf("0")) - .updateSeq(false) - .endKey("testString") - .endKeyDocId("testString") - .group(false) - .groupLevel(Long.valueOf("1")) - .key("testString") - .keys(java.util.Arrays.asList("examplekey")) - .reduce(true) - .stable(false) - .startKey("testString") - .startKeyDocId("testString") - .update("true") - .build(); + // Construct an instance of the HeadUpInformationOptions model + HeadUpInformationOptions headUpInformationOptionsModel = new HeadUpInformationOptions(); - // Invoke postView() with a valid options model and verify the result - Response response = cloudantService.postView(postViewOptionsModel).execute(); + // Invoke headUpInformation() with a valid options model and verify the result + Response response = cloudantService.headUpInformation(headUpInformationOptionsModel).execute(); assertNotNull(response); - ViewResult responseObj = response.getResult(); - assertNotNull(responseObj); + Void responseObj = response.getResult(); + assertNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "POST"); + assertEquals(request.getMethod(), "HEAD"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postViewPath); + assertEquals(parsedPath, headUpInformationPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postView operation with and without retries enabled + // Test the headUpInformation operation with and without retries enabled @Test - public void testPostViewWRetries() throws Throwable { + public void testHeadUpInformationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostViewWOptions(); + testHeadUpInformationWOptions(); cloudantService.disableRetries(); - testPostViewWOptions(); - } - - // Test the postView operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostViewNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.postView(null).execute(); + testHeadUpInformationWOptions(); } - // Test the postViewAsStream operation with a valid options model parameter + // Test the getActiveTasks operation with a valid options model parameter @Test - public void testPostViewAsStreamWOptions() throws Throwable { + public void testGetActiveTasksWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; - String postViewAsStreamPath = "/testString/_design/testString/_view/testString"; + String mockResponseBody = "[{\"bulk_get_attempts\": 0, \"bulk_get_docs\": 0, \"changes_done\": 0, \"changes_pending\": 0, \"checkpoint_interval\": 30000, \"checkpointed_source_seq\": \"checkpointedSourceSeq\", \"continuous\": false, \"database\": \"database\", \"design_document\": \"designDocument\", \"doc_id\": \"docId\", \"doc_write_failures\": 0, \"docs_read\": 0, \"docs_written\": 0, \"index\": \"index\", \"indexer_pid\": \"indexerPid\", \"missing_revisions_found\": 0, \"node\": \"node\", \"phase\": \"docid_sort\", \"pid\": \"pid\", \"process_status\": \"exiting\", \"progress\": 0, \"replication_id\": \"replicationId\", \"retry\": false, \"revisions_checked\": 0, \"source\": \"source\", \"source_seq\": \"sourceSeq\", \"started_on\": 0, \"target\": \"target\", \"through_seq\": \"throughSeq\", \"total_changes\": 0, \"type\": \"database_compaction\", \"updated_on\": 0, \"user\": \"user\", \"view\": 0}]"; + String getActiveTasksPath = "/_active_tasks"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostViewOptions model - PostViewOptions postViewOptionsModel = new PostViewOptions.Builder() - .db("testString") - .ddoc("testString") - .view("testString") - .attEncodingInfo(false) - .attachments(false) - .conflicts(false) - .descending(false) - .includeDocs(true) - .inclusiveEnd(true) - .limit(Long.valueOf("10")) - .skip(Long.valueOf("0")) - .updateSeq(false) - .endKey("testString") - .endKeyDocId("testString") - .group(false) - .groupLevel(Long.valueOf("1")) - .key("testString") - .keys(java.util.Arrays.asList("examplekey")) - .reduce(true) - .stable(false) - .startKey("testString") - .startKeyDocId("testString") - .update("true") - .build(); + // Construct an instance of the GetActiveTasksOptions model + GetActiveTasksOptions getActiveTasksOptionsModel = new GetActiveTasksOptions(); - // Invoke postViewAsStream() with a valid options model and verify the result - Response response = cloudantService.postViewAsStream(postViewOptionsModel).execute(); + // Invoke getActiveTasks() with a valid options model and verify the result + Response> response = cloudantService.getActiveTasks(getActiveTasksOptionsModel).execute(); assertNotNull(response); - try (InputStream responseObj = response.getResult();) { - assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); - } + List responseObj = response.getResult(); + assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "POST"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postViewAsStreamPath); + assertEquals(parsedPath, getActiveTasksPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postViewAsStream operation with and without retries enabled + // Test the getActiveTasks operation with and without retries enabled @Test - public void testPostViewAsStreamWRetries() throws Throwable { + public void testGetActiveTasksWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostViewAsStreamWOptions(); + testGetActiveTasksWOptions(); cloudantService.disableRetries(); - testPostViewAsStreamWOptions(); - } - - // Test the postViewAsStream operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostViewAsStreamNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.postViewAsStream(null).execute(); + testGetActiveTasksWOptions(); } - // Test the postViewQueries operation with a valid options model parameter + // Test the getActivityTrackerEvents operation with a valid options model parameter @Test - public void testPostViewQueriesWOptions() throws Throwable { + public void testGetActivityTrackerEventsWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"results\": [{\"total_rows\": 0, \"update_seq\": \"updateSeq\", \"rows\": [{\"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0, \"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"id\": \"id\", \"key\": \"anyValue\", \"value\": \"anyValue\"}]}]}"; - String postViewQueriesPath = "/testString/_design/testString/_view/testString/queries"; + String mockResponseBody = "{\"types\": [\"management\"]}"; + String getActivityTrackerEventsPath = "/_api/v2/user/activity_tracker/events"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the ViewQuery model - ViewQuery viewQueryModel = new ViewQuery.Builder() - .attEncodingInfo(false) - .attachments(false) - .conflicts(false) - .descending(false) - .includeDocs(true) - .inclusiveEnd(true) - .limit(Long.valueOf("5")) - .skip(Long.valueOf("0")) - .updateSeq(false) - .endKey("testString") - .endKeyDocId("testString") - .group(false) - .groupLevel(Long.valueOf("1")) - .key("testString") - .keys(java.util.Arrays.asList("testString")) - .reduce(true) - .stable(false) - .startKey("testString") - .startKeyDocId("testString") - .update("true") - .build(); - - // Construct an instance of the PostViewQueriesOptions model - PostViewQueriesOptions postViewQueriesOptionsModel = new PostViewQueriesOptions.Builder() - .db("testString") - .ddoc("testString") - .view("testString") - .queries(java.util.Arrays.asList(viewQueryModel)) - .build(); + // Construct an instance of the GetActivityTrackerEventsOptions model + GetActivityTrackerEventsOptions getActivityTrackerEventsOptionsModel = new GetActivityTrackerEventsOptions(); - // Invoke postViewQueries() with a valid options model and verify the result - Response response = cloudantService.postViewQueries(postViewQueriesOptionsModel).execute(); + // Invoke getActivityTrackerEvents() with a valid options model and verify the result + Response response = cloudantService.getActivityTrackerEvents(getActivityTrackerEventsOptionsModel).execute(); assertNotNull(response); - ViewQueriesResult responseObj = response.getResult(); + ActivityTrackerEvents responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "POST"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postViewQueriesPath); + assertEquals(parsedPath, getActivityTrackerEventsPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postViewQueries operation with and without retries enabled + // Test the getActivityTrackerEvents operation with and without retries enabled @Test - public void testPostViewQueriesWRetries() throws Throwable { + public void testGetActivityTrackerEventsWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostViewQueriesWOptions(); + testGetActivityTrackerEventsWOptions(); cloudantService.disableRetries(); - testPostViewQueriesWOptions(); - } - - // Test the postViewQueries operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostViewQueriesNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.postViewQueries(null).execute(); + testGetActivityTrackerEventsWOptions(); } - // Test the postViewQueriesAsStream operation with a valid options model parameter + // Test the postActivityTrackerEvents operation with a valid options model parameter @Test - public void testPostViewQueriesAsStreamWOptions() throws Throwable { + public void testPostActivityTrackerEventsWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; - String postViewQueriesAsStreamPath = "/testString/_design/testString/_view/testString/queries"; + String mockResponseBody = "{\"ok\": true}"; + String postActivityTrackerEventsPath = "/_api/v2/user/activity_tracker/events"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the ViewQuery model - ViewQuery viewQueryModel = new ViewQuery.Builder() - .attEncodingInfo(false) - .attachments(false) - .conflicts(false) - .descending(false) - .includeDocs(true) - .inclusiveEnd(true) - .limit(Long.valueOf("5")) - .skip(Long.valueOf("0")) - .updateSeq(false) - .endKey("testString") - .endKeyDocId("testString") - .group(false) - .groupLevel(Long.valueOf("1")) - .key("testString") - .keys(java.util.Arrays.asList("testString")) - .reduce(true) - .stable(false) - .startKey("testString") - .startKeyDocId("testString") - .update("true") - .build(); - - // Construct an instance of the PostViewQueriesOptions model - PostViewQueriesOptions postViewQueriesOptionsModel = new PostViewQueriesOptions.Builder() - .db("testString") - .ddoc("testString") - .view("testString") - .queries(java.util.Arrays.asList(viewQueryModel)) + // Construct an instance of the PostActivityTrackerEventsOptions model + PostActivityTrackerEventsOptions postActivityTrackerEventsOptionsModel = new PostActivityTrackerEventsOptions.Builder() + .types(java.util.Arrays.asList("management", "data")) .build(); - // Invoke postViewQueriesAsStream() with a valid options model and verify the result - Response response = cloudantService.postViewQueriesAsStream(postViewQueriesOptionsModel).execute(); + // Invoke postActivityTrackerEvents() with a valid options model and verify the result + Response response = cloudantService.postActivityTrackerEvents(postActivityTrackerEventsOptionsModel).execute(); assertNotNull(response); - try (InputStream responseObj = response.getResult();) { - assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); - } + Ok responseObj = response.getResult(); + assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); @@ -3001,50 +2879,47 @@ public void testPostViewQueriesAsStreamWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postViewQueriesAsStreamPath); + assertEquals(parsedPath, postActivityTrackerEventsPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postViewQueriesAsStream operation with and without retries enabled + // Test the postActivityTrackerEvents operation with and without retries enabled @Test - public void testPostViewQueriesAsStreamWRetries() throws Throwable { + public void testPostActivityTrackerEventsWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostViewQueriesAsStreamWOptions(); + testPostActivityTrackerEventsWOptions(); cloudantService.disableRetries(); - testPostViewQueriesAsStreamWOptions(); + testPostActivityTrackerEventsWOptions(); } - // Test the postViewQueriesAsStream operation with a null options model (negative test) + // Test the postActivityTrackerEvents operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostViewQueriesAsStreamNoOptions() throws Throwable { + public void testPostActivityTrackerEventsNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postViewQueriesAsStream(null).execute(); + cloudantService.postActivityTrackerEvents(null).execute(); } - // Test the getPartitionInformation operation with a valid options model parameter + // Test the getCapacityDatabasesInformation operation with a valid options model parameter @Test - public void testGetPartitionInformationWOptions() throws Throwable { + public void testGetCapacityDatabasesInformationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"db_name\": \"dbName\", \"doc_count\": 0, \"doc_del_count\": 0, \"partition\": \"partition\", \"partitioned_indexes\": {\"count\": 0, \"indexes\": {\"search\": 0, \"view\": 0}, \"limit\": 0}, \"sizes\": {\"active\": 0, \"external\": 0}}"; - String getPartitionInformationPath = "/testString/_partition/testString"; + String mockResponseBody = "{\"current\": {\"databases\": {\"total\": 0}}}"; + String getCapacityDatabasesInformationPath = "/_api/v2/user/capacity/databases"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetPartitionInformationOptions model - GetPartitionInformationOptions getPartitionInformationOptionsModel = new GetPartitionInformationOptions.Builder() - .db("testString") - .partitionKey("testString") - .build(); + // Construct an instance of the GetCapacityDatabasesInformationOptions model + GetCapacityDatabasesInformationOptions getCapacityDatabasesInformationOptionsModel = new GetCapacityDatabasesInformationOptions(); - // Invoke getPartitionInformation() with a valid options model and verify the result - Response response = cloudantService.getPartitionInformation(getPartitionInformationOptionsModel).execute(); + // Invoke getCapacityDatabasesInformation() with a valid options model and verify the result + Response response = cloudantService.getCapacityDatabasesInformation(getCapacityDatabasesInformationOptionsModel).execute(); assertNotNull(response); - PartitionInformation responseObj = response.getResult(); + CapacityDatabasesInformation responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -3053,308 +2928,269 @@ public void testGetPartitionInformationWOptions() throws Throwable { assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getPartitionInformationPath); + assertEquals(parsedPath, getCapacityDatabasesInformationPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the getPartitionInformation operation with and without retries enabled + // Test the getCapacityDatabasesInformation operation with and without retries enabled @Test - public void testGetPartitionInformationWRetries() throws Throwable { + public void testGetCapacityDatabasesInformationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetPartitionInformationWOptions(); + testGetCapacityDatabasesInformationWOptions(); cloudantService.disableRetries(); - testGetPartitionInformationWOptions(); - } - - // Test the getPartitionInformation operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetPartitionInformationNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.getPartitionInformation(null).execute(); + testGetCapacityDatabasesInformationWOptions(); } - // Test the postPartitionAllDocs operation with a valid options model parameter + // Test the getCurrentDatabasesInformation operation with a valid options model parameter @Test - public void testPostPartitionAllDocsWOptions() throws Throwable { + public void testGetCurrentDatabasesInformationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"total_rows\": 0, \"rows\": [{\"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0, \"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"id\": \"id\", \"key\": \"key\", \"value\": {\"deleted\": false, \"rev\": \"rev\"}}], \"update_seq\": \"updateSeq\"}"; - String postPartitionAllDocsPath = "/testString/_partition/testString/_all_docs"; + String mockResponseBody = "{\"databases\": {\"total\": 0}}"; + String getCurrentDatabasesInformationPath = "/_api/v2/user/current/databases"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostPartitionAllDocsOptions model - PostPartitionAllDocsOptions postPartitionAllDocsOptionsModel = new PostPartitionAllDocsOptions.Builder() - .db("testString") - .partitionKey("testString") - .attEncodingInfo(false) - .attachments(false) - .conflicts(false) - .descending(false) - .includeDocs(false) - .inclusiveEnd(true) - .limit(Long.valueOf("10")) - .skip(Long.valueOf("0")) - .updateSeq(false) - .endKey("testString") - .key("testString") - .keys(java.util.Arrays.asList("testString")) - .startKey("0007741142412418284") - .build(); + // Construct an instance of the GetCurrentDatabasesInformationOptions model + GetCurrentDatabasesInformationOptions getCurrentDatabasesInformationOptionsModel = new GetCurrentDatabasesInformationOptions(); - // Invoke postPartitionAllDocs() with a valid options model and verify the result - Response response = cloudantService.postPartitionAllDocs(postPartitionAllDocsOptionsModel).execute(); + // Invoke getCurrentDatabasesInformation() with a valid options model and verify the result + Response response = cloudantService.getCurrentDatabasesInformation(getCurrentDatabasesInformationOptionsModel).execute(); assertNotNull(response); - AllDocsResult responseObj = response.getResult(); + CurrentDatabasesInformation responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "POST"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postPartitionAllDocsPath); + assertEquals(parsedPath, getCurrentDatabasesInformationPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postPartitionAllDocs operation with and without retries enabled + // Test the getCurrentDatabasesInformation operation with and without retries enabled @Test - public void testPostPartitionAllDocsWRetries() throws Throwable { + public void testGetCurrentDatabasesInformationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostPartitionAllDocsWOptions(); + testGetCurrentDatabasesInformationWOptions(); cloudantService.disableRetries(); - testPostPartitionAllDocsWOptions(); - } - - // Test the postPartitionAllDocs operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostPartitionAllDocsNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.postPartitionAllDocs(null).execute(); + testGetCurrentDatabasesInformationWOptions(); } - // Test the postPartitionAllDocsAsStream operation with a valid options model parameter + // Test the getCurrentThroughputInformation operation with a valid options model parameter @Test - public void testPostPartitionAllDocsAsStreamWOptions() throws Throwable { + public void testGetCurrentThroughputInformationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; - String postPartitionAllDocsAsStreamPath = "/testString/_partition/testString/_all_docs"; + String mockResponseBody = "{\"throughput\": {\"query\": 0, \"read\": 0, \"write\": 0}}"; + String getCurrentThroughputInformationPath = "/_api/v2/user/current/throughput"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostPartitionAllDocsOptions model - PostPartitionAllDocsOptions postPartitionAllDocsOptionsModel = new PostPartitionAllDocsOptions.Builder() - .db("testString") - .partitionKey("testString") - .attEncodingInfo(false) - .attachments(false) - .conflicts(false) - .descending(false) - .includeDocs(false) - .inclusiveEnd(true) - .limit(Long.valueOf("10")) - .skip(Long.valueOf("0")) - .updateSeq(false) - .endKey("testString") - .key("testString") - .keys(java.util.Arrays.asList("testString")) - .startKey("0007741142412418284") - .build(); + // Construct an instance of the GetCurrentThroughputInformationOptions model + GetCurrentThroughputInformationOptions getCurrentThroughputInformationOptionsModel = new GetCurrentThroughputInformationOptions(); - // Invoke postPartitionAllDocsAsStream() with a valid options model and verify the result - Response response = cloudantService.postPartitionAllDocsAsStream(postPartitionAllDocsOptionsModel).execute(); + // Invoke getCurrentThroughputInformation() with a valid options model and verify the result + Response response = cloudantService.getCurrentThroughputInformation(getCurrentThroughputInformationOptionsModel).execute(); assertNotNull(response); - try (InputStream responseObj = response.getResult();) { - assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); - } + CurrentThroughputInformation responseObj = response.getResult(); + assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "POST"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postPartitionAllDocsAsStreamPath); + assertEquals(parsedPath, getCurrentThroughputInformationPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postPartitionAllDocsAsStream operation with and without retries enabled + // Test the getCurrentThroughputInformation operation with and without retries enabled @Test - public void testPostPartitionAllDocsAsStreamWRetries() throws Throwable { + public void testGetCurrentThroughputInformationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostPartitionAllDocsAsStreamWOptions(); + testGetCurrentThroughputInformationWOptions(); cloudantService.disableRetries(); - testPostPartitionAllDocsAsStreamWOptions(); - } - - // Test the postPartitionAllDocsAsStream operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostPartitionAllDocsAsStreamNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.postPartitionAllDocsAsStream(null).execute(); + testGetCurrentThroughputInformationWOptions(); } - // Test the postPartitionSearch operation with a valid options model parameter + // Test the getMembershipInformation operation with a valid options model parameter @Test - public void testPostPartitionSearchWOptions() throws Throwable { + public void testGetMembershipInformationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"total_rows\": 0, \"bookmark\": \"bookmark\", \"by\": \"by\", \"counts\": {\"mapKey\": {\"mapKey\": 0}}, \"ranges\": {\"mapKey\": {\"mapKey\": 0}}, \"rows\": [{\"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"fields\": {\"anyKey\": \"anyValue\"}, \"highlights\": {\"mapKey\": [\"inner\"]}, \"id\": \"id\"}], \"groups\": [{\"total_rows\": 0, \"bookmark\": \"bookmark\", \"by\": \"by\", \"counts\": {\"mapKey\": {\"mapKey\": 0}}, \"ranges\": {\"mapKey\": {\"mapKey\": 0}}, \"rows\": [{\"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"fields\": {\"anyKey\": \"anyValue\"}, \"highlights\": {\"mapKey\": [\"inner\"]}, \"id\": \"id\"}]}]}"; - String postPartitionSearchPath = "/testString/_partition/testString/_design/testString/_search/testString"; + String mockResponseBody = "{\"all_nodes\": [\"allNodes\"], \"cluster_nodes\": [\"clusterNodes\"]}"; + String getMembershipInformationPath = "/_membership"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostPartitionSearchOptions model - PostPartitionSearchOptions postPartitionSearchOptionsModel = new PostPartitionSearchOptions.Builder() - .db("testString") - .partitionKey("testString") - .ddoc("testString") - .index("testString") - .query("name:Jane* AND active:True") - .bookmark("testString") - .highlightFields(java.util.Arrays.asList("testString")) - .highlightNumber(Long.valueOf("1")) - .highlightPostTag("") - .highlightPreTag("") - .highlightSize(Long.valueOf("100")) - .includeDocs(false) - .includeFields(java.util.Arrays.asList("testString")) - .limit(Long.valueOf("3")) - .sort(java.util.Arrays.asList("testString")) - .stale("ok") - .build(); + // Construct an instance of the GetMembershipInformationOptions model + GetMembershipInformationOptions getMembershipInformationOptionsModel = new GetMembershipInformationOptions(); - // Invoke postPartitionSearch() with a valid options model and verify the result - Response response = cloudantService.postPartitionSearch(postPartitionSearchOptionsModel).execute(); + // Invoke getMembershipInformation() with a valid options model and verify the result + Response response = cloudantService.getMembershipInformation(getMembershipInformationOptionsModel).execute(); assertNotNull(response); - SearchResult responseObj = response.getResult(); + MembershipInformation responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "POST"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postPartitionSearchPath); + assertEquals(parsedPath, getMembershipInformationPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postPartitionSearch operation with and without retries enabled + // Test the getMembershipInformation operation with and without retries enabled @Test - public void testPostPartitionSearchWRetries() throws Throwable { + public void testGetMembershipInformationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostPartitionSearchWOptions(); + testGetMembershipInformationWOptions(); cloudantService.disableRetries(); - testPostPartitionSearchWOptions(); - } - - // Test the postPartitionSearch operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostPartitionSearchNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.postPartitionSearch(null).execute(); + testGetMembershipInformationWOptions(); } - // Test the postPartitionSearchAsStream operation with a valid options model parameter + // Test the getUpInformation operation with a valid options model parameter @Test - public void testPostPartitionSearchAsStreamWOptions() throws Throwable { + public void testGetUpInformationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; - String postPartitionSearchAsStreamPath = "/testString/_partition/testString/_design/testString/_search/testString"; + String mockResponseBody = "{\"cluster\": \"cluster\", \"seeds\": {\"anyKey\": \"anyValue\"}, \"status\": \"maintenance_mode\"}"; + String getUpInformationPath = "/_up"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostPartitionSearchOptions model - PostPartitionSearchOptions postPartitionSearchOptionsModel = new PostPartitionSearchOptions.Builder() - .db("testString") - .partitionKey("testString") - .ddoc("testString") - .index("testString") - .query("name:Jane* AND active:True") - .bookmark("testString") - .highlightFields(java.util.Arrays.asList("testString")) - .highlightNumber(Long.valueOf("1")) - .highlightPostTag("") - .highlightPreTag("") - .highlightSize(Long.valueOf("100")) - .includeDocs(false) - .includeFields(java.util.Arrays.asList("testString")) - .limit(Long.valueOf("3")) - .sort(java.util.Arrays.asList("testString")) - .stale("ok") - .build(); + // Construct an instance of the GetUpInformationOptions model + GetUpInformationOptions getUpInformationOptionsModel = new GetUpInformationOptions(); - // Invoke postPartitionSearchAsStream() with a valid options model and verify the result - Response response = cloudantService.postPartitionSearchAsStream(postPartitionSearchOptionsModel).execute(); + // Invoke getUpInformation() with a valid options model and verify the result + Response response = cloudantService.getUpInformation(getUpInformationOptionsModel).execute(); assertNotNull(response); - try (InputStream responseObj = response.getResult();) { - assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); - } + UpInformation responseObj = response.getResult(); + assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "POST"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postPartitionSearchAsStreamPath); + assertEquals(parsedPath, getUpInformationPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postPartitionSearchAsStream operation with and without retries enabled + // Test the getUpInformation operation with and without retries enabled @Test - public void testPostPartitionSearchAsStreamWRetries() throws Throwable { + public void testGetUpInformationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostPartitionSearchAsStreamWOptions(); + testGetUpInformationWOptions(); cloudantService.disableRetries(); - testPostPartitionSearchAsStreamWOptions(); + testGetUpInformationWOptions(); } - // Test the postPartitionSearchAsStream operation with a null options model (negative test) + // Test the postIndexInfo operation with a valid options model parameter + @Test + public void testPostIndexInfoWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"bookmark\": \"bookmark\", \"search_indexes\": [{\"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0, \"ddoc\": \"ddoc\", \"info\": {\"committed_seq\": 0, \"disk_size\": 0, \"doc_count\": 0, \"doc_del_count\": 0, \"pending_seq\": 0, \"signature\": \"signature\", \"updates_pending\": {\"copies\": 0, \"copies_expected\": 0, \"maximum\": 0, \"minimum\": 0, \"preferred\": 0, \"total\": 0}}, \"name\": \"name\"}], \"total_rows\": 0, \"view_indexes\": [{\"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0, \"ddoc\": \"ddoc\", \"info\": {\"collator_versions\": [\"collatorVersions\"], \"compact_running\": true, \"language\": \"language\", \"signature\": \"signature\", \"sizes\": {\"active\": 0, \"external\": 0, \"file\": 0}, \"updater_running\": true, \"updates_pending\": {\"copies\": 0, \"copies_expected\": 0, \"maximum\": 0, \"minimum\": 0, \"preferred\": 0, \"total\": 0}, \"waiting_clients\": 0, \"waiting_commit\": false}, \"views\": [\"views\"]}]}"; + String postIndexInfoPath = "/testString/_index_info"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the PostIndexInfoOptions model + PostIndexInfoOptions postIndexInfoOptionsModel = new PostIndexInfoOptions.Builder() + .db("testString") + .attEncodingInfo(false) + .attachments(false) + .conflicts(false) + .descending(false) + .includeDocs(false) + .inclusiveEnd(true) + .limit(Long.valueOf("0")) + .skip(Long.valueOf("0")) + .updateSeq(false) + .endKey("testString") + .key("testString") + .keys(java.util.Arrays.asList("_design/cookbook")) + .startKey("testString") + .type(java.util.Arrays.asList("search")) + .build(); + + // Invoke postIndexInfo() with a valid options model and verify the result + Response response = cloudantService.postIndexInfo(postIndexInfoOptionsModel).execute(); + assertNotNull(response); + IndexInfoResult responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, postIndexInfoPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the postIndexInfo operation with and without retries enabled + @Test + public void testPostIndexInfoWRetries() throws Throwable { + cloudantService.enableRetries(4, 30); + testPostIndexInfoWOptions(); + + cloudantService.disableRetries(); + testPostIndexInfoWOptions(); + } + + // Test the postIndexInfo operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostPartitionSearchAsStreamNoOptions() throws Throwable { + public void testPostIndexInfoNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postPartitionSearchAsStream(null).execute(); + cloudantService.postIndexInfo(null).execute(); } - // Test the postPartitionView operation with a valid options model parameter + // Test the postView operation with a valid options model parameter @Test - public void testPostPartitionViewWOptions() throws Throwable { + public void testPostViewWOptions() throws Throwable { // Register a mock response String mockResponseBody = "{\"total_rows\": 0, \"update_seq\": \"updateSeq\", \"rows\": [{\"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0, \"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"id\": \"id\", \"key\": \"anyValue\", \"value\": \"anyValue\"}]}"; - String postPartitionViewPath = "/testString/_partition/testString/_design/testString/_view/testString"; + String postViewPath = "/testString/_design/testString/_view/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostPartitionViewOptions model - PostPartitionViewOptions postPartitionViewOptionsModel = new PostPartitionViewOptions.Builder() + // Construct an instance of the PostViewOptions model + PostViewOptions postViewOptionsModel = new PostViewOptions.Builder() .db("testString") - .partitionKey("testString") .ddoc("testString") .view("testString") .attEncodingInfo(false) @@ -3373,13 +3209,14 @@ public void testPostPartitionViewWOptions() throws Throwable { .key("testString") .keys(java.util.Arrays.asList("examplekey")) .reduce(true) + .stable(false) .startKey("testString") .startKeyDocId("testString") .update("true") .build(); - // Invoke postPartitionView() with a valid options model and verify the result - Response response = cloudantService.postPartitionView(postPartitionViewOptionsModel).execute(); + // Invoke postView() with a valid options model and verify the result + Response response = cloudantService.postView(postViewOptionsModel).execute(); assertNotNull(response); ViewResult responseObj = response.getResult(); assertNotNull(responseObj); @@ -3390,44 +3227,43 @@ public void testPostPartitionViewWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postPartitionViewPath); + assertEquals(parsedPath, postViewPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postPartitionView operation with and without retries enabled + // Test the postView operation with and without retries enabled @Test - public void testPostPartitionViewWRetries() throws Throwable { + public void testPostViewWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostPartitionViewWOptions(); + testPostViewWOptions(); cloudantService.disableRetries(); - testPostPartitionViewWOptions(); + testPostViewWOptions(); } - // Test the postPartitionView operation with a null options model (negative test) + // Test the postView operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostPartitionViewNoOptions() throws Throwable { + public void testPostViewNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postPartitionView(null).execute(); + cloudantService.postView(null).execute(); } - // Test the postPartitionViewAsStream operation with a valid options model parameter + // Test the postViewAsStream operation with a valid options model parameter @Test - public void testPostPartitionViewAsStreamWOptions() throws Throwable { + public void testPostViewAsStreamWOptions() throws Throwable { // Register a mock response String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; - String postPartitionViewAsStreamPath = "/testString/_partition/testString/_design/testString/_view/testString"; + String postViewAsStreamPath = "/testString/_design/testString/_view/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostPartitionViewOptions model - PostPartitionViewOptions postPartitionViewOptionsModel = new PostPartitionViewOptions.Builder() + // Construct an instance of the PostViewOptions model + PostViewOptions postViewOptionsModel = new PostViewOptions.Builder() .db("testString") - .partitionKey("testString") .ddoc("testString") .view("testString") .attEncodingInfo(false) @@ -3446,13 +3282,14 @@ public void testPostPartitionViewAsStreamWOptions() throws Throwable { .key("testString") .keys(java.util.Arrays.asList("examplekey")) .reduce(true) + .stable(false) .startKey("testString") .startKeyDocId("testString") .update("true") .build(); - // Invoke postPartitionViewAsStream() with a valid options model and verify the result - Response response = cloudantService.postPartitionViewAsStream(postPartitionViewOptionsModel).execute(); + // Invoke postViewAsStream() with a valid options model and verify the result + Response response = cloudantService.postViewAsStream(postViewOptionsModel).execute(); assertNotNull(response); try (InputStream responseObj = response.getResult();) { assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); @@ -3464,62 +3301,76 @@ public void testPostPartitionViewAsStreamWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postPartitionViewAsStreamPath); + assertEquals(parsedPath, postViewAsStreamPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postPartitionViewAsStream operation with and without retries enabled + // Test the postViewAsStream operation with and without retries enabled @Test - public void testPostPartitionViewAsStreamWRetries() throws Throwable { + public void testPostViewAsStreamWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostPartitionViewAsStreamWOptions(); + testPostViewAsStreamWOptions(); cloudantService.disableRetries(); - testPostPartitionViewAsStreamWOptions(); + testPostViewAsStreamWOptions(); } - // Test the postPartitionViewAsStream operation with a null options model (negative test) + // Test the postViewAsStream operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostPartitionViewAsStreamNoOptions() throws Throwable { + public void testPostViewAsStreamNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postPartitionViewAsStream(null).execute(); + cloudantService.postViewAsStream(null).execute(); } - // Test the postPartitionExplain operation with a valid options model parameter + // Test the postViewQueries operation with a valid options model parameter @Test - public void testPostPartitionExplainWOptions() throws Throwable { + public void testPostViewQueriesWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"covering\": true, \"dbname\": \"dbname\", \"fields\": [\"fields\"], \"index\": {\"ddoc\": \"ddoc\", \"def\": {\"default_analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"default_field\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"enabled\": true}, \"fields\": [{\"name\": \"name\", \"type\": \"boolean\"}], \"index_array_lengths\": true, \"partial_filter_selector\": {\"anyKey\": \"anyValue\"}}, \"name\": \"name\", \"partitioned\": false, \"type\": \"json\"}, \"index_candidates\": [{\"analysis\": {\"covering\": true, \"ranking\": 1, \"reasons\": [{\"name\": \"alphabetically_comes_after\"}], \"usable\": true}, \"index\": {\"ddoc\": \"ddoc\", \"def\": {\"default_analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"default_field\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"enabled\": true}, \"fields\": [{\"name\": \"name\", \"type\": \"boolean\"}], \"index_array_lengths\": true, \"partial_filter_selector\": {\"anyKey\": \"anyValue\"}}, \"name\": \"name\", \"partitioned\": false, \"type\": \"json\"}}], \"limit\": 25, \"mrargs\": {\"conflicts\": \"anyValue\", \"direction\": \"fwd\", \"end_key\": \"anyValue\", \"include_docs\": false, \"partition\": \"partition\", \"reduce\": true, \"stable\": true, \"start_key\": \"anyValue\", \"update\": \"anyValue\", \"view_type\": \"map\"}, \"opts\": {\"bookmark\": \"bookmark\", \"conflicts\": false, \"execution_stats\": false, \"fields\": [\"fields\"], \"limit\": 25, \"partition\": \"partition\", \"r\": 1, \"skip\": 0, \"sort\": \"anyValue\", \"stable\": false, \"stale\": false, \"update\": true, \"use_index\": [\"useIndex\"]}, \"partitioned\": \"anyValue\", \"selector\": {\"anyKey\": \"anyValue\"}, \"selector_hints\": [{\"indexable_fields\": [\"indexableFields\"], \"type\": \"json\", \"unindexable_fields\": [\"unindexableFields\"]}], \"skip\": 0}"; - String postPartitionExplainPath = "/testString/_partition/testString/_explain"; + String mockResponseBody = "{\"results\": [{\"total_rows\": 0, \"update_seq\": \"updateSeq\", \"rows\": [{\"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0, \"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"id\": \"id\", \"key\": \"anyValue\", \"value\": \"anyValue\"}]}]}"; + String postViewQueriesPath = "/testString/_design/testString/_view/testString/queries"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostPartitionExplainOptions model - PostPartitionExplainOptions postPartitionExplainOptionsModel = new PostPartitionExplainOptions.Builder() - .db("testString") - .partitionKey("testString") - .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) - .allowFallback(true) - .bookmark("testString") - .conflicts(true) - .executionStats(true) - .fields(java.util.Arrays.asList("productId", "name", "description")) - .limit(Long.valueOf("25")) + // Construct an instance of the ViewQuery model + ViewQuery viewQueryModel = new ViewQuery.Builder() + .attEncodingInfo(false) + .attachments(false) + .conflicts(false) + .descending(false) + .includeDocs(true) + .inclusiveEnd(true) + .limit(Long.valueOf("5")) .skip(Long.valueOf("0")) - .sort(java.util.Arrays.asList(java.util.Collections.singletonMap("key1", "asc"))) - .stable(true) + .updateSeq(false) + .endKey("testString") + .endKeyDocId("testString") + .group(false) + .groupLevel(Long.valueOf("1")) + .key("testString") + .keys(java.util.Arrays.asList("testString")) + .reduce(true) + .stable(false) + .startKey("testString") + .startKeyDocId("testString") .update("true") - .useIndex(java.util.Arrays.asList("testString")) .build(); - // Invoke postPartitionExplain() with a valid options model and verify the result - Response response = cloudantService.postPartitionExplain(postPartitionExplainOptionsModel).execute(); + // Construct an instance of the PostViewQueriesOptions model + PostViewQueriesOptions postViewQueriesOptionsModel = new PostViewQueriesOptions.Builder() + .db("testString") + .ddoc("testString") + .view("testString") + .queries(java.util.Arrays.asList(viewQueryModel)) + .build(); + + // Invoke postViewQueries() with a valid options model and verify the result + Response response = cloudantService.postViewQueries(postViewQueriesOptionsModel).execute(); assertNotNull(response); - ExplainResult responseObj = response.getResult(); + ViewQueriesResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -3528,63 +3379,78 @@ public void testPostPartitionExplainWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postPartitionExplainPath); + assertEquals(parsedPath, postViewQueriesPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postPartitionExplain operation with and without retries enabled + // Test the postViewQueries operation with and without retries enabled @Test - public void testPostPartitionExplainWRetries() throws Throwable { + public void testPostViewQueriesWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostPartitionExplainWOptions(); + testPostViewQueriesWOptions(); cloudantService.disableRetries(); - testPostPartitionExplainWOptions(); + testPostViewQueriesWOptions(); } - // Test the postPartitionExplain operation with a null options model (negative test) + // Test the postViewQueries operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostPartitionExplainNoOptions() throws Throwable { + public void testPostViewQueriesNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postPartitionExplain(null).execute(); + cloudantService.postViewQueries(null).execute(); } - // Test the postPartitionFind operation with a valid options model parameter + // Test the postViewQueriesAsStream operation with a valid options model parameter @Test - public void testPostPartitionFindWOptions() throws Throwable { + public void testPostViewQueriesAsStreamWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"bookmark\": \"bookmark\", \"docs\": [{\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}], \"execution_stats\": {\"execution_time_ms\": 15, \"results_returned\": 0, \"total_docs_examined\": 0, \"total_keys_examined\": 0, \"total_quorum_docs_examined\": 0}, \"warning\": \"warning\"}"; - String postPartitionFindPath = "/testString/_partition/testString/_find"; + String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; + String postViewQueriesAsStreamPath = "/testString/_design/testString/_view/testString/queries"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostPartitionFindOptions model - PostPartitionFindOptions postPartitionFindOptionsModel = new PostPartitionFindOptions.Builder() - .db("testString") - .partitionKey("testString") - .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) - .allowFallback(true) - .bookmark("testString") - .conflicts(true) - .executionStats(true) - .fields(java.util.Arrays.asList("productId", "name", "description")) - .limit(Long.valueOf("25")) + // Construct an instance of the ViewQuery model + ViewQuery viewQueryModel = new ViewQuery.Builder() + .attEncodingInfo(false) + .attachments(false) + .conflicts(false) + .descending(false) + .includeDocs(true) + .inclusiveEnd(true) + .limit(Long.valueOf("5")) .skip(Long.valueOf("0")) - .sort(java.util.Arrays.asList(java.util.Collections.singletonMap("key1", "asc"))) - .stable(true) + .updateSeq(false) + .endKey("testString") + .endKeyDocId("testString") + .group(false) + .groupLevel(Long.valueOf("1")) + .key("testString") + .keys(java.util.Arrays.asList("testString")) + .reduce(true) + .stable(false) + .startKey("testString") + .startKeyDocId("testString") .update("true") - .useIndex(java.util.Arrays.asList("testString")) .build(); - // Invoke postPartitionFind() with a valid options model and verify the result - Response response = cloudantService.postPartitionFind(postPartitionFindOptionsModel).execute(); + // Construct an instance of the PostViewQueriesOptions model + PostViewQueriesOptions postViewQueriesOptionsModel = new PostViewQueriesOptions.Builder() + .db("testString") + .ddoc("testString") + .view("testString") + .queries(java.util.Arrays.asList(viewQueryModel)) + .build(); + + // Invoke postViewQueriesAsStream() with a valid options model and verify the result + Response response = cloudantService.postViewQueriesAsStream(postViewQueriesOptionsModel).execute(); assertNotNull(response); - FindResult responseObj = response.getResult(); - assertNotNull(responseObj); + try (InputStream responseObj = response.getResult();) { + assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); + } // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); @@ -3592,127 +3458,115 @@ public void testPostPartitionFindWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postPartitionFindPath); + assertEquals(parsedPath, postViewQueriesAsStreamPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postPartitionFind operation with and without retries enabled + // Test the postViewQueriesAsStream operation with and without retries enabled @Test - public void testPostPartitionFindWRetries() throws Throwable { + public void testPostViewQueriesAsStreamWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostPartitionFindWOptions(); + testPostViewQueriesAsStreamWOptions(); cloudantService.disableRetries(); - testPostPartitionFindWOptions(); + testPostViewQueriesAsStreamWOptions(); } - // Test the postPartitionFind operation with a null options model (negative test) + // Test the postViewQueriesAsStream operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostPartitionFindNoOptions() throws Throwable { + public void testPostViewQueriesAsStreamNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postPartitionFind(null).execute(); + cloudantService.postViewQueriesAsStream(null).execute(); } - // Test the postPartitionFindAsStream operation with a valid options model parameter + // Test the getPartitionInformation operation with a valid options model parameter @Test - public void testPostPartitionFindAsStreamWOptions() throws Throwable { + public void testGetPartitionInformationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; - String postPartitionFindAsStreamPath = "/testString/_partition/testString/_find"; + String mockResponseBody = "{\"db_name\": \"dbName\", \"doc_count\": 0, \"doc_del_count\": 0, \"partition\": \"partition\", \"partitioned_indexes\": {\"count\": 0, \"indexes\": {\"search\": 0, \"view\": 0}, \"limit\": 0}, \"sizes\": {\"active\": 0, \"external\": 0}}"; + String getPartitionInformationPath = "/testString/_partition/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostPartitionFindOptions model - PostPartitionFindOptions postPartitionFindOptionsModel = new PostPartitionFindOptions.Builder() + // Construct an instance of the GetPartitionInformationOptions model + GetPartitionInformationOptions getPartitionInformationOptionsModel = new GetPartitionInformationOptions.Builder() .db("testString") .partitionKey("testString") - .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) - .allowFallback(true) - .bookmark("testString") - .conflicts(true) - .executionStats(true) - .fields(java.util.Arrays.asList("productId", "name", "description")) - .limit(Long.valueOf("25")) - .skip(Long.valueOf("0")) - .sort(java.util.Arrays.asList(java.util.Collections.singletonMap("key1", "asc"))) - .stable(true) - .update("true") - .useIndex(java.util.Arrays.asList("testString")) .build(); - // Invoke postPartitionFindAsStream() with a valid options model and verify the result - Response response = cloudantService.postPartitionFindAsStream(postPartitionFindOptionsModel).execute(); + // Invoke getPartitionInformation() with a valid options model and verify the result + Response response = cloudantService.getPartitionInformation(getPartitionInformationOptionsModel).execute(); assertNotNull(response); - try (InputStream responseObj = response.getResult();) { - assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); - } + PartitionInformation responseObj = response.getResult(); + assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "POST"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postPartitionFindAsStreamPath); + assertEquals(parsedPath, getPartitionInformationPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postPartitionFindAsStream operation with and without retries enabled + // Test the getPartitionInformation operation with and without retries enabled @Test - public void testPostPartitionFindAsStreamWRetries() throws Throwable { + public void testGetPartitionInformationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostPartitionFindAsStreamWOptions(); + testGetPartitionInformationWOptions(); cloudantService.disableRetries(); - testPostPartitionFindAsStreamWOptions(); + testGetPartitionInformationWOptions(); } - // Test the postPartitionFindAsStream operation with a null options model (negative test) + // Test the getPartitionInformation operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostPartitionFindAsStreamNoOptions() throws Throwable { + public void testGetPartitionInformationNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postPartitionFindAsStream(null).execute(); + cloudantService.getPartitionInformation(null).execute(); } - // Test the postExplain operation with a valid options model parameter + // Test the postPartitionAllDocs operation with a valid options model parameter @Test - public void testPostExplainWOptions() throws Throwable { + public void testPostPartitionAllDocsWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"covering\": true, \"dbname\": \"dbname\", \"fields\": [\"fields\"], \"index\": {\"ddoc\": \"ddoc\", \"def\": {\"default_analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"default_field\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"enabled\": true}, \"fields\": [{\"name\": \"name\", \"type\": \"boolean\"}], \"index_array_lengths\": true, \"partial_filter_selector\": {\"anyKey\": \"anyValue\"}}, \"name\": \"name\", \"partitioned\": false, \"type\": \"json\"}, \"index_candidates\": [{\"analysis\": {\"covering\": true, \"ranking\": 1, \"reasons\": [{\"name\": \"alphabetically_comes_after\"}], \"usable\": true}, \"index\": {\"ddoc\": \"ddoc\", \"def\": {\"default_analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"default_field\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"enabled\": true}, \"fields\": [{\"name\": \"name\", \"type\": \"boolean\"}], \"index_array_lengths\": true, \"partial_filter_selector\": {\"anyKey\": \"anyValue\"}}, \"name\": \"name\", \"partitioned\": false, \"type\": \"json\"}}], \"limit\": 25, \"mrargs\": {\"conflicts\": \"anyValue\", \"direction\": \"fwd\", \"end_key\": \"anyValue\", \"include_docs\": false, \"partition\": \"partition\", \"reduce\": true, \"stable\": true, \"start_key\": \"anyValue\", \"update\": \"anyValue\", \"view_type\": \"map\"}, \"opts\": {\"bookmark\": \"bookmark\", \"conflicts\": false, \"execution_stats\": false, \"fields\": [\"fields\"], \"limit\": 25, \"partition\": \"partition\", \"r\": 1, \"skip\": 0, \"sort\": \"anyValue\", \"stable\": false, \"stale\": false, \"update\": true, \"use_index\": [\"useIndex\"]}, \"partitioned\": \"anyValue\", \"selector\": {\"anyKey\": \"anyValue\"}, \"selector_hints\": [{\"indexable_fields\": [\"indexableFields\"], \"type\": \"json\", \"unindexable_fields\": [\"unindexableFields\"]}], \"skip\": 0}"; - String postExplainPath = "/testString/_explain"; + String mockResponseBody = "{\"total_rows\": 0, \"rows\": [{\"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0, \"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"id\": \"id\", \"key\": \"key\", \"value\": {\"deleted\": false, \"rev\": \"rev\"}}], \"update_seq\": \"updateSeq\"}"; + String postPartitionAllDocsPath = "/testString/_partition/testString/_all_docs"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostExplainOptions model - PostExplainOptions postExplainOptionsModel = new PostExplainOptions.Builder() + // Construct an instance of the PostPartitionAllDocsOptions model + PostPartitionAllDocsOptions postPartitionAllDocsOptionsModel = new PostPartitionAllDocsOptions.Builder() .db("testString") - .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) - .allowFallback(true) - .bookmark("testString") - .conflicts(true) - .executionStats(true) - .fields(java.util.Arrays.asList("_id", "type", "name", "email")) - .limit(Long.valueOf("3")) + .partitionKey("testString") + .attEncodingInfo(false) + .attachments(false) + .conflicts(false) + .descending(false) + .includeDocs(false) + .inclusiveEnd(true) + .limit(Long.valueOf("10")) .skip(Long.valueOf("0")) - .sort(java.util.Arrays.asList(java.util.Collections.singletonMap("key1", "asc"))) - .stable(true) - .update("true") - .useIndex(java.util.Arrays.asList("testString")) - .r(Long.valueOf("1")) + .updateSeq(false) + .endKey("testString") + .key("testString") + .keys(java.util.Arrays.asList("testString")) + .startKey("0007741142412418284") .build(); - // Invoke postExplain() with a valid options model and verify the result - Response response = cloudantService.postExplain(postExplainOptionsModel).execute(); + // Invoke postPartitionAllDocs() with a valid options model and verify the result + Response response = cloudantService.postPartitionAllDocs(postPartitionAllDocsOptionsModel).execute(); assertNotNull(response); - ExplainResult responseObj = response.getResult(); + AllDocsResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -3721,63 +3575,65 @@ public void testPostExplainWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postExplainPath); + assertEquals(parsedPath, postPartitionAllDocsPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postExplain operation with and without retries enabled + // Test the postPartitionAllDocs operation with and without retries enabled @Test - public void testPostExplainWRetries() throws Throwable { + public void testPostPartitionAllDocsWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostExplainWOptions(); + testPostPartitionAllDocsWOptions(); cloudantService.disableRetries(); - testPostExplainWOptions(); + testPostPartitionAllDocsWOptions(); } - // Test the postExplain operation with a null options model (negative test) + // Test the postPartitionAllDocs operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostExplainNoOptions() throws Throwable { + public void testPostPartitionAllDocsNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postExplain(null).execute(); + cloudantService.postPartitionAllDocs(null).execute(); } - // Test the postFind operation with a valid options model parameter + // Test the postPartitionAllDocsAsStream operation with a valid options model parameter @Test - public void testPostFindWOptions() throws Throwable { + public void testPostPartitionAllDocsAsStreamWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"bookmark\": \"bookmark\", \"docs\": [{\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}], \"execution_stats\": {\"execution_time_ms\": 15, \"results_returned\": 0, \"total_docs_examined\": 0, \"total_keys_examined\": 0, \"total_quorum_docs_examined\": 0}, \"warning\": \"warning\"}"; - String postFindPath = "/testString/_find"; + String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; + String postPartitionAllDocsAsStreamPath = "/testString/_partition/testString/_all_docs"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostFindOptions model - PostFindOptions postFindOptionsModel = new PostFindOptions.Builder() + // Construct an instance of the PostPartitionAllDocsOptions model + PostPartitionAllDocsOptions postPartitionAllDocsOptionsModel = new PostPartitionAllDocsOptions.Builder() .db("testString") - .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) - .allowFallback(true) - .bookmark("testString") - .conflicts(true) - .executionStats(true) - .fields(java.util.Arrays.asList("_id", "type", "name", "email")) - .limit(Long.valueOf("3")) + .partitionKey("testString") + .attEncodingInfo(false) + .attachments(false) + .conflicts(false) + .descending(false) + .includeDocs(false) + .inclusiveEnd(true) + .limit(Long.valueOf("10")) .skip(Long.valueOf("0")) - .sort(java.util.Arrays.asList(java.util.Collections.singletonMap("key1", "asc"))) - .stable(true) - .update("true") - .useIndex(java.util.Arrays.asList("testString")) - .r(Long.valueOf("1")) + .updateSeq(false) + .endKey("testString") + .key("testString") + .keys(java.util.Arrays.asList("testString")) + .startKey("0007741142412418284") .build(); - // Invoke postFind() with a valid options model and verify the result - Response response = cloudantService.postFind(postFindOptionsModel).execute(); + // Invoke postPartitionAllDocsAsStream() with a valid options model and verify the result + Response response = cloudantService.postPartitionAllDocsAsStream(postPartitionAllDocsOptionsModel).execute(); assertNotNull(response); - FindResult responseObj = response.getResult(); - assertNotNull(responseObj); + try (InputStream responseObj = response.getResult();) { + assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); + } // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); @@ -3785,64 +3641,65 @@ public void testPostFindWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postFindPath); + assertEquals(parsedPath, postPartitionAllDocsAsStreamPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postFind operation with and without retries enabled + // Test the postPartitionAllDocsAsStream operation with and without retries enabled @Test - public void testPostFindWRetries() throws Throwable { + public void testPostPartitionAllDocsAsStreamWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostFindWOptions(); + testPostPartitionAllDocsAsStreamWOptions(); cloudantService.disableRetries(); - testPostFindWOptions(); + testPostPartitionAllDocsAsStreamWOptions(); } - // Test the postFind operation with a null options model (negative test) + // Test the postPartitionAllDocsAsStream operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostFindNoOptions() throws Throwable { + public void testPostPartitionAllDocsAsStreamNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postFind(null).execute(); + cloudantService.postPartitionAllDocsAsStream(null).execute(); } - // Test the postFindAsStream operation with a valid options model parameter + // Test the postPartitionSearch operation with a valid options model parameter @Test - public void testPostFindAsStreamWOptions() throws Throwable { + public void testPostPartitionSearchWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; - String postFindAsStreamPath = "/testString/_find"; + String mockResponseBody = "{\"total_rows\": 0, \"bookmark\": \"bookmark\", \"by\": \"by\", \"counts\": {\"mapKey\": {\"mapKey\": 0}}, \"ranges\": {\"mapKey\": {\"mapKey\": 0}}, \"rows\": [{\"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"fields\": {\"anyKey\": \"anyValue\"}, \"highlights\": {\"mapKey\": [\"inner\"]}, \"id\": \"id\"}], \"groups\": [{\"total_rows\": 0, \"bookmark\": \"bookmark\", \"by\": \"by\", \"counts\": {\"mapKey\": {\"mapKey\": 0}}, \"ranges\": {\"mapKey\": {\"mapKey\": 0}}, \"rows\": [{\"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"fields\": {\"anyKey\": \"anyValue\"}, \"highlights\": {\"mapKey\": [\"inner\"]}, \"id\": \"id\"}]}]}"; + String postPartitionSearchPath = "/testString/_partition/testString/_design/testString/_search/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostFindOptions model - PostFindOptions postFindOptionsModel = new PostFindOptions.Builder() + // Construct an instance of the PostPartitionSearchOptions model + PostPartitionSearchOptions postPartitionSearchOptionsModel = new PostPartitionSearchOptions.Builder() .db("testString") - .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) - .allowFallback(true) + .partitionKey("testString") + .ddoc("testString") + .index("testString") + .query("name:Jane* AND active:True") .bookmark("testString") - .conflicts(true) - .executionStats(true) - .fields(java.util.Arrays.asList("_id", "type", "name", "email")) + .highlightFields(java.util.Arrays.asList("testString")) + .highlightNumber(Long.valueOf("1")) + .highlightPostTag("") + .highlightPreTag("") + .highlightSize(Long.valueOf("100")) + .includeDocs(false) + .includeFields(java.util.Arrays.asList("testString")) .limit(Long.valueOf("3")) - .skip(Long.valueOf("0")) - .sort(java.util.Arrays.asList(java.util.Collections.singletonMap("key1", "asc"))) - .stable(true) - .update("true") - .useIndex(java.util.Arrays.asList("testString")) - .r(Long.valueOf("1")) + .sort(java.util.Arrays.asList("testString")) + .stale("ok") .build(); - // Invoke postFindAsStream() with a valid options model and verify the result - Response response = cloudantService.postFindAsStream(postFindOptionsModel).execute(); + // Invoke postPartitionSearch() with a valid options model and verify the result + Response response = cloudantService.postPartitionSearch(postPartitionSearchOptionsModel).execute(); assertNotNull(response); - try (InputStream responseObj = response.getResult();) { - assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); - } + SearchResult responseObj = response.getResult(); + assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); @@ -3850,133 +3707,138 @@ public void testPostFindAsStreamWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postFindAsStreamPath); + assertEquals(parsedPath, postPartitionSearchPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postFindAsStream operation with and without retries enabled + // Test the postPartitionSearch operation with and without retries enabled @Test - public void testPostFindAsStreamWRetries() throws Throwable { + public void testPostPartitionSearchWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostFindAsStreamWOptions(); + testPostPartitionSearchWOptions(); cloudantService.disableRetries(); - testPostFindAsStreamWOptions(); + testPostPartitionSearchWOptions(); } - // Test the postFindAsStream operation with a null options model (negative test) + // Test the postPartitionSearch operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostFindAsStreamNoOptions() throws Throwable { + public void testPostPartitionSearchNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postFindAsStream(null).execute(); + cloudantService.postPartitionSearch(null).execute(); } - // Test the getIndexesInformation operation with a valid options model parameter + // Test the postPartitionSearchAsStream operation with a valid options model parameter @Test - public void testGetIndexesInformationWOptions() throws Throwable { + public void testPostPartitionSearchAsStreamWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"total_rows\": 0, \"indexes\": [{\"ddoc\": \"ddoc\", \"def\": {\"default_analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"default_field\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"enabled\": true}, \"fields\": [{\"name\": \"name\", \"type\": \"boolean\"}], \"index_array_lengths\": true, \"partial_filter_selector\": {\"anyKey\": \"anyValue\"}}, \"name\": \"name\", \"partitioned\": false, \"type\": \"json\"}]}"; - String getIndexesInformationPath = "/testString/_index"; + String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; + String postPartitionSearchAsStreamPath = "/testString/_partition/testString/_design/testString/_search/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetIndexesInformationOptions model - GetIndexesInformationOptions getIndexesInformationOptionsModel = new GetIndexesInformationOptions.Builder() + // Construct an instance of the PostPartitionSearchOptions model + PostPartitionSearchOptions postPartitionSearchOptionsModel = new PostPartitionSearchOptions.Builder() .db("testString") - .build(); - - // Invoke getIndexesInformation() with a valid options model and verify the result - Response response = cloudantService.getIndexesInformation(getIndexesInformationOptionsModel).execute(); - assertNotNull(response); - IndexesInformation responseObj = response.getResult(); - assertNotNull(responseObj); - - // Verify the contents of the request sent to the mock server - RecordedRequest request = server.takeRequest(); - assertNotNull(request); - assertEquals(request.getMethod(), "GET"); + .partitionKey("testString") + .ddoc("testString") + .index("testString") + .query("name:Jane* AND active:True") + .bookmark("testString") + .highlightFields(java.util.Arrays.asList("testString")) + .highlightNumber(Long.valueOf("1")) + .highlightPostTag("") + .highlightPreTag("") + .highlightSize(Long.valueOf("100")) + .includeDocs(false) + .includeFields(java.util.Arrays.asList("testString")) + .limit(Long.valueOf("3")) + .sort(java.util.Arrays.asList("testString")) + .stale("ok") + .build(); + + // Invoke postPartitionSearchAsStream() with a valid options model and verify the result + Response response = cloudantService.postPartitionSearchAsStream(postPartitionSearchOptionsModel).execute(); + assertNotNull(response); + try (InputStream responseObj = response.getResult();) { + assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); + } + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getIndexesInformationPath); + assertEquals(parsedPath, postPartitionSearchAsStreamPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the getIndexesInformation operation with and without retries enabled + // Test the postPartitionSearchAsStream operation with and without retries enabled @Test - public void testGetIndexesInformationWRetries() throws Throwable { + public void testPostPartitionSearchAsStreamWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetIndexesInformationWOptions(); + testPostPartitionSearchAsStreamWOptions(); cloudantService.disableRetries(); - testGetIndexesInformationWOptions(); + testPostPartitionSearchAsStreamWOptions(); } - // Test the getIndexesInformation operation with a null options model (negative test) + // Test the postPartitionSearchAsStream operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetIndexesInformationNoOptions() throws Throwable { + public void testPostPartitionSearchAsStreamNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.getIndexesInformation(null).execute(); + cloudantService.postPartitionSearchAsStream(null).execute(); } - // Test the postIndex operation with a valid options model parameter + // Test the postPartitionView operation with a valid options model parameter @Test - public void testPostIndexWOptions() throws Throwable { + public void testPostPartitionViewWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"name\": \"name\", \"result\": \"created\"}"; - String postIndexPath = "/testString/_index"; + String mockResponseBody = "{\"total_rows\": 0, \"update_seq\": \"updateSeq\", \"rows\": [{\"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0, \"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"id\": \"id\", \"key\": \"anyValue\", \"value\": \"anyValue\"}]}"; + String postPartitionViewPath = "/testString/_partition/testString/_design/testString/_view/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the Analyzer model - Analyzer analyzerModel = new Analyzer.Builder() - .name("classic") - .stopwords(java.util.Arrays.asList("testString")) - .build(); - - // Construct an instance of the IndexTextOperatorDefaultField model - IndexTextOperatorDefaultField indexTextOperatorDefaultFieldModel = new IndexTextOperatorDefaultField.Builder() - .analyzer(analyzerModel) - .enabled(true) - .build(); - - // Construct an instance of the IndexField model - IndexField indexFieldModel = new IndexField.Builder() - .name("asc") - .type("boolean") - .add("foo", "asc") - .build(); - - // Construct an instance of the IndexDefinition model - IndexDefinition indexDefinitionModel = new IndexDefinition.Builder() - .defaultAnalyzer(analyzerModel) - .defaultField(indexTextOperatorDefaultFieldModel) - .fields(java.util.Arrays.asList(indexFieldModel)) - .indexArrayLengths(true) - .partialFilterSelector(java.util.Collections.singletonMap("anyKey", "anyValue")) - .build(); - - // Construct an instance of the PostIndexOptions model - PostIndexOptions postIndexOptionsModel = new PostIndexOptions.Builder() + // Construct an instance of the PostPartitionViewOptions model + PostPartitionViewOptions postPartitionViewOptionsModel = new PostPartitionViewOptions.Builder() .db("testString") - .index(indexDefinitionModel) - .ddoc("json-index") - .name("getUserByName") - .partitioned(true) - .type("json") + .partitionKey("testString") + .ddoc("testString") + .view("testString") + .attEncodingInfo(false) + .attachments(false) + .conflicts(false) + .descending(false) + .includeDocs(true) + .inclusiveEnd(true) + .limit(Long.valueOf("10")) + .skip(Long.valueOf("0")) + .updateSeq(false) + .endKey("testString") + .endKeyDocId("testString") + .group(false) + .groupLevel(Long.valueOf("1")) + .key("testString") + .keys(java.util.Arrays.asList("examplekey")) + .reduce(true) + .startKey("testString") + .startKeyDocId("testString") + .update("true") .build(); - // Invoke postIndex() with a valid options model and verify the result - Response response = cloudantService.postIndex(postIndexOptionsModel).execute(); + // Invoke postPartitionView() with a valid options model and verify the result + Response response = cloudantService.postPartitionView(postPartitionViewOptionsModel).execute(); assertNotNull(response); - IndexResult responseObj = response.getResult(); + ViewResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -3985,104 +3847,136 @@ public void testPostIndexWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postIndexPath); + assertEquals(parsedPath, postPartitionViewPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postIndex operation with and without retries enabled + // Test the postPartitionView operation with and without retries enabled @Test - public void testPostIndexWRetries() throws Throwable { + public void testPostPartitionViewWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostIndexWOptions(); + testPostPartitionViewWOptions(); cloudantService.disableRetries(); - testPostIndexWOptions(); + testPostPartitionViewWOptions(); } - // Test the postIndex operation with a null options model (negative test) + // Test the postPartitionView operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostIndexNoOptions() throws Throwable { + public void testPostPartitionViewNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postIndex(null).execute(); + cloudantService.postPartitionView(null).execute(); } - // Test the deleteIndex operation with a valid options model parameter + // Test the postPartitionViewAsStream operation with a valid options model parameter @Test - public void testDeleteIndexWOptions() throws Throwable { + public void testPostPartitionViewAsStreamWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"ok\": true}"; - String deleteIndexPath = "/testString/_index/_design/testString/json/testString"; + String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; + String postPartitionViewAsStreamPath = "/testString/_partition/testString/_design/testString/_view/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the DeleteIndexOptions model - DeleteIndexOptions deleteIndexOptionsModel = new DeleteIndexOptions.Builder() + // Construct an instance of the PostPartitionViewOptions model + PostPartitionViewOptions postPartitionViewOptionsModel = new PostPartitionViewOptions.Builder() .db("testString") + .partitionKey("testString") .ddoc("testString") - .type("json") - .index("testString") + .view("testString") + .attEncodingInfo(false) + .attachments(false) + .conflicts(false) + .descending(false) + .includeDocs(true) + .inclusiveEnd(true) + .limit(Long.valueOf("10")) + .skip(Long.valueOf("0")) + .updateSeq(false) + .endKey("testString") + .endKeyDocId("testString") + .group(false) + .groupLevel(Long.valueOf("1")) + .key("testString") + .keys(java.util.Arrays.asList("examplekey")) + .reduce(true) + .startKey("testString") + .startKeyDocId("testString") + .update("true") .build(); - // Invoke deleteIndex() with a valid options model and verify the result - Response response = cloudantService.deleteIndex(deleteIndexOptionsModel).execute(); + // Invoke postPartitionViewAsStream() with a valid options model and verify the result + Response response = cloudantService.postPartitionViewAsStream(postPartitionViewOptionsModel).execute(); assertNotNull(response); - Ok responseObj = response.getResult(); - assertNotNull(responseObj); + try (InputStream responseObj = response.getResult();) { + assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); + } // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "DELETE"); + assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, deleteIndexPath); + assertEquals(parsedPath, postPartitionViewAsStreamPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the deleteIndex operation with and without retries enabled + // Test the postPartitionViewAsStream operation with and without retries enabled @Test - public void testDeleteIndexWRetries() throws Throwable { + public void testPostPartitionViewAsStreamWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testDeleteIndexWOptions(); + testPostPartitionViewAsStreamWOptions(); cloudantService.disableRetries(); - testDeleteIndexWOptions(); + testPostPartitionViewAsStreamWOptions(); } - // Test the deleteIndex operation with a null options model (negative test) + // Test the postPartitionViewAsStream operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testDeleteIndexNoOptions() throws Throwable { + public void testPostPartitionViewAsStreamNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.deleteIndex(null).execute(); + cloudantService.postPartitionViewAsStream(null).execute(); } - // Test the postSearchAnalyze operation with a valid options model parameter + // Test the postPartitionExplain operation with a valid options model parameter @Test - public void testPostSearchAnalyzeWOptions() throws Throwable { + public void testPostPartitionExplainWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"tokens\": [\"tokens\"]}"; - String postSearchAnalyzePath = "/_search_analyze"; + String mockResponseBody = "{\"covering\": true, \"dbname\": \"dbname\", \"fields\": [\"fields\"], \"index\": {\"ddoc\": \"ddoc\", \"def\": {\"default_analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"default_field\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"enabled\": true}, \"fields\": [{\"name\": \"name\", \"type\": \"boolean\"}], \"index_array_lengths\": true, \"partial_filter_selector\": {\"anyKey\": \"anyValue\"}}, \"name\": \"name\", \"partitioned\": false, \"type\": \"json\"}, \"index_candidates\": [{\"analysis\": {\"covering\": true, \"ranking\": 1, \"reasons\": [{\"name\": \"alphabetically_comes_after\"}], \"usable\": true}, \"index\": {\"ddoc\": \"ddoc\", \"def\": {\"default_analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"default_field\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"enabled\": true}, \"fields\": [{\"name\": \"name\", \"type\": \"boolean\"}], \"index_array_lengths\": true, \"partial_filter_selector\": {\"anyKey\": \"anyValue\"}}, \"name\": \"name\", \"partitioned\": false, \"type\": \"json\"}}], \"limit\": 25, \"mrargs\": {\"conflicts\": \"anyValue\", \"direction\": \"fwd\", \"end_key\": \"anyValue\", \"include_docs\": false, \"partition\": \"partition\", \"reduce\": true, \"stable\": true, \"start_key\": \"anyValue\", \"update\": \"anyValue\", \"view_type\": \"map\"}, \"opts\": {\"bookmark\": \"bookmark\", \"conflicts\": false, \"execution_stats\": false, \"fields\": [\"fields\"], \"limit\": 25, \"partition\": \"partition\", \"r\": 1, \"skip\": 0, \"sort\": \"anyValue\", \"stable\": false, \"stale\": false, \"update\": true, \"use_index\": [\"useIndex\"]}, \"partitioned\": \"anyValue\", \"selector\": {\"anyKey\": \"anyValue\"}, \"selector_hints\": [{\"indexable_fields\": [\"indexableFields\"], \"type\": \"json\", \"unindexable_fields\": [\"unindexableFields\"]}], \"skip\": 0}"; + String postPartitionExplainPath = "/testString/_partition/testString/_explain"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostSearchAnalyzeOptions model - PostSearchAnalyzeOptions postSearchAnalyzeOptionsModel = new PostSearchAnalyzeOptions.Builder() - .analyzer("english") - .text("running is fun") + // Construct an instance of the PostPartitionExplainOptions model + PostPartitionExplainOptions postPartitionExplainOptionsModel = new PostPartitionExplainOptions.Builder() + .db("testString") + .partitionKey("testString") + .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) + .allowFallback(true) + .bookmark("testString") + .conflicts(true) + .executionStats(true) + .fields(java.util.Arrays.asList("productId", "name", "description")) + .limit(Long.valueOf("25")) + .skip(Long.valueOf("0")) + .sort(java.util.Arrays.asList(java.util.Collections.singletonMap("key1", "asc"))) + .stable(true) + .update("true") + .useIndex(java.util.Arrays.asList("testString")) .build(); - // Invoke postSearchAnalyze() with a valid options model and verify the result - Response response = cloudantService.postSearchAnalyze(postSearchAnalyzeOptionsModel).execute(); + // Invoke postPartitionExplain() with a valid options model and verify the result + Response response = cloudantService.postPartitionExplain(postPartitionExplainOptionsModel).execute(); assertNotNull(response); - SearchAnalyzeResult responseObj = response.getResult(); + ExplainResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -4091,69 +3985,62 @@ public void testPostSearchAnalyzeWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postSearchAnalyzePath); + assertEquals(parsedPath, postPartitionExplainPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postSearchAnalyze operation with and without retries enabled + // Test the postPartitionExplain operation with and without retries enabled @Test - public void testPostSearchAnalyzeWRetries() throws Throwable { + public void testPostPartitionExplainWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostSearchAnalyzeWOptions(); + testPostPartitionExplainWOptions(); cloudantService.disableRetries(); - testPostSearchAnalyzeWOptions(); + testPostPartitionExplainWOptions(); } - // Test the postSearchAnalyze operation with a null options model (negative test) + // Test the postPartitionExplain operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostSearchAnalyzeNoOptions() throws Throwable { + public void testPostPartitionExplainNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postSearchAnalyze(null).execute(); + cloudantService.postPartitionExplain(null).execute(); } - // Test the postSearch operation with a valid options model parameter + // Test the postPartitionFind operation with a valid options model parameter @Test - public void testPostSearchWOptions() throws Throwable { + public void testPostPartitionFindWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"total_rows\": 0, \"bookmark\": \"bookmark\", \"by\": \"by\", \"counts\": {\"mapKey\": {\"mapKey\": 0}}, \"ranges\": {\"mapKey\": {\"mapKey\": 0}}, \"rows\": [{\"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"fields\": {\"anyKey\": \"anyValue\"}, \"highlights\": {\"mapKey\": [\"inner\"]}, \"id\": \"id\"}], \"groups\": [{\"total_rows\": 0, \"bookmark\": \"bookmark\", \"by\": \"by\", \"counts\": {\"mapKey\": {\"mapKey\": 0}}, \"ranges\": {\"mapKey\": {\"mapKey\": 0}}, \"rows\": [{\"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"fields\": {\"anyKey\": \"anyValue\"}, \"highlights\": {\"mapKey\": [\"inner\"]}, \"id\": \"id\"}]}]}"; - String postSearchPath = "/testString/_design/testString/_search/testString"; + String mockResponseBody = "{\"bookmark\": \"bookmark\", \"docs\": [{\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}], \"execution_stats\": {\"execution_time_ms\": 15, \"results_returned\": 0, \"total_docs_examined\": 0, \"total_keys_examined\": 0, \"total_quorum_docs_examined\": 0}, \"warning\": \"warning\"}"; + String postPartitionFindPath = "/testString/_partition/testString/_find"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostSearchOptions model - PostSearchOptions postSearchOptionsModel = new PostSearchOptions.Builder() - .db("testString") - .ddoc("testString") - .index("testString") - .query("name:Jane* AND active:True") + // Construct an instance of the PostPartitionFindOptions model + PostPartitionFindOptions postPartitionFindOptionsModel = new PostPartitionFindOptions.Builder() + .db("testString") + .partitionKey("testString") + .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) + .allowFallback(true) .bookmark("testString") - .highlightFields(java.util.Arrays.asList("testString")) - .highlightNumber(Long.valueOf("1")) - .highlightPostTag("") - .highlightPreTag("") - .highlightSize(Long.valueOf("100")) - .includeDocs(false) - .includeFields(java.util.Arrays.asList("testString")) - .limit(Long.valueOf("3")) - .sort(java.util.Arrays.asList("testString")) - .stale("ok") - .counts(java.util.Arrays.asList("testString")) - .drilldown(java.util.Arrays.asList(java.util.Arrays.asList("testString"))) - .groupField("testString") - .groupLimit(Long.valueOf("1")) - .groupSort(java.util.Arrays.asList("testString")) - .ranges(java.util.Collections.singletonMap("key1", java.util.Collections.singletonMap("key1", "testString"))) + .conflicts(true) + .executionStats(true) + .fields(java.util.Arrays.asList("productId", "name", "description")) + .limit(Long.valueOf("25")) + .skip(Long.valueOf("0")) + .sort(java.util.Arrays.asList(java.util.Collections.singletonMap("key1", "asc"))) + .stable(true) + .update("true") + .useIndex(java.util.Arrays.asList("testString")) .build(); - // Invoke postSearch() with a valid options model and verify the result - Response response = cloudantService.postSearch(postSearchOptionsModel).execute(); + // Invoke postPartitionFind() with a valid options model and verify the result + Response response = cloudantService.postPartitionFind(postPartitionFindOptionsModel).execute(); assertNotNull(response); - SearchResult responseObj = response.getResult(); + FindResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -4162,67 +4049,60 @@ public void testPostSearchWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postSearchPath); + assertEquals(parsedPath, postPartitionFindPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postSearch operation with and without retries enabled + // Test the postPartitionFind operation with and without retries enabled @Test - public void testPostSearchWRetries() throws Throwable { + public void testPostPartitionFindWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostSearchWOptions(); + testPostPartitionFindWOptions(); cloudantService.disableRetries(); - testPostSearchWOptions(); + testPostPartitionFindWOptions(); } - // Test the postSearch operation with a null options model (negative test) + // Test the postPartitionFind operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostSearchNoOptions() throws Throwable { + public void testPostPartitionFindNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postSearch(null).execute(); + cloudantService.postPartitionFind(null).execute(); } - // Test the postSearchAsStream operation with a valid options model parameter + // Test the postPartitionFindAsStream operation with a valid options model parameter @Test - public void testPostSearchAsStreamWOptions() throws Throwable { + public void testPostPartitionFindAsStreamWOptions() throws Throwable { // Register a mock response String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; - String postSearchAsStreamPath = "/testString/_design/testString/_search/testString"; + String postPartitionFindAsStreamPath = "/testString/_partition/testString/_find"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostSearchOptions model - PostSearchOptions postSearchOptionsModel = new PostSearchOptions.Builder() + // Construct an instance of the PostPartitionFindOptions model + PostPartitionFindOptions postPartitionFindOptionsModel = new PostPartitionFindOptions.Builder() .db("testString") - .ddoc("testString") - .index("testString") - .query("name:Jane* AND active:True") + .partitionKey("testString") + .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) + .allowFallback(true) .bookmark("testString") - .highlightFields(java.util.Arrays.asList("testString")) - .highlightNumber(Long.valueOf("1")) - .highlightPostTag("") - .highlightPreTag("") - .highlightSize(Long.valueOf("100")) - .includeDocs(false) - .includeFields(java.util.Arrays.asList("testString")) - .limit(Long.valueOf("3")) - .sort(java.util.Arrays.asList("testString")) - .stale("ok") - .counts(java.util.Arrays.asList("testString")) - .drilldown(java.util.Arrays.asList(java.util.Arrays.asList("testString"))) - .groupField("testString") - .groupLimit(Long.valueOf("1")) - .groupSort(java.util.Arrays.asList("testString")) - .ranges(java.util.Collections.singletonMap("key1", java.util.Collections.singletonMap("key1", "testString"))) + .conflicts(true) + .executionStats(true) + .fields(java.util.Arrays.asList("productId", "name", "description")) + .limit(Long.valueOf("25")) + .skip(Long.valueOf("0")) + .sort(java.util.Arrays.asList(java.util.Collections.singletonMap("key1", "asc"))) + .stable(true) + .update("true") + .useIndex(java.util.Arrays.asList("testString")) .build(); - // Invoke postSearchAsStream() with a valid options model and verify the result - Response response = cloudantService.postSearchAsStream(postSearchOptionsModel).execute(); + // Invoke postPartitionFindAsStream() with a valid options model and verify the result + Response response = cloudantService.postPartitionFindAsStream(postPartitionFindOptionsModel).execute(); assertNotNull(response); try (InputStream responseObj = response.getResult();) { assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); @@ -4234,409 +4114,503 @@ public void testPostSearchAsStreamWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postSearchAsStreamPath); + assertEquals(parsedPath, postPartitionFindAsStreamPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postSearchAsStream operation with and without retries enabled + // Test the postPartitionFindAsStream operation with and without retries enabled @Test - public void testPostSearchAsStreamWRetries() throws Throwable { + public void testPostPartitionFindAsStreamWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostSearchAsStreamWOptions(); + testPostPartitionFindAsStreamWOptions(); cloudantService.disableRetries(); - testPostSearchAsStreamWOptions(); + testPostPartitionFindAsStreamWOptions(); } - // Test the postSearchAsStream operation with a null options model (negative test) + // Test the postPartitionFindAsStream operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostSearchAsStreamNoOptions() throws Throwable { + public void testPostPartitionFindAsStreamNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postSearchAsStream(null).execute(); + cloudantService.postPartitionFindAsStream(null).execute(); } - // Test the getSearchDiskSize operation with a valid options model parameter + // Test the postExplain operation with a valid options model parameter @Test - public void testGetSearchDiskSizeWOptions() throws Throwable { + public void testPostExplainWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"name\": \"name\", \"search_index\": {\"disk_size\": 0}}"; - String getSearchDiskSizePath = "/testString/_design/testString/_search_disk_size/testString"; + String mockResponseBody = "{\"covering\": true, \"dbname\": \"dbname\", \"fields\": [\"fields\"], \"index\": {\"ddoc\": \"ddoc\", \"def\": {\"default_analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"default_field\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"enabled\": true}, \"fields\": [{\"name\": \"name\", \"type\": \"boolean\"}], \"index_array_lengths\": true, \"partial_filter_selector\": {\"anyKey\": \"anyValue\"}}, \"name\": \"name\", \"partitioned\": false, \"type\": \"json\"}, \"index_candidates\": [{\"analysis\": {\"covering\": true, \"ranking\": 1, \"reasons\": [{\"name\": \"alphabetically_comes_after\"}], \"usable\": true}, \"index\": {\"ddoc\": \"ddoc\", \"def\": {\"default_analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"default_field\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"enabled\": true}, \"fields\": [{\"name\": \"name\", \"type\": \"boolean\"}], \"index_array_lengths\": true, \"partial_filter_selector\": {\"anyKey\": \"anyValue\"}}, \"name\": \"name\", \"partitioned\": false, \"type\": \"json\"}}], \"limit\": 25, \"mrargs\": {\"conflicts\": \"anyValue\", \"direction\": \"fwd\", \"end_key\": \"anyValue\", \"include_docs\": false, \"partition\": \"partition\", \"reduce\": true, \"stable\": true, \"start_key\": \"anyValue\", \"update\": \"anyValue\", \"view_type\": \"map\"}, \"opts\": {\"bookmark\": \"bookmark\", \"conflicts\": false, \"execution_stats\": false, \"fields\": [\"fields\"], \"limit\": 25, \"partition\": \"partition\", \"r\": 1, \"skip\": 0, \"sort\": \"anyValue\", \"stable\": false, \"stale\": false, \"update\": true, \"use_index\": [\"useIndex\"]}, \"partitioned\": \"anyValue\", \"selector\": {\"anyKey\": \"anyValue\"}, \"selector_hints\": [{\"indexable_fields\": [\"indexableFields\"], \"type\": \"json\", \"unindexable_fields\": [\"unindexableFields\"]}], \"skip\": 0}"; + String postExplainPath = "/testString/_explain"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetSearchDiskSizeOptions model - GetSearchDiskSizeOptions getSearchDiskSizeOptionsModel = new GetSearchDiskSizeOptions.Builder() + // Construct an instance of the PostExplainOptions model + PostExplainOptions postExplainOptionsModel = new PostExplainOptions.Builder() .db("testString") - .ddoc("testString") - .index("testString") + .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) + .allowFallback(true) + .bookmark("testString") + .conflicts(true) + .executionStats(true) + .fields(java.util.Arrays.asList("_id", "type", "name", "email")) + .limit(Long.valueOf("3")) + .skip(Long.valueOf("0")) + .sort(java.util.Arrays.asList(java.util.Collections.singletonMap("key1", "asc"))) + .stable(true) + .update("true") + .useIndex(java.util.Arrays.asList("testString")) + .r(Long.valueOf("1")) .build(); - // Invoke getSearchDiskSize() with a valid options model and verify the result - Response response = cloudantService.getSearchDiskSize(getSearchDiskSizeOptionsModel).execute(); + // Invoke postExplain() with a valid options model and verify the result + Response response = cloudantService.postExplain(postExplainOptionsModel).execute(); assertNotNull(response); - SearchDiskSizeInformation responseObj = response.getResult(); + ExplainResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "GET"); + assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getSearchDiskSizePath); + assertEquals(parsedPath, postExplainPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the getSearchDiskSize operation with and without retries enabled + // Test the postExplain operation with and without retries enabled @Test - public void testGetSearchDiskSizeWRetries() throws Throwable { + public void testPostExplainWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetSearchDiskSizeWOptions(); + testPostExplainWOptions(); cloudantService.disableRetries(); - testGetSearchDiskSizeWOptions(); + testPostExplainWOptions(); } - // Test the getSearchDiskSize operation with a null options model (negative test) + // Test the postExplain operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetSearchDiskSizeNoOptions() throws Throwable { + public void testPostExplainNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.getSearchDiskSize(null).execute(); + cloudantService.postExplain(null).execute(); } - // Test the getSearchInfo operation with a valid options model parameter + // Test the postFind operation with a valid options model parameter @Test - public void testGetSearchInfoWOptions() throws Throwable { + public void testPostFindWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"name\": \"name\", \"search_index\": {\"committed_seq\": 0, \"disk_size\": 0, \"doc_count\": 0, \"doc_del_count\": 0, \"pending_seq\": 0, \"signature\": \"signature\"}}"; - String getSearchInfoPath = "/testString/_design/testString/_search_info/testString"; + String mockResponseBody = "{\"bookmark\": \"bookmark\", \"docs\": [{\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}], \"execution_stats\": {\"execution_time_ms\": 15, \"results_returned\": 0, \"total_docs_examined\": 0, \"total_keys_examined\": 0, \"total_quorum_docs_examined\": 0}, \"warning\": \"warning\"}"; + String postFindPath = "/testString/_find"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetSearchInfoOptions model - GetSearchInfoOptions getSearchInfoOptionsModel = new GetSearchInfoOptions.Builder() + // Construct an instance of the PostFindOptions model + PostFindOptions postFindOptionsModel = new PostFindOptions.Builder() .db("testString") - .ddoc("testString") - .index("testString") + .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) + .allowFallback(true) + .bookmark("testString") + .conflicts(true) + .executionStats(true) + .fields(java.util.Arrays.asList("_id", "type", "name", "email")) + .limit(Long.valueOf("3")) + .skip(Long.valueOf("0")) + .sort(java.util.Arrays.asList(java.util.Collections.singletonMap("key1", "asc"))) + .stable(true) + .update("true") + .useIndex(java.util.Arrays.asList("testString")) + .r(Long.valueOf("1")) .build(); - // Invoke getSearchInfo() with a valid options model and verify the result - Response response = cloudantService.getSearchInfo(getSearchInfoOptionsModel).execute(); + // Invoke postFind() with a valid options model and verify the result + Response response = cloudantService.postFind(postFindOptionsModel).execute(); assertNotNull(response); - SearchInfoResult responseObj = response.getResult(); + FindResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "GET"); + assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getSearchInfoPath); + assertEquals(parsedPath, postFindPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the getSearchInfo operation with and without retries enabled + // Test the postFind operation with and without retries enabled @Test - public void testGetSearchInfoWRetries() throws Throwable { + public void testPostFindWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetSearchInfoWOptions(); + testPostFindWOptions(); cloudantService.disableRetries(); - testGetSearchInfoWOptions(); + testPostFindWOptions(); } - // Test the getSearchInfo operation with a null options model (negative test) + // Test the postFind operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetSearchInfoNoOptions() throws Throwable { + public void testPostFindNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.getSearchInfo(null).execute(); + cloudantService.postFind(null).execute(); } - // Test the headReplicationDocument operation with a valid options model parameter + // Test the postFindAsStream operation with a valid options model parameter @Test - public void testHeadReplicationDocumentWOptions() throws Throwable { + public void testPostFindAsStreamWOptions() throws Throwable { // Register a mock response - String mockResponseBody = ""; - String headReplicationDocumentPath = "/_replicator/testString"; + String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; + String postFindAsStreamPath = "/testString/_find"; server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the HeadReplicationDocumentOptions model - HeadReplicationDocumentOptions headReplicationDocumentOptionsModel = new HeadReplicationDocumentOptions.Builder() - .docId("testString") - .ifNoneMatch("testString") + // Construct an instance of the PostFindOptions model + PostFindOptions postFindOptionsModel = new PostFindOptions.Builder() + .db("testString") + .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) + .allowFallback(true) + .bookmark("testString") + .conflicts(true) + .executionStats(true) + .fields(java.util.Arrays.asList("_id", "type", "name", "email")) + .limit(Long.valueOf("3")) + .skip(Long.valueOf("0")) + .sort(java.util.Arrays.asList(java.util.Collections.singletonMap("key1", "asc"))) + .stable(true) + .update("true") + .useIndex(java.util.Arrays.asList("testString")) + .r(Long.valueOf("1")) .build(); - // Invoke headReplicationDocument() with a valid options model and verify the result - Response response = cloudantService.headReplicationDocument(headReplicationDocumentOptionsModel).execute(); + // Invoke postFindAsStream() with a valid options model and verify the result + Response response = cloudantService.postFindAsStream(postFindOptionsModel).execute(); assertNotNull(response); - Void responseObj = response.getResult(); - assertNull(responseObj); + try (InputStream responseObj = response.getResult();) { + assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); + } // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "HEAD"); + assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, headReplicationDocumentPath); + assertEquals(parsedPath, postFindAsStreamPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the headReplicationDocument operation with and without retries enabled + // Test the postFindAsStream operation with and without retries enabled @Test - public void testHeadReplicationDocumentWRetries() throws Throwable { + public void testPostFindAsStreamWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testHeadReplicationDocumentWOptions(); + testPostFindAsStreamWOptions(); cloudantService.disableRetries(); - testHeadReplicationDocumentWOptions(); + testPostFindAsStreamWOptions(); } - // Test the headReplicationDocument operation with a null options model (negative test) + // Test the postFindAsStream operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testHeadReplicationDocumentNoOptions() throws Throwable { + public void testPostFindAsStreamNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.headReplicationDocument(null).execute(); + cloudantService.postFindAsStream(null).execute(); } - // Test the headSchedulerDocument operation with a valid options model parameter + // Test the getIndexesInformation operation with a valid options model parameter @Test - public void testHeadSchedulerDocumentWOptions() throws Throwable { + public void testGetIndexesInformationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = ""; - String headSchedulerDocumentPath = "/_scheduler/docs/_replicator/testString"; + String mockResponseBody = "{\"total_rows\": 0, \"indexes\": [{\"ddoc\": \"ddoc\", \"def\": {\"default_analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"default_field\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"enabled\": true}, \"fields\": [{\"name\": \"name\", \"type\": \"boolean\"}], \"index_array_lengths\": true, \"partial_filter_selector\": {\"anyKey\": \"anyValue\"}}, \"name\": \"name\", \"partitioned\": false, \"type\": \"json\"}]}"; + String getIndexesInformationPath = "/testString/_index"; server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the HeadSchedulerDocumentOptions model - HeadSchedulerDocumentOptions headSchedulerDocumentOptionsModel = new HeadSchedulerDocumentOptions.Builder() - .docId("testString") + // Construct an instance of the GetIndexesInformationOptions model + GetIndexesInformationOptions getIndexesInformationOptionsModel = new GetIndexesInformationOptions.Builder() + .db("testString") .build(); - // Invoke headSchedulerDocument() with a valid options model and verify the result - Response response = cloudantService.headSchedulerDocument(headSchedulerDocumentOptionsModel).execute(); + // Invoke getIndexesInformation() with a valid options model and verify the result + Response response = cloudantService.getIndexesInformation(getIndexesInformationOptionsModel).execute(); assertNotNull(response); - Void responseObj = response.getResult(); - assertNull(responseObj); + IndexesInformation responseObj = response.getResult(); + assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "HEAD"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, headSchedulerDocumentPath); + assertEquals(parsedPath, getIndexesInformationPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the headSchedulerDocument operation with and without retries enabled + // Test the getIndexesInformation operation with and without retries enabled @Test - public void testHeadSchedulerDocumentWRetries() throws Throwable { + public void testGetIndexesInformationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testHeadSchedulerDocumentWOptions(); + testGetIndexesInformationWOptions(); cloudantService.disableRetries(); - testHeadSchedulerDocumentWOptions(); + testGetIndexesInformationWOptions(); } - // Test the headSchedulerDocument operation with a null options model (negative test) + // Test the getIndexesInformation operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testHeadSchedulerDocumentNoOptions() throws Throwable { + public void testGetIndexesInformationNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.headSchedulerDocument(null).execute(); + cloudantService.getIndexesInformation(null).execute(); } - // Test the headSchedulerJob operation with a valid options model parameter + // Test the postIndex operation with a valid options model parameter @Test - public void testHeadSchedulerJobWOptions() throws Throwable { + public void testPostIndexWOptions() throws Throwable { // Register a mock response - String mockResponseBody = ""; - String headSchedulerJobPath = "/_scheduler/jobs/testString"; + String mockResponseBody = "{\"id\": \"id\", \"name\": \"name\", \"result\": \"created\"}"; + String postIndexPath = "/testString/_index"; server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the HeadSchedulerJobOptions model - HeadSchedulerJobOptions headSchedulerJobOptionsModel = new HeadSchedulerJobOptions.Builder() - .jobId("testString") + // Construct an instance of the Analyzer model + Analyzer analyzerModel = new Analyzer.Builder() + .name("classic") + .stopwords(java.util.Arrays.asList("testString")) .build(); - // Invoke headSchedulerJob() with a valid options model and verify the result - Response response = cloudantService.headSchedulerJob(headSchedulerJobOptionsModel).execute(); + // Construct an instance of the IndexTextOperatorDefaultField model + IndexTextOperatorDefaultField indexTextOperatorDefaultFieldModel = new IndexTextOperatorDefaultField.Builder() + .analyzer(analyzerModel) + .enabled(true) + .build(); + + // Construct an instance of the IndexField model + IndexField indexFieldModel = new IndexField.Builder() + .name("asc") + .type("boolean") + .add("foo", "asc") + .build(); + + // Construct an instance of the IndexDefinition model + IndexDefinition indexDefinitionModel = new IndexDefinition.Builder() + .defaultAnalyzer(analyzerModel) + .defaultField(indexTextOperatorDefaultFieldModel) + .fields(java.util.Arrays.asList(indexFieldModel)) + .indexArrayLengths(true) + .partialFilterSelector(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the PostIndexOptions model + PostIndexOptions postIndexOptionsModel = new PostIndexOptions.Builder() + .db("testString") + .index(indexDefinitionModel) + .ddoc("json-index") + .name("getUserByName") + .partitioned(true) + .type("json") + .build(); + + // Invoke postIndex() with a valid options model and verify the result + Response response = cloudantService.postIndex(postIndexOptionsModel).execute(); assertNotNull(response); - Void responseObj = response.getResult(); - assertNull(responseObj); + IndexResult responseObj = response.getResult(); + assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "HEAD"); + assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, headSchedulerJobPath); + assertEquals(parsedPath, postIndexPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the headSchedulerJob operation with and without retries enabled + // Test the postIndex operation with and without retries enabled @Test - public void testHeadSchedulerJobWRetries() throws Throwable { + public void testPostIndexWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testHeadSchedulerJobWOptions(); + testPostIndexWOptions(); cloudantService.disableRetries(); - testHeadSchedulerJobWOptions(); + testPostIndexWOptions(); } - // Test the headSchedulerJob operation with a null options model (negative test) + // Test the postIndex operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testHeadSchedulerJobNoOptions() throws Throwable { + public void testPostIndexNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.headSchedulerJob(null).execute(); + cloudantService.postIndex(null).execute(); } - // Test the postReplicator operation with a valid options model parameter + // Test the deleteIndex operation with a valid options model parameter @Test - public void testPostReplicatorWOptions() throws Throwable { + public void testDeleteIndexWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; - String postReplicatorPath = "/_replicator"; + String mockResponseBody = "{\"ok\": true}"; + String deleteIndexPath = "/testString/_index/_design/testString/json/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") - .setResponseCode(201) + .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the Attachment model - Attachment attachmentModel = new Attachment.Builder() - .contentType("testString") - .data(TestUtilities.createMockByteArray("VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=")) - .digest("testString") - .encodedLength(Long.valueOf("0")) - .encoding("testString") - .follows(true) - .length(Long.valueOf("0")) - .revpos(Long.valueOf("1")) - .stub(true) + // Construct an instance of the DeleteIndexOptions model + DeleteIndexOptions deleteIndexOptionsModel = new DeleteIndexOptions.Builder() + .db("testString") + .ddoc("testString") + .type("json") + .index("testString") .build(); - // Construct an instance of the Revisions model - Revisions revisionsModel = new Revisions.Builder() - .ids(java.util.Arrays.asList("testString")) - .start(Long.valueOf("1")) - .build(); + // Invoke deleteIndex() with a valid options model and verify the result + Response response = cloudantService.deleteIndex(deleteIndexOptionsModel).execute(); + assertNotNull(response); + Ok responseObj = response.getResult(); + assertNotNull(responseObj); - // Construct an instance of the DocumentRevisionStatus model - DocumentRevisionStatus documentRevisionStatusModel = new DocumentRevisionStatus.Builder() - .rev("testString") - .status("available") - .build(); + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteIndexPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - // Construct an instance of the ReplicationCreateTargetParameters model - ReplicationCreateTargetParameters replicationCreateTargetParametersModel = new ReplicationCreateTargetParameters.Builder() - .n(Long.valueOf("3")) - .partitioned(false) - .q(Long.valueOf("1")) - .build(); + // Test the deleteIndex operation with and without retries enabled + @Test + public void testDeleteIndexWRetries() throws Throwable { + cloudantService.enableRetries(4, 30); + testDeleteIndexWOptions(); - // Construct an instance of the ReplicationDatabaseAuthBasic model - ReplicationDatabaseAuthBasic replicationDatabaseAuthBasicModel = new ReplicationDatabaseAuthBasic.Builder() - .password("testString") - .username("testString") - .build(); + cloudantService.disableRetries(); + testDeleteIndexWOptions(); + } - // Construct an instance of the ReplicationDatabaseAuthIam model - ReplicationDatabaseAuthIam replicationDatabaseAuthIamModel = new ReplicationDatabaseAuthIam.Builder() - .apiKey("testString") - .build(); + // Test the deleteIndex operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteIndexNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.deleteIndex(null).execute(); + } - // Construct an instance of the ReplicationDatabaseAuth model - ReplicationDatabaseAuth replicationDatabaseAuthModel = new ReplicationDatabaseAuth.Builder() - .basic(replicationDatabaseAuthBasicModel) - .iam(replicationDatabaseAuthIamModel) - .build(); + // Test the postSearchAnalyze operation with a valid options model parameter + @Test + public void testPostSearchAnalyzeWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"tokens\": [\"tokens\"]}"; + String postSearchAnalyzePath = "/_search_analyze"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - // Construct an instance of the ReplicationDatabase model - ReplicationDatabase replicationDatabaseModel = new ReplicationDatabase.Builder() - .auth(replicationDatabaseAuthModel) - .headers(java.util.Collections.singletonMap("key1", "testString")) - .url("https://my-source-instance.cloudantnosqldb.appdomain.cloud.example/animaldb") + // Construct an instance of the PostSearchAnalyzeOptions model + PostSearchAnalyzeOptions postSearchAnalyzeOptionsModel = new PostSearchAnalyzeOptions.Builder() + .analyzer("english") + .text("running is fun") .build(); - // Construct an instance of the UserContext model - UserContext userContextModel = new UserContext.Builder() - .db("testString") - .name("john") - .roles(java.util.Arrays.asList("_replicator")) - .build(); + // Invoke postSearchAnalyze() with a valid options model and verify the result + Response response = cloudantService.postSearchAnalyze(postSearchAnalyzeOptionsModel).execute(); + assertNotNull(response); + SearchAnalyzeResult responseObj = response.getResult(); + assertNotNull(responseObj); - // Construct an instance of the ReplicationDocument model - ReplicationDocument replicationDocumentModel = new ReplicationDocument.Builder() - .attachments(java.util.Collections.singletonMap("key1", attachmentModel)) - .conflicts(java.util.Arrays.asList("testString")) - .deleted(true) - .deletedConflicts(java.util.Arrays.asList("testString")) - .id("testString") - .localSeq("testString") - .rev("testString") - .revisions(revisionsModel) - .revsInfo(java.util.Arrays.asList(documentRevisionStatusModel)) - .cancel(false) - .checkpointInterval(Long.valueOf("4500")) - .connectionTimeout(Long.valueOf("15000")) - .continuous(true) - .createTarget(true) - .createTargetParams(replicationCreateTargetParametersModel) - .docIds(java.util.Arrays.asList("badger", "lemur", "llama")) - .filter("ddoc/my_filter") - .httpConnections(Long.valueOf("10")) - .owner("testString") - .queryParams(java.util.Collections.singletonMap("key1", "testString")) - .retriesPerRequest(Long.valueOf("3")) - .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) - .sinceSeq("34-g1AAAAGjeJzLYWBgYMlgTmGQT0lKzi9KdU") - .socketOptions("[{keepalive, true}, {nodelay, false}]") - .source(replicationDatabaseModel) - .sourceProxy("testString") - .target(replicationDatabaseModel) - .targetProxy("testString") - .useBulkGet(true) - .useCheckpoints(false) - .userCtx(userContextModel) - .winningRevsOnly(false) - .workerBatchSize(Long.valueOf("400")) - .workerProcesses(Long.valueOf("3")) - .add("foo", "testString") - .build(); + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, postSearchAnalyzePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } - // Construct an instance of the PostReplicatorOptions model - PostReplicatorOptions postReplicatorOptionsModel = new PostReplicatorOptions.Builder() - .replicationDocument(replicationDocumentModel) - .batch("ok") + // Test the postSearchAnalyze operation with and without retries enabled + @Test + public void testPostSearchAnalyzeWRetries() throws Throwable { + cloudantService.enableRetries(4, 30); + testPostSearchAnalyzeWOptions(); + + cloudantService.disableRetries(); + testPostSearchAnalyzeWOptions(); + } + + // Test the postSearchAnalyze operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPostSearchAnalyzeNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.postSearchAnalyze(null).execute(); + } + + // Test the postSearch operation with a valid options model parameter + @Test + public void testPostSearchWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"total_rows\": 0, \"bookmark\": \"bookmark\", \"by\": \"by\", \"counts\": {\"mapKey\": {\"mapKey\": 0}}, \"ranges\": {\"mapKey\": {\"mapKey\": 0}}, \"rows\": [{\"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"fields\": {\"anyKey\": \"anyValue\"}, \"highlights\": {\"mapKey\": [\"inner\"]}, \"id\": \"id\"}], \"groups\": [{\"total_rows\": 0, \"bookmark\": \"bookmark\", \"by\": \"by\", \"counts\": {\"mapKey\": {\"mapKey\": 0}}, \"ranges\": {\"mapKey\": {\"mapKey\": 0}}, \"rows\": [{\"doc\": {\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}, \"fields\": {\"anyKey\": \"anyValue\"}, \"highlights\": {\"mapKey\": [\"inner\"]}, \"id\": \"id\"}]}]}"; + String postSearchPath = "/testString/_design/testString/_search/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the PostSearchOptions model + PostSearchOptions postSearchOptionsModel = new PostSearchOptions.Builder() + .db("testString") + .ddoc("testString") + .index("testString") + .query("name:Jane* AND active:True") + .bookmark("testString") + .highlightFields(java.util.Arrays.asList("testString")) + .highlightNumber(Long.valueOf("1")) + .highlightPostTag("") + .highlightPreTag("") + .highlightSize(Long.valueOf("100")) + .includeDocs(false) + .includeFields(java.util.Arrays.asList("testString")) + .limit(Long.valueOf("3")) + .sort(java.util.Arrays.asList("testString")) + .stale("ok") + .counts(java.util.Arrays.asList("testString")) + .drilldown(java.util.Arrays.asList(java.util.Arrays.asList("testString"))) + .groupField("testString") + .groupLimit(Long.valueOf("1")) + .groupSort(java.util.Arrays.asList("testString")) + .ranges(java.util.Collections.singletonMap("key1", java.util.Collections.singletonMap("key1", "testString"))) .build(); - // Invoke postReplicator() with a valid options model and verify the result - Response response = cloudantService.postReplicator(postReplicatorOptionsModel).execute(); + // Invoke postSearch() with a valid options model and verify the result + Response response = cloudantService.postSearch(postSearchOptionsModel).execute(); assertNotNull(response); - DocumentResult responseObj = response.getResult(); + SearchResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -4645,117 +4619,176 @@ public void testPostReplicatorWOptions() throws Throwable { assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postReplicatorPath); - // Verify query params + assertEquals(parsedPath, postSearchPath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); - assertNotNull(query); - assertEquals(query.get("batch"), "ok"); + assertNull(query); } - // Test the postReplicator operation with and without retries enabled + // Test the postSearch operation with and without retries enabled @Test - public void testPostReplicatorWRetries() throws Throwable { + public void testPostSearchWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostReplicatorWOptions(); + testPostSearchWOptions(); cloudantService.disableRetries(); - testPostReplicatorWOptions(); + testPostSearchWOptions(); } - // Test the postReplicator operation with a null options model (negative test) + // Test the postSearch operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostReplicatorNoOptions() throws Throwable { + public void testPostSearchNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postReplicator(null).execute(); + cloudantService.postSearch(null).execute(); } - // Test the deleteReplicationDocument operation with a valid options model parameter + // Test the postSearchAsStream operation with a valid options model parameter @Test - public void testDeleteReplicationDocumentWOptions() throws Throwable { + public void testPostSearchAsStreamWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; - String deleteReplicationDocumentPath = "/_replicator/testString"; + String mockResponseBody = "{\"foo\": \"this is a mock response for JSON streaming\"}"; + String postSearchAsStreamPath = "/testString/_design/testString/_search/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the DeleteReplicationDocumentOptions model - DeleteReplicationDocumentOptions deleteReplicationDocumentOptionsModel = new DeleteReplicationDocumentOptions.Builder() - .docId("testString") - .ifMatch("testString") - .batch("ok") - .rev("testString") + // Construct an instance of the PostSearchOptions model + PostSearchOptions postSearchOptionsModel = new PostSearchOptions.Builder() + .db("testString") + .ddoc("testString") + .index("testString") + .query("name:Jane* AND active:True") + .bookmark("testString") + .highlightFields(java.util.Arrays.asList("testString")) + .highlightNumber(Long.valueOf("1")) + .highlightPostTag("") + .highlightPreTag("") + .highlightSize(Long.valueOf("100")) + .includeDocs(false) + .includeFields(java.util.Arrays.asList("testString")) + .limit(Long.valueOf("3")) + .sort(java.util.Arrays.asList("testString")) + .stale("ok") + .counts(java.util.Arrays.asList("testString")) + .drilldown(java.util.Arrays.asList(java.util.Arrays.asList("testString"))) + .groupField("testString") + .groupLimit(Long.valueOf("1")) + .groupSort(java.util.Arrays.asList("testString")) + .ranges(java.util.Collections.singletonMap("key1", java.util.Collections.singletonMap("key1", "testString"))) .build(); - // Invoke deleteReplicationDocument() with a valid options model and verify the result - Response response = cloudantService.deleteReplicationDocument(deleteReplicationDocumentOptionsModel).execute(); + // Invoke postSearchAsStream() with a valid options model and verify the result + Response response = cloudantService.postSearchAsStream(postSearchOptionsModel).execute(); assertNotNull(response); - DocumentResult responseObj = response.getResult(); + try (InputStream responseObj = response.getResult();) { + assertEquals(new String(responseObj.readAllBytes()), mockResponseBody); + } + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, postSearchAsStreamPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the postSearchAsStream operation with and without retries enabled + @Test + public void testPostSearchAsStreamWRetries() throws Throwable { + cloudantService.enableRetries(4, 30); + testPostSearchAsStreamWOptions(); + + cloudantService.disableRetries(); + testPostSearchAsStreamWOptions(); + } + + // Test the postSearchAsStream operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPostSearchAsStreamNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.postSearchAsStream(null).execute(); + } + + // Test the getSearchDiskSize operation with a valid options model parameter + @Test + public void testGetSearchDiskSizeWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"name\": \"name\", \"search_index\": {\"disk_size\": 0}}"; + String getSearchDiskSizePath = "/testString/_design/testString/_search_disk_size/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetSearchDiskSizeOptions model + GetSearchDiskSizeOptions getSearchDiskSizeOptionsModel = new GetSearchDiskSizeOptions.Builder() + .db("testString") + .ddoc("testString") + .index("testString") + .build(); + + // Invoke getSearchDiskSize() with a valid options model and verify the result + Response response = cloudantService.getSearchDiskSize(getSearchDiskSizeOptionsModel).execute(); + assertNotNull(response); + SearchDiskSizeInformation responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "DELETE"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, deleteReplicationDocumentPath); - // Verify query params + assertEquals(parsedPath, getSearchDiskSizePath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); - assertNotNull(query); - assertEquals(query.get("batch"), "ok"); - assertEquals(query.get("rev"), "testString"); + assertNull(query); } - // Test the deleteReplicationDocument operation with and without retries enabled + // Test the getSearchDiskSize operation with and without retries enabled @Test - public void testDeleteReplicationDocumentWRetries() throws Throwable { + public void testGetSearchDiskSizeWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testDeleteReplicationDocumentWOptions(); + testGetSearchDiskSizeWOptions(); cloudantService.disableRetries(); - testDeleteReplicationDocumentWOptions(); + testGetSearchDiskSizeWOptions(); } - // Test the deleteReplicationDocument operation with a null options model (negative test) + // Test the getSearchDiskSize operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testDeleteReplicationDocumentNoOptions() throws Throwable { + public void testGetSearchDiskSizeNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.deleteReplicationDocument(null).execute(); + cloudantService.getSearchDiskSize(null).execute(); } - // Test the getReplicationDocument operation with a valid options model parameter + // Test the getSearchInfo operation with a valid options model parameter @Test - public void testGetReplicationDocumentWOptions() throws Throwable { + public void testGetSearchInfoWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}], \"cancel\": true, \"checkpoint_interval\": 30000, \"connection_timeout\": 30000, \"continuous\": false, \"create_target\": false, \"create_target_params\": {\"n\": 3, \"partitioned\": false, \"q\": 16}, \"doc_ids\": [\"docIds\"], \"filter\": \"filter\", \"http_connections\": 20, \"owner\": \"owner\", \"query_params\": {\"mapKey\": \"inner\"}, \"retries_per_request\": 5, \"selector\": {\"anyKey\": \"anyValue\"}, \"since_seq\": \"sinceSeq\", \"socket_options\": \"socketOptions\", \"source\": {\"auth\": {\"basic\": {\"password\": \"password\", \"username\": \"username\"}, \"iam\": {\"api_key\": \"apiKey\"}}, \"headers\": {\"mapKey\": \"inner\"}, \"url\": \"url\"}, \"source_proxy\": \"sourceProxy\", \"target\": {\"auth\": {\"basic\": {\"password\": \"password\", \"username\": \"username\"}, \"iam\": {\"api_key\": \"apiKey\"}}, \"headers\": {\"mapKey\": \"inner\"}, \"url\": \"url\"}, \"target_proxy\": \"targetProxy\", \"use_bulk_get\": true, \"use_checkpoints\": true, \"user_ctx\": {\"db\": \"db\", \"name\": \"name\", \"roles\": [\"_reader\"]}, \"winning_revs_only\": false, \"worker_batch_size\": 500, \"worker_processes\": 4}"; - String getReplicationDocumentPath = "/_replicator/testString"; + String mockResponseBody = "{\"name\": \"name\", \"search_index\": {\"committed_seq\": 0, \"disk_size\": 0, \"doc_count\": 0, \"doc_del_count\": 0, \"pending_seq\": 0, \"signature\": \"signature\", \"updates_pending\": {\"copies\": 0, \"copies_expected\": 0, \"maximum\": 0, \"minimum\": 0, \"preferred\": 0, \"total\": 0}}}"; + String getSearchInfoPath = "/testString/_design/testString/_search_info/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetReplicationDocumentOptions model - GetReplicationDocumentOptions getReplicationDocumentOptionsModel = new GetReplicationDocumentOptions.Builder() - .docId("testString") - .ifNoneMatch("testString") - .attachments(false) - .attEncodingInfo(false) - .conflicts(false) - .deletedConflicts(false) - .latest(false) - .localSeq(false) - .meta(false) - .rev("testString") - .revs(false) - .revsInfo(false) + // Construct an instance of the GetSearchInfoOptions model + GetSearchInfoOptions getSearchInfoOptionsModel = new GetSearchInfoOptions.Builder() + .db("testString") + .ddoc("testString") + .index("testString") .build(); - // Invoke getReplicationDocument() with a valid options model and verify the result - Response response = cloudantService.getReplicationDocument(getReplicationDocumentOptionsModel).execute(); + // Invoke getSearchInfo() with a valid options model and verify the result + Response response = cloudantService.getSearchInfo(getSearchInfoOptionsModel).execute(); assertNotNull(response); - ReplicationDocument responseObj = response.getResult(); + SearchInfoResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -4764,45 +4797,186 @@ public void testGetReplicationDocumentWOptions() throws Throwable { assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getReplicationDocumentPath); - // Verify query params + assertEquals(parsedPath, getSearchInfoPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getSearchInfo operation with and without retries enabled + @Test + public void testGetSearchInfoWRetries() throws Throwable { + cloudantService.enableRetries(4, 30); + testGetSearchInfoWOptions(); + + cloudantService.disableRetries(); + testGetSearchInfoWOptions(); + } + + // Test the getSearchInfo operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetSearchInfoNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.getSearchInfo(null).execute(); + } + + // Test the headReplicationDocument operation with a valid options model parameter + @Test + public void testHeadReplicationDocumentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String headReplicationDocumentPath = "/_replicator/testString"; + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the HeadReplicationDocumentOptions model + HeadReplicationDocumentOptions headReplicationDocumentOptionsModel = new HeadReplicationDocumentOptions.Builder() + .docId("testString") + .ifNoneMatch("testString") + .build(); + + // Invoke headReplicationDocument() with a valid options model and verify the result + Response response = cloudantService.headReplicationDocument(headReplicationDocumentOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "HEAD"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, headReplicationDocumentPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the headReplicationDocument operation with and without retries enabled + @Test + public void testHeadReplicationDocumentWRetries() throws Throwable { + cloudantService.enableRetries(4, 30); + testHeadReplicationDocumentWOptions(); + + cloudantService.disableRetries(); + testHeadReplicationDocumentWOptions(); + } + + // Test the headReplicationDocument operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testHeadReplicationDocumentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.headReplicationDocument(null).execute(); + } + + // Test the headSchedulerDocument operation with a valid options model parameter + @Test + public void testHeadSchedulerDocumentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String headSchedulerDocumentPath = "/_scheduler/docs/_replicator/testString"; + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the HeadSchedulerDocumentOptions model + HeadSchedulerDocumentOptions headSchedulerDocumentOptionsModel = new HeadSchedulerDocumentOptions.Builder() + .docId("testString") + .build(); + + // Invoke headSchedulerDocument() with a valid options model and verify the result + Response response = cloudantService.headSchedulerDocument(headSchedulerDocumentOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "HEAD"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, headSchedulerDocumentPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the headSchedulerDocument operation with and without retries enabled + @Test + public void testHeadSchedulerDocumentWRetries() throws Throwable { + cloudantService.enableRetries(4, 30); + testHeadSchedulerDocumentWOptions(); + + cloudantService.disableRetries(); + testHeadSchedulerDocumentWOptions(); + } + + // Test the headSchedulerDocument operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testHeadSchedulerDocumentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.headSchedulerDocument(null).execute(); + } + + // Test the headSchedulerJob operation with a valid options model parameter + @Test + public void testHeadSchedulerJobWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String headSchedulerJobPath = "/_scheduler/jobs/testString"; + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the HeadSchedulerJobOptions model + HeadSchedulerJobOptions headSchedulerJobOptionsModel = new HeadSchedulerJobOptions.Builder() + .jobId("testString") + .build(); + + // Invoke headSchedulerJob() with a valid options model and verify the result + Response response = cloudantService.headSchedulerJob(headSchedulerJobOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "HEAD"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, headSchedulerJobPath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); - assertNotNull(query); - assertEquals(Boolean.valueOf(query.get("attachments")), Boolean.valueOf(false)); - assertEquals(Boolean.valueOf(query.get("att_encoding_info")), Boolean.valueOf(false)); - assertEquals(Boolean.valueOf(query.get("conflicts")), Boolean.valueOf(false)); - assertEquals(Boolean.valueOf(query.get("deleted_conflicts")), Boolean.valueOf(false)); - assertEquals(Boolean.valueOf(query.get("latest")), Boolean.valueOf(false)); - assertEquals(Boolean.valueOf(query.get("local_seq")), Boolean.valueOf(false)); - assertEquals(Boolean.valueOf(query.get("meta")), Boolean.valueOf(false)); - assertEquals(query.get("rev"), "testString"); - assertEquals(Boolean.valueOf(query.get("revs")), Boolean.valueOf(false)); - assertEquals(Boolean.valueOf(query.get("revs_info")), Boolean.valueOf(false)); + assertNull(query); } - // Test the getReplicationDocument operation with and without retries enabled + // Test the headSchedulerJob operation with and without retries enabled @Test - public void testGetReplicationDocumentWRetries() throws Throwable { + public void testHeadSchedulerJobWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetReplicationDocumentWOptions(); + testHeadSchedulerJobWOptions(); cloudantService.disableRetries(); - testGetReplicationDocumentWOptions(); + testHeadSchedulerJobWOptions(); } - // Test the getReplicationDocument operation with a null options model (negative test) + // Test the headSchedulerJob operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetReplicationDocumentNoOptions() throws Throwable { + public void testHeadSchedulerJobNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.getReplicationDocument(null).execute(); + cloudantService.headSchedulerJob(null).execute(); } - // Test the putReplicationDocument operation with a valid options model parameter + // Test the postReplicator operation with a valid options model parameter @Test - public void testPutReplicationDocumentWOptions() throws Throwable { + public void testPostReplicatorWOptions() throws Throwable { // Register a mock response String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; - String putReplicationDocumentPath = "/_replicator/testString"; + String postReplicatorPath = "/_replicator"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(201) @@ -4851,10 +5025,21 @@ public void testPutReplicationDocumentWOptions() throws Throwable { .apiKey("testString") .build(); + // Construct an instance of the ReplicationDatabaseAuthIBMIam model + ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIamModel = new ReplicationDatabaseAuthIBMIam.Builder() + .apiKey("testString") + .build(); + + // Construct an instance of the ReplicationDatabaseAuthIBM model + ReplicationDatabaseAuthIBM replicationDatabaseAuthIbmModel = new ReplicationDatabaseAuthIBM.Builder() + .iam(replicationDatabaseAuthIbmIamModel) + .build(); + // Construct an instance of the ReplicationDatabaseAuth model ReplicationDatabaseAuth replicationDatabaseAuthModel = new ReplicationDatabaseAuth.Builder() .basic(replicationDatabaseAuthBasicModel) .iam(replicationDatabaseAuthIamModel) + .ibm(replicationDatabaseAuthIbmModel) .build(); // Construct an instance of the ReplicationDatabase model @@ -4893,6 +5078,7 @@ public void testPutReplicationDocumentWOptions() throws Throwable { .httpConnections(Long.valueOf("10")) .owner("testString") .queryParams(java.util.Collections.singletonMap("key1", "testString")) + .requestCompression("gzip") .retriesPerRequest(Long.valueOf("3")) .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) .sinceSeq("34-g1AAAAGjeJzLYWBgYMlgTmGQT0lKzi9KdU") @@ -4900,488 +5086,325 @@ public void testPutReplicationDocumentWOptions() throws Throwable { .source(replicationDatabaseModel) .sourceProxy("testString") .target(replicationDatabaseModel) - .targetProxy("testString") - .useBulkGet(true) - .useCheckpoints(false) - .userCtx(userContextModel) - .winningRevsOnly(false) - .workerBatchSize(Long.valueOf("400")) - .workerProcesses(Long.valueOf("3")) - .add("foo", "testString") - .build(); - - // Construct an instance of the PutReplicationDocumentOptions model - PutReplicationDocumentOptions putReplicationDocumentOptionsModel = new PutReplicationDocumentOptions.Builder() - .docId("testString") - .replicationDocument(replicationDocumentModel) - .ifMatch("testString") - .batch("ok") - .newEdits(false) - .rev("testString") - .build(); - - // Invoke putReplicationDocument() with a valid options model and verify the result - Response response = cloudantService.putReplicationDocument(putReplicationDocumentOptionsModel).execute(); - assertNotNull(response); - DocumentResult responseObj = response.getResult(); - assertNotNull(responseObj); - - // Verify the contents of the request sent to the mock server - RecordedRequest request = server.takeRequest(); - assertNotNull(request); - assertEquals(request.getMethod(), "PUT"); - // Verify request path - String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, putReplicationDocumentPath); - // Verify query params - Map query = TestUtilities.parseQueryString(request); - assertNotNull(query); - assertEquals(query.get("batch"), "ok"); - assertEquals(Boolean.valueOf(query.get("new_edits")), Boolean.valueOf(false)); - assertEquals(query.get("rev"), "testString"); - } - - // Test the putReplicationDocument operation with and without retries enabled - @Test - public void testPutReplicationDocumentWRetries() throws Throwable { - cloudantService.enableRetries(4, 30); - testPutReplicationDocumentWOptions(); - - cloudantService.disableRetries(); - testPutReplicationDocumentWOptions(); - } - - // Test the putReplicationDocument operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testPutReplicationDocumentNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.putReplicationDocument(null).execute(); - } - - // Test the getSchedulerDocs operation with a valid options model parameter - @Test - public void testGetSchedulerDocsWOptions() throws Throwable { - // Register a mock response - String mockResponseBody = "{\"total_rows\": 0, \"docs\": [{\"database\": \"database\", \"doc_id\": \"docId\", \"error_count\": 0, \"id\": \"id\", \"info\": {\"changes_pending\": 0, \"checkpointed_source_seq\": \"checkpointedSourceSeq\", \"doc_write_failures\": 0, \"docs_read\": 0, \"docs_written\": 0, \"error\": \"error\", \"missing_revisions_found\": 0, \"revisions_checked\": 0, \"source_seq\": \"sourceSeq\", \"through_seq\": \"throughSeq\"}, \"last_updated\": \"2019-01-01T12:00:00.000Z\", \"node\": \"node\", \"source\": \"source\", \"source_proxy\": \"sourceProxy\", \"start_time\": \"2019-01-01T12:00:00.000Z\", \"state\": \"initializing\", \"target\": \"target\", \"target_proxy\": \"targetProxy\"}]}"; - String getSchedulerDocsPath = "/_scheduler/docs"; - server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") - .setResponseCode(200) - .setBody(mockResponseBody)); - - // Construct an instance of the GetSchedulerDocsOptions model - GetSchedulerDocsOptions getSchedulerDocsOptionsModel = new GetSchedulerDocsOptions.Builder() - .limit(Long.valueOf("0")) - .skip(Long.valueOf("0")) - .states(java.util.Arrays.asList("initializing")) - .build(); - - // Invoke getSchedulerDocs() with a valid options model and verify the result - Response response = cloudantService.getSchedulerDocs(getSchedulerDocsOptionsModel).execute(); - assertNotNull(response); - SchedulerDocsResult responseObj = response.getResult(); - assertNotNull(responseObj); - - // Verify the contents of the request sent to the mock server - RecordedRequest request = server.takeRequest(); - assertNotNull(request); - assertEquals(request.getMethod(), "GET"); - // Verify request path - String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getSchedulerDocsPath); - // Verify query params - Map query = TestUtilities.parseQueryString(request); - assertNotNull(query); - assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("0")); - assertEquals(Long.valueOf(query.get("skip")), Long.valueOf("0")); - assertEquals(query.get("states"), RequestUtils.join(java.util.Arrays.asList("initializing"), ",")); - } - - // Test the getSchedulerDocs operation with and without retries enabled - @Test - public void testGetSchedulerDocsWRetries() throws Throwable { - cloudantService.enableRetries(4, 30); - testGetSchedulerDocsWOptions(); - - cloudantService.disableRetries(); - testGetSchedulerDocsWOptions(); - } - - // Test the getSchedulerDocument operation with a valid options model parameter - @Test - public void testGetSchedulerDocumentWOptions() throws Throwable { - // Register a mock response - String mockResponseBody = "{\"database\": \"database\", \"doc_id\": \"docId\", \"error_count\": 0, \"id\": \"id\", \"info\": {\"changes_pending\": 0, \"checkpointed_source_seq\": \"checkpointedSourceSeq\", \"doc_write_failures\": 0, \"docs_read\": 0, \"docs_written\": 0, \"error\": \"error\", \"missing_revisions_found\": 0, \"revisions_checked\": 0, \"source_seq\": \"sourceSeq\", \"through_seq\": \"throughSeq\"}, \"last_updated\": \"2019-01-01T12:00:00.000Z\", \"node\": \"node\", \"source\": \"source\", \"source_proxy\": \"sourceProxy\", \"start_time\": \"2019-01-01T12:00:00.000Z\", \"state\": \"initializing\", \"target\": \"target\", \"target_proxy\": \"targetProxy\"}"; - String getSchedulerDocumentPath = "/_scheduler/docs/_replicator/testString"; - server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") - .setResponseCode(200) - .setBody(mockResponseBody)); - - // Construct an instance of the GetSchedulerDocumentOptions model - GetSchedulerDocumentOptions getSchedulerDocumentOptionsModel = new GetSchedulerDocumentOptions.Builder() - .docId("testString") - .build(); - - // Invoke getSchedulerDocument() with a valid options model and verify the result - Response response = cloudantService.getSchedulerDocument(getSchedulerDocumentOptionsModel).execute(); - assertNotNull(response); - SchedulerDocument responseObj = response.getResult(); - assertNotNull(responseObj); - - // Verify the contents of the request sent to the mock server - RecordedRequest request = server.takeRequest(); - assertNotNull(request); - assertEquals(request.getMethod(), "GET"); - // Verify request path - String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getSchedulerDocumentPath); - // Verify that there is no query string - Map query = TestUtilities.parseQueryString(request); - assertNull(query); - } - - // Test the getSchedulerDocument operation with and without retries enabled - @Test - public void testGetSchedulerDocumentWRetries() throws Throwable { - cloudantService.enableRetries(4, 30); - testGetSchedulerDocumentWOptions(); - - cloudantService.disableRetries(); - testGetSchedulerDocumentWOptions(); - } - - // Test the getSchedulerDocument operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetSchedulerDocumentNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.getSchedulerDocument(null).execute(); - } - - // Test the getSchedulerJobs operation with a valid options model parameter - @Test - public void testGetSchedulerJobsWOptions() throws Throwable { - // Register a mock response - String mockResponseBody = "{\"total_rows\": 0, \"jobs\": [{\"database\": \"database\", \"doc_id\": \"docId\", \"history\": [{\"reason\": \"reason\", \"timestamp\": \"2019-01-01T12:00:00.000Z\", \"type\": \"type\"}], \"id\": \"id\", \"info\": {\"changes_pending\": 0, \"checkpointed_source_seq\": \"checkpointedSourceSeq\", \"doc_write_failures\": 0, \"docs_read\": 0, \"docs_written\": 0, \"error\": \"error\", \"missing_revisions_found\": 0, \"revisions_checked\": 0, \"source_seq\": \"sourceSeq\", \"through_seq\": \"throughSeq\"}, \"node\": \"node\", \"pid\": \"pid\", \"source\": \"source\", \"start_time\": \"2019-01-01T12:00:00.000Z\", \"target\": \"target\", \"user\": \"user\"}]}"; - String getSchedulerJobsPath = "/_scheduler/jobs"; - server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") - .setResponseCode(200) - .setBody(mockResponseBody)); - - // Construct an instance of the GetSchedulerJobsOptions model - GetSchedulerJobsOptions getSchedulerJobsOptionsModel = new GetSchedulerJobsOptions.Builder() - .limit(Long.valueOf("25")) - .skip(Long.valueOf("0")) - .build(); - - // Invoke getSchedulerJobs() with a valid options model and verify the result - Response response = cloudantService.getSchedulerJobs(getSchedulerJobsOptionsModel).execute(); - assertNotNull(response); - SchedulerJobsResult responseObj = response.getResult(); - assertNotNull(responseObj); - - // Verify the contents of the request sent to the mock server - RecordedRequest request = server.takeRequest(); - assertNotNull(request); - assertEquals(request.getMethod(), "GET"); - // Verify request path - String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getSchedulerJobsPath); - // Verify query params - Map query = TestUtilities.parseQueryString(request); - assertNotNull(query); - assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("25")); - assertEquals(Long.valueOf(query.get("skip")), Long.valueOf("0")); - } - - // Test the getSchedulerJobs operation with and without retries enabled - @Test - public void testGetSchedulerJobsWRetries() throws Throwable { - cloudantService.enableRetries(4, 30); - testGetSchedulerJobsWOptions(); - - cloudantService.disableRetries(); - testGetSchedulerJobsWOptions(); - } - - // Test the getSchedulerJob operation with a valid options model parameter - @Test - public void testGetSchedulerJobWOptions() throws Throwable { - // Register a mock response - String mockResponseBody = "{\"database\": \"database\", \"doc_id\": \"docId\", \"history\": [{\"reason\": \"reason\", \"timestamp\": \"2019-01-01T12:00:00.000Z\", \"type\": \"type\"}], \"id\": \"id\", \"info\": {\"changes_pending\": 0, \"checkpointed_source_seq\": \"checkpointedSourceSeq\", \"doc_write_failures\": 0, \"docs_read\": 0, \"docs_written\": 0, \"error\": \"error\", \"missing_revisions_found\": 0, \"revisions_checked\": 0, \"source_seq\": \"sourceSeq\", \"through_seq\": \"throughSeq\"}, \"node\": \"node\", \"pid\": \"pid\", \"source\": \"source\", \"start_time\": \"2019-01-01T12:00:00.000Z\", \"target\": \"target\", \"user\": \"user\"}"; - String getSchedulerJobPath = "/_scheduler/jobs/testString"; - server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") - .setResponseCode(200) - .setBody(mockResponseBody)); + .targetProxy("testString") + .useBulkGet(true) + .useCheckpoints(false) + .userCtx(userContextModel) + .winningRevsOnly(false) + .workerBatchSize(Long.valueOf("400")) + .workerProcesses(Long.valueOf("3")) + .add("foo", "testString") + .build(); - // Construct an instance of the GetSchedulerJobOptions model - GetSchedulerJobOptions getSchedulerJobOptionsModel = new GetSchedulerJobOptions.Builder() - .jobId("testString") + // Construct an instance of the PostReplicatorOptions model + PostReplicatorOptions postReplicatorOptionsModel = new PostReplicatorOptions.Builder() + .replicationDocument(replicationDocumentModel) + .batch("ok") .build(); - // Invoke getSchedulerJob() with a valid options model and verify the result - Response response = cloudantService.getSchedulerJob(getSchedulerJobOptionsModel).execute(); + // Invoke postReplicator() with a valid options model and verify the result + Response response = cloudantService.postReplicator(postReplicatorOptionsModel).execute(); assertNotNull(response); - SchedulerJob responseObj = response.getResult(); + DocumentResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "GET"); + assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getSchedulerJobPath); - // Verify that there is no query string + assertEquals(parsedPath, postReplicatorPath); + // Verify query params Map query = TestUtilities.parseQueryString(request); - assertNull(query); + assertNotNull(query); + assertEquals(query.get("batch"), "ok"); } - // Test the getSchedulerJob operation with and without retries enabled + // Test the postReplicator operation with and without retries enabled @Test - public void testGetSchedulerJobWRetries() throws Throwable { + public void testPostReplicatorWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetSchedulerJobWOptions(); + testPostReplicatorWOptions(); cloudantService.disableRetries(); - testGetSchedulerJobWOptions(); + testPostReplicatorWOptions(); } - // Test the getSchedulerJob operation with a null options model (negative test) + // Test the postReplicator operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetSchedulerJobNoOptions() throws Throwable { + public void testPostReplicatorNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.getSchedulerJob(null).execute(); + cloudantService.postReplicator(null).execute(); } - // Test the getSessionInformation operation with a valid options model parameter + // Test the deleteReplicationDocument operation with a valid options model parameter @Test - public void testGetSessionInformationWOptions() throws Throwable { + public void testDeleteReplicationDocumentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"ok\": true, \"info\": {\"authenticated\": \"authenticated\", \"authentication_db\": \"authenticationDb\", \"authentication_handlers\": [\"authenticationHandlers\"]}, \"userCtx\": {\"db\": \"db\", \"name\": \"name\", \"roles\": [\"_reader\"]}}"; - String getSessionInformationPath = "/_session"; + String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; + String deleteReplicationDocumentPath = "/_replicator/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetSessionInformationOptions model - GetSessionInformationOptions getSessionInformationOptionsModel = new GetSessionInformationOptions(); + // Construct an instance of the DeleteReplicationDocumentOptions model + DeleteReplicationDocumentOptions deleteReplicationDocumentOptionsModel = new DeleteReplicationDocumentOptions.Builder() + .docId("testString") + .ifMatch("testString") + .batch("ok") + .rev("testString") + .build(); - // Invoke getSessionInformation() with a valid options model and verify the result - Response response = cloudantService.getSessionInformation(getSessionInformationOptionsModel).execute(); + // Invoke deleteReplicationDocument() with a valid options model and verify the result + Response response = cloudantService.deleteReplicationDocument(deleteReplicationDocumentOptionsModel).execute(); assertNotNull(response); - SessionInformation responseObj = response.getResult(); + DocumentResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "GET"); + assertEquals(request.getMethod(), "DELETE"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getSessionInformationPath); - // Verify that there is no query string + assertEquals(parsedPath, deleteReplicationDocumentPath); + // Verify query params Map query = TestUtilities.parseQueryString(request); - assertNull(query); + assertNotNull(query); + assertEquals(query.get("batch"), "ok"); + assertEquals(query.get("rev"), "testString"); } - // Test the getSessionInformation operation with and without retries enabled + // Test the deleteReplicationDocument operation with and without retries enabled @Test - public void testGetSessionInformationWRetries() throws Throwable { + public void testDeleteReplicationDocumentWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetSessionInformationWOptions(); + testDeleteReplicationDocumentWOptions(); cloudantService.disableRetries(); - testGetSessionInformationWOptions(); - } - - // Test the postApiKeys operation with a valid options model parameter - @Test - public void testPostApiKeysWOptions() throws Throwable { - // Register a mock response - String mockResponseBody = "{\"ok\": true, \"key\": \"key\", \"password\": \"password\"}"; - String postApiKeysPath = "/_api/v2/api_keys"; - server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") - .setResponseCode(201) - .setBody(mockResponseBody)); - - // Construct an instance of the PostApiKeysOptions model - PostApiKeysOptions postApiKeysOptionsModel = new PostApiKeysOptions(); - - // Invoke postApiKeys() with a valid options model and verify the result - Response response = cloudantService.postApiKeys(postApiKeysOptionsModel).execute(); - assertNotNull(response); - ApiKeysResult responseObj = response.getResult(); - assertNotNull(responseObj); - - // Verify the contents of the request sent to the mock server - RecordedRequest request = server.takeRequest(); - assertNotNull(request); - assertEquals(request.getMethod(), "POST"); - // Verify request path - String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postApiKeysPath); - // Verify that there is no query string - Map query = TestUtilities.parseQueryString(request); - assertNull(query); + testDeleteReplicationDocumentWOptions(); } - // Test the postApiKeys operation with and without retries enabled - @Test - public void testPostApiKeysWRetries() throws Throwable { - cloudantService.enableRetries(4, 30); - testPostApiKeysWOptions(); - - cloudantService.disableRetries(); - testPostApiKeysWOptions(); + // Test the deleteReplicationDocument operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteReplicationDocumentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.deleteReplicationDocument(null).execute(); } - // Test the putCloudantSecurityConfiguration operation with a valid options model parameter + // Test the getReplicationDocument operation with a valid options model parameter @Test - public void testPutCloudantSecurityConfigurationWOptions() throws Throwable { + public void testGetReplicationDocumentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"ok\": true}"; - String putCloudantSecurityConfigurationPath = "/_api/v2/db/testString/_security"; + String mockResponseBody = "{\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}], \"cancel\": true, \"checkpoint_interval\": 30000, \"connection_timeout\": 30000, \"continuous\": false, \"create_target\": false, \"create_target_params\": {\"n\": 3, \"partitioned\": false, \"q\": 16}, \"doc_ids\": [\"docIds\"], \"filter\": \"filter\", \"http_connections\": 20, \"owner\": \"owner\", \"query_params\": {\"mapKey\": \"inner\"}, \"request_compression\": \"none\", \"retries_per_request\": 5, \"selector\": {\"anyKey\": \"anyValue\"}, \"since_seq\": \"sinceSeq\", \"socket_options\": \"socketOptions\", \"source\": {\"auth\": {\"basic\": {\"password\": \"password\", \"username\": \"username\"}, \"iam\": {\"api_key\": \"apiKey\"}, \"ibm\": {\"iam\": {\"api_key\": \"apiKey\"}}}, \"headers\": {\"mapKey\": \"inner\"}, \"url\": \"url\"}, \"source_proxy\": \"sourceProxy\", \"target\": {\"auth\": {\"basic\": {\"password\": \"password\", \"username\": \"username\"}, \"iam\": {\"api_key\": \"apiKey\"}, \"ibm\": {\"iam\": {\"api_key\": \"apiKey\"}}}, \"headers\": {\"mapKey\": \"inner\"}, \"url\": \"url\"}, \"target_proxy\": \"targetProxy\", \"use_bulk_get\": true, \"use_checkpoints\": true, \"user_ctx\": {\"db\": \"db\", \"name\": \"name\", \"roles\": [\"_reader\"]}, \"winning_revs_only\": false, \"worker_batch_size\": 500, \"worker_processes\": 4}"; + String getReplicationDocumentPath = "/_replicator/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the SecurityObject model - SecurityObject securityObjectModel = new SecurityObject.Builder() - .names(java.util.Arrays.asList("testString")) - .roles(java.util.Arrays.asList("testString")) - .build(); - - // Construct an instance of the PutCloudantSecurityConfigurationOptions model - PutCloudantSecurityConfigurationOptions putCloudantSecurityConfigurationOptionsModel = new PutCloudantSecurityConfigurationOptions.Builder() - .db("testString") - .cloudant(java.util.Collections.singletonMap("key1", java.util.Arrays.asList("_reader"))) - .admins(securityObjectModel) - .couchdbAuthOnly(true) - .members(securityObjectModel) + // Construct an instance of the GetReplicationDocumentOptions model + GetReplicationDocumentOptions getReplicationDocumentOptionsModel = new GetReplicationDocumentOptions.Builder() + .docId("testString") + .ifNoneMatch("testString") + .attachments(false) + .attEncodingInfo(false) + .conflicts(false) + .deletedConflicts(false) + .latest(false) + .localSeq(false) + .meta(false) + .rev("testString") + .revs(false) + .revsInfo(false) .build(); - // Invoke putCloudantSecurityConfiguration() with a valid options model and verify the result - Response response = cloudantService.putCloudantSecurityConfiguration(putCloudantSecurityConfigurationOptionsModel).execute(); + // Invoke getReplicationDocument() with a valid options model and verify the result + Response response = cloudantService.getReplicationDocument(getReplicationDocumentOptionsModel).execute(); assertNotNull(response); - Ok responseObj = response.getResult(); + ReplicationDocument responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "PUT"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, putCloudantSecurityConfigurationPath); - // Verify that there is no query string + assertEquals(parsedPath, getReplicationDocumentPath); + // Verify query params Map query = TestUtilities.parseQueryString(request); - assertNull(query); + assertNotNull(query); + assertEquals(Boolean.valueOf(query.get("attachments")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("att_encoding_info")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("conflicts")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("deleted_conflicts")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("latest")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("local_seq")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("meta")), Boolean.valueOf(false)); + assertEquals(query.get("rev"), "testString"); + assertEquals(Boolean.valueOf(query.get("revs")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("revs_info")), Boolean.valueOf(false)); } - // Test the putCloudantSecurityConfiguration operation with and without retries enabled + // Test the getReplicationDocument operation with and without retries enabled @Test - public void testPutCloudantSecurityConfigurationWRetries() throws Throwable { + public void testGetReplicationDocumentWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPutCloudantSecurityConfigurationWOptions(); + testGetReplicationDocumentWOptions(); cloudantService.disableRetries(); - testPutCloudantSecurityConfigurationWOptions(); + testGetReplicationDocumentWOptions(); } - // Test the putCloudantSecurityConfiguration operation with a null options model (negative test) + // Test the getReplicationDocument operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPutCloudantSecurityConfigurationNoOptions() throws Throwable { + public void testGetReplicationDocumentNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.putCloudantSecurityConfiguration(null).execute(); + cloudantService.getReplicationDocument(null).execute(); } - // Test the getSecurity operation with a valid options model parameter + // Test the putReplicationDocument operation with a valid options model parameter @Test - public void testGetSecurityWOptions() throws Throwable { + public void testPutReplicationDocumentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"admins\": {\"names\": [\"names\"], \"roles\": [\"roles\"]}, \"cloudant\": {\"mapKey\": [\"_reader\"]}, \"couchdb_auth_only\": false, \"members\": {\"names\": [\"names\"], \"roles\": [\"roles\"]}}"; - String getSecurityPath = "/testString/_security"; + String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; + String putReplicationDocumentPath = "/_replicator/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") - .setResponseCode(200) + .setResponseCode(201) .setBody(mockResponseBody)); - // Construct an instance of the GetSecurityOptions model - GetSecurityOptions getSecurityOptionsModel = new GetSecurityOptions.Builder() - .db("testString") + // Construct an instance of the Attachment model + Attachment attachmentModel = new Attachment.Builder() + .contentType("testString") + .data(TestUtilities.createMockByteArray("VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=")) + .digest("testString") + .encodedLength(Long.valueOf("0")) + .encoding("testString") + .follows(true) + .length(Long.valueOf("0")) + .revpos(Long.valueOf("1")) + .stub(true) + .build(); + + // Construct an instance of the Revisions model + Revisions revisionsModel = new Revisions.Builder() + .ids(java.util.Arrays.asList("testString")) + .start(Long.valueOf("1")) + .build(); + + // Construct an instance of the DocumentRevisionStatus model + DocumentRevisionStatus documentRevisionStatusModel = new DocumentRevisionStatus.Builder() + .rev("testString") + .status("available") + .build(); + + // Construct an instance of the ReplicationCreateTargetParameters model + ReplicationCreateTargetParameters replicationCreateTargetParametersModel = new ReplicationCreateTargetParameters.Builder() + .n(Long.valueOf("3")) + .partitioned(false) + .q(Long.valueOf("1")) + .build(); + + // Construct an instance of the ReplicationDatabaseAuthBasic model + ReplicationDatabaseAuthBasic replicationDatabaseAuthBasicModel = new ReplicationDatabaseAuthBasic.Builder() + .password("testString") + .username("testString") + .build(); + + // Construct an instance of the ReplicationDatabaseAuthIam model + ReplicationDatabaseAuthIam replicationDatabaseAuthIamModel = new ReplicationDatabaseAuthIam.Builder() + .apiKey("testString") .build(); - // Invoke getSecurity() with a valid options model and verify the result - Response response = cloudantService.getSecurity(getSecurityOptionsModel).execute(); - assertNotNull(response); - Security responseObj = response.getResult(); - assertNotNull(responseObj); - - // Verify the contents of the request sent to the mock server - RecordedRequest request = server.takeRequest(); - assertNotNull(request); - assertEquals(request.getMethod(), "GET"); - // Verify request path - String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getSecurityPath); - // Verify that there is no query string - Map query = TestUtilities.parseQueryString(request); - assertNull(query); - } + // Construct an instance of the ReplicationDatabaseAuthIBMIam model + ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIamModel = new ReplicationDatabaseAuthIBMIam.Builder() + .apiKey("testString") + .build(); - // Test the getSecurity operation with and without retries enabled - @Test - public void testGetSecurityWRetries() throws Throwable { - cloudantService.enableRetries(4, 30); - testGetSecurityWOptions(); + // Construct an instance of the ReplicationDatabaseAuthIBM model + ReplicationDatabaseAuthIBM replicationDatabaseAuthIbmModel = new ReplicationDatabaseAuthIBM.Builder() + .iam(replicationDatabaseAuthIbmIamModel) + .build(); - cloudantService.disableRetries(); - testGetSecurityWOptions(); - } + // Construct an instance of the ReplicationDatabaseAuth model + ReplicationDatabaseAuth replicationDatabaseAuthModel = new ReplicationDatabaseAuth.Builder() + .basic(replicationDatabaseAuthBasicModel) + .iam(replicationDatabaseAuthIamModel) + .ibm(replicationDatabaseAuthIbmModel) + .build(); - // Test the getSecurity operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetSecurityNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.getSecurity(null).execute(); - } + // Construct an instance of the ReplicationDatabase model + ReplicationDatabase replicationDatabaseModel = new ReplicationDatabase.Builder() + .auth(replicationDatabaseAuthModel) + .headers(java.util.Collections.singletonMap("key1", "testString")) + .url("https://my-source-instance.cloudantnosqldb.appdomain.cloud.example/animaldb") + .build(); - // Test the putSecurity operation with a valid options model parameter - @Test - public void testPutSecurityWOptions() throws Throwable { - // Register a mock response - String mockResponseBody = "{\"ok\": true}"; - String putSecurityPath = "/testString/_security"; - server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") - .setResponseCode(200) - .setBody(mockResponseBody)); + // Construct an instance of the UserContext model + UserContext userContextModel = new UserContext.Builder() + .db("testString") + .name("john") + .roles(java.util.Arrays.asList("_replicator")) + .build(); - // Construct an instance of the SecurityObject model - SecurityObject securityObjectModel = new SecurityObject.Builder() - .names(java.util.Arrays.asList("superuser")) - .roles(java.util.Arrays.asList("admins")) + // Construct an instance of the ReplicationDocument model + ReplicationDocument replicationDocumentModel = new ReplicationDocument.Builder() + .attachments(java.util.Collections.singletonMap("key1", attachmentModel)) + .conflicts(java.util.Arrays.asList("testString")) + .deleted(true) + .deletedConflicts(java.util.Arrays.asList("testString")) + .id("testString") + .localSeq("testString") + .rev("testString") + .revisions(revisionsModel) + .revsInfo(java.util.Arrays.asList(documentRevisionStatusModel)) + .cancel(false) + .checkpointInterval(Long.valueOf("4500")) + .connectionTimeout(Long.valueOf("15000")) + .continuous(true) + .createTarget(true) + .createTargetParams(replicationCreateTargetParametersModel) + .docIds(java.util.Arrays.asList("badger", "lemur", "llama")) + .filter("ddoc/my_filter") + .httpConnections(Long.valueOf("10")) + .owner("testString") + .queryParams(java.util.Collections.singletonMap("key1", "testString")) + .requestCompression("gzip") + .retriesPerRequest(Long.valueOf("3")) + .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) + .sinceSeq("34-g1AAAAGjeJzLYWBgYMlgTmGQT0lKzi9KdU") + .socketOptions("[{keepalive, true}, {nodelay, false}]") + .source(replicationDatabaseModel) + .sourceProxy("testString") + .target(replicationDatabaseModel) + .targetProxy("testString") + .useBulkGet(true) + .useCheckpoints(false) + .userCtx(userContextModel) + .winningRevsOnly(false) + .workerBatchSize(Long.valueOf("400")) + .workerProcesses(Long.valueOf("3")) + .add("foo", "testString") .build(); - // Construct an instance of the PutSecurityOptions model - PutSecurityOptions putSecurityOptionsModel = new PutSecurityOptions.Builder() - .db("testString") - .admins(securityObjectModel) - .cloudant(java.util.Collections.singletonMap("key1", java.util.Arrays.asList("_reader"))) - .couchdbAuthOnly(true) - .members(securityObjectModel) + // Construct an instance of the PutReplicationDocumentOptions model + PutReplicationDocumentOptions putReplicationDocumentOptionsModel = new PutReplicationDocumentOptions.Builder() + .docId("testString") + .replicationDocument(replicationDocumentModel) + .ifMatch("testString") + .batch("ok") + .newEdits(false) + .rev("testString") .build(); - // Invoke putSecurity() with a valid options model and verify the result - Response response = cloudantService.putSecurity(putSecurityOptionsModel).execute(); + // Invoke putReplicationDocument() with a valid options model and verify the result + Response response = cloudantService.putReplicationDocument(putReplicationDocumentOptionsModel).execute(); assertNotNull(response); - Ok responseObj = response.getResult(); + DocumentResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -5390,47 +5413,54 @@ public void testPutSecurityWOptions() throws Throwable { assertEquals(request.getMethod(), "PUT"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, putSecurityPath); - // Verify that there is no query string + assertEquals(parsedPath, putReplicationDocumentPath); + // Verify query params Map query = TestUtilities.parseQueryString(request); - assertNull(query); + assertNotNull(query); + assertEquals(query.get("batch"), "ok"); + assertEquals(Boolean.valueOf(query.get("new_edits")), Boolean.valueOf(false)); + assertEquals(query.get("rev"), "testString"); } - // Test the putSecurity operation with and without retries enabled + // Test the putReplicationDocument operation with and without retries enabled @Test - public void testPutSecurityWRetries() throws Throwable { + public void testPutReplicationDocumentWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPutSecurityWOptions(); + testPutReplicationDocumentWOptions(); cloudantService.disableRetries(); - testPutSecurityWOptions(); + testPutReplicationDocumentWOptions(); } - // Test the putSecurity operation with a null options model (negative test) + // Test the putReplicationDocument operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPutSecurityNoOptions() throws Throwable { + public void testPutReplicationDocumentNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.putSecurity(null).execute(); + cloudantService.putReplicationDocument(null).execute(); } - // Test the getCorsInformation operation with a valid options model parameter + // Test the getSchedulerDocs operation with a valid options model parameter @Test - public void testGetCorsInformationWOptions() throws Throwable { + public void testGetSchedulerDocsWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"allow_credentials\": true, \"enable_cors\": true, \"origins\": [\"origins\"]}"; - String getCorsInformationPath = "/_api/v2/user/config/cors"; + String mockResponseBody = "{\"total_rows\": 0, \"docs\": [{\"database\": \"database\", \"doc_id\": \"docId\", \"error_count\": 0, \"id\": \"id\", \"info\": {\"changes_pending\": 0, \"checkpointed_source_seq\": \"checkpointedSourceSeq\", \"doc_write_failures\": 0, \"docs_read\": 0, \"docs_written\": 0, \"error\": \"error\", \"missing_revisions_found\": 0, \"revisions_checked\": 0, \"source_seq\": \"sourceSeq\", \"through_seq\": \"throughSeq\"}, \"last_updated\": \"2019-01-01T12:00:00.000Z\", \"node\": \"node\", \"source\": \"source\", \"source_proxy\": \"sourceProxy\", \"start_time\": \"2019-01-01T12:00:00.000Z\", \"state\": \"initializing\", \"target\": \"target\", \"target_proxy\": \"targetProxy\"}]}"; + String getSchedulerDocsPath = "/_scheduler/docs"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetCorsInformationOptions model - GetCorsInformationOptions getCorsInformationOptionsModel = new GetCorsInformationOptions(); + // Construct an instance of the GetSchedulerDocsOptions model + GetSchedulerDocsOptions getSchedulerDocsOptionsModel = new GetSchedulerDocsOptions.Builder() + .limit(Long.valueOf("0")) + .skip(Long.valueOf("0")) + .states(java.util.Arrays.asList("initializing")) + .build(); - // Invoke getCorsInformation() with a valid options model and verify the result - Response response = cloudantService.getCorsInformation(getCorsInformationOptionsModel).execute(); + // Invoke getSchedulerDocs() with a valid options model and verify the result + Response response = cloudantService.getSchedulerDocs(getSchedulerDocsOptionsModel).execute(); assertNotNull(response); - CorsInformation responseObj = response.getResult(); + SchedulerDocsResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -5439,218 +5469,193 @@ public void testGetCorsInformationWOptions() throws Throwable { assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getCorsInformationPath); - // Verify that there is no query string + assertEquals(parsedPath, getSchedulerDocsPath); + // Verify query params Map query = TestUtilities.parseQueryString(request); - assertNull(query); + assertNotNull(query); + assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("0")); + assertEquals(Long.valueOf(query.get("skip")), Long.valueOf("0")); + assertEquals(query.get("states"), RequestUtils.join(java.util.Arrays.asList("initializing"), ",")); } - // Test the getCorsInformation operation with and without retries enabled + // Test the getSchedulerDocs operation with and without retries enabled @Test - public void testGetCorsInformationWRetries() throws Throwable { + public void testGetSchedulerDocsWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetCorsInformationWOptions(); + testGetSchedulerDocsWOptions(); cloudantService.disableRetries(); - testGetCorsInformationWOptions(); + testGetSchedulerDocsWOptions(); } - // Test the putCorsConfiguration operation with a valid options model parameter + // Test the getSchedulerDocument operation with a valid options model parameter @Test - public void testPutCorsConfigurationWOptions() throws Throwable { + public void testGetSchedulerDocumentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"ok\": true}"; - String putCorsConfigurationPath = "/_api/v2/user/config/cors"; + String mockResponseBody = "{\"database\": \"database\", \"doc_id\": \"docId\", \"error_count\": 0, \"id\": \"id\", \"info\": {\"changes_pending\": 0, \"checkpointed_source_seq\": \"checkpointedSourceSeq\", \"doc_write_failures\": 0, \"docs_read\": 0, \"docs_written\": 0, \"error\": \"error\", \"missing_revisions_found\": 0, \"revisions_checked\": 0, \"source_seq\": \"sourceSeq\", \"through_seq\": \"throughSeq\"}, \"last_updated\": \"2019-01-01T12:00:00.000Z\", \"node\": \"node\", \"source\": \"source\", \"source_proxy\": \"sourceProxy\", \"start_time\": \"2019-01-01T12:00:00.000Z\", \"state\": \"initializing\", \"target\": \"target\", \"target_proxy\": \"targetProxy\"}"; + String getSchedulerDocumentPath = "/_scheduler/docs/_replicator/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PutCorsConfigurationOptions model - PutCorsConfigurationOptions putCorsConfigurationOptionsModel = new PutCorsConfigurationOptions.Builder() - .origins(java.util.Arrays.asList("https://example.com", "https://www.example.com")) - .allowCredentials(true) - .enableCors(true) + // Construct an instance of the GetSchedulerDocumentOptions model + GetSchedulerDocumentOptions getSchedulerDocumentOptionsModel = new GetSchedulerDocumentOptions.Builder() + .docId("testString") .build(); - // Invoke putCorsConfiguration() with a valid options model and verify the result - Response response = cloudantService.putCorsConfiguration(putCorsConfigurationOptionsModel).execute(); + // Invoke getSchedulerDocument() with a valid options model and verify the result + Response response = cloudantService.getSchedulerDocument(getSchedulerDocumentOptionsModel).execute(); assertNotNull(response); - Ok responseObj = response.getResult(); + SchedulerDocument responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "PUT"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, putCorsConfigurationPath); + assertEquals(parsedPath, getSchedulerDocumentPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the putCorsConfiguration operation with and without retries enabled + // Test the getSchedulerDocument operation with and without retries enabled @Test - public void testPutCorsConfigurationWRetries() throws Throwable { + public void testGetSchedulerDocumentWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPutCorsConfigurationWOptions(); + testGetSchedulerDocumentWOptions(); cloudantService.disableRetries(); - testPutCorsConfigurationWOptions(); + testGetSchedulerDocumentWOptions(); } - // Test the putCorsConfiguration operation with a null options model (negative test) + // Test the getSchedulerDocument operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPutCorsConfigurationNoOptions() throws Throwable { + public void testGetSchedulerDocumentNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.putCorsConfiguration(null).execute(); + cloudantService.getSchedulerDocument(null).execute(); } - // Test the headAttachment operation with a valid options model parameter + // Test the getSchedulerJobs operation with a valid options model parameter @Test - public void testHeadAttachmentWOptions() throws Throwable { + public void testGetSchedulerJobsWOptions() throws Throwable { // Register a mock response - String mockResponseBody = ""; - String headAttachmentPath = "/testString/testString/testString"; + String mockResponseBody = "{\"total_rows\": 0, \"jobs\": [{\"database\": \"database\", \"doc_id\": \"docId\", \"history\": [{\"reason\": \"reason\", \"timestamp\": \"2019-01-01T12:00:00.000Z\", \"type\": \"type\"}], \"id\": \"id\", \"info\": {\"changes_pending\": 0, \"checkpointed_source_seq\": \"checkpointedSourceSeq\", \"doc_write_failures\": 0, \"docs_read\": 0, \"docs_written\": 0, \"error\": \"error\", \"missing_revisions_found\": 0, \"revisions_checked\": 0, \"source_seq\": \"sourceSeq\", \"through_seq\": \"throughSeq\"}, \"node\": \"node\", \"pid\": \"pid\", \"source\": \"source\", \"start_time\": \"2019-01-01T12:00:00.000Z\", \"target\": \"target\", \"user\": \"user\"}]}"; + String getSchedulerJobsPath = "/_scheduler/jobs"; server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the HeadAttachmentOptions model - HeadAttachmentOptions headAttachmentOptionsModel = new HeadAttachmentOptions.Builder() - .db("testString") - .docId("testString") - .attachmentName("testString") - .ifMatch("testString") - .ifNoneMatch("testString") - .rev("testString") + // Construct an instance of the GetSchedulerJobsOptions model + GetSchedulerJobsOptions getSchedulerJobsOptionsModel = new GetSchedulerJobsOptions.Builder() + .limit(Long.valueOf("25")) + .skip(Long.valueOf("0")) .build(); - // Invoke headAttachment() with a valid options model and verify the result - Response response = cloudantService.headAttachment(headAttachmentOptionsModel).execute(); + // Invoke getSchedulerJobs() with a valid options model and verify the result + Response response = cloudantService.getSchedulerJobs(getSchedulerJobsOptionsModel).execute(); assertNotNull(response); - Void responseObj = response.getResult(); - assertNull(responseObj); + SchedulerJobsResult responseObj = response.getResult(); + assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "HEAD"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, headAttachmentPath); + assertEquals(parsedPath, getSchedulerJobsPath); // Verify query params Map query = TestUtilities.parseQueryString(request); assertNotNull(query); - assertEquals(query.get("rev"), "testString"); + assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("25")); + assertEquals(Long.valueOf(query.get("skip")), Long.valueOf("0")); } - // Test the headAttachment operation with and without retries enabled + // Test the getSchedulerJobs operation with and without retries enabled @Test - public void testHeadAttachmentWRetries() throws Throwable { + public void testGetSchedulerJobsWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testHeadAttachmentWOptions(); + testGetSchedulerJobsWOptions(); cloudantService.disableRetries(); - testHeadAttachmentWOptions(); - } - - // Test the headAttachment operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testHeadAttachmentNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.headAttachment(null).execute(); + testGetSchedulerJobsWOptions(); } - // Test the deleteAttachment operation with a valid options model parameter + // Test the getSchedulerJob operation with a valid options model parameter @Test - public void testDeleteAttachmentWOptions() throws Throwable { + public void testGetSchedulerJobWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; - String deleteAttachmentPath = "/testString/testString/testString"; + String mockResponseBody = "{\"database\": \"database\", \"doc_id\": \"docId\", \"history\": [{\"reason\": \"reason\", \"timestamp\": \"2019-01-01T12:00:00.000Z\", \"type\": \"type\"}], \"id\": \"id\", \"info\": {\"changes_pending\": 0, \"checkpointed_source_seq\": \"checkpointedSourceSeq\", \"doc_write_failures\": 0, \"docs_read\": 0, \"docs_written\": 0, \"error\": \"error\", \"missing_revisions_found\": 0, \"revisions_checked\": 0, \"source_seq\": \"sourceSeq\", \"through_seq\": \"throughSeq\"}, \"node\": \"node\", \"pid\": \"pid\", \"source\": \"source\", \"start_time\": \"2019-01-01T12:00:00.000Z\", \"target\": \"target\", \"user\": \"user\"}"; + String getSchedulerJobPath = "/_scheduler/jobs/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the DeleteAttachmentOptions model - DeleteAttachmentOptions deleteAttachmentOptionsModel = new DeleteAttachmentOptions.Builder() - .db("testString") - .docId("testString") - .attachmentName("testString") - .ifMatch("testString") - .rev("testString") - .batch("ok") + // Construct an instance of the GetSchedulerJobOptions model + GetSchedulerJobOptions getSchedulerJobOptionsModel = new GetSchedulerJobOptions.Builder() + .jobId("testString") .build(); - // Invoke deleteAttachment() with a valid options model and verify the result - Response response = cloudantService.deleteAttachment(deleteAttachmentOptionsModel).execute(); + // Invoke getSchedulerJob() with a valid options model and verify the result + Response response = cloudantService.getSchedulerJob(getSchedulerJobOptionsModel).execute(); assertNotNull(response); - DocumentResult responseObj = response.getResult(); + SchedulerJob responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "DELETE"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, deleteAttachmentPath); - // Verify query params + assertEquals(parsedPath, getSchedulerJobPath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); - assertNotNull(query); - assertEquals(query.get("rev"), "testString"); - assertEquals(query.get("batch"), "ok"); + assertNull(query); } - // Test the deleteAttachment operation with and without retries enabled + // Test the getSchedulerJob operation with and without retries enabled @Test - public void testDeleteAttachmentWRetries() throws Throwable { + public void testGetSchedulerJobWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testDeleteAttachmentWOptions(); + testGetSchedulerJobWOptions(); cloudantService.disableRetries(); - testDeleteAttachmentWOptions(); + testGetSchedulerJobWOptions(); } - // Test the deleteAttachment operation with a null options model (negative test) + // Test the getSchedulerJob operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testDeleteAttachmentNoOptions() throws Throwable { + public void testGetSchedulerJobNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.deleteAttachment(null).execute(); + cloudantService.getSchedulerJob(null).execute(); } - // Test the getAttachment operation with a valid options model parameter + // Test the getSessionInformation operation with a valid options model parameter @Test - public void testGetAttachmentWOptions() throws Throwable { + public void testGetSessionInformationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "This is a mock binary response."; - String getAttachmentPath = "/testString/testString/testString"; + String mockResponseBody = "{\"ok\": true, \"info\": {\"authenticated\": \"authenticated\", \"authentication_db\": \"authenticationDb\", \"authentication_handlers\": [\"authenticationHandlers\"]}, \"userCtx\": {\"db\": \"db\", \"name\": \"name\", \"roles\": [\"_reader\"]}}"; + String getSessionInformationPath = "/_session"; server.enqueue(new MockResponse() - .setHeader("Content-type", "*/*") + .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetAttachmentOptions model - GetAttachmentOptions getAttachmentOptionsModel = new GetAttachmentOptions.Builder() - .db("testString") - .docId("testString") - .attachmentName("testString") - .accept("testString") - .ifMatch("testString") - .ifNoneMatch("testString") - .range("testString") - .rev("testString") - .build(); + // Construct an instance of the GetSessionInformationOptions model + GetSessionInformationOptions getSessionInformationOptionsModel = new GetSessionInformationOptions(); - // Invoke getAttachment() with a valid options model and verify the result - Response response = cloudantService.getAttachment(getAttachmentOptionsModel).execute(); + // Invoke getSessionInformation() with a valid options model and verify the result + Response response = cloudantService.getSessionInformation(getSessionInformationOptionsModel).execute(); assertNotNull(response); - try (InputStream responseObj = response.getResult();) { - assertNotNull(responseObj); - } + SessionInformation responseObj = response.getResult(); + assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); @@ -5658,709 +5663,698 @@ public void testGetAttachmentWOptions() throws Throwable { assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getAttachmentPath); - // Verify query params + assertEquals(parsedPath, getSessionInformationPath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); - assertNotNull(query); - assertEquals(query.get("rev"), "testString"); + assertNull(query); } - // Test the getAttachment operation with and without retries enabled + // Test the getSessionInformation operation with and without retries enabled @Test - public void testGetAttachmentWRetries() throws Throwable { + public void testGetSessionInformationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetAttachmentWOptions(); + testGetSessionInformationWOptions(); cloudantService.disableRetries(); - testGetAttachmentWOptions(); - } - - // Test the getAttachment operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetAttachmentNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.getAttachment(null).execute(); + testGetSessionInformationWOptions(); } - // Test the putAttachment operation with a valid options model parameter + // Test the postApiKeys operation with a valid options model parameter @Test - public void testPutAttachmentWOptions() throws Throwable { + public void testPostApiKeysWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; - String putAttachmentPath = "/testString/testString/testString"; + String mockResponseBody = "{\"ok\": true, \"key\": \"key\", \"password\": \"password\"}"; + String postApiKeysPath = "/_api/v2/api_keys"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(201) .setBody(mockResponseBody)); - // Construct an instance of the PutAttachmentOptions model - PutAttachmentOptions putAttachmentOptionsModel = new PutAttachmentOptions.Builder() - .db("testString") - .docId("testString") - .attachmentName("testString") - .attachment(TestUtilities.createMockStream("This is a mock file.")) - .contentType("application/octet-stream") - .ifMatch("testString") - .rev("testString") - .build(); + // Construct an instance of the PostApiKeysOptions model + PostApiKeysOptions postApiKeysOptionsModel = new PostApiKeysOptions(); - // Invoke putAttachment() with a valid options model and verify the result - Response response = cloudantService.putAttachment(putAttachmentOptionsModel).execute(); + // Invoke postApiKeys() with a valid options model and verify the result + Response response = cloudantService.postApiKeys(postApiKeysOptionsModel).execute(); assertNotNull(response); - DocumentResult responseObj = response.getResult(); + ApiKeysResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "PUT"); + assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, putAttachmentPath); - // Verify header parameters - assertEquals(request.getHeader("Content-Type"), "application/octet-stream"); - // Verify query params + assertEquals(parsedPath, postApiKeysPath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); - assertNotNull(query); - assertEquals(query.get("rev"), "testString"); + assertNull(query); } - // Test the putAttachment operation with and without retries enabled + // Test the postApiKeys operation with and without retries enabled @Test - public void testPutAttachmentWRetries() throws Throwable { + public void testPostApiKeysWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPutAttachmentWOptions(); + testPostApiKeysWOptions(); cloudantService.disableRetries(); - testPutAttachmentWOptions(); - } - - // Test the putAttachment operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testPutAttachmentNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.putAttachment(null).execute(); + testPostApiKeysWOptions(); } - // Test the headLocalDocument operation with a valid options model parameter + // Test the putCloudantSecurityConfiguration operation with a valid options model parameter @Test - public void testHeadLocalDocumentWOptions() throws Throwable { + public void testPutCloudantSecurityConfigurationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = ""; - String headLocalDocumentPath = "/testString/_local/testString"; + String mockResponseBody = "{\"ok\": true}"; + String putCloudantSecurityConfigurationPath = "/_api/v2/db/testString/_security"; server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the HeadLocalDocumentOptions model - HeadLocalDocumentOptions headLocalDocumentOptionsModel = new HeadLocalDocumentOptions.Builder() + // Construct an instance of the SecurityObject model + SecurityObject securityObjectModel = new SecurityObject.Builder() + .names(java.util.Arrays.asList("testString")) + .roles(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the PutCloudantSecurityConfigurationOptions model + PutCloudantSecurityConfigurationOptions putCloudantSecurityConfigurationOptionsModel = new PutCloudantSecurityConfigurationOptions.Builder() .db("testString") - .docId("testString") - .ifNoneMatch("testString") + .cloudant(java.util.Collections.singletonMap("key1", java.util.Arrays.asList("_reader"))) + .admins(securityObjectModel) + .couchdbAuthOnly(true) + .members(securityObjectModel) .build(); - // Invoke headLocalDocument() with a valid options model and verify the result - Response response = cloudantService.headLocalDocument(headLocalDocumentOptionsModel).execute(); + // Invoke putCloudantSecurityConfiguration() with a valid options model and verify the result + Response response = cloudantService.putCloudantSecurityConfiguration(putCloudantSecurityConfigurationOptionsModel).execute(); assertNotNull(response); - Void responseObj = response.getResult(); - assertNull(responseObj); + Ok responseObj = response.getResult(); + assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "HEAD"); + assertEquals(request.getMethod(), "PUT"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, headLocalDocumentPath); + assertEquals(parsedPath, putCloudantSecurityConfigurationPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the headLocalDocument operation with and without retries enabled + // Test the putCloudantSecurityConfiguration operation with and without retries enabled @Test - public void testHeadLocalDocumentWRetries() throws Throwable { + public void testPutCloudantSecurityConfigurationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testHeadLocalDocumentWOptions(); + testPutCloudantSecurityConfigurationWOptions(); cloudantService.disableRetries(); - testHeadLocalDocumentWOptions(); + testPutCloudantSecurityConfigurationWOptions(); } - // Test the headLocalDocument operation with a null options model (negative test) + // Test the putCloudantSecurityConfiguration operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testHeadLocalDocumentNoOptions() throws Throwable { + public void testPutCloudantSecurityConfigurationNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.headLocalDocument(null).execute(); + cloudantService.putCloudantSecurityConfiguration(null).execute(); } - // Test the deleteLocalDocument operation with a valid options model parameter + // Test the getSecurity operation with a valid options model parameter @Test - public void testDeleteLocalDocumentWOptions() throws Throwable { + public void testGetSecurityWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; - String deleteLocalDocumentPath = "/testString/_local/testString"; + String mockResponseBody = "{\"admins\": {\"names\": [\"names\"], \"roles\": [\"roles\"]}, \"cloudant\": {\"mapKey\": [\"_reader\"]}, \"couchdb_auth_only\": false, \"members\": {\"names\": [\"names\"], \"roles\": [\"roles\"]}}"; + String getSecurityPath = "/testString/_security"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the DeleteLocalDocumentOptions model - DeleteLocalDocumentOptions deleteLocalDocumentOptionsModel = new DeleteLocalDocumentOptions.Builder() + // Construct an instance of the GetSecurityOptions model + GetSecurityOptions getSecurityOptionsModel = new GetSecurityOptions.Builder() .db("testString") - .docId("testString") - .batch("ok") .build(); - // Invoke deleteLocalDocument() with a valid options model and verify the result - Response response = cloudantService.deleteLocalDocument(deleteLocalDocumentOptionsModel).execute(); + // Invoke getSecurity() with a valid options model and verify the result + Response response = cloudantService.getSecurity(getSecurityOptionsModel).execute(); assertNotNull(response); - DocumentResult responseObj = response.getResult(); + Security responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "DELETE"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, deleteLocalDocumentPath); - // Verify query params + assertEquals(parsedPath, getSecurityPath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); - assertNotNull(query); - assertEquals(query.get("batch"), "ok"); + assertNull(query); } - // Test the deleteLocalDocument operation with and without retries enabled + // Test the getSecurity operation with and without retries enabled @Test - public void testDeleteLocalDocumentWRetries() throws Throwable { + public void testGetSecurityWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testDeleteLocalDocumentWOptions(); + testGetSecurityWOptions(); cloudantService.disableRetries(); - testDeleteLocalDocumentWOptions(); + testGetSecurityWOptions(); } - // Test the deleteLocalDocument operation with a null options model (negative test) + // Test the getSecurity operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testDeleteLocalDocumentNoOptions() throws Throwable { + public void testGetSecurityNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.deleteLocalDocument(null).execute(); + cloudantService.getSecurity(null).execute(); } - // Test the getLocalDocument operation with a valid options model parameter + // Test the putSecurity operation with a valid options model parameter @Test - public void testGetLocalDocumentWOptions() throws Throwable { + public void testPutSecurityWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}"; - String getLocalDocumentPath = "/testString/_local/testString"; + String mockResponseBody = "{\"ok\": true}"; + String putSecurityPath = "/testString/_security"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetLocalDocumentOptions model - GetLocalDocumentOptions getLocalDocumentOptionsModel = new GetLocalDocumentOptions.Builder() + // Construct an instance of the SecurityObject model + SecurityObject securityObjectModel = new SecurityObject.Builder() + .names(java.util.Arrays.asList("superuser")) + .roles(java.util.Arrays.asList("admins")) + .build(); + + // Construct an instance of the PutSecurityOptions model + PutSecurityOptions putSecurityOptionsModel = new PutSecurityOptions.Builder() .db("testString") - .docId("testString") - .accept("application/json") - .ifNoneMatch("testString") - .attachments(false) - .attEncodingInfo(false) - .localSeq(false) + .admins(securityObjectModel) + .cloudant(java.util.Collections.singletonMap("key1", java.util.Arrays.asList("_reader"))) + .couchdbAuthOnly(true) + .members(securityObjectModel) .build(); - // Invoke getLocalDocument() with a valid options model and verify the result - Response response = cloudantService.getLocalDocument(getLocalDocumentOptionsModel).execute(); + // Invoke putSecurity() with a valid options model and verify the result + Response response = cloudantService.putSecurity(putSecurityOptionsModel).execute(); assertNotNull(response); - Document responseObj = response.getResult(); + Ok responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "GET"); + assertEquals(request.getMethod(), "PUT"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getLocalDocumentPath); - // Verify query params + assertEquals(parsedPath, putSecurityPath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); - assertNotNull(query); - assertEquals(Boolean.valueOf(query.get("attachments")), Boolean.valueOf(false)); - assertEquals(Boolean.valueOf(query.get("att_encoding_info")), Boolean.valueOf(false)); - assertEquals(Boolean.valueOf(query.get("local_seq")), Boolean.valueOf(false)); + assertNull(query); } - // Test the getLocalDocument operation with and without retries enabled + // Test the putSecurity operation with and without retries enabled @Test - public void testGetLocalDocumentWRetries() throws Throwable { + public void testPutSecurityWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetLocalDocumentWOptions(); + testPutSecurityWOptions(); cloudantService.disableRetries(); - testGetLocalDocumentWOptions(); + testPutSecurityWOptions(); } - // Test the getLocalDocument operation with a null options model (negative test) + // Test the putSecurity operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetLocalDocumentNoOptions() throws Throwable { + public void testPutSecurityNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.getLocalDocument(null).execute(); + cloudantService.putSecurity(null).execute(); } - // Test the putLocalDocument operation with a valid options model parameter + // Test the getCorsInformation operation with a valid options model parameter @Test - public void testPutLocalDocumentWOptions() throws Throwable { + public void testGetCorsInformationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; - String putLocalDocumentPath = "/testString/_local/testString"; + String mockResponseBody = "{\"allow_credentials\": true, \"enable_cors\": true, \"origins\": [\"origins\"]}"; + String getCorsInformationPath = "/_api/v2/user/config/cors"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") - .setResponseCode(201) + .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the Attachment model - Attachment attachmentModel = new Attachment.Builder() - .contentType("testString") - .data(TestUtilities.createMockByteArray("VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=")) - .digest("testString") - .encodedLength(Long.valueOf("0")) - .encoding("testString") - .follows(true) - .length(Long.valueOf("0")) - .revpos(Long.valueOf("1")) - .stub(true) - .build(); - - // Construct an instance of the Revisions model - Revisions revisionsModel = new Revisions.Builder() - .ids(java.util.Arrays.asList("testString")) - .start(Long.valueOf("1")) - .build(); - - // Construct an instance of the DocumentRevisionStatus model - DocumentRevisionStatus documentRevisionStatusModel = new DocumentRevisionStatus.Builder() - .rev("testString") - .status("available") - .build(); - - // Construct an instance of the Document model - Document documentModel = new Document.Builder() - .attachments(java.util.Collections.singletonMap("key1", attachmentModel)) - .conflicts(java.util.Arrays.asList("testString")) - .deleted(true) - .deletedConflicts(java.util.Arrays.asList("testString")) - .id("exampleid") - .localSeq("testString") - .rev("testString") - .revisions(revisionsModel) - .revsInfo(java.util.Arrays.asList(documentRevisionStatusModel)) - .add("brand", "Foo") - .add("colours", "[\"red\",\"green\",\"black\",\"blue\"]") - .add("description", "Slim Colourful Design Electronic Cooking Appliance for ...") - .add("image", "assets/img/0gmsnghhew.jpg") - .add("keywords", "[\"Foo\",\"Scales\",\"Weight\",\"Digital\",\"Kitchen\"]") - .add("name", "Digital Kitchen Scales") - .add("price", "14.99") - .add("productId", "1000042") - .add("taxonomy", "[\"Home\",\"Kitchen\",\"Small Appliances\"]") - .add("type", "product") - .build(); - - // Construct an instance of the PutLocalDocumentOptions model - PutLocalDocumentOptions putLocalDocumentOptionsModel = new PutLocalDocumentOptions.Builder() - .db("testString") - .docId("testString") - .document(documentModel) - .contentType("application/json") - .batch("ok") - .build(); + // Construct an instance of the GetCorsInformationOptions model + GetCorsInformationOptions getCorsInformationOptionsModel = new GetCorsInformationOptions(); - // Invoke putLocalDocument() with a valid options model and verify the result - Response response = cloudantService.putLocalDocument(putLocalDocumentOptionsModel).execute(); + // Invoke getCorsInformation() with a valid options model and verify the result + Response response = cloudantService.getCorsInformation(getCorsInformationOptionsModel).execute(); assertNotNull(response); - DocumentResult responseObj = response.getResult(); + CorsInformation responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "PUT"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, putLocalDocumentPath); - // Verify query params + assertEquals(parsedPath, getCorsInformationPath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); - assertNotNull(query); - assertEquals(query.get("batch"), "ok"); + assertNull(query); } - // Test the putLocalDocument operation with and without retries enabled + // Test the getCorsInformation operation with and without retries enabled @Test - public void testPutLocalDocumentWRetries() throws Throwable { + public void testGetCorsInformationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPutLocalDocumentWOptions(); + testGetCorsInformationWOptions(); cloudantService.disableRetries(); - testPutLocalDocumentWOptions(); - } - - // Test the putLocalDocument operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testPutLocalDocumentNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - cloudantService.putLocalDocument(null).execute(); + testGetCorsInformationWOptions(); } - // Test the postRevsDiff operation with a valid options model parameter + // Test the putCorsConfiguration operation with a valid options model parameter @Test - public void testPostRevsDiffWOptions() throws Throwable { + public void testPutCorsConfigurationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"mapKey\": {\"missing\": [\"missing\"], \"possible_ancestors\": [\"possibleAncestors\"]}}"; - String postRevsDiffPath = "/testString/_revs_diff"; + String mockResponseBody = "{\"ok\": true}"; + String putCorsConfigurationPath = "/_api/v2/user/config/cors"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostRevsDiffOptions model - PostRevsDiffOptions postRevsDiffOptionsModel = new PostRevsDiffOptions.Builder() - .db("testString") - .documentRevisions(java.util.Collections.singletonMap("key1", java.util.Arrays.asList("testString"))) + // Construct an instance of the PutCorsConfigurationOptions model + PutCorsConfigurationOptions putCorsConfigurationOptionsModel = new PutCorsConfigurationOptions.Builder() + .origins(java.util.Arrays.asList("https://example.com", "https://www.example.com")) + .allowCredentials(true) + .enableCors(true) .build(); - // Invoke postRevsDiff() with a valid options model and verify the result - Response> response = cloudantService.postRevsDiff(postRevsDiffOptionsModel).execute(); + // Invoke putCorsConfiguration() with a valid options model and verify the result + Response response = cloudantService.putCorsConfiguration(putCorsConfigurationOptionsModel).execute(); assertNotNull(response); - Map responseObj = response.getResult(); + Ok responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "POST"); + assertEquals(request.getMethod(), "PUT"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postRevsDiffPath); + assertEquals(parsedPath, putCorsConfigurationPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the postRevsDiff operation with and without retries enabled + // Test the putCorsConfiguration operation with and without retries enabled @Test - public void testPostRevsDiffWRetries() throws Throwable { + public void testPutCorsConfigurationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostRevsDiffWOptions(); + testPutCorsConfigurationWOptions(); cloudantService.disableRetries(); - testPostRevsDiffWOptions(); + testPutCorsConfigurationWOptions(); } - // Test the postRevsDiff operation with a null options model (negative test) + // Test the putCorsConfiguration operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostRevsDiffNoOptions() throws Throwable { + public void testPutCorsConfigurationNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postRevsDiff(null).execute(); + cloudantService.putCorsConfiguration(null).execute(); } - // Test the getShardsInformation operation with a valid options model parameter + // Test the headAttachment operation with a valid options model parameter @Test - public void testGetShardsInformationWOptions() throws Throwable { + public void testHeadAttachmentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"shards\": {\"mapKey\": [\"inner\"]}}"; - String getShardsInformationPath = "/testString/_shards"; + String mockResponseBody = ""; + String headAttachmentPath = "/testString/testString/testString"; server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetShardsInformationOptions model - GetShardsInformationOptions getShardsInformationOptionsModel = new GetShardsInformationOptions.Builder() + // Construct an instance of the HeadAttachmentOptions model + HeadAttachmentOptions headAttachmentOptionsModel = new HeadAttachmentOptions.Builder() .db("testString") + .docId("testString") + .attachmentName("testString") + .ifMatch("testString") + .ifNoneMatch("testString") + .rev("testString") .build(); - // Invoke getShardsInformation() with a valid options model and verify the result - Response response = cloudantService.getShardsInformation(getShardsInformationOptionsModel).execute(); + // Invoke headAttachment() with a valid options model and verify the result + Response response = cloudantService.headAttachment(headAttachmentOptionsModel).execute(); assertNotNull(response); - ShardsInformation responseObj = response.getResult(); - assertNotNull(responseObj); + Void responseObj = response.getResult(); + assertNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "GET"); + assertEquals(request.getMethod(), "HEAD"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getShardsInformationPath); - // Verify that there is no query string + assertEquals(parsedPath, headAttachmentPath); + // Verify query params Map query = TestUtilities.parseQueryString(request); - assertNull(query); + assertNotNull(query); + assertEquals(query.get("rev"), "testString"); } - // Test the getShardsInformation operation with and without retries enabled + // Test the headAttachment operation with and without retries enabled @Test - public void testGetShardsInformationWRetries() throws Throwable { + public void testHeadAttachmentWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetShardsInformationWOptions(); + testHeadAttachmentWOptions(); cloudantService.disableRetries(); - testGetShardsInformationWOptions(); + testHeadAttachmentWOptions(); } - // Test the getShardsInformation operation with a null options model (negative test) + // Test the headAttachment operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetShardsInformationNoOptions() throws Throwable { + public void testHeadAttachmentNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.getShardsInformation(null).execute(); + cloudantService.headAttachment(null).execute(); } - // Test the getDocumentShardsInfo operation with a valid options model parameter + // Test the deleteAttachment operation with a valid options model parameter @Test - public void testGetDocumentShardsInfoWOptions() throws Throwable { + public void testDeleteAttachmentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"nodes\": [\"nodes\"], \"range\": \"range\"}"; - String getDocumentShardsInfoPath = "/testString/_shards/testString"; + String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; + String deleteAttachmentPath = "/testString/testString/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetDocumentShardsInfoOptions model - GetDocumentShardsInfoOptions getDocumentShardsInfoOptionsModel = new GetDocumentShardsInfoOptions.Builder() + // Construct an instance of the DeleteAttachmentOptions model + DeleteAttachmentOptions deleteAttachmentOptionsModel = new DeleteAttachmentOptions.Builder() .db("testString") .docId("testString") + .attachmentName("testString") + .ifMatch("testString") + .rev("testString") + .batch("ok") .build(); - // Invoke getDocumentShardsInfo() with a valid options model and verify the result - Response response = cloudantService.getDocumentShardsInfo(getDocumentShardsInfoOptionsModel).execute(); + // Invoke deleteAttachment() with a valid options model and verify the result + Response response = cloudantService.deleteAttachment(deleteAttachmentOptionsModel).execute(); assertNotNull(response); - DocumentShardInfo responseObj = response.getResult(); + DocumentResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "GET"); + assertEquals(request.getMethod(), "DELETE"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getDocumentShardsInfoPath); - // Verify that there is no query string + assertEquals(parsedPath, deleteAttachmentPath); + // Verify query params Map query = TestUtilities.parseQueryString(request); - assertNull(query); + assertNotNull(query); + assertEquals(query.get("rev"), "testString"); + assertEquals(query.get("batch"), "ok"); } - // Test the getDocumentShardsInfo operation with and without retries enabled + // Test the deleteAttachment operation with and without retries enabled @Test - public void testGetDocumentShardsInfoWRetries() throws Throwable { + public void testDeleteAttachmentWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetDocumentShardsInfoWOptions(); + testDeleteAttachmentWOptions(); cloudantService.disableRetries(); - testGetDocumentShardsInfoWOptions(); + testDeleteAttachmentWOptions(); } - // Test the getDocumentShardsInfo operation with a null options model (negative test) + // Test the deleteAttachment operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetDocumentShardsInfoNoOptions() throws Throwable { + public void testDeleteAttachmentNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.getDocumentShardsInfo(null).execute(); + cloudantService.deleteAttachment(null).execute(); } - // Test the headUpInformation operation with a valid options model parameter + // Test the getAttachment operation with a valid options model parameter @Test - public void testHeadUpInformationWOptions() throws Throwable { + public void testGetAttachmentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = ""; - String headUpInformationPath = "/_up"; + String mockResponseBody = "This is a mock binary response."; + String getAttachmentPath = "/testString/testString/testString"; server.enqueue(new MockResponse() + .setHeader("Content-type", "*/*") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the HeadUpInformationOptions model - HeadUpInformationOptions headUpInformationOptionsModel = new HeadUpInformationOptions(); + // Construct an instance of the GetAttachmentOptions model + GetAttachmentOptions getAttachmentOptionsModel = new GetAttachmentOptions.Builder() + .db("testString") + .docId("testString") + .attachmentName("testString") + .accept("testString") + .ifMatch("testString") + .ifNoneMatch("testString") + .range("testString") + .rev("testString") + .build(); - // Invoke headUpInformation() with a valid options model and verify the result - Response response = cloudantService.headUpInformation(headUpInformationOptionsModel).execute(); + // Invoke getAttachment() with a valid options model and verify the result + Response response = cloudantService.getAttachment(getAttachmentOptionsModel).execute(); assertNotNull(response); - Void responseObj = response.getResult(); - assertNull(responseObj); + try (InputStream responseObj = response.getResult();) { + assertNotNull(responseObj); + } // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "HEAD"); + assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, headUpInformationPath); - // Verify that there is no query string + assertEquals(parsedPath, getAttachmentPath); + // Verify query params Map query = TestUtilities.parseQueryString(request); - assertNull(query); + assertNotNull(query); + assertEquals(query.get("rev"), "testString"); } - // Test the headUpInformation operation with and without retries enabled + // Test the getAttachment operation with and without retries enabled @Test - public void testHeadUpInformationWRetries() throws Throwable { + public void testGetAttachmentWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testHeadUpInformationWOptions(); + testGetAttachmentWOptions(); cloudantService.disableRetries(); - testHeadUpInformationWOptions(); + testGetAttachmentWOptions(); } - // Test the getActiveTasks operation with a valid options model parameter + // Test the getAttachment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAttachmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.getAttachment(null).execute(); + } + + // Test the putAttachment operation with a valid options model parameter @Test - public void testGetActiveTasksWOptions() throws Throwable { + public void testPutAttachmentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "[{\"bulk_get_attempts\": 0, \"bulk_get_docs\": 0, \"changes_done\": 0, \"changes_pending\": 0, \"checkpoint_interval\": 30000, \"checkpointed_source_seq\": \"checkpointedSourceSeq\", \"continuous\": false, \"database\": \"database\", \"design_document\": \"designDocument\", \"doc_id\": \"docId\", \"doc_write_failures\": 0, \"docs_read\": 0, \"docs_written\": 0, \"index\": \"index\", \"indexer_pid\": \"indexerPid\", \"missing_revisions_found\": 0, \"node\": \"node\", \"phase\": \"docid_sort\", \"pid\": \"pid\", \"process_status\": \"exiting\", \"progress\": 0, \"replication_id\": \"replicationId\", \"retry\": false, \"revisions_checked\": 0, \"source\": \"source\", \"source_seq\": \"sourceSeq\", \"started_on\": 0, \"target\": \"target\", \"through_seq\": \"throughSeq\", \"total_changes\": 0, \"type\": \"database_compaction\", \"updated_on\": 0, \"user\": \"user\", \"view\": 0}]"; - String getActiveTasksPath = "/_active_tasks"; + String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; + String putAttachmentPath = "/testString/testString/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") - .setResponseCode(200) + .setResponseCode(201) .setBody(mockResponseBody)); - // Construct an instance of the GetActiveTasksOptions model - GetActiveTasksOptions getActiveTasksOptionsModel = new GetActiveTasksOptions(); + // Construct an instance of the PutAttachmentOptions model + PutAttachmentOptions putAttachmentOptionsModel = new PutAttachmentOptions.Builder() + .db("testString") + .docId("testString") + .attachmentName("testString") + .attachment(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .ifMatch("testString") + .rev("testString") + .build(); - // Invoke getActiveTasks() with a valid options model and verify the result - Response> response = cloudantService.getActiveTasks(getActiveTasksOptionsModel).execute(); + // Invoke putAttachment() with a valid options model and verify the result + Response response = cloudantService.putAttachment(putAttachmentOptionsModel).execute(); assertNotNull(response); - List responseObj = response.getResult(); + DocumentResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "GET"); + assertEquals(request.getMethod(), "PUT"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getActiveTasksPath); - // Verify that there is no query string + assertEquals(parsedPath, putAttachmentPath); + // Verify header parameters + assertEquals(request.getHeader("Content-Type"), "application/octet-stream"); + // Verify query params Map query = TestUtilities.parseQueryString(request); - assertNull(query); + assertNotNull(query); + assertEquals(query.get("rev"), "testString"); } - // Test the getActiveTasks operation with and without retries enabled + // Test the putAttachment operation with and without retries enabled @Test - public void testGetActiveTasksWRetries() throws Throwable { + public void testPutAttachmentWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetActiveTasksWOptions(); + testPutAttachmentWOptions(); cloudantService.disableRetries(); - testGetActiveTasksWOptions(); + testPutAttachmentWOptions(); } - // Test the getActivityTrackerEvents operation with a valid options model parameter + // Test the putAttachment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPutAttachmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.putAttachment(null).execute(); + } + + // Test the headLocalDocument operation with a valid options model parameter @Test - public void testGetActivityTrackerEventsWOptions() throws Throwable { + public void testHeadLocalDocumentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"types\": [\"management\"]}"; - String getActivityTrackerEventsPath = "/_api/v2/user/activity_tracker/events"; + String mockResponseBody = ""; + String headLocalDocumentPath = "/testString/_local/testString"; server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetActivityTrackerEventsOptions model - GetActivityTrackerEventsOptions getActivityTrackerEventsOptionsModel = new GetActivityTrackerEventsOptions(); + // Construct an instance of the HeadLocalDocumentOptions model + HeadLocalDocumentOptions headLocalDocumentOptionsModel = new HeadLocalDocumentOptions.Builder() + .db("testString") + .docId("testString") + .ifNoneMatch("testString") + .build(); - // Invoke getActivityTrackerEvents() with a valid options model and verify the result - Response response = cloudantService.getActivityTrackerEvents(getActivityTrackerEventsOptionsModel).execute(); + // Invoke headLocalDocument() with a valid options model and verify the result + Response response = cloudantService.headLocalDocument(headLocalDocumentOptionsModel).execute(); assertNotNull(response); - ActivityTrackerEvents responseObj = response.getResult(); - assertNotNull(responseObj); + Void responseObj = response.getResult(); + assertNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "GET"); + assertEquals(request.getMethod(), "HEAD"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getActivityTrackerEventsPath); + assertEquals(parsedPath, headLocalDocumentPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the getActivityTrackerEvents operation with and without retries enabled + // Test the headLocalDocument operation with and without retries enabled @Test - public void testGetActivityTrackerEventsWRetries() throws Throwable { + public void testHeadLocalDocumentWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetActivityTrackerEventsWOptions(); + testHeadLocalDocumentWOptions(); cloudantService.disableRetries(); - testGetActivityTrackerEventsWOptions(); + testHeadLocalDocumentWOptions(); } - // Test the postActivityTrackerEvents operation with a valid options model parameter + // Test the headLocalDocument operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testHeadLocalDocumentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.headLocalDocument(null).execute(); + } + + // Test the deleteLocalDocument operation with a valid options model parameter @Test - public void testPostActivityTrackerEventsWOptions() throws Throwable { + public void testDeleteLocalDocumentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"ok\": true}"; - String postActivityTrackerEventsPath = "/_api/v2/user/activity_tracker/events"; + String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; + String deleteLocalDocumentPath = "/testString/_local/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the PostActivityTrackerEventsOptions model - PostActivityTrackerEventsOptions postActivityTrackerEventsOptionsModel = new PostActivityTrackerEventsOptions.Builder() - .types(java.util.Arrays.asList("management", "data")) + // Construct an instance of the DeleteLocalDocumentOptions model + DeleteLocalDocumentOptions deleteLocalDocumentOptionsModel = new DeleteLocalDocumentOptions.Builder() + .db("testString") + .docId("testString") + .batch("ok") .build(); - // Invoke postActivityTrackerEvents() with a valid options model and verify the result - Response response = cloudantService.postActivityTrackerEvents(postActivityTrackerEventsOptionsModel).execute(); + // Invoke deleteLocalDocument() with a valid options model and verify the result + Response response = cloudantService.deleteLocalDocument(deleteLocalDocumentOptionsModel).execute(); assertNotNull(response); - Ok responseObj = response.getResult(); + DocumentResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "POST"); + assertEquals(request.getMethod(), "DELETE"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, postActivityTrackerEventsPath); - // Verify that there is no query string + assertEquals(parsedPath, deleteLocalDocumentPath); + // Verify query params Map query = TestUtilities.parseQueryString(request); - assertNull(query); + assertNotNull(query); + assertEquals(query.get("batch"), "ok"); } - // Test the postActivityTrackerEvents operation with and without retries enabled + // Test the deleteLocalDocument operation with and without retries enabled @Test - public void testPostActivityTrackerEventsWRetries() throws Throwable { + public void testDeleteLocalDocumentWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testPostActivityTrackerEventsWOptions(); + testDeleteLocalDocumentWOptions(); cloudantService.disableRetries(); - testPostActivityTrackerEventsWOptions(); + testDeleteLocalDocumentWOptions(); } - // Test the postActivityTrackerEvents operation with a null options model (negative test) + // Test the deleteLocalDocument operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) - public void testPostActivityTrackerEventsNoOptions() throws Throwable { + public void testDeleteLocalDocumentNoOptions() throws Throwable { server.enqueue(new MockResponse()); - cloudantService.postActivityTrackerEvents(null).execute(); + cloudantService.deleteLocalDocument(null).execute(); } - // Test the getCapacityDatabasesInformation operation with a valid options model parameter + // Test the getLocalDocument operation with a valid options model parameter @Test - public void testGetCapacityDatabasesInformationWOptions() throws Throwable { + public void testGetLocalDocumentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"current\": {\"databases\": {\"total\": 0}}}"; - String getCapacityDatabasesInformationPath = "/_api/v2/user/capacity/databases"; + String mockResponseBody = "{\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}]}"; + String getLocalDocumentPath = "/testString/_local/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetCapacityDatabasesInformationOptions model - GetCapacityDatabasesInformationOptions getCapacityDatabasesInformationOptionsModel = new GetCapacityDatabasesInformationOptions(); + // Construct an instance of the GetLocalDocumentOptions model + GetLocalDocumentOptions getLocalDocumentOptionsModel = new GetLocalDocumentOptions.Builder() + .db("testString") + .docId("testString") + .accept("application/json") + .ifNoneMatch("testString") + .attachments(false) + .attEncodingInfo(false) + .localSeq(false) + .build(); - // Invoke getCapacityDatabasesInformation() with a valid options model and verify the result - Response response = cloudantService.getCapacityDatabasesInformation(getCapacityDatabasesInformationOptionsModel).execute(); + // Invoke getLocalDocument() with a valid options model and verify the result + Response response = cloudantService.getLocalDocument(getLocalDocumentOptionsModel).execute(); assertNotNull(response); - CapacityDatabasesInformation responseObj = response.getResult(); + Document responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -6369,124 +6363,208 @@ public void testGetCapacityDatabasesInformationWOptions() throws Throwable { assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getCapacityDatabasesInformationPath); - // Verify that there is no query string + assertEquals(parsedPath, getLocalDocumentPath); + // Verify query params Map query = TestUtilities.parseQueryString(request); - assertNull(query); + assertNotNull(query); + assertEquals(Boolean.valueOf(query.get("attachments")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("att_encoding_info")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("local_seq")), Boolean.valueOf(false)); } - // Test the getCapacityDatabasesInformation operation with and without retries enabled + // Test the getLocalDocument operation with and without retries enabled @Test - public void testGetCapacityDatabasesInformationWRetries() throws Throwable { + public void testGetLocalDocumentWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetCapacityDatabasesInformationWOptions(); + testGetLocalDocumentWOptions(); cloudantService.disableRetries(); - testGetCapacityDatabasesInformationWOptions(); + testGetLocalDocumentWOptions(); } - // Test the getCurrentDatabasesInformation operation with a valid options model parameter + // Test the getLocalDocument operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetLocalDocumentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.getLocalDocument(null).execute(); + } + + // Test the putLocalDocument operation with a valid options model parameter @Test - public void testGetCurrentDatabasesInformationWOptions() throws Throwable { + public void testPutLocalDocumentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"databases\": {\"total\": 0}}"; - String getCurrentDatabasesInformationPath = "/_api/v2/user/current/databases"; + String mockResponseBody = "{\"id\": \"id\", \"rev\": \"rev\", \"ok\": true, \"caused_by\": \"causedBy\", \"error\": \"error\", \"reason\": \"reason\", \"ref\": 0}"; + String putLocalDocumentPath = "/testString/_local/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") - .setResponseCode(200) + .setResponseCode(201) .setBody(mockResponseBody)); - // Construct an instance of the GetCurrentDatabasesInformationOptions model - GetCurrentDatabasesInformationOptions getCurrentDatabasesInformationOptionsModel = new GetCurrentDatabasesInformationOptions(); + // Construct an instance of the Attachment model + Attachment attachmentModel = new Attachment.Builder() + .contentType("testString") + .data(TestUtilities.createMockByteArray("VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=")) + .digest("testString") + .encodedLength(Long.valueOf("0")) + .encoding("testString") + .follows(true) + .length(Long.valueOf("0")) + .revpos(Long.valueOf("1")) + .stub(true) + .build(); - // Invoke getCurrentDatabasesInformation() with a valid options model and verify the result - Response response = cloudantService.getCurrentDatabasesInformation(getCurrentDatabasesInformationOptionsModel).execute(); + // Construct an instance of the Revisions model + Revisions revisionsModel = new Revisions.Builder() + .ids(java.util.Arrays.asList("testString")) + .start(Long.valueOf("1")) + .build(); + + // Construct an instance of the DocumentRevisionStatus model + DocumentRevisionStatus documentRevisionStatusModel = new DocumentRevisionStatus.Builder() + .rev("testString") + .status("available") + .build(); + + // Construct an instance of the Document model + Document documentModel = new Document.Builder() + .attachments(java.util.Collections.singletonMap("key1", attachmentModel)) + .conflicts(java.util.Arrays.asList("testString")) + .deleted(true) + .deletedConflicts(java.util.Arrays.asList("testString")) + .id("exampleid") + .localSeq("testString") + .rev("testString") + .revisions(revisionsModel) + .revsInfo(java.util.Arrays.asList(documentRevisionStatusModel)) + .add("brand", "Foo") + .add("colours", "[\"red\",\"green\",\"black\",\"blue\"]") + .add("description", "Slim Colourful Design Electronic Cooking Appliance for ...") + .add("image", "assets/img/0gmsnghhew.jpg") + .add("keywords", "[\"Foo\",\"Scales\",\"Weight\",\"Digital\",\"Kitchen\"]") + .add("name", "Digital Kitchen Scales") + .add("price", "14.99") + .add("productId", "1000042") + .add("taxonomy", "[\"Home\",\"Kitchen\",\"Small Appliances\"]") + .add("type", "product") + .build(); + + // Construct an instance of the PutLocalDocumentOptions model + PutLocalDocumentOptions putLocalDocumentOptionsModel = new PutLocalDocumentOptions.Builder() + .db("testString") + .docId("testString") + .document(documentModel) + .contentType("application/json") + .batch("ok") + .build(); + + // Invoke putLocalDocument() with a valid options model and verify the result + Response response = cloudantService.putLocalDocument(putLocalDocumentOptionsModel).execute(); assertNotNull(response); - CurrentDatabasesInformation responseObj = response.getResult(); + DocumentResult responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "GET"); + assertEquals(request.getMethod(), "PUT"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getCurrentDatabasesInformationPath); - // Verify that there is no query string + assertEquals(parsedPath, putLocalDocumentPath); + // Verify query params Map query = TestUtilities.parseQueryString(request); - assertNull(query); + assertNotNull(query); + assertEquals(query.get("batch"), "ok"); } - // Test the getCurrentDatabasesInformation operation with and without retries enabled + // Test the putLocalDocument operation with and without retries enabled @Test - public void testGetCurrentDatabasesInformationWRetries() throws Throwable { + public void testPutLocalDocumentWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetCurrentDatabasesInformationWOptions(); + testPutLocalDocumentWOptions(); cloudantService.disableRetries(); - testGetCurrentDatabasesInformationWOptions(); + testPutLocalDocumentWOptions(); } - // Test the getCurrentThroughputInformation operation with a valid options model parameter + // Test the putLocalDocument operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPutLocalDocumentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.putLocalDocument(null).execute(); + } + + // Test the postRevsDiff operation with a valid options model parameter @Test - public void testGetCurrentThroughputInformationWOptions() throws Throwable { + public void testPostRevsDiffWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"throughput\": {\"query\": 0, \"read\": 0, \"write\": 0}}"; - String getCurrentThroughputInformationPath = "/_api/v2/user/current/throughput"; + String mockResponseBody = "{\"mapKey\": {\"missing\": [\"missing\"], \"possible_ancestors\": [\"possibleAncestors\"]}}"; + String postRevsDiffPath = "/testString/_revs_diff"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetCurrentThroughputInformationOptions model - GetCurrentThroughputInformationOptions getCurrentThroughputInformationOptionsModel = new GetCurrentThroughputInformationOptions(); + // Construct an instance of the PostRevsDiffOptions model + PostRevsDiffOptions postRevsDiffOptionsModel = new PostRevsDiffOptions.Builder() + .db("testString") + .documentRevisions(java.util.Collections.singletonMap("key1", java.util.Arrays.asList("testString"))) + .build(); - // Invoke getCurrentThroughputInformation() with a valid options model and verify the result - Response response = cloudantService.getCurrentThroughputInformation(getCurrentThroughputInformationOptionsModel).execute(); + // Invoke postRevsDiff() with a valid options model and verify the result + Response> response = cloudantService.postRevsDiff(postRevsDiffOptionsModel).execute(); assertNotNull(response); - CurrentThroughputInformation responseObj = response.getResult(); + Map responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); - assertEquals(request.getMethod(), "GET"); + assertEquals(request.getMethod(), "POST"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getCurrentThroughputInformationPath); + assertEquals(parsedPath, postRevsDiffPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the getCurrentThroughputInformation operation with and without retries enabled + // Test the postRevsDiff operation with and without retries enabled @Test - public void testGetCurrentThroughputInformationWRetries() throws Throwable { + public void testPostRevsDiffWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetCurrentThroughputInformationWOptions(); + testPostRevsDiffWOptions(); cloudantService.disableRetries(); - testGetCurrentThroughputInformationWOptions(); + testPostRevsDiffWOptions(); } - // Test the getMembershipInformation operation with a valid options model parameter + // Test the postRevsDiff operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPostRevsDiffNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.postRevsDiff(null).execute(); + } + + // Test the getShardsInformation operation with a valid options model parameter @Test - public void testGetMembershipInformationWOptions() throws Throwable { + public void testGetShardsInformationWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"all_nodes\": [\"allNodes\"], \"cluster_nodes\": [\"clusterNodes\"]}"; - String getMembershipInformationPath = "/_membership"; + String mockResponseBody = "{\"shards\": {\"mapKey\": [\"inner\"]}}"; + String getShardsInformationPath = "/testString/_shards"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetMembershipInformationOptions model - GetMembershipInformationOptions getMembershipInformationOptionsModel = new GetMembershipInformationOptions(); + // Construct an instance of the GetShardsInformationOptions model + GetShardsInformationOptions getShardsInformationOptionsModel = new GetShardsInformationOptions.Builder() + .db("testString") + .build(); - // Invoke getMembershipInformation() with a valid options model and verify the result - Response response = cloudantService.getMembershipInformation(getMembershipInformationOptionsModel).execute(); + // Invoke getShardsInformation() with a valid options model and verify the result + Response response = cloudantService.getShardsInformation(getShardsInformationOptionsModel).execute(); assertNotNull(response); - MembershipInformation responseObj = response.getResult(); + ShardsInformation responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -6495,40 +6573,50 @@ public void testGetMembershipInformationWOptions() throws Throwable { assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getMembershipInformationPath); + assertEquals(parsedPath, getShardsInformationPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the getMembershipInformation operation with and without retries enabled + // Test the getShardsInformation operation with and without retries enabled @Test - public void testGetMembershipInformationWRetries() throws Throwable { + public void testGetShardsInformationWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetMembershipInformationWOptions(); + testGetShardsInformationWOptions(); cloudantService.disableRetries(); - testGetMembershipInformationWOptions(); + testGetShardsInformationWOptions(); } - // Test the getUpInformation operation with a valid options model parameter + // Test the getShardsInformation operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetShardsInformationNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.getShardsInformation(null).execute(); + } + + // Test the getDocumentShardsInfo operation with a valid options model parameter @Test - public void testGetUpInformationWOptions() throws Throwable { + public void testGetDocumentShardsInfoWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"cluster\": \"cluster\", \"seeds\": {\"anyKey\": \"anyValue\"}, \"status\": \"maintenance_mode\"}"; - String getUpInformationPath = "/_up"; + String mockResponseBody = "{\"nodes\": [\"nodes\"], \"range\": \"range\"}"; + String getDocumentShardsInfoPath = "/testString/_shards/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) .setBody(mockResponseBody)); - // Construct an instance of the GetUpInformationOptions model - GetUpInformationOptions getUpInformationOptionsModel = new GetUpInformationOptions(); + // Construct an instance of the GetDocumentShardsInfoOptions model + GetDocumentShardsInfoOptions getDocumentShardsInfoOptionsModel = new GetDocumentShardsInfoOptions.Builder() + .db("testString") + .docId("testString") + .build(); - // Invoke getUpInformation() with a valid options model and verify the result - Response response = cloudantService.getUpInformation(getUpInformationOptionsModel).execute(); + // Invoke getDocumentShardsInfo() with a valid options model and verify the result + Response response = cloudantService.getDocumentShardsInfo(getDocumentShardsInfoOptionsModel).execute(); assertNotNull(response); - UpInformation responseObj = response.getResult(); + DocumentShardInfo responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -6537,20 +6625,27 @@ public void testGetUpInformationWOptions() throws Throwable { assertEquals(request.getMethod(), "GET"); // Verify request path String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getUpInformationPath); + assertEquals(parsedPath, getDocumentShardsInfoPath); // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); } - // Test the getUpInformation operation with and without retries enabled + // Test the getDocumentShardsInfo operation with and without retries enabled @Test - public void testGetUpInformationWRetries() throws Throwable { + public void testGetDocumentShardsInfoWRetries() throws Throwable { cloudantService.enableRetries(4, 30); - testGetUpInformationWOptions(); + testGetDocumentShardsInfoWOptions(); cloudantService.disableRetries(); - testGetUpInformationWOptions(); + testGetDocumentShardsInfoWOptions(); + } + + // Test the getDocumentShardsInfo operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDocumentShardsInfoNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + cloudantService.getDocumentShardsInfo(null).execute(); } // Perform setup needed before each test method diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/IndexInfoResultTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/IndexInfoResultTest.java new file mode 100644 index 000000000..97c13cc64 --- /dev/null +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/IndexInfoResultTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.cloudant.v1.model.ContentInformationSizes; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewIndex; +import com.ibm.cloud.cloudant.v1.model.IndexInfoResult; +import com.ibm.cloud.cloudant.v1.model.SearchIndexInfo; +import com.ibm.cloud.cloudant.v1.model.SearchIndexInformation; +import com.ibm.cloud.cloudant.v1.model.UpdatesPending; +import com.ibm.cloud.cloudant.v1.model.ViewIndexInformation; +import com.ibm.cloud.cloudant.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the IndexInfoResult model. + */ +public class IndexInfoResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testIndexInfoResult() throws Throwable { + IndexInfoResult indexInfoResultModel = new IndexInfoResult(); + assertNull(indexInfoResultModel.getBookmark()); + assertNull(indexInfoResultModel.getSearchIndexes()); + assertNull(indexInfoResultModel.getTotalRows()); + assertNull(indexInfoResultModel.getViewIndexes()); + } +} \ No newline at end of file diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/PostIndexInfoOptionsTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/PostIndexInfoOptionsTest.java new file mode 100644 index 000000000..aab6e06c1 --- /dev/null +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/PostIndexInfoOptionsTest.java @@ -0,0 +1,73 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.cloudant.v1.model.PostIndexInfoOptions; +import com.ibm.cloud.cloudant.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the PostIndexInfoOptions model. + */ +public class PostIndexInfoOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPostIndexInfoOptions() throws Throwable { + PostIndexInfoOptions postIndexInfoOptionsModel = new PostIndexInfoOptions.Builder() + .db("testString") + .attEncodingInfo(false) + .attachments(false) + .conflicts(false) + .descending(false) + .includeDocs(false) + .inclusiveEnd(true) + .limit(Long.valueOf("0")) + .skip(Long.valueOf("0")) + .updateSeq(false) + .endKey("testString") + .key("testString") + .keys(java.util.Arrays.asList("testString")) + .startKey("testString") + .type(java.util.Arrays.asList("search")) + .build(); + assertEquals(postIndexInfoOptionsModel.db(), "testString"); + assertEquals(postIndexInfoOptionsModel.attEncodingInfo(), Boolean.valueOf(false)); + assertEquals(postIndexInfoOptionsModel.attachments(), Boolean.valueOf(false)); + assertEquals(postIndexInfoOptionsModel.conflicts(), Boolean.valueOf(false)); + assertEquals(postIndexInfoOptionsModel.descending(), Boolean.valueOf(false)); + assertEquals(postIndexInfoOptionsModel.includeDocs(), Boolean.valueOf(false)); + assertEquals(postIndexInfoOptionsModel.inclusiveEnd(), Boolean.valueOf(true)); + assertEquals(postIndexInfoOptionsModel.limit(), Long.valueOf("0")); + assertEquals(postIndexInfoOptionsModel.skip(), Long.valueOf("0")); + assertEquals(postIndexInfoOptionsModel.updateSeq(), Boolean.valueOf(false)); + assertEquals(postIndexInfoOptionsModel.endKey(), "testString"); + assertEquals(postIndexInfoOptionsModel.key(), "testString"); + assertEquals(postIndexInfoOptionsModel.keys(), java.util.Arrays.asList("testString")); + assertEquals(postIndexInfoOptionsModel.startKey(), "testString"); + assertEquals(postIndexInfoOptionsModel.type(), java.util.Arrays.asList("search")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPostIndexInfoOptionsError() throws Throwable { + new PostIndexInfoOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/PostReplicatorOptionsTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/PostReplicatorOptionsTest.java index 104c18d07..d811e4766 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/PostReplicatorOptionsTest.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/PostReplicatorOptionsTest.java @@ -20,6 +20,8 @@ import com.ibm.cloud.cloudant.v1.model.ReplicationDatabase; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuth; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthBasic; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBM; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBMIam; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIam; import com.ibm.cloud.cloudant.v1.model.ReplicationDocument; import com.ibm.cloud.cloudant.v1.model.Revisions; @@ -97,12 +99,24 @@ public void testPostReplicatorOptions() throws Throwable { .build(); assertEquals(replicationDatabaseAuthIamModel.apiKey(), "testString"); + ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIamModel = new ReplicationDatabaseAuthIBMIam.Builder() + .apiKey("testString") + .build(); + assertEquals(replicationDatabaseAuthIbmIamModel.apiKey(), "testString"); + + ReplicationDatabaseAuthIBM replicationDatabaseAuthIbmModel = new ReplicationDatabaseAuthIBM.Builder() + .iam(replicationDatabaseAuthIbmIamModel) + .build(); + assertEquals(replicationDatabaseAuthIbmModel.iam(), replicationDatabaseAuthIbmIamModel); + ReplicationDatabaseAuth replicationDatabaseAuthModel = new ReplicationDatabaseAuth.Builder() .basic(replicationDatabaseAuthBasicModel) .iam(replicationDatabaseAuthIamModel) + .ibm(replicationDatabaseAuthIbmModel) .build(); assertEquals(replicationDatabaseAuthModel.basic(), replicationDatabaseAuthBasicModel); assertEquals(replicationDatabaseAuthModel.iam(), replicationDatabaseAuthIamModel); + assertEquals(replicationDatabaseAuthModel.ibm(), replicationDatabaseAuthIbmModel); ReplicationDatabase replicationDatabaseModel = new ReplicationDatabase.Builder() .auth(replicationDatabaseAuthModel) @@ -143,6 +157,7 @@ public void testPostReplicatorOptions() throws Throwable { .httpConnections(Long.valueOf("20")) .owner("testString") .queryParams(java.util.Collections.singletonMap("key1", "testString")) + .requestCompression("none") .retriesPerRequest(Long.valueOf("5")) .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) .sinceSeq("testString") @@ -179,6 +194,7 @@ public void testPostReplicatorOptions() throws Throwable { assertEquals(replicationDocumentModel.getHttpConnections(), Long.valueOf("20")); assertEquals(replicationDocumentModel.getOwner(), "testString"); assertEquals(replicationDocumentModel.getQueryParams(), java.util.Collections.singletonMap("key1", "testString")); + assertEquals(replicationDocumentModel.getRequestCompression(), "none"); assertEquals(replicationDocumentModel.getRetriesPerRequest(), Long.valueOf("5")); assertEquals(replicationDocumentModel.getSelector(), java.util.Collections.singletonMap("anyKey", "anyValue")); assertEquals(replicationDocumentModel.getSinceSeq(), "testString"); diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/PutReplicationDocumentOptionsTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/PutReplicationDocumentOptionsTest.java index f7644a63a..707fa87aa 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/PutReplicationDocumentOptionsTest.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/PutReplicationDocumentOptionsTest.java @@ -20,6 +20,8 @@ import com.ibm.cloud.cloudant.v1.model.ReplicationDatabase; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuth; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthBasic; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBM; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBMIam; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIam; import com.ibm.cloud.cloudant.v1.model.ReplicationDocument; import com.ibm.cloud.cloudant.v1.model.Revisions; @@ -97,12 +99,24 @@ public void testPutReplicationDocumentOptions() throws Throwable { .build(); assertEquals(replicationDatabaseAuthIamModel.apiKey(), "testString"); + ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIamModel = new ReplicationDatabaseAuthIBMIam.Builder() + .apiKey("testString") + .build(); + assertEquals(replicationDatabaseAuthIbmIamModel.apiKey(), "testString"); + + ReplicationDatabaseAuthIBM replicationDatabaseAuthIbmModel = new ReplicationDatabaseAuthIBM.Builder() + .iam(replicationDatabaseAuthIbmIamModel) + .build(); + assertEquals(replicationDatabaseAuthIbmModel.iam(), replicationDatabaseAuthIbmIamModel); + ReplicationDatabaseAuth replicationDatabaseAuthModel = new ReplicationDatabaseAuth.Builder() .basic(replicationDatabaseAuthBasicModel) .iam(replicationDatabaseAuthIamModel) + .ibm(replicationDatabaseAuthIbmModel) .build(); assertEquals(replicationDatabaseAuthModel.basic(), replicationDatabaseAuthBasicModel); assertEquals(replicationDatabaseAuthModel.iam(), replicationDatabaseAuthIamModel); + assertEquals(replicationDatabaseAuthModel.ibm(), replicationDatabaseAuthIbmModel); ReplicationDatabase replicationDatabaseModel = new ReplicationDatabase.Builder() .auth(replicationDatabaseAuthModel) @@ -143,6 +157,7 @@ public void testPutReplicationDocumentOptions() throws Throwable { .httpConnections(Long.valueOf("20")) .owner("testString") .queryParams(java.util.Collections.singletonMap("key1", "testString")) + .requestCompression("none") .retriesPerRequest(Long.valueOf("5")) .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) .sinceSeq("testString") @@ -179,6 +194,7 @@ public void testPutReplicationDocumentOptions() throws Throwable { assertEquals(replicationDocumentModel.getHttpConnections(), Long.valueOf("20")); assertEquals(replicationDocumentModel.getOwner(), "testString"); assertEquals(replicationDocumentModel.getQueryParams(), java.util.Collections.singletonMap("key1", "testString")); + assertEquals(replicationDocumentModel.getRequestCompression(), "none"); assertEquals(replicationDocumentModel.getRetriesPerRequest(), Long.valueOf("5")); assertEquals(replicationDocumentModel.getSelector(), java.util.Collections.singletonMap("anyKey", "anyValue")); assertEquals(replicationDocumentModel.getSinceSeq(), "testString"); diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBMIamTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBMIamTest.java new file mode 100644 index 000000000..b77354444 --- /dev/null +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBMIamTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBMIam; +import com.ibm.cloud.cloudant.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ReplicationDatabaseAuthIBMIam model. + */ +public class ReplicationDatabaseAuthIBMIamTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testReplicationDatabaseAuthIBMIam() throws Throwable { + ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIamModel = new ReplicationDatabaseAuthIBMIam.Builder() + .apiKey("testString") + .build(); + assertEquals(replicationDatabaseAuthIbmIamModel.apiKey(), "testString"); + + String json = TestUtilities.serialize(replicationDatabaseAuthIbmIamModel); + + ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIamModelNew = TestUtilities.deserialize(json, ReplicationDatabaseAuthIBMIam.class); + assertTrue(replicationDatabaseAuthIbmIamModelNew instanceof ReplicationDatabaseAuthIBMIam); + assertEquals(replicationDatabaseAuthIbmIamModelNew.apiKey(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testReplicationDatabaseAuthIBMIamError() throws Throwable { + new ReplicationDatabaseAuthIBMIam.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBMTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBMTest.java new file mode 100644 index 000000000..e7905a779 --- /dev/null +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthIBMTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBM; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBMIam; +import com.ibm.cloud.cloudant.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ReplicationDatabaseAuthIBM model. + */ +public class ReplicationDatabaseAuthIBMTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testReplicationDatabaseAuthIBM() throws Throwable { + ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIamModel = new ReplicationDatabaseAuthIBMIam.Builder() + .apiKey("testString") + .build(); + assertEquals(replicationDatabaseAuthIbmIamModel.apiKey(), "testString"); + + ReplicationDatabaseAuthIBM replicationDatabaseAuthIbmModel = new ReplicationDatabaseAuthIBM.Builder() + .iam(replicationDatabaseAuthIbmIamModel) + .build(); + assertEquals(replicationDatabaseAuthIbmModel.iam(), replicationDatabaseAuthIbmIamModel); + + String json = TestUtilities.serialize(replicationDatabaseAuthIbmModel); + + ReplicationDatabaseAuthIBM replicationDatabaseAuthIbmModelNew = TestUtilities.deserialize(json, ReplicationDatabaseAuthIBM.class); + assertTrue(replicationDatabaseAuthIbmModelNew instanceof ReplicationDatabaseAuthIBM); + assertEquals(replicationDatabaseAuthIbmModelNew.iam().toString(), replicationDatabaseAuthIbmIamModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testReplicationDatabaseAuthIBMError() throws Throwable { + new ReplicationDatabaseAuthIBM.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthTest.java index b1d4ce3e2..e6d880ecd 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthTest.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseAuthTest.java @@ -15,6 +15,8 @@ import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuth; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthBasic; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBM; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBMIam; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIam; import com.ibm.cloud.cloudant.v1.utils.TestUtilities; import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; @@ -45,12 +47,24 @@ public void testReplicationDatabaseAuth() throws Throwable { .build(); assertEquals(replicationDatabaseAuthIamModel.apiKey(), "testString"); + ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIamModel = new ReplicationDatabaseAuthIBMIam.Builder() + .apiKey("testString") + .build(); + assertEquals(replicationDatabaseAuthIbmIamModel.apiKey(), "testString"); + + ReplicationDatabaseAuthIBM replicationDatabaseAuthIbmModel = new ReplicationDatabaseAuthIBM.Builder() + .iam(replicationDatabaseAuthIbmIamModel) + .build(); + assertEquals(replicationDatabaseAuthIbmModel.iam(), replicationDatabaseAuthIbmIamModel); + ReplicationDatabaseAuth replicationDatabaseAuthModel = new ReplicationDatabaseAuth.Builder() .basic(replicationDatabaseAuthBasicModel) .iam(replicationDatabaseAuthIamModel) + .ibm(replicationDatabaseAuthIbmModel) .build(); assertEquals(replicationDatabaseAuthModel.basic(), replicationDatabaseAuthBasicModel); assertEquals(replicationDatabaseAuthModel.iam(), replicationDatabaseAuthIamModel); + assertEquals(replicationDatabaseAuthModel.ibm(), replicationDatabaseAuthIbmModel); String json = TestUtilities.serialize(replicationDatabaseAuthModel); @@ -58,5 +72,6 @@ public void testReplicationDatabaseAuth() throws Throwable { assertTrue(replicationDatabaseAuthModelNew instanceof ReplicationDatabaseAuth); assertEquals(replicationDatabaseAuthModelNew.basic().toString(), replicationDatabaseAuthBasicModel.toString()); assertEquals(replicationDatabaseAuthModelNew.iam().toString(), replicationDatabaseAuthIamModel.toString()); + assertEquals(replicationDatabaseAuthModelNew.ibm().toString(), replicationDatabaseAuthIbmModel.toString()); } } \ No newline at end of file diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseTest.java index 785fe11de..1d9a5e190 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseTest.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDatabaseTest.java @@ -16,6 +16,8 @@ import com.ibm.cloud.cloudant.v1.model.ReplicationDatabase; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuth; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthBasic; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBM; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBMIam; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIam; import com.ibm.cloud.cloudant.v1.utils.TestUtilities; import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; @@ -46,12 +48,24 @@ public void testReplicationDatabase() throws Throwable { .build(); assertEquals(replicationDatabaseAuthIamModel.apiKey(), "testString"); + ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIamModel = new ReplicationDatabaseAuthIBMIam.Builder() + .apiKey("testString") + .build(); + assertEquals(replicationDatabaseAuthIbmIamModel.apiKey(), "testString"); + + ReplicationDatabaseAuthIBM replicationDatabaseAuthIbmModel = new ReplicationDatabaseAuthIBM.Builder() + .iam(replicationDatabaseAuthIbmIamModel) + .build(); + assertEquals(replicationDatabaseAuthIbmModel.iam(), replicationDatabaseAuthIbmIamModel); + ReplicationDatabaseAuth replicationDatabaseAuthModel = new ReplicationDatabaseAuth.Builder() .basic(replicationDatabaseAuthBasicModel) .iam(replicationDatabaseAuthIamModel) + .ibm(replicationDatabaseAuthIbmModel) .build(); assertEquals(replicationDatabaseAuthModel.basic(), replicationDatabaseAuthBasicModel); assertEquals(replicationDatabaseAuthModel.iam(), replicationDatabaseAuthIamModel); + assertEquals(replicationDatabaseAuthModel.ibm(), replicationDatabaseAuthIbmModel); ReplicationDatabase replicationDatabaseModel = new ReplicationDatabase.Builder() .auth(replicationDatabaseAuthModel) diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDocumentTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDocumentTest.java index e97db5811..1b4f71c7c 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDocumentTest.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ReplicationDocumentTest.java @@ -19,6 +19,8 @@ import com.ibm.cloud.cloudant.v1.model.ReplicationDatabase; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuth; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthBasic; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBM; +import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIBMIam; import com.ibm.cloud.cloudant.v1.model.ReplicationDatabaseAuthIam; import com.ibm.cloud.cloudant.v1.model.ReplicationDocument; import com.ibm.cloud.cloudant.v1.model.Revisions; @@ -96,12 +98,24 @@ public void testReplicationDocument() throws Throwable { .build(); assertEquals(replicationDatabaseAuthIamModel.apiKey(), "testString"); + ReplicationDatabaseAuthIBMIam replicationDatabaseAuthIbmIamModel = new ReplicationDatabaseAuthIBMIam.Builder() + .apiKey("testString") + .build(); + assertEquals(replicationDatabaseAuthIbmIamModel.apiKey(), "testString"); + + ReplicationDatabaseAuthIBM replicationDatabaseAuthIbmModel = new ReplicationDatabaseAuthIBM.Builder() + .iam(replicationDatabaseAuthIbmIamModel) + .build(); + assertEquals(replicationDatabaseAuthIbmModel.iam(), replicationDatabaseAuthIbmIamModel); + ReplicationDatabaseAuth replicationDatabaseAuthModel = new ReplicationDatabaseAuth.Builder() .basic(replicationDatabaseAuthBasicModel) .iam(replicationDatabaseAuthIamModel) + .ibm(replicationDatabaseAuthIbmModel) .build(); assertEquals(replicationDatabaseAuthModel.basic(), replicationDatabaseAuthBasicModel); assertEquals(replicationDatabaseAuthModel.iam(), replicationDatabaseAuthIamModel); + assertEquals(replicationDatabaseAuthModel.ibm(), replicationDatabaseAuthIbmModel); ReplicationDatabase replicationDatabaseModel = new ReplicationDatabase.Builder() .auth(replicationDatabaseAuthModel) @@ -142,6 +156,7 @@ public void testReplicationDocument() throws Throwable { .httpConnections(Long.valueOf("20")) .owner("testString") .queryParams(java.util.Collections.singletonMap("key1", "testString")) + .requestCompression("none") .retriesPerRequest(Long.valueOf("5")) .selector(java.util.Collections.singletonMap("anyKey", "anyValue")) .sinceSeq("testString") @@ -178,6 +193,7 @@ public void testReplicationDocument() throws Throwable { assertEquals(replicationDocumentModel.getHttpConnections(), Long.valueOf("20")); assertEquals(replicationDocumentModel.getOwner(), "testString"); assertEquals(replicationDocumentModel.getQueryParams(), java.util.Collections.singletonMap("key1", "testString")); + assertEquals(replicationDocumentModel.getRequestCompression(), "none"); assertEquals(replicationDocumentModel.getRetriesPerRequest(), Long.valueOf("5")); assertEquals(replicationDocumentModel.getSelector(), java.util.Collections.singletonMap("anyKey", "anyValue")); assertEquals(replicationDocumentModel.getSinceSeq(), "testString"); @@ -212,6 +228,7 @@ public void testReplicationDocument() throws Throwable { assertEquals(replicationDocumentModelNew.getFilter(), "testString"); assertEquals(replicationDocumentModelNew.getHttpConnections(), Long.valueOf("20")); assertEquals(replicationDocumentModelNew.getOwner(), "testString"); + assertEquals(replicationDocumentModelNew.getRequestCompression(), "none"); assertEquals(replicationDocumentModelNew.getRetriesPerRequest(), Long.valueOf("5")); assertEquals(replicationDocumentModelNew.getSelector().toString(), java.util.Collections.singletonMap("anyKey", "anyValue").toString()); assertEquals(replicationDocumentModelNew.getSinceSeq(), "testString"); diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInfoTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInfoTest.java index d0867b17f..c42eb1c70 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInfoTest.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInfoTest.java @@ -14,6 +14,7 @@ package com.ibm.cloud.cloudant.v1.model; import com.ibm.cloud.cloudant.v1.model.SearchIndexInfo; +import com.ibm.cloud.cloudant.v1.model.UpdatesPending; import com.ibm.cloud.cloudant.v1.utils.TestUtilities; import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import java.io.InputStream; @@ -38,5 +39,6 @@ public void testSearchIndexInfo() throws Throwable { assertNull(searchIndexInfoModel.getDocDelCount()); assertNull(searchIndexInfoModel.getPendingSeq()); assertNull(searchIndexInfoModel.getSignature()); + assertNull(searchIndexInfoModel.getUpdatesPending()); } } \ No newline at end of file diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInformationTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInformationTest.java new file mode 100644 index 000000000..18c3d4416 --- /dev/null +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/SearchIndexInformationTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.cloudant.v1.model.SearchIndexInfo; +import com.ibm.cloud.cloudant.v1.model.SearchIndexInformation; +import com.ibm.cloud.cloudant.v1.model.UpdatesPending; +import com.ibm.cloud.cloudant.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the SearchIndexInformation model. + */ +public class SearchIndexInformationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchIndexInformation() throws Throwable { + SearchIndexInformation searchIndexInformationModel = new SearchIndexInformation(); + assertNull(searchIndexInformationModel.isOk()); + assertNull(searchIndexInformationModel.getCausedBy()); + assertNull(searchIndexInformationModel.getError()); + assertNull(searchIndexInformationModel.getReason()); + assertNull(searchIndexInformationModel.getRef()); + assertNull(searchIndexInformationModel.getDdoc()); + assertNull(searchIndexInformationModel.getInfo()); + assertNull(searchIndexInformationModel.getName()); + } +} \ No newline at end of file diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/SearchInfoResultTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/SearchInfoResultTest.java index 7e9572c2f..a8c60d387 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/SearchInfoResultTest.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/SearchInfoResultTest.java @@ -15,6 +15,7 @@ import com.ibm.cloud.cloudant.v1.model.SearchIndexInfo; import com.ibm.cloud.cloudant.v1.model.SearchInfoResult; +import com.ibm.cloud.cloudant.v1.model.UpdatesPending; import com.ibm.cloud.cloudant.v1.utils.TestUtilities; import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import java.io.InputStream; diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/UpdatesPendingTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/UpdatesPendingTest.java index 7ae26a307..d08a7b979 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/UpdatesPendingTest.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/UpdatesPendingTest.java @@ -32,6 +32,9 @@ public class UpdatesPendingTest { @Test public void testUpdatesPending() throws Throwable { UpdatesPending updatesPendingModel = new UpdatesPending(); + assertNull(updatesPendingModel.getCopies()); + assertNull(updatesPendingModel.getCopiesExpected()); + assertNull(updatesPendingModel.getMaximum()); assertNull(updatesPendingModel.getMinimum()); assertNull(updatesPendingModel.getPreferred()); assertNull(updatesPendingModel.getTotal()); diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ViewIndexInformationTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ViewIndexInformationTest.java new file mode 100644 index 000000000..04a9aaa3d --- /dev/null +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/ViewIndexInformationTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.cloudant.v1.model.ContentInformationSizes; +import com.ibm.cloud.cloudant.v1.model.DesignDocumentViewIndex; +import com.ibm.cloud.cloudant.v1.model.UpdatesPending; +import com.ibm.cloud.cloudant.v1.model.ViewIndexInformation; +import com.ibm.cloud.cloudant.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ViewIndexInformation model. + */ +public class ViewIndexInformationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testViewIndexInformation() throws Throwable { + ViewIndexInformation viewIndexInformationModel = new ViewIndexInformation(); + assertNull(viewIndexInformationModel.isOk()); + assertNull(viewIndexInformationModel.getCausedBy()); + assertNull(viewIndexInformationModel.getError()); + assertNull(viewIndexInformationModel.getReason()); + assertNull(viewIndexInformationModel.getRef()); + assertNull(viewIndexInformationModel.getDdoc()); + assertNull(viewIndexInformationModel.getInfo()); + assertNull(viewIndexInformationModel.getViews()); + } +} \ No newline at end of file diff --git a/stubs/gen-its-mappings.json b/stubs/gen-its-mappings.json index 167727145..524e2b5d5 100644 --- a/stubs/gen-its-mappings.json +++ b/stubs/gen-its-mappings.json @@ -2499,6 +2499,103 @@ }, "uuid": "6026c807-3ad5-3944-a4cc-6a4906aaefd3" }, + { + "id": "a1b2c3d4-e5f6-3789-abcd-ef0123456789", + "request": { + "url": "/testString/_index_info", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{}", + "ignoreArrayOrder": false, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "headers": { + "Cache-Control": "must-revalidate", + "Content-Type": "application/json", + "Date": "Mon, 23 May 2022 20:24:06 GMT", + "Server": "CouchDB/3.2.1 (Erlang OTP/20)", + "transaction-id": "a1b2c3d4e5f642406f8d93f1e20e401f", + "X-Cloudant-Action": "cloudantnosqldb.any-document.read", + "X-Couch-Request-ID": "a1b2c3d4e5", + "X-Frame-Options": "DENY", + "Strict-Transport-Security": "max-age=31536000", + "X-Content-Type-Options": "nosniff", + "X-Cloudant-Request-Class": "query", + "X-Cloudant-Backend": "bm-cc-us-east-05", + "Via": "1.1 lb1.bm-cc-us-east-05 (Glum/1.102.0)", + "Vary": "Accept-Encoding" + }, + "jsonBody": { + "total_rows": 1, + "bookmark": null, + "view_indexes": [ + { + "ddoc": "_design/testString", + "views": [ + "testString" + ], + "ok": true, + "info": { + "updates_pending": { + "minimum": 0, + "preferred": 0, + "total": 0, + "maximum": 0, + "copies": 24, + "copies_expected": 24 + }, + "waiting_commit": false, + "waiting_clients": 0, + "updater_running": false, + "update_seq": 14, + "sizes": { + "file": 30623, + "external": 1307, + "active": 2725 + }, + "signature": "bedc44e56c2ba97902aeaac2b51ad77c", + "purge_seq": 0, + "language": "javascript", + "compact_running": false, + "collator_versions": [ + "153.128" + ] + } + } + ], + "search_indexes": [ + { + "ddoc": "_design/testString", + "name": "testString", + "ok": true, + "info": { + "updates_pending": { + "minimum": 0, + "preferred": 0, + "total": 0, + "maximum": 0, + "copies": 24, + "copies_expected": 24 + }, + "signature": "f4c96067e9edeafd9afdf2876740b4cb", + "pending_seq": 14, + "doc_del_count": 0, + "doc_count": 11, + "disk_size": 14966, + "committed_seq": 14 + } + } + ], + "nouveau_indexes": [] + } + }, + "uuid": "a1b2c3d4-e5f6-3789-abcd-ef0123456789" + }, { "id": "c8bd56cb-8f5b-3521-80a9-75231b5a5069", "request": {