From 99ee158262498587e3d9c1ae079fb6bef28e6ecc Mon Sep 17 00:00:00 2001 From: cloudant-sdks-automation <71659186+cloudant-sdks-automation@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:10:34 +0000 Subject: [PATCH] ci(generated): add POST /_replicator IT stub Generated SDK source code using: - Generator version 3.98.0 - Specification version 1.0.0-dev0.1.23 - Automation (cloudant-sdks) version eea18a5 --- cloudant/v1.ts | 699 +++++++++++++----------- stubs/gen-its-mappings.json | 48 +- test/integration/cloudant.v1.test.js | 222 ++++++-- test/unit/cloudant.v1.test.js | 769 +++++++++++++++++---------- 4 files changed, 1089 insertions(+), 649 deletions(-) diff --git a/cloudant/v1.ts b/cloudant/v1.ts index bc67e2437..3c61dd9af 100644 --- a/cloudant/v1.ts +++ b/cloudant/v1.ts @@ -153,40 +153,32 @@ class CloudantV1 extends CloudantBaseService { } /** - * Retrieve one or more UUIDs. - * - * Requests one or more Universally Unique Identifiers (UUIDs) from the instance. The response is a JSON object that - * provides a list of UUIDs. + * Retrieve provisioned throughput capacity information. * - * **Tip:** The authentication for this endpoint is only enforced when using IAM. + * View the amount of provisioned throughput capacity that is allocated to an IBM Cloudant instance and what is the + * target provisioned throughput capacity. * * @param {Object} [params] - The parameters to send to the service. - * @param {number} [params.count] - Query parameter to specify the number of UUIDs to return. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ - public getUuids( - params?: CloudantV1.GetUuidsParams - ): Promise> { + public getCapacityThroughputInformation( + params?: CloudantV1.GetCapacityThroughputInformationParams + ): Promise> { const _params = { ...params }; const _requiredParams = []; - const _validParams = ['count', 'headers']; + const _validParams = ['headers']; const _validationErrors = validateParams(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } - const query = { - 'count': _params.count, - }; - - const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getUuids'); + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getCapacityThroughputInformation'); const parameters = { options: { - url: '/_uuids', + url: '/_api/v2/user/capacity/throughput', method: 'GET', - qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend( @@ -202,37 +194,44 @@ class CloudantV1 extends CloudantBaseService { return this.createRequestAndDeserializeResponse( parameters, - CloudantV1.UuidsResult.deserialize, + CloudantV1.CapacityThroughputInformation.deserialize, ); } /** - * Retrieve provisioned throughput capacity information. + * Update the target provisioned throughput capacity. * - * View the amount of provisioned throughput capacity that is allocated to an IBM Cloudant instance and what is the - * target provisioned throughput capacity. + * Sets the target provisioned throughput capacity for an IBM Cloudant instance. When target capacity is changed, the + * current capacity asynchronously changes to meet the target capacity. * - * @param {Object} [params] - The parameters to send to the service. + * @param {Object} params - The parameters to send to the service. + * @param {number} params.blocks - A number of blocks of throughput units. A block consists of 100 reads/sec, 50 + * writes/sec, and 5 global queries/sec of provisioned throughput capacity. Not available for some plans. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise>} */ - public getCapacityThroughputInformation( - params?: CloudantV1.GetCapacityThroughputInformationParams + public putCapacityThroughputConfiguration( + params: CloudantV1.PutCapacityThroughputConfigurationParams ): Promise> { const _params = { ...params }; - const _requiredParams = []; - const _validParams = ['headers']; + const _requiredParams = ['blocks']; + const _validParams = ['blocks', 'headers']; const _validationErrors = validateParams(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } - const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getCapacityThroughputInformation'); + const body = { + 'blocks': _params.blocks, + }; + + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'putCapacityThroughputConfiguration'); const parameters = { options: { url: '/_api/v2/user/capacity/throughput', - method: 'GET', + method: 'PUT', + body, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend( @@ -240,6 +239,7 @@ class CloudantV1 extends CloudantBaseService { sdkHeaders, { 'Accept': 'application/json', + 'Content-Type': 'application/json', }, _params.headers ), @@ -253,39 +253,40 @@ class CloudantV1 extends CloudantBaseService { } /** - * Update the target provisioned throughput capacity. + * Retrieve one or more UUIDs. * - * Sets the target provisioned throughput capacity for an IBM Cloudant instance. When target capacity is changed, the - * current capacity asynchronously changes to meet the target capacity. + * Requests one or more Universally Unique Identifiers (UUIDs) from the instance. The response is a JSON object that + * provides a list of UUIDs. * - * @param {Object} params - The parameters to send to the service. - * @param {number} params.blocks - A number of blocks of throughput units. A block consists of 100 reads/sec, 50 - * writes/sec, and 5 global queries/sec of provisioned throughput capacity. Not available for some plans. + * **Tip:** The authentication for this endpoint is only enforced when using IAM. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {number} [params.count] - Query parameter to specify the number of UUIDs to return. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ - public putCapacityThroughputConfiguration( - params: CloudantV1.PutCapacityThroughputConfigurationParams - ): Promise> { + public getUuids( + params?: CloudantV1.GetUuidsParams + ): Promise> { const _params = { ...params }; - const _requiredParams = ['blocks']; - const _validParams = ['blocks', 'headers']; + const _requiredParams = []; + const _validParams = ['count', 'headers']; const _validationErrors = validateParams(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } - const body = { - 'blocks': _params.blocks, + const query = { + 'count': _params.count, }; - const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'putCapacityThroughputConfiguration'); + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getUuids'); const parameters = { options: { - url: '/_api/v2/user/capacity/throughput', - method: 'PUT', - body, + url: '/_uuids', + method: 'GET', + qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend( @@ -293,7 +294,6 @@ class CloudantV1 extends CloudantBaseService { sdkHeaders, { 'Accept': 'application/json', - 'Content-Type': 'application/json', }, _params.headers ), @@ -302,7 +302,7 @@ class CloudantV1 extends CloudantBaseService { return this.createRequestAndDeserializeResponse( parameters, - CloudantV1.CapacityThroughputInformation.deserialize, + CloudantV1.UuidsResult.deserialize, ); } /************************* @@ -5155,10 +5155,10 @@ class CloudantV1 extends CloudantBaseService { * @param {string[]} [params.groupSort] - This field defines the order of the groups in a search that uses * group_field. The default sort order is relevance. This field can have the same values as the sort field, so single * fields and arrays of fields are supported. This option is only available when making global queries. - * @param {JsonObject} [params.ranges] - This field defines ranges for faceted, numeric search fields. The value is a - * JSON object where the fields names are faceted numeric search fields, and the values of the fields are JSON - * objects. The field names of the JSON objects are names for ranges. The values are strings that describe the range, - * for example "[0 TO 10]". This option is only available when making global queries. + * @param {JsonObject} [params.ranges] - Object mapping faceted, numeric search field names to the required ranges. + * Each key is a field name and each value is another object defining the ranges by mapping range name keys to string + * values describing the numeric ranges, for example "[0 TO 10]". This option is only available when making global + * queries. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise>} */ @@ -5281,10 +5281,10 @@ class CloudantV1 extends CloudantBaseService { * @param {string[]} [params.groupSort] - This field defines the order of the groups in a search that uses * group_field. The default sort order is relevance. This field can have the same values as the sort field, so single * fields and arrays of fields are supported. This option is only available when making global queries. - * @param {JsonObject} [params.ranges] - This field defines ranges for faceted, numeric search fields. The value is a - * JSON object where the fields names are faceted numeric search fields, and the values of the fields are JSON - * objects. The field names of the JSON objects are names for ranges. The values are strings that describe the range, - * for example "[0 TO 10]". This option is only available when making global queries. + * @param {JsonObject} [params.ranges] - Object mapping faceted, numeric search field names to the required ranges. + * Each key is a field name and each value is another object defining the ranges by mapping range name keys to string + * values describing the numeric ranges, for example "[0 TO 10]". This option is only available when making global + * queries. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise>} */ @@ -5412,7 +5412,7 @@ class CloudantV1 extends CloudantBaseService { ************************/ /** - * Retrieve the HTTP headers for a replication document. + * Retrieve the HTTP headers for a persistent replication. * * 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}` @@ -5560,7 +5560,64 @@ class CloudantV1 extends CloudantBaseService { } /** - * Cancel a replication. + * 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 {Object} params - The parameters to send to the service. + * @param {ReplicationDocument} params.replicationDocument - HTTP request body for replication operations. + * @param {string} [params.batch] - Query parameter to specify whether to store in batch mode. The server will respond + * with a HTTP 202 Accepted response code immediately. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public postReplicator( + params: CloudantV1.PostReplicatorParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['replicationDocument']; + const _validParams = ['replicationDocument', 'batch', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = CloudantV1.ReplicationDocument.serialize(_params.replicationDocument); + const query = { + 'batch': _params.batch, + }; + + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'postReplicator'); + + const parameters = { + options: { + url: '/_replicator', + method: 'POST', + body, + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequestAndDeserializeResponse( + parameters, + CloudantV1.DocumentResult.deserialize, + ); + } + + /** + * Cancel a persistent replication. * * Cancels a replication by deleting the document that describes it from the `_replicator` database. * @@ -5622,7 +5679,7 @@ class CloudantV1 extends CloudantBaseService { } /** - * Retrieve a replication document. + * Retrieve the configuration for a persistent replication. * * 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. @@ -5709,7 +5766,7 @@ class CloudantV1 extends CloudantBaseService { } /** - * Create or modify a replication using a replication document. + * Create or modify a persistent replication. * * Creates or modifies a document in the `_replicator` database to start a new replication or to edit an existing * replication. @@ -6054,39 +6111,33 @@ class CloudantV1 extends CloudantBaseService { ************************/ /** - * Retrieve database permissions information. + * Generates API keys for apps or persons to enable database access. * - * 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. + * 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 {Object} params - The parameters to send to the service. - * @param {string} params.db - Path parameter to specify the database name. + * @param {Object} [params] - The parameters to send to the service. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ - public getSecurity( - params: CloudantV1.GetSecurityParams - ): Promise> { + public postApiKeys( + params?: CloudantV1.PostApiKeysParams + ): Promise> { const _params = { ...params }; - const _requiredParams = ['db']; - const _validParams = ['db', 'headers']; + const _requiredParams = []; + const _validParams = ['headers']; const _validationErrors = validateParams(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } - const path = { - 'db': _params.db, - }; - - const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getSecurity'); + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'postApiKeys'); const parameters = { options: { - url: '/{db}/_security', - method: 'GET', - path, + url: '/_api/v2/api_keys', + method: 'POST', }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend( @@ -6102,16 +6153,15 @@ class CloudantV1 extends CloudantBaseService { return this.createRequestAndDeserializeResponse( parameters, - CloudantV1.Security.deserialize, + CloudantV1.ApiKeysResult.deserialize, ); } /** - * Modify database permissions. + * Modify only Cloudant related 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. + * 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 * @@ -6121,40 +6171,40 @@ class CloudantV1 extends CloudantBaseService { * * @param {Object} params - The parameters to send to the service. * @param {string} params.db - Path parameter to specify the database name. + * @param {JsonObject} params.cloudant - Database permissions for Cloudant users and/or API keys. * @param {SecurityObject} [params.admins] - Schema for names and roles to map to a database permission. - * @param {SecurityObject} [params.members] - Schema for names and roles to map to a database permission. - * @param {JsonObject} [params.cloudant] - Database permissions for Cloudant users and/or API keys. * @param {boolean} [params.couchdbAuthOnly] - Manage permissions using the `_users` database only. + * @param {SecurityObject} [params.members] - Schema for names and roles to map to a database permission. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise>} */ - public putSecurity( - params: CloudantV1.PutSecurityParams + public putCloudantSecurityConfiguration( + params: CloudantV1.PutCloudantSecurityConfigurationParams ): Promise> { const _params = { ...params }; - const _requiredParams = ['db']; - const _validParams = ['db', 'admins', 'members', 'cloudant', 'couchdbAuthOnly', 'headers']; + const _requiredParams = ['db', 'cloudant']; + const _validParams = ['db', 'cloudant', 'admins', 'couchdbAuthOnly', 'members', 'headers']; const _validationErrors = validateParams(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } const body = { - 'admins': CloudantV1.SecurityObject.serialize(_params.admins), - 'members': CloudantV1.SecurityObject.serialize(_params.members), 'cloudant': _params.cloudant, + 'admins': CloudantV1.SecurityObject.serialize(_params.admins), 'couchdb_auth_only': _params.couchdbAuthOnly, + 'members': CloudantV1.SecurityObject.serialize(_params.members), }; const path = { 'db': _params.db, }; - const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'putSecurity'); + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'putCloudantSecurityConfiguration'); const parameters = { options: { - url: '/{db}/_security', + url: '/_api/v2/db/{db}/_security', method: 'PUT', body, path, @@ -6179,33 +6229,39 @@ class CloudantV1 extends CloudantBaseService { } /** - * Generates API keys for apps or persons to enable database access. + * Retrieve database permissions information. * - * 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. + * 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 {Object} [params] - The parameters to send to the service. + * @param {Object} params - The parameters to send to the service. + * @param {string} params.db - Path parameter to specify the database name. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ - public postApiKeys( - params?: CloudantV1.PostApiKeysParams - ): Promise> { + public getSecurity( + params: CloudantV1.GetSecurityParams + ): Promise> { const _params = { ...params }; - const _requiredParams = []; - const _validParams = ['headers']; + const _requiredParams = ['db']; + const _validParams = ['db', 'headers']; const _validationErrors = validateParams(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } - const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'postApiKeys'); + const path = { + 'db': _params.db, + }; + + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getSecurity'); const parameters = { options: { - url: '/_api/v2/api_keys', - method: 'POST', + url: '/{db}/_security', + method: 'GET', + path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend( @@ -6221,15 +6277,16 @@ class CloudantV1 extends CloudantBaseService { return this.createRequestAndDeserializeResponse( parameters, - CloudantV1.ApiKeysResult.deserialize, + CloudantV1.Security.deserialize, ); } /** - * Modify only Cloudant related database permissions. + * Modify 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. + * 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 * @@ -6239,40 +6296,40 @@ class CloudantV1 extends CloudantBaseService { * * @param {Object} params - The parameters to send to the service. * @param {string} params.db - Path parameter to specify the database name. - * @param {JsonObject} params.cloudant - Database permissions for Cloudant users and/or API keys. * @param {SecurityObject} [params.admins] - Schema for names and roles to map to a database permission. - * @param {SecurityObject} [params.members] - Schema for names and roles to map to a database permission. + * @param {JsonObject} [params.cloudant] - Database permissions for Cloudant users and/or API keys. * @param {boolean} [params.couchdbAuthOnly] - Manage permissions using the `_users` database only. + * @param {SecurityObject} [params.members] - Schema for names and roles to map to a database permission. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise>} */ - public putCloudantSecurityConfiguration( - params: CloudantV1.PutCloudantSecurityConfigurationParams + public putSecurity( + params: CloudantV1.PutSecurityParams ): Promise> { const _params = { ...params }; - const _requiredParams = ['db', 'cloudant']; - const _validParams = ['db', 'cloudant', 'admins', 'members', 'couchdbAuthOnly', 'headers']; + const _requiredParams = ['db']; + const _validParams = ['db', 'admins', 'cloudant', 'couchdbAuthOnly', 'members', 'headers']; const _validationErrors = validateParams(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } const body = { - 'cloudant': _params.cloudant, 'admins': CloudantV1.SecurityObject.serialize(_params.admins), - 'members': CloudantV1.SecurityObject.serialize(_params.members), + 'cloudant': _params.cloudant, 'couchdb_auth_only': _params.couchdbAuthOnly, + 'members': CloudantV1.SecurityObject.serialize(_params.members), }; const path = { 'db': _params.db, }; - const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'putCloudantSecurityConfiguration'); + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'putSecurity'); const parameters = { options: { - url: '/_api/v2/db/{db}/_security', + url: '/{db}/_security', method: 'PUT', body, path, @@ -7192,19 +7249,17 @@ class CloudantV1 extends CloudantBaseService { } /** - * Retrieve cluster membership information. + * Retrieve Activity Tracker events information. * - * 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. + * Check event types that are being sent to IBM Cloud Activity Tracker for the IBM Cloudant instance. * * @param {Object} [params] - The parameters to send to the service. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ - public getMembershipInformation( - params?: CloudantV1.GetMembershipInformationParams - ): Promise> { + public getActivityTrackerEvents( + params?: CloudantV1.GetActivityTrackerEventsParams + ): Promise> { const _params = { ...params }; const _requiredParams = []; const _validParams = ['headers']; @@ -7213,11 +7268,11 @@ class CloudantV1 extends CloudantBaseService { return Promise.reject(_validationErrors); } - const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getMembershipInformation'); + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getActivityTrackerEvents'); const parameters = { options: { - url: '/_membership', + url: '/_api/v2/user/activity_tracker/events', method: 'GET', }, defaultOptions: extend(true, {}, this.baseOptions, { @@ -7234,39 +7289,43 @@ class CloudantV1 extends CloudantBaseService { return this.createRequestAndDeserializeResponse( parameters, - CloudantV1.MembershipInformation.deserialize, + CloudantV1.ActivityTrackerEvents.deserialize, ); } /** - * Retrieve information about whether the server is up. - * - * Confirms that the server is up, running, and ready to respond to requests. If `maintenance_mode` is `true` or - * `nolb`, the endpoint returns a 404 response. + * Modify Activity Tracker events configuration. * - * **Tip:** The authentication for this endpoint is only enforced when using IAM. + * Configure event types that are being sent to IBM Cloud Activity Tracker for the IBM Cloudant instance. * - * @param {Object} [params] - The parameters to send to the service. + * @param {Object} params - The parameters to send to the service. + * @param {string[]} params.types - An array of event types that are being sent to IBM Cloud Activity Tracker for the + * IBM Cloudant instance. "management" is a required element of this array. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ - public getUpInformation( - params?: CloudantV1.GetUpInformationParams - ): Promise> { + public postActivityTrackerEvents( + params: CloudantV1.PostActivityTrackerEventsParams + ): Promise> { const _params = { ...params }; - const _requiredParams = []; - const _validParams = ['headers']; + const _requiredParams = ['types']; + const _validParams = ['types', 'headers']; const _validationErrors = validateParams(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } - const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getUpInformation'); + const body = { + 'types': _params.types, + }; + + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'postActivityTrackerEvents'); const parameters = { options: { - url: '/_up', - method: 'GET', + url: '/_api/v2/user/activity_tracker/events', + method: 'POST', + body, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend( @@ -7274,6 +7333,7 @@ class CloudantV1 extends CloudantBaseService { sdkHeaders, { 'Accept': 'application/json', + 'Content-Type': 'application/json', }, _params.headers ), @@ -7282,22 +7342,24 @@ class CloudantV1 extends CloudantBaseService { return this.createRequestAndDeserializeResponse( parameters, - CloudantV1.UpInformation.deserialize, + CloudantV1.Ok.deserialize, ); } /** - * Retrieve Activity Tracker events information. + * Retrieve the current provisioned throughput capacity consumption. * - * Check event types that are being sent to IBM Cloud Activity Tracker for the IBM Cloudant instance. + * 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 {Object} [params] - The parameters to send to the service. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ - public getActivityTrackerEvents( - params?: CloudantV1.GetActivityTrackerEventsParams - ): Promise> { + public getCurrentThroughputInformation( + params?: CloudantV1.GetCurrentThroughputInformationParams + ): Promise> { const _params = { ...params }; const _requiredParams = []; const _validParams = ['headers']; @@ -7306,11 +7368,11 @@ class CloudantV1 extends CloudantBaseService { return Promise.reject(_validationErrors); } - const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getActivityTrackerEvents'); + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getCurrentThroughputInformation'); const parameters = { options: { - url: '/_api/v2/user/activity_tracker/events', + url: '/_api/v2/user/current/throughput', method: 'GET', }, defaultOptions: extend(true, {}, this.baseOptions, { @@ -7327,43 +7389,38 @@ class CloudantV1 extends CloudantBaseService { return this.createRequestAndDeserializeResponse( parameters, - CloudantV1.ActivityTrackerEvents.deserialize, + CloudantV1.CurrentThroughputInformation.deserialize, ); } /** - * Modify Activity Tracker events configuration. + * Retrieve cluster membership information. * - * Configure event types that are being sent to IBM Cloud Activity Tracker for the IBM Cloudant instance. + * 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 {Object} params - The parameters to send to the service. - * @param {string[]} params.types - An array of event types that are being sent to IBM Cloud Activity Tracker for the - * IBM Cloudant instance. "management" is a required element of this array. + * @param {Object} [params] - The parameters to send to the service. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ - public postActivityTrackerEvents( - params: CloudantV1.PostActivityTrackerEventsParams - ): Promise> { + public getMembershipInformation( + params?: CloudantV1.GetMembershipInformationParams + ): Promise> { const _params = { ...params }; - const _requiredParams = ['types']; - const _validParams = ['types', 'headers']; + const _requiredParams = []; + const _validParams = ['headers']; const _validationErrors = validateParams(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } - const body = { - 'types': _params.types, - }; - - const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'postActivityTrackerEvents'); + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getMembershipInformation'); const parameters = { options: { - url: '/_api/v2/user/activity_tracker/events', - method: 'POST', - body, + url: '/_membership', + method: 'GET', }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend( @@ -7371,7 +7428,6 @@ class CloudantV1 extends CloudantBaseService { sdkHeaders, { 'Accept': 'application/json', - 'Content-Type': 'application/json', }, _params.headers ), @@ -7380,24 +7436,25 @@ class CloudantV1 extends CloudantBaseService { return this.createRequestAndDeserializeResponse( parameters, - CloudantV1.Ok.deserialize, + CloudantV1.MembershipInformation.deserialize, ); } /** - * Retrieve the current provisioned throughput capacity consumption. + * Retrieve information about whether the server is up. * - * 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. + * Confirms that the server is up, running, and ready to respond to requests. If `maintenance_mode` is `true` or + * `nolb`, the endpoint returns a 404 response. + * + * **Tip:** The authentication for this endpoint is only enforced when using IAM. * * @param {Object} [params] - The parameters to send to the service. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ - public getCurrentThroughputInformation( - params?: CloudantV1.GetCurrentThroughputInformationParams - ): Promise> { + public getUpInformation( + params?: CloudantV1.GetUpInformationParams + ): Promise> { const _params = { ...params }; const _requiredParams = []; const _validParams = ['headers']; @@ -7406,11 +7463,11 @@ class CloudantV1 extends CloudantBaseService { return Promise.reject(_validationErrors); } - const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getCurrentThroughputInformation'); + const sdkHeaders = getSdkHeaders(CloudantV1.DEFAULT_SERVICE_NAME, 'v1', 'getUpInformation'); const parameters = { options: { - url: '/_api/v2/user/current/throughput', + url: '/_up', method: 'GET', }, defaultOptions: extend(true, {}, this.baseOptions, { @@ -7427,7 +7484,7 @@ class CloudantV1 extends CloudantBaseService { return this.createRequestAndDeserializeResponse( parameters, - CloudantV1.CurrentThroughputInformation.deserialize, + CloudantV1.UpInformation.deserialize, ); } } @@ -7469,13 +7526,6 @@ namespace CloudantV1 { headers?: OutgoingHttpHeaders; } - /** Parameters for the `getUuids` operation. */ - export interface GetUuidsParams { - /** Query parameter to specify the number of UUIDs to return. */ - count?: number; - headers?: OutgoingHttpHeaders; - } - /** Parameters for the `getCapacityThroughputInformation` operation. */ export interface GetCapacityThroughputInformationParams { headers?: OutgoingHttpHeaders; @@ -7490,6 +7540,13 @@ namespace CloudantV1 { headers?: OutgoingHttpHeaders; } + /** Parameters for the `getUuids` operation. */ + export interface GetUuidsParams { + /** Query parameter to specify the number of UUIDs to return. */ + count?: number; + headers?: OutgoingHttpHeaders; + } + /** Parameters for the `getDbUpdates` operation. */ export interface GetDbUpdatesParams { /** Query parameter to specify whether to return the documents in descending by key order. */ @@ -7651,7 +7708,7 @@ namespace CloudantV1 { * will only return the current "winning" revision; all_docs will return all leaf revisions (including conflicts * and deleted former conflicts). */ - style?: string; + style?: PostChangesConstants.Style | string; /** Query parameter to specify the maximum period in milliseconds to wait for a change before the response is * sent, even if there are no results. Only applicable for `longpoll` or `continuous` feeds. Default value is * specified by `httpd/changes_timeout` configuration option. Note that `60000` value is also the default maximum @@ -7674,6 +7731,11 @@ namespace CloudantV1 { LONGPOLL = 'longpoll', NORMAL = 'normal', } + /** Query parameter to specify how many revisions are returned in the changes array. The default, `main_only`, will only return the current "winning" revision; all_docs will return all leaf revisions (including conflicts and deleted former conflicts). */ + export enum Style { + MAIN_ONLY = 'main_only', + ALL_DOCS = 'all_docs', + } } /** Parameters for the `postChangesAsStream` operation. */ @@ -7791,7 +7853,7 @@ namespace CloudantV1 { * will only return the current "winning" revision; all_docs will return all leaf revisions (including conflicts * and deleted former conflicts). */ - style?: string; + style?: PostChangesAsStreamConstants.Style | string; /** Query parameter to specify the maximum period in milliseconds to wait for a change before the response is * sent, even if there are no results. Only applicable for `longpoll` or `continuous` feeds. Default value is * specified by `httpd/changes_timeout` configuration option. Note that `60000` value is also the default maximum @@ -7814,6 +7876,11 @@ namespace CloudantV1 { LONGPOLL = 'longpoll', NORMAL = 'normal', } + /** Query parameter to specify how many revisions are returned in the changes array. The default, `main_only`, will only return the current "winning" revision; all_docs will return all leaf revisions (including conflicts and deleted former conflicts). */ + export enum Style { + MAIN_ONLY = 'main_only', + ALL_DOCS = 'all_docs', + } } /** Parameters for the `headDatabase` operation. */ @@ -10006,10 +10073,9 @@ namespace CloudantV1 { * supported. This option is only available when making global queries. */ groupSort?: string[]; - /** This field defines ranges for faceted, numeric search fields. The value is a JSON object where the fields - * names are faceted numeric search fields, and the values of the fields are JSON objects. The field names of the - * JSON objects are names for ranges. The values are strings that describe the range, for example "[0 TO 10]". This - * option is only available when making global queries. + /** Object mapping faceted, numeric search field names to the required ranges. Each key is a field name and each + * value is another object defining the ranges by mapping range name keys to string values describing the numeric + * ranges, for example "[0 TO 10]". This option is only available when making global queries. */ ranges?: JsonObject; headers?: OutgoingHttpHeaders; @@ -10095,10 +10161,9 @@ namespace CloudantV1 { * supported. This option is only available when making global queries. */ groupSort?: string[]; - /** This field defines ranges for faceted, numeric search fields. The value is a JSON object where the fields - * names are faceted numeric search fields, and the values of the fields are JSON objects. The field names of the - * JSON objects are names for ranges. The values are strings that describe the range, for example "[0 TO 10]". This - * option is only available when making global queries. + /** Object mapping faceted, numeric search field names to the required ranges. Each key is a field name and each + * value is another object defining the ranges by mapping range name keys to string values describing the numeric + * ranges, for example "[0 TO 10]". This option is only available when making global queries. */ ranges?: JsonObject; headers?: OutgoingHttpHeaders; @@ -10148,6 +10213,25 @@ namespace CloudantV1 { headers?: OutgoingHttpHeaders; } + /** Parameters for the `postReplicator` operation. */ + export interface PostReplicatorParams { + /** HTTP request body for replication operations. */ + replicationDocument: ReplicationDocument; + /** Query parameter to specify whether to store in batch mode. The server will respond with a HTTP 202 Accepted + * response code immediately. + */ + batch?: PostReplicatorConstants.Batch | string; + headers?: OutgoingHttpHeaders; + } + + /** Constants for the `postReplicator` operation. */ + export namespace PostReplicatorConstants { + /** Query parameter to specify whether to store in batch mode. The server will respond with a HTTP 202 Accepted response code immediately. */ + export enum Batch { + OK = 'ok', + } + } + /** Parameters for the `deleteReplicationDocument` operation. */ export interface DeleteReplicationDocumentParams { /** Path parameter to specify the document ID. */ @@ -10298,30 +10382,28 @@ namespace CloudantV1 { headers?: OutgoingHttpHeaders; } - /** Parameters for the `getSecurity` operation. */ - export interface GetSecurityParams { - /** Path parameter to specify the database name. */ - db: string; + /** Parameters for the `postApiKeys` operation. */ + export interface PostApiKeysParams { headers?: OutgoingHttpHeaders; } - /** Parameters for the `putSecurity` operation. */ - export interface PutSecurityParams { + /** Parameters for the `putCloudantSecurityConfiguration` operation. */ + export interface PutCloudantSecurityConfigurationParams { /** Path parameter to specify the database name. */ db: string; + /** Database permissions for Cloudant users and/or API keys. */ + cloudant: JsonObject; /** Schema for names and roles to map to a database permission. */ admins?: SecurityObject; - /** Schema for names and roles to map to a database permission. */ - members?: SecurityObject; - /** Database permissions for Cloudant users and/or API keys. */ - cloudant?: JsonObject; /** Manage permissions using the `_users` database only. */ couchdbAuthOnly?: boolean; + /** Schema for names and roles to map to a database permission. */ + members?: SecurityObject; headers?: OutgoingHttpHeaders; } - /** Constants for the `putSecurity` operation. */ - export namespace PutSecurityConstants { + /** Constants for the `putCloudantSecurityConfiguration` operation. */ + export namespace PutCloudantSecurityConfigurationConstants { /** Database permissions for Cloudant users and/or API keys. */ export enum Cloudant { READER = '_reader', @@ -10335,28 +10417,30 @@ namespace CloudantV1 { } } - /** Parameters for the `postApiKeys` operation. */ - export interface PostApiKeysParams { + /** Parameters for the `getSecurity` operation. */ + export interface GetSecurityParams { + /** Path parameter to specify the database name. */ + db: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `putCloudantSecurityConfiguration` operation. */ - export interface PutCloudantSecurityConfigurationParams { + /** Parameters for the `putSecurity` operation. */ + export interface PutSecurityParams { /** Path parameter to specify the database name. */ db: string; - /** Database permissions for Cloudant users and/or API keys. */ - cloudant: JsonObject; /** Schema for names and roles to map to a database permission. */ admins?: SecurityObject; - /** Schema for names and roles to map to a database permission. */ - members?: SecurityObject; + /** Database permissions for Cloudant users and/or API keys. */ + cloudant?: JsonObject; /** Manage permissions using the `_users` database only. */ couchdbAuthOnly?: boolean; + /** Schema for names and roles to map to a database permission. */ + members?: SecurityObject; headers?: OutgoingHttpHeaders; } - /** Constants for the `putCloudantSecurityConfiguration` operation. */ - export namespace PutCloudantSecurityConfigurationConstants { + /** Constants for the `putSecurity` operation. */ + export namespace PutSecurityConstants { /** Database permissions for Cloudant users and/or API keys. */ export enum Cloudant { READER = '_reader', @@ -10608,16 +10692,6 @@ namespace CloudantV1 { headers?: OutgoingHttpHeaders; } - /** Parameters for the `getMembershipInformation` operation. */ - export interface GetMembershipInformationParams { - headers?: OutgoingHttpHeaders; - } - - /** Parameters for the `getUpInformation` operation. */ - export interface GetUpInformationParams { - headers?: OutgoingHttpHeaders; - } - /** Parameters for the `getActivityTrackerEvents` operation. */ export interface GetActivityTrackerEventsParams { headers?: OutgoingHttpHeaders; @@ -10646,6 +10720,16 @@ namespace CloudantV1 { headers?: OutgoingHttpHeaders; } + /** Parameters for the `getMembershipInformation` operation. */ + export interface GetMembershipInformationParams { + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getUpInformation` operation. */ + export interface GetUpInformationParams { + headers?: OutgoingHttpHeaders; + } + /************************* * model interfaces ************************/ @@ -11304,7 +11388,7 @@ namespace CloudantV1 { * Schema for the result of an all documents operation. */ export class AllDocsResult { - /** Number of total rows. */ + /** Total number of document results. */ totalRows: number; /** List of doc results. */ @@ -11364,7 +11448,7 @@ namespace CloudantV1 { * * For search indexes the default is `standard` * For query text indexes the default is `keyword` * For a query * text index default_field the default is `standard`. */ - name?: Analyzer.Constants.Name | string; + name: Analyzer.Constants.Name | string; /** Custom stopwords to use with the named analyzer. */ stopwords?: string[]; @@ -11445,7 +11529,7 @@ namespace CloudantV1 { } } export interface Transport { - name?: string; + name: string; stopwords?: string[]; } } @@ -11459,7 +11543,7 @@ namespace CloudantV1 { * * For search indexes the default is `standard` * For query text indexes the default is `keyword` * For a query * text index default_field the default is `standard`. */ - name?: AnalyzerConfiguration.Constants.Name | string; + name: AnalyzerConfiguration.Constants.Name | string; /** Custom stopwords to use with the named analyzer. */ stopwords?: string[]; @@ -11549,7 +11633,7 @@ namespace CloudantV1 { } } export interface Transport { - name?: string; + name: string; stopwords?: string[]; fields?: {[key: string]: Analyzer.Transport}; } @@ -12490,6 +12574,9 @@ namespace CloudantV1 { */ instanceStartTime: string; + /** Information about database's partitioned indexes. */ + partitionedIndexes?: PartitionedIndexesInformation; + /** Schema for database properties. */ props: DatabaseInformationProps; @@ -12504,9 +12591,6 @@ namespace CloudantV1 { /** The UUID of the database. */ uuid?: string; - /** Information about database's partitioned indexes. */ - partitionedIndexes?: PartitionedIndexesInformation; - static serialize(obj): DatabaseInformation.Transport { if (obj === undefined || obj === null || typeof obj === 'string') { return obj; @@ -12542,6 +12626,9 @@ namespace CloudantV1 { if (obj.instanceStartTime !== undefined) { copy.instance_start_time = obj.instanceStartTime; } + if (obj.partitionedIndexes !== undefined) { + copy.partitioned_indexes = PartitionedIndexesInformation.serialize(obj.partitionedIndexes); + } if (obj.props !== undefined) { copy.props = DatabaseInformationProps.serialize(obj.props); } @@ -12554,9 +12641,6 @@ namespace CloudantV1 { if (obj.uuid !== undefined) { copy.uuid = obj.uuid; } - if (obj.partitionedIndexes !== undefined) { - copy.partitioned_indexes = PartitionedIndexesInformation.serialize(obj.partitionedIndexes); - } return copy as unknown as DatabaseInformation.Transport; } @@ -12595,6 +12679,9 @@ namespace CloudantV1 { if (obj.instance_start_time !== undefined) { copy.instanceStartTime = obj.instance_start_time; } + if (obj.partitioned_indexes !== undefined) { + copy.partitionedIndexes = PartitionedIndexesInformation.deserialize(obj.partitioned_indexes); + } if (obj.props !== undefined) { copy.props = DatabaseInformationProps.deserialize(obj.props); } @@ -12607,9 +12694,6 @@ namespace CloudantV1 { if (obj.uuid !== undefined) { copy.uuid = obj.uuid; } - if (obj.partitioned_indexes !== undefined) { - copy.partitionedIndexes = PartitionedIndexesInformation.deserialize(obj.partitioned_indexes); - } return copy as unknown as DatabaseInformation; } } @@ -12625,11 +12709,11 @@ namespace CloudantV1 { doc_del_count: number; engine?: string; instance_start_time: string; + partitioned_indexes?: PartitionedIndexesInformation.Transport; props: DatabaseInformationProps.Transport; sizes: ContentInformationSizes.Transport; update_seq: string; uuid?: string; - partitioned_indexes?: PartitionedIndexesInformation.Transport; } } @@ -14209,40 +14293,40 @@ namespace CloudantV1 { */ export class ExplainResultMrArgs { /** Schema for any JSON type. */ - conflicts?: any; + conflicts: any; /** Direction parameter passed to the underlying view. */ - direction?: ExplainResultMrArgs.Constants.Direction | string; + direction: ExplainResultMrArgs.Constants.Direction | string; /** Schema for any JSON type. */ - endKey?: any; + endKey: any; /** A parameter that specifies whether to include the full content of the documents in the response in the * underlying view. */ - includeDocs?: boolean; + includeDocs: boolean; /** Partition parameter passed to the underlying view. */ - partition?: string | null; + partition: string | null; /** A parameter that specifies returning only documents that match any of the specified keys in the underlying * view. */ - reduce?: boolean; + reduce: boolean; /** A parameter that specifies whether the view results should be returned form a "stable" set of shards passed * to the underlying view. */ - stable?: boolean; + stable: boolean; /** Schema for any JSON type. */ startKey?: any; /** Schema for any JSON type. */ - update?: any; + update: any; /** The type of the underlying view. */ - viewType?: ExplainResultMrArgs.Constants.ViewType | string; + viewType: ExplainResultMrArgs.Constants.ViewType | string; static serialize(obj): ExplainResultMrArgs.Transport { if (obj === undefined || obj === null || typeof obj === 'string') { @@ -14324,8 +14408,8 @@ namespace CloudantV1 { export namespace Constants { /** Direction parameter passed to the underlying view. */ export enum Direction { - ASC = 'asc', - DESC = 'desc', + FWD = 'fwd', + REV = 'rev', } /** The type of the underlying view. */ export enum ViewType { @@ -14334,16 +14418,16 @@ namespace CloudantV1 { } } export interface Transport { - conflicts?: any; - direction?: string; - end_key?: any; - include_docs?: boolean; - partition?: string; - reduce?: boolean; - stable?: boolean; + conflicts: any; + direction: string; + end_key: any; + include_docs: boolean; + partition: string; + reduce: boolean; + stable: boolean; start_key?: any; - update?: any; - view_type?: string; + update: any; + view_type: string; } } @@ -14659,7 +14743,7 @@ namespace CloudantV1 { * * too_many_fields: json The index has more fields than the chosen one. * * unfavored_type: any The type of the index is not preferred. */ - name?: IndexAnalysisExclusionReason.Constants.Name | string; + name: IndexAnalysisExclusionReason.Constants.Name | string; static serialize(obj): IndexAnalysisExclusionReason.Transport { if (obj === undefined || obj === null || typeof obj === 'string') { @@ -14701,7 +14785,7 @@ namespace CloudantV1 { } } export interface Transport { - name?: string; + name: string; } } @@ -15154,7 +15238,7 @@ namespace CloudantV1 { * Schema for information about the indexes in a database. */ export class IndexesInformation { - /** Number of total rows. */ + /** Total number of query indexes in the database. */ totalRows: number; /** Indexes. */ @@ -16456,7 +16540,7 @@ namespace CloudantV1 { * Schema for a listing of replication scheduler documents. */ export class SchedulerDocsResult { - /** Number of total rows. */ + /** Total number of replication scheduler documents. */ totalRows: number; /** Array of replication scheduler doc objects. */ @@ -16997,7 +17081,7 @@ namespace CloudantV1 { * Schema for a listing of replication scheduler jobs. */ export class SchedulerJobsResult { - /** Number of total rows. */ + /** Total number of replication jobs. */ totalRows: number; /** Array of replication job objects. */ @@ -17271,7 +17355,9 @@ namespace CloudantV1 { * Schema for the result of a query search operation. */ export class SearchResult { - /** Number of total rows. */ + /** Total number of rows in the index matching the search query. The limit may truncate the number of matches + * returned. + */ totalRows: number; /** Opaque bookmark token used when paginating results. */ @@ -17368,7 +17454,9 @@ namespace CloudantV1 { * Schema for the result of a query search operation. */ export class SearchResultProperties { - /** Number of total rows. */ + /** Total number of rows in the index matching the search query. The limit may truncate the number of matches + * returned. + */ totalRows: number; /** Opaque bookmark token used when paginating results. */ @@ -17525,15 +17613,15 @@ namespace CloudantV1 { /** Schema for names and roles to map to a database permission. */ admins?: SecurityObject; - /** Schema for names and roles to map to a database permission. */ - members?: SecurityObject; - /** Database permissions for Cloudant users and/or API keys. */ cloudant?: JsonObject; /** Manage permissions using the `_users` database only. */ couchdbAuthOnly?: boolean; + /** Schema for names and roles to map to a database permission. */ + members?: SecurityObject; + static serialize(obj): Security.Transport { if (obj === undefined || obj === null || typeof obj === 'string') { return obj; @@ -17542,15 +17630,15 @@ namespace CloudantV1 { if (obj.admins !== undefined) { copy.admins = SecurityObject.serialize(obj.admins); } - if (obj.members !== undefined) { - copy.members = SecurityObject.serialize(obj.members); - } if (obj.cloudant !== undefined) { copy.cloudant = obj.cloudant; } if (obj.couchdbAuthOnly !== undefined) { copy.couchdb_auth_only = obj.couchdbAuthOnly; } + if (obj.members !== undefined) { + copy.members = SecurityObject.serialize(obj.members); + } return copy as unknown as Security.Transport; } @@ -17562,24 +17650,24 @@ namespace CloudantV1 { if (obj.admins !== undefined) { copy.admins = SecurityObject.deserialize(obj.admins); } - if (obj.members !== undefined) { - copy.members = SecurityObject.deserialize(obj.members); - } if (obj.cloudant !== undefined) { copy.cloudant = obj.cloudant; } if (obj.couchdb_auth_only !== undefined) { copy.couchdbAuthOnly = obj.couchdb_auth_only; } + if (obj.members !== undefined) { + copy.members = SecurityObject.deserialize(obj.members); + } return copy as unknown as Security; } } export namespace Security { export interface Transport { admins?: SecurityObject.Transport; - members?: SecurityObject.Transport; cloudant?: JsonObject; couchdb_auth_only?: boolean; + members?: SecurityObject.Transport; } } @@ -17700,15 +17788,15 @@ namespace CloudantV1 { /** List of enabled optional features. */ features: string[]; + /** List of feature flags. */ + featuresFlags: string[]; + /** Schema for server vendor information. */ vendor: ServerVendor; /** Apache CouchDB version. */ version: string; - /** List of feature flags. */ - featuresFlags: string[]; - static serialize(obj): ServerInformation.Transport { if (obj === undefined || obj === null || typeof obj === 'string') { return obj; @@ -17720,15 +17808,15 @@ namespace CloudantV1 { if (obj.features !== undefined) { copy.features = obj.features; } + if (obj.featuresFlags !== undefined) { + copy.features_flags = obj.featuresFlags; + } if (obj.vendor !== undefined) { copy.vendor = ServerVendor.serialize(obj.vendor); } if (obj.version !== undefined) { copy.version = obj.version; } - if (obj.featuresFlags !== undefined) { - copy.features_flags = obj.featuresFlags; - } return copy as unknown as ServerInformation.Transport; } @@ -17743,15 +17831,15 @@ namespace CloudantV1 { if (obj.features !== undefined) { copy.features = obj.features; } + if (obj.features_flags !== undefined) { + copy.featuresFlags = obj.features_flags; + } if (obj.vendor !== undefined) { copy.vendor = ServerVendor.deserialize(obj.vendor); } if (obj.version !== undefined) { copy.version = obj.version; } - if (obj.features_flags !== undefined) { - copy.featuresFlags = obj.features_flags; - } return copy as unknown as ServerInformation; } } @@ -17759,9 +17847,9 @@ namespace CloudantV1 { export interface Transport { couchdb: string; features: string[]; + features_flags: string[]; vendor: ServerVendor.Transport; version: string; - features_flags: string[]; } } @@ -18587,7 +18675,10 @@ namespace CloudantV1 { * Schema for the result of a query view operation. */ export class ViewResult { - /** Number of total rows. */ + /** Total number of rows in the view index. Note that if the request query narrows the view this is not the + * number of matching rows. The number of matching rows, up to the specified `limit`, is the size of the `rows` + * array. + */ totalRows?: number; /** Current update sequence for the database. */ diff --git a/stubs/gen-its-mappings.json b/stubs/gen-its-mappings.json index 981ed6467..dc40ad97d 100644 --- a/stubs/gen-its-mappings.json +++ b/stubs/gen-its-mappings.json @@ -383,7 +383,7 @@ "equalTo": "normal" }, "heartbeat": { - "equalTo": "0" + "equalTo": "1" }, "since": { "equalTo": "0" @@ -476,6 +476,48 @@ }, "uuid": "2da72265-1cef-3bc6-bb1b-2cdeb811ceba" }, + { + "id": "109ff4b5-4d2a-32b8-890d-f15cfe54173b", + "request": { + "urlPath": "/_replicator", + "method": "POST", + "queryParameters": { + "batch": { + "equalTo": "ok" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"source\": {\"url\": \"https://my-source-instance.cloudantnosqldb.appdomain.cloud.example/animaldb\"}, \"target\": {\"url\": \"https://my-source-instance.cloudantnosqldb.appdomain.cloud.example/animaldb\"}}", + "ignoreArrayOrder": false, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "body": "{\"ok\":true,\"id\":\"testString\",\"rev\":\"1-257d246167d34fcc2ca07926ba0213d1\"}", + "headers": { + "Cache-Control": "must-revalidate", + "Content-Type": "application/json", + "Date": "Fri, 20 May 2022 16:54:50 GMT", + "ETag": "W/\"22-257d246167d34fcc2ca07926ba0213d1\"", + "Location": "https://84ab8038-d8f1-450c-9645-4d16b448eb31-bluemix.cloudant.com/_replicator/testString", + "Server": "CouchDB/3.2.1 (Erlang OTP/20)", + "transaction-id": "ce157aeb0e62a81f05c0e8c9e4d24c55", + "X-Cloudant-Action": "cloudantnosqldb.replication.write", + "X-Couch-Request-ID": "ce157aeb0e", + "X-Frame-Options": "DENY", + "Strict-Transport-Security": "max-age=31536000", + "X-Content-Type-Options": "nosniff", + "X-Cloudant-Request-Class": "write", + "X-Cloudant-Backend": "bm-cc-us-east-05", + "Via": "1.1 lb1.bm-cc-us-east-05 (Glum/1.102.0)", + "Vary": "Accept-Encoding" + } + }, + "uuid": "109ff4b5-4d2a-32b8-890d-f15cfe54173b" + }, { "id": "ea621c78-5215-34ac-94ce-95e13e1182bd", "request": { @@ -1222,7 +1264,7 @@ "equalTo": "testString" }, "heartbeat": { - "equalTo": "0" + "equalTo": "1" }, "include_docs": { "equalTo": "false" @@ -2444,7 +2486,7 @@ "equalTo": "false" }, "q": { - "equalTo": "26" + "equalTo": "16" } } }, diff --git a/test/integration/cloudant.v1.test.js b/test/integration/cloudant.v1.test.js index 7fcbec222..0bec52f32 100644 --- a/test/integration/cloudant.v1.test.js +++ b/test/integration/cloudant.v1.test.js @@ -53,17 +53,6 @@ describe('CloudantV1_integration', () => { expect(res.result).toBeDefined(); }); - test('getUuids()', async () => { - const params = { - count: 1, - }; - - const res = await cloudantService.getUuids(params); - expect(res).toBeDefined(); - expect(res.status).toBe(200); - expect(res.result).toBeDefined(); - }); - test('getCapacityThroughputInformation()', async () => { const res = await cloudantService.getCapacityThroughputInformation(); expect(res).toBeDefined(); @@ -82,11 +71,22 @@ describe('CloudantV1_integration', () => { expect(res.result).toBeDefined(); }); + test('getUuids()', async () => { + const params = { + count: 1, + }; + + const res = await cloudantService.getUuids(params); + expect(res).toBeDefined(); + expect(res.status).toBe(200); + expect(res.result).toBeDefined(); + }); + test('getDbUpdates()', async () => { const params = { descending: false, feed: 'normal', - heartbeat: 0, + heartbeat: 1, limit: 0, timeout: 60000, since: '0', @@ -111,7 +111,7 @@ describe('CloudantV1_integration', () => { descending: false, feed: 'normal', filter: 'testString', - heartbeat: 0, + heartbeat: 1, includeDocs: false, limit: 0, seqInterval: 1, @@ -140,7 +140,7 @@ describe('CloudantV1_integration', () => { descending: false, feed: 'normal', filter: 'testString', - heartbeat: 0, + heartbeat: 1, includeDocs: false, limit: 0, seqInterval: 1, @@ -208,7 +208,7 @@ describe('CloudantV1_integration', () => { const params = { db: 'testString', partitioned: false, - q: 26, + q: 16, }; const res = await cloudantService.putDatabase(params); @@ -1338,7 +1338,7 @@ describe('CloudantV1_integration', () => { groupField: 'testString', groupLimit: 1, groupSort: ['testString'], - ranges: { 'key1': { 'key1': { 'key1': 'testString' } } }, + ranges: { 'key1': { 'key1': 'testString' } }, }; const res = await cloudantService.postSearch(params); @@ -1369,7 +1369,7 @@ describe('CloudantV1_integration', () => { groupField: 'testString', groupLimit: 1, groupSort: ['testString'], - ranges: { 'key1': { 'key1': { 'key1': 'testString' } } }, + ranges: { 'key1': { 'key1': 'testString' } }, }; const res = await cloudantService.postSearchAsStream(params); @@ -1425,6 +1425,122 @@ describe('CloudantV1_integration', () => { expect(res.result).toBeDefined(); }); + test('postReplicator()', async () => { + // Request models needed by this operation. + + // Attachment + const attachmentModel = { + contentType: 'testString', + data: Buffer.from('VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=', 'base64'), + digest: 'testString', + encodedLength: 0, + encoding: 'testString', + follows: true, + length: 0, + revpos: 1, + stub: true, + }; + + // Revisions + const revisionsModel = { + ids: ['testString'], + start: 1, + }; + + // DocumentRevisionStatus + const documentRevisionStatusModel = { + rev: 'testString', + status: 'available', + }; + + // ReplicationCreateTargetParameters + const replicationCreateTargetParametersModel = { + n: 3, + partitioned: false, + q: 1, + }; + + // ReplicationDatabaseAuthBasic + const replicationDatabaseAuthBasicModel = { + password: 'testString', + username: 'testString', + }; + + // ReplicationDatabaseAuthIam + const replicationDatabaseAuthIamModel = { + apiKey: 'testString', + }; + + // ReplicationDatabaseAuth + const replicationDatabaseAuthModel = { + basic: replicationDatabaseAuthBasicModel, + iam: replicationDatabaseAuthIamModel, + }; + + // ReplicationDatabase + const replicationDatabaseModel = { + auth: replicationDatabaseAuthModel, + headers: { 'key1': 'testString' }, + url: 'https://my-source-instance.cloudantnosqldb.appdomain.cloud.example/animaldb', + }; + + // UserContext + const userContextModel = { + db: 'testString', + name: 'john', + roles: ['_replicator'], + }; + + // ReplicationDocument + const replicationDocumentModel = { + _attachments: { 'key1': attachmentModel }, + _conflicts: ['testString'], + _deleted: true, + _deleted_conflicts: ['testString'], + _id: 'testString', + _local_seq: 'testString', + _rev: 'testString', + _revisions: revisionsModel, + _revs_info: [documentRevisionStatusModel], + cancel: false, + checkpointInterval: 4500, + connectionTimeout: 15000, + continuous: true, + createTarget: true, + createTargetParams: replicationCreateTargetParametersModel, + docIds: ['badger', 'lemur', 'llama'], + filter: 'ddoc/my_filter', + httpConnections: 10, + owner: 'testString', + queryParams: { 'key1': 'testString' }, + retriesPerRequest: 3, + selector: { _id: { '$regex': 'docid' } }, + 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: 400, + workerProcesses: 3, + foo: 'testString', + }; + + const params = { + replicationDocument: replicationDocumentModel, + batch: 'ok', + }; + + const res = await cloudantService.postReplicator(params); + expect(res).toBeDefined(); + expect(res.status).toBe(201); + expect(res.result).toBeDefined(); + }); + test('getReplicationDocument()', async () => { const params = { docId: 'testString', @@ -1621,65 +1737,65 @@ describe('CloudantV1_integration', () => { expect(res.result).toBeDefined(); }); - test('getSecurity()', async () => { - const params = { - db: 'testString', - }; - - const res = await cloudantService.getSecurity(params); + test('postApiKeys()', async () => { + const res = await cloudantService.postApiKeys(); expect(res).toBeDefined(); - expect(res.status).toBe(200); + expect(res.status).toBe(201); expect(res.result).toBeDefined(); }); - test('putSecurity()', async () => { + test('putCloudantSecurityConfiguration()', async () => { // Request models needed by this operation. // SecurityObject const securityObjectModel = { - names: ['superuser'], - roles: ['admins'], + names: ['testString'], + roles: ['testString'], }; const params = { db: 'testString', + cloudant: { antsellseadespecteposene: ['_reader', '_writer', '_admin'], garbados: ['_reader', '_writer'], nobody: ['_reader'] }, admins: securityObjectModel, - members: securityObjectModel, - cloudant: { 'key1': ['_reader'] }, couchdbAuthOnly: true, + members: securityObjectModel, }; - const res = await cloudantService.putSecurity(params); + const res = await cloudantService.putCloudantSecurityConfiguration(params); expect(res).toBeDefined(); expect(res.status).toBe(200); expect(res.result).toBeDefined(); }); - test('postApiKeys()', async () => { - const res = await cloudantService.postApiKeys(); + test('getSecurity()', async () => { + const params = { + db: 'testString', + }; + + const res = await cloudantService.getSecurity(params); expect(res).toBeDefined(); - expect(res.status).toBe(201); + expect(res.status).toBe(200); expect(res.result).toBeDefined(); }); - test('putCloudantSecurityConfiguration()', async () => { + test('putSecurity()', async () => { // Request models needed by this operation. // SecurityObject const securityObjectModel = { - names: ['testString'], - roles: ['testString'], + names: ['superuser'], + roles: ['admins'], }; const params = { db: 'testString', - cloudant: { antsellseadespecteposene: ['_reader', '_writer', '_admin'], garbados: ['_reader', '_writer'], nobody: ['_reader'] }, admins: securityObjectModel, - members: securityObjectModel, + cloudant: { 'key1': ['_reader'] }, couchdbAuthOnly: true, + members: securityObjectModel, }; - const res = await cloudantService.putCloudantSecurityConfiguration(params); + const res = await cloudantService.putSecurity(params); expect(res).toBeDefined(); expect(res.status).toBe(200); expect(res.result).toBeDefined(); @@ -1850,20 +1966,6 @@ describe('CloudantV1_integration', () => { expect(res.result).toBeDefined(); }); - test('getMembershipInformation()', async () => { - const res = await cloudantService.getMembershipInformation(); - expect(res).toBeDefined(); - expect(res.status).toBe(200); - expect(res.result).toBeDefined(); - }); - - test('getUpInformation()', async () => { - const res = await cloudantService.getUpInformation(); - expect(res).toBeDefined(); - expect(res.status).toBe(200); - expect(res.result).toBeDefined(); - }); - test('getActivityTrackerEvents()', async () => { const res = await cloudantService.getActivityTrackerEvents(); expect(res).toBeDefined(); @@ -1889,6 +1991,20 @@ describe('CloudantV1_integration', () => { expect(res.result).toBeDefined(); }); + test('getMembershipInformation()', async () => { + const res = await cloudantService.getMembershipInformation(); + expect(res).toBeDefined(); + expect(res.status).toBe(200); + expect(res.result).toBeDefined(); + }); + + test('getUpInformation()', async () => { + const res = await cloudantService.getUpInformation(); + expect(res).toBeDefined(); + expect(res.status).toBe(200); + expect(res.result).toBeDefined(); + }); + test('deleteDatabase()', async () => { const params = { db: 'testString', diff --git a/test/unit/cloudant.v1.test.js b/test/unit/cloudant.v1.test.js index 2dbc9f3a4..6b16e5e8a 100644 --- a/test/unit/cloudant.v1.test.js +++ b/test/unit/cloudant.v1.test.js @@ -182,70 +182,6 @@ describe('CloudantV1', () => { }); }); - describe('getUuids', () => { - describe('positive tests', () => { - function __getUuidsTest() { - // Construct the params object for operation getUuids - const count = 1; - const getUuidsParams = { - count, - }; - - const getUuidsResult = cloudantService.getUuids(getUuidsParams); - - // all methods should return a Promise - expectToBePromise(getUuidsResult); - - // assert that create request was called - expect(createRequestMock).toHaveBeenCalledTimes(1); - - const mockRequestOptions = getOptions(createRequestMock); - - checkUrlAndMethod(mockRequestOptions, '/_uuids', 'GET'); - const expectedAccept = 'application/json'; - const expectedContentType = undefined; - checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); - expect(mockRequestOptions.qs.count).toEqual(count); - } - - test('should pass the right params to createRequest with enable and disable retries', () => { - // baseline test - __getUuidsTest(); - - // enable retries and test again - createRequestMock.mockClear(); - cloudantService.enableRetries(); - __getUuidsTest(); - - // disable retries and test again - createRequestMock.mockClear(); - cloudantService.disableRetries(); - __getUuidsTest(); - }); - - test('should prioritize user-given headers', () => { - // parameters - const userAccept = 'fake/accept'; - const userContentType = 'fake/contentType'; - const getUuidsParams = { - headers: { - Accept: userAccept, - 'Content-Type': userContentType, - }, - }; - - cloudantService.getUuids(getUuidsParams); - checkMediaHeaders(createRequestMock, userAccept, userContentType); - }); - - test('should not have any problems when no parameters are passed in', () => { - // invoke the method with no parameters - cloudantService.getUuids({}); - checkForSuccessfulExecution(createRequestMock); - }); - }); - }); - describe('getCapacityThroughputInformation', () => { describe('positive tests', () => { function __getCapacityThroughputInformationTest() { @@ -390,13 +326,77 @@ describe('CloudantV1', () => { }); }); + describe('getUuids', () => { + describe('positive tests', () => { + function __getUuidsTest() { + // Construct the params object for operation getUuids + const count = 1; + const getUuidsParams = { + count, + }; + + const getUuidsResult = cloudantService.getUuids(getUuidsParams); + + // all methods should return a Promise + expectToBePromise(getUuidsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/_uuids', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.count).toEqual(count); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __getUuidsTest(); + + // enable retries and test again + createRequestMock.mockClear(); + cloudantService.enableRetries(); + __getUuidsTest(); + + // disable retries and test again + createRequestMock.mockClear(); + cloudantService.disableRetries(); + __getUuidsTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const getUuidsParams = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + cloudantService.getUuids(getUuidsParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + cloudantService.getUuids({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + describe('getDbUpdates', () => { describe('positive tests', () => { function __getDbUpdatesTest() { // Construct the params object for operation getDbUpdates const descending = false; const feed = 'normal'; - const heartbeat = 0; + const heartbeat = 1; const limit = 0; const timeout = 60000; const since = '0'; @@ -484,7 +484,7 @@ describe('CloudantV1', () => { const descending = false; const feed = 'normal'; const filter = 'testString'; - const heartbeat = 0; + const heartbeat = 1; const includeDocs = false; const limit = 0; const seqInterval = 1; @@ -622,7 +622,7 @@ describe('CloudantV1', () => { const descending = false; const feed = 'normal'; const filter = 'testString'; - const heartbeat = 0; + const heartbeat = 1; const includeDocs = false; const limit = 0; const seqInterval = 1; @@ -1164,7 +1164,7 @@ describe('CloudantV1', () => { // Construct the params object for operation putDatabase const db = 'testString'; const partitioned = false; - const q = 26; + const q = 16; const putDatabaseParams = { db, partitioned, @@ -6678,7 +6678,7 @@ describe('CloudantV1', () => { const groupField = 'testString'; const groupLimit = 1; const groupSort = ['testString']; - const ranges = { 'key1': { 'key1': { 'key1': 'testString' } } }; + const ranges = { 'key1': { 'key1': 'testString' } }; const postSearchParams = { db, ddoc, @@ -6828,7 +6828,7 @@ describe('CloudantV1', () => { const groupField = 'testString'; const groupLimit = 1; const groupSort = ['testString']; - const ranges = { 'key1': { 'key1': { 'key1': 'testString' } } }; + const ranges = { 'key1': { 'key1': 'testString' } }; const postSearchAsStreamParams = { db, ddoc, @@ -7304,54 +7304,245 @@ describe('CloudantV1', () => { }); }); - describe('deleteReplicationDocument', () => { + describe('postReplicator', () => { describe('positive tests', () => { - function __deleteReplicationDocumentTest() { - // Construct the params object for operation deleteReplicationDocument - const docId = 'testString'; - const ifMatch = 'testString'; + // Request models needed by this operation. + + // Attachment + const attachmentModel = { + contentType: 'testString', + data: Buffer.from('VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=', 'base64'), + digest: 'testString', + encodedLength: 0, + encoding: 'testString', + follows: true, + length: 0, + revpos: 1, + stub: true, + }; + + // Revisions + const revisionsModel = { + ids: ['testString'], + start: 1, + }; + + // DocumentRevisionStatus + const documentRevisionStatusModel = { + rev: 'testString', + status: 'available', + }; + + // ReplicationCreateTargetParameters + const replicationCreateTargetParametersModel = { + n: 3, + partitioned: false, + q: 1, + }; + + // ReplicationDatabaseAuthBasic + const replicationDatabaseAuthBasicModel = { + password: 'testString', + username: 'testString', + }; + + // ReplicationDatabaseAuthIam + const replicationDatabaseAuthIamModel = { + apiKey: 'testString', + }; + + // ReplicationDatabaseAuth + const replicationDatabaseAuthModel = { + basic: replicationDatabaseAuthBasicModel, + iam: replicationDatabaseAuthIamModel, + }; + + // ReplicationDatabase + const replicationDatabaseModel = { + auth: replicationDatabaseAuthModel, + headers: { 'key1': 'testString' }, + url: 'https://my-source-instance.cloudantnosqldb.appdomain.cloud.example/animaldb', + }; + + // UserContext + const userContextModel = { + db: 'testString', + name: 'john', + roles: ['_replicator'], + }; + + // ReplicationDocument + const replicationDocumentModel = { + _attachments: { 'key1': attachmentModel }, + _conflicts: ['testString'], + _deleted: true, + _deleted_conflicts: ['testString'], + _id: 'testString', + _local_seq: 'testString', + _rev: 'testString', + _revisions: revisionsModel, + _revs_info: [documentRevisionStatusModel], + cancel: false, + checkpointInterval: 4500, + connectionTimeout: 15000, + continuous: true, + createTarget: true, + createTargetParams: replicationCreateTargetParametersModel, + docIds: ['badger', 'lemur', 'llama'], + filter: 'ddoc/my_filter', + httpConnections: 10, + owner: 'testString', + queryParams: { 'key1': 'testString' }, + retriesPerRequest: 3, + selector: { _id: { '$regex': 'docid' } }, + 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: 400, + workerProcesses: 3, + foo: 'testString', + }; + + function __postReplicatorTest() { + // Construct the params object for operation postReplicator + const replicationDocument = replicationDocumentModel; const batch = 'ok'; - const rev = 'testString'; - const deleteReplicationDocumentParams = { - docId, - ifMatch, + const postReplicatorParams = { + replicationDocument, batch, - rev, }; - const deleteReplicationDocumentResult = cloudantService.deleteReplicationDocument(deleteReplicationDocumentParams); + const postReplicatorResult = cloudantService.postReplicator(postReplicatorParams); // all methods should return a Promise - expectToBePromise(deleteReplicationDocumentResult); + expectToBePromise(postReplicatorResult); // assert that create request was called expect(createRequestMock).toHaveBeenCalledTimes(1); const mockRequestOptions = getOptions(createRequestMock); - checkUrlAndMethod(mockRequestOptions, '/_replicator/{doc_id}', 'DELETE'); + checkUrlAndMethod(mockRequestOptions, '/_replicator', 'POST'); const expectedAccept = 'application/json'; - const expectedContentType = undefined; + const expectedContentType = 'application/json'; checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); - checkUserHeader(createRequestMock, 'If-Match', ifMatch); + expect(mockRequestOptions.body).toEqual(CloudantV1.ReplicationDocument.serialize(replicationDocument)); expect(mockRequestOptions.qs.batch).toEqual(batch); - expect(mockRequestOptions.qs.rev).toEqual(rev); - expect(mockRequestOptions.path.doc_id).toEqual(docId); } test('should pass the right params to createRequest with enable and disable retries', () => { // baseline test - __deleteReplicationDocumentTest(); + __postReplicatorTest(); // enable retries and test again createRequestMock.mockClear(); cloudantService.enableRetries(); - __deleteReplicationDocumentTest(); + __postReplicatorTest(); // disable retries and test again createRequestMock.mockClear(); cloudantService.disableRetries(); - __deleteReplicationDocumentTest(); + __postReplicatorTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const replicationDocument = replicationDocumentModel; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const postReplicatorParams = { + replicationDocument, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + cloudantService.postReplicator(postReplicatorParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await cloudantService.postReplicator({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await cloudantService.postReplicator(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('deleteReplicationDocument', () => { + describe('positive tests', () => { + function __deleteReplicationDocumentTest() { + // Construct the params object for operation deleteReplicationDocument + const docId = 'testString'; + const ifMatch = 'testString'; + const batch = 'ok'; + const rev = 'testString'; + const deleteReplicationDocumentParams = { + docId, + ifMatch, + batch, + rev, + }; + + const deleteReplicationDocumentResult = cloudantService.deleteReplicationDocument(deleteReplicationDocumentParams); + + // all methods should return a Promise + expectToBePromise(deleteReplicationDocumentResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/_replicator/{doc_id}', 'DELETE'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'If-Match', ifMatch); + expect(mockRequestOptions.qs.batch).toEqual(batch); + expect(mockRequestOptions.qs.rev).toEqual(rev); + expect(mockRequestOptions.path.doc_id).toEqual(docId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __deleteReplicationDocumentTest(); + + // enable retries and test again + createRequestMock.mockClear(); + cloudantService.enableRetries(); + __deleteReplicationDocumentTest(); + + // disable retries and test again + createRequestMock.mockClear(); + cloudantService.disableRetries(); + __deleteReplicationDocumentTest(); }); test('should prioritize user-given headers', () => { @@ -8084,165 +8275,143 @@ describe('CloudantV1', () => { }); }); - describe('getSecurity', () => { + describe('postApiKeys', () => { describe('positive tests', () => { - function __getSecurityTest() { - // Construct the params object for operation getSecurity - const db = 'testString'; - const getSecurityParams = { - db, - }; + function __postApiKeysTest() { + // Construct the params object for operation postApiKeys + const postApiKeysParams = {}; - const getSecurityResult = cloudantService.getSecurity(getSecurityParams); + const postApiKeysResult = cloudantService.postApiKeys(postApiKeysParams); // all methods should return a Promise - expectToBePromise(getSecurityResult); + expectToBePromise(postApiKeysResult); // assert that create request was called expect(createRequestMock).toHaveBeenCalledTimes(1); const mockRequestOptions = getOptions(createRequestMock); - checkUrlAndMethod(mockRequestOptions, '/{db}/_security', 'GET'); + checkUrlAndMethod(mockRequestOptions, '/_api/v2/api_keys', 'POST'); const expectedAccept = 'application/json'; const expectedContentType = undefined; checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); - expect(mockRequestOptions.path.db).toEqual(db); } test('should pass the right params to createRequest with enable and disable retries', () => { // baseline test - __getSecurityTest(); + __postApiKeysTest(); // enable retries and test again createRequestMock.mockClear(); cloudantService.enableRetries(); - __getSecurityTest(); + __postApiKeysTest(); // disable retries and test again createRequestMock.mockClear(); cloudantService.disableRetries(); - __getSecurityTest(); + __postApiKeysTest(); }); test('should prioritize user-given headers', () => { // parameters - const db = 'testString'; const userAccept = 'fake/accept'; const userContentType = 'fake/contentType'; - const getSecurityParams = { - db, + const postApiKeysParams = { headers: { Accept: userAccept, 'Content-Type': userContentType, }, }; - cloudantService.getSecurity(getSecurityParams); + cloudantService.postApiKeys(postApiKeysParams); checkMediaHeaders(createRequestMock, userAccept, userContentType); }); - }); - - describe('negative tests', () => { - test('should enforce required parameters', async () => { - let err; - try { - await cloudantService.getSecurity({}); - } catch (e) { - err = e; - } - - expect(err.message).toMatch(/Missing required parameters/); - }); - test('should reject promise when required params are not given', async () => { - let err; - try { - await cloudantService.getSecurity(); - } catch (e) { - err = e; - } - - expect(err.message).toMatch(/Missing required parameters/); + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + cloudantService.postApiKeys({}); + checkForSuccessfulExecution(createRequestMock); }); }); }); - describe('putSecurity', () => { + describe('putCloudantSecurityConfiguration', () => { describe('positive tests', () => { // Request models needed by this operation. // SecurityObject const securityObjectModel = { - names: ['superuser'], - roles: ['admins'], + names: ['testString'], + roles: ['testString'], }; - function __putSecurityTest() { - // Construct the params object for operation putSecurity + function __putCloudantSecurityConfigurationTest() { + // Construct the params object for operation putCloudantSecurityConfiguration const db = 'testString'; - const admins = securityObjectModel; - const members = securityObjectModel; const cloudant = { 'key1': ['_reader'] }; + const admins = securityObjectModel; const couchdbAuthOnly = true; - const putSecurityParams = { + const members = securityObjectModel; + const putCloudantSecurityConfigurationParams = { db, - admins, - members, cloudant, + admins, couchdbAuthOnly, + members, }; - const putSecurityResult = cloudantService.putSecurity(putSecurityParams); + const putCloudantSecurityConfigurationResult = cloudantService.putCloudantSecurityConfiguration(putCloudantSecurityConfigurationParams); // all methods should return a Promise - expectToBePromise(putSecurityResult); + expectToBePromise(putCloudantSecurityConfigurationResult); // assert that create request was called expect(createRequestMock).toHaveBeenCalledTimes(1); const mockRequestOptions = getOptions(createRequestMock); - checkUrlAndMethod(mockRequestOptions, '/{db}/_security', 'PUT'); + checkUrlAndMethod(mockRequestOptions, '/_api/v2/db/{db}/_security', 'PUT'); const expectedAccept = 'application/json'; const expectedContentType = 'application/json'; checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); - expect(mockRequestOptions.body.admins).toEqual(CloudantV1.SecurityObject.serialize(securityObjectModel)); - expect(mockRequestOptions.body.members).toEqual(CloudantV1.SecurityObject.serialize(securityObjectModel)); expect(mockRequestOptions.body.cloudant).toEqual(cloudant); + expect(mockRequestOptions.body.admins).toEqual(CloudantV1.SecurityObject.serialize(securityObjectModel)); expect(mockRequestOptions.body.couchdb_auth_only).toEqual(couchdbAuthOnly); + expect(mockRequestOptions.body.members).toEqual(CloudantV1.SecurityObject.serialize(securityObjectModel)); expect(mockRequestOptions.path.db).toEqual(db); } test('should pass the right params to createRequest with enable and disable retries', () => { // baseline test - __putSecurityTest(); + __putCloudantSecurityConfigurationTest(); // enable retries and test again createRequestMock.mockClear(); cloudantService.enableRetries(); - __putSecurityTest(); + __putCloudantSecurityConfigurationTest(); // disable retries and test again createRequestMock.mockClear(); cloudantService.disableRetries(); - __putSecurityTest(); + __putCloudantSecurityConfigurationTest(); }); test('should prioritize user-given headers', () => { // parameters const db = 'testString'; + const cloudant = { 'key1': ['_reader'] }; const userAccept = 'fake/accept'; const userContentType = 'fake/contentType'; - const putSecurityParams = { + const putCloudantSecurityConfigurationParams = { db, + cloudant, headers: { Accept: userAccept, 'Content-Type': userContentType, }, }; - cloudantService.putSecurity(putSecurityParams); + cloudantService.putCloudantSecurityConfiguration(putCloudantSecurityConfigurationParams); checkMediaHeaders(createRequestMock, userAccept, userContentType); }); }); @@ -8251,7 +8420,7 @@ describe('CloudantV1', () => { test('should enforce required parameters', async () => { let err; try { - await cloudantService.putSecurity({}); + await cloudantService.putCloudantSecurityConfiguration({}); } catch (e) { err = e; } @@ -8262,7 +8431,7 @@ describe('CloudantV1', () => { test('should reject promise when required params are not given', async () => { let err; try { - await cloudantService.putSecurity(); + await cloudantService.putCloudantSecurityConfiguration(); } catch (e) { err = e; } @@ -8272,143 +8441,165 @@ describe('CloudantV1', () => { }); }); - describe('postApiKeys', () => { + describe('getSecurity', () => { describe('positive tests', () => { - function __postApiKeysTest() { - // Construct the params object for operation postApiKeys - const postApiKeysParams = {}; + function __getSecurityTest() { + // Construct the params object for operation getSecurity + const db = 'testString'; + const getSecurityParams = { + db, + }; - const postApiKeysResult = cloudantService.postApiKeys(postApiKeysParams); + const getSecurityResult = cloudantService.getSecurity(getSecurityParams); // all methods should return a Promise - expectToBePromise(postApiKeysResult); + expectToBePromise(getSecurityResult); // assert that create request was called expect(createRequestMock).toHaveBeenCalledTimes(1); const mockRequestOptions = getOptions(createRequestMock); - checkUrlAndMethod(mockRequestOptions, '/_api/v2/api_keys', 'POST'); + checkUrlAndMethod(mockRequestOptions, '/{db}/_security', 'GET'); const expectedAccept = 'application/json'; const expectedContentType = undefined; checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.db).toEqual(db); } test('should pass the right params to createRequest with enable and disable retries', () => { // baseline test - __postApiKeysTest(); + __getSecurityTest(); // enable retries and test again createRequestMock.mockClear(); cloudantService.enableRetries(); - __postApiKeysTest(); + __getSecurityTest(); // disable retries and test again createRequestMock.mockClear(); cloudantService.disableRetries(); - __postApiKeysTest(); + __getSecurityTest(); }); test('should prioritize user-given headers', () => { // parameters + const db = 'testString'; const userAccept = 'fake/accept'; const userContentType = 'fake/contentType'; - const postApiKeysParams = { + const getSecurityParams = { + db, headers: { Accept: userAccept, 'Content-Type': userContentType, }, }; - cloudantService.postApiKeys(postApiKeysParams); + cloudantService.getSecurity(getSecurityParams); checkMediaHeaders(createRequestMock, userAccept, userContentType); }); + }); - test('should not have any problems when no parameters are passed in', () => { - // invoke the method with no parameters - cloudantService.postApiKeys({}); - checkForSuccessfulExecution(createRequestMock); + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await cloudantService.getSecurity({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await cloudantService.getSecurity(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); }); }); }); - describe('putCloudantSecurityConfiguration', () => { + describe('putSecurity', () => { describe('positive tests', () => { // Request models needed by this operation. // SecurityObject const securityObjectModel = { - names: ['testString'], - roles: ['testString'], + names: ['superuser'], + roles: ['admins'], }; - function __putCloudantSecurityConfigurationTest() { - // Construct the params object for operation putCloudantSecurityConfiguration + function __putSecurityTest() { + // Construct the params object for operation putSecurity const db = 'testString'; - const cloudant = { 'key1': ['_reader'] }; const admins = securityObjectModel; - const members = securityObjectModel; + const cloudant = { 'key1': ['_reader'] }; const couchdbAuthOnly = true; - const putCloudantSecurityConfigurationParams = { + const members = securityObjectModel; + const putSecurityParams = { db, - cloudant, admins, - members, + cloudant, couchdbAuthOnly, + members, }; - const putCloudantSecurityConfigurationResult = cloudantService.putCloudantSecurityConfiguration(putCloudantSecurityConfigurationParams); + const putSecurityResult = cloudantService.putSecurity(putSecurityParams); // all methods should return a Promise - expectToBePromise(putCloudantSecurityConfigurationResult); + expectToBePromise(putSecurityResult); // assert that create request was called expect(createRequestMock).toHaveBeenCalledTimes(1); const mockRequestOptions = getOptions(createRequestMock); - checkUrlAndMethod(mockRequestOptions, '/_api/v2/db/{db}/_security', 'PUT'); + checkUrlAndMethod(mockRequestOptions, '/{db}/_security', 'PUT'); const expectedAccept = 'application/json'; const expectedContentType = 'application/json'; checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); - expect(mockRequestOptions.body.cloudant).toEqual(cloudant); expect(mockRequestOptions.body.admins).toEqual(CloudantV1.SecurityObject.serialize(securityObjectModel)); - expect(mockRequestOptions.body.members).toEqual(CloudantV1.SecurityObject.serialize(securityObjectModel)); + expect(mockRequestOptions.body.cloudant).toEqual(cloudant); expect(mockRequestOptions.body.couchdb_auth_only).toEqual(couchdbAuthOnly); + expect(mockRequestOptions.body.members).toEqual(CloudantV1.SecurityObject.serialize(securityObjectModel)); expect(mockRequestOptions.path.db).toEqual(db); } test('should pass the right params to createRequest with enable and disable retries', () => { // baseline test - __putCloudantSecurityConfigurationTest(); + __putSecurityTest(); // enable retries and test again createRequestMock.mockClear(); cloudantService.enableRetries(); - __putCloudantSecurityConfigurationTest(); + __putSecurityTest(); // disable retries and test again createRequestMock.mockClear(); cloudantService.disableRetries(); - __putCloudantSecurityConfigurationTest(); + __putSecurityTest(); }); test('should prioritize user-given headers', () => { // parameters const db = 'testString'; - const cloudant = { 'key1': ['_reader'] }; const userAccept = 'fake/accept'; const userContentType = 'fake/contentType'; - const putCloudantSecurityConfigurationParams = { + const putSecurityParams = { db, - cloudant, headers: { Accept: userAccept, 'Content-Type': userContentType, }, }; - cloudantService.putCloudantSecurityConfiguration(putCloudantSecurityConfigurationParams); + cloudantService.putSecurity(putSecurityParams); checkMediaHeaders(createRequestMock, userAccept, userContentType); }); }); @@ -8417,7 +8608,7 @@ describe('CloudantV1', () => { test('should enforce required parameters', async () => { let err; try { - await cloudantService.putCloudantSecurityConfiguration({}); + await cloudantService.putSecurity({}); } catch (e) { err = e; } @@ -8428,7 +8619,7 @@ describe('CloudantV1', () => { test('should reject promise when required params are not given', async () => { let err; try { - await cloudantService.putCloudantSecurityConfiguration(); + await cloudantService.putSecurity(); } catch (e) { err = e; } @@ -9784,23 +9975,23 @@ describe('CloudantV1', () => { }); }); - describe('getMembershipInformation', () => { + describe('getActivityTrackerEvents', () => { describe('positive tests', () => { - function __getMembershipInformationTest() { - // Construct the params object for operation getMembershipInformation - const getMembershipInformationParams = {}; + function __getActivityTrackerEventsTest() { + // Construct the params object for operation getActivityTrackerEvents + const getActivityTrackerEventsParams = {}; - const getMembershipInformationResult = cloudantService.getMembershipInformation(getMembershipInformationParams); + const getActivityTrackerEventsResult = cloudantService.getActivityTrackerEvents(getActivityTrackerEventsParams); // all methods should return a Promise - expectToBePromise(getMembershipInformationResult); + expectToBePromise(getActivityTrackerEventsResult); // assert that create request was called expect(createRequestMock).toHaveBeenCalledTimes(1); const mockRequestOptions = getOptions(createRequestMock); - checkUrlAndMethod(mockRequestOptions, '/_membership', 'GET'); + checkUrlAndMethod(mockRequestOptions, '/_api/v2/user/activity_tracker/events', 'GET'); const expectedAccept = 'application/json'; const expectedContentType = undefined; checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); @@ -9808,119 +9999,143 @@ describe('CloudantV1', () => { test('should pass the right params to createRequest with enable and disable retries', () => { // baseline test - __getMembershipInformationTest(); + __getActivityTrackerEventsTest(); // enable retries and test again createRequestMock.mockClear(); cloudantService.enableRetries(); - __getMembershipInformationTest(); + __getActivityTrackerEventsTest(); // disable retries and test again createRequestMock.mockClear(); cloudantService.disableRetries(); - __getMembershipInformationTest(); + __getActivityTrackerEventsTest(); }); test('should prioritize user-given headers', () => { // parameters const userAccept = 'fake/accept'; const userContentType = 'fake/contentType'; - const getMembershipInformationParams = { + const getActivityTrackerEventsParams = { headers: { Accept: userAccept, 'Content-Type': userContentType, }, }; - cloudantService.getMembershipInformation(getMembershipInformationParams); + cloudantService.getActivityTrackerEvents(getActivityTrackerEventsParams); checkMediaHeaders(createRequestMock, userAccept, userContentType); }); test('should not have any problems when no parameters are passed in', () => { // invoke the method with no parameters - cloudantService.getMembershipInformation({}); + cloudantService.getActivityTrackerEvents({}); checkForSuccessfulExecution(createRequestMock); }); }); }); - describe('getUpInformation', () => { + describe('postActivityTrackerEvents', () => { describe('positive tests', () => { - function __getUpInformationTest() { - // Construct the params object for operation getUpInformation - const getUpInformationParams = {}; + function __postActivityTrackerEventsTest() { + // Construct the params object for operation postActivityTrackerEvents + const types = ['management', 'data']; + const postActivityTrackerEventsParams = { + types, + }; - const getUpInformationResult = cloudantService.getUpInformation(getUpInformationParams); + const postActivityTrackerEventsResult = cloudantService.postActivityTrackerEvents(postActivityTrackerEventsParams); // all methods should return a Promise - expectToBePromise(getUpInformationResult); + expectToBePromise(postActivityTrackerEventsResult); // assert that create request was called expect(createRequestMock).toHaveBeenCalledTimes(1); const mockRequestOptions = getOptions(createRequestMock); - checkUrlAndMethod(mockRequestOptions, '/_up', 'GET'); + checkUrlAndMethod(mockRequestOptions, '/_api/v2/user/activity_tracker/events', 'POST'); const expectedAccept = 'application/json'; - const expectedContentType = undefined; + const expectedContentType = 'application/json'; checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.body.types).toEqual(types); } test('should pass the right params to createRequest with enable and disable retries', () => { // baseline test - __getUpInformationTest(); + __postActivityTrackerEventsTest(); // enable retries and test again createRequestMock.mockClear(); cloudantService.enableRetries(); - __getUpInformationTest(); + __postActivityTrackerEventsTest(); // disable retries and test again createRequestMock.mockClear(); cloudantService.disableRetries(); - __getUpInformationTest(); + __postActivityTrackerEventsTest(); }); test('should prioritize user-given headers', () => { // parameters + const types = ['management', 'data']; const userAccept = 'fake/accept'; const userContentType = 'fake/contentType'; - const getUpInformationParams = { + const postActivityTrackerEventsParams = { + types, headers: { Accept: userAccept, 'Content-Type': userContentType, }, }; - cloudantService.getUpInformation(getUpInformationParams); + cloudantService.postActivityTrackerEvents(postActivityTrackerEventsParams); checkMediaHeaders(createRequestMock, userAccept, userContentType); }); + }); - test('should not have any problems when no parameters are passed in', () => { - // invoke the method with no parameters - cloudantService.getUpInformation({}); - checkForSuccessfulExecution(createRequestMock); + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await cloudantService.postActivityTrackerEvents({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await cloudantService.postActivityTrackerEvents(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); }); }); }); - describe('getActivityTrackerEvents', () => { + describe('getCurrentThroughputInformation', () => { describe('positive tests', () => { - function __getActivityTrackerEventsTest() { - // Construct the params object for operation getActivityTrackerEvents - const getActivityTrackerEventsParams = {}; + function __getCurrentThroughputInformationTest() { + // Construct the params object for operation getCurrentThroughputInformation + const getCurrentThroughputInformationParams = {}; - const getActivityTrackerEventsResult = cloudantService.getActivityTrackerEvents(getActivityTrackerEventsParams); + const getCurrentThroughputInformationResult = cloudantService.getCurrentThroughputInformation(getCurrentThroughputInformationParams); // all methods should return a Promise - expectToBePromise(getActivityTrackerEventsResult); + expectToBePromise(getCurrentThroughputInformationResult); // assert that create request was called expect(createRequestMock).toHaveBeenCalledTimes(1); const mockRequestOptions = getOptions(createRequestMock); - checkUrlAndMethod(mockRequestOptions, '/_api/v2/user/activity_tracker/events', 'GET'); + checkUrlAndMethod(mockRequestOptions, '/_api/v2/user/current/throughput', 'GET'); const expectedAccept = 'application/json'; const expectedContentType = undefined; checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); @@ -9928,143 +10143,119 @@ describe('CloudantV1', () => { test('should pass the right params to createRequest with enable and disable retries', () => { // baseline test - __getActivityTrackerEventsTest(); + __getCurrentThroughputInformationTest(); // enable retries and test again createRequestMock.mockClear(); cloudantService.enableRetries(); - __getActivityTrackerEventsTest(); + __getCurrentThroughputInformationTest(); // disable retries and test again createRequestMock.mockClear(); cloudantService.disableRetries(); - __getActivityTrackerEventsTest(); + __getCurrentThroughputInformationTest(); }); test('should prioritize user-given headers', () => { // parameters const userAccept = 'fake/accept'; const userContentType = 'fake/contentType'; - const getActivityTrackerEventsParams = { + const getCurrentThroughputInformationParams = { headers: { Accept: userAccept, 'Content-Type': userContentType, }, }; - cloudantService.getActivityTrackerEvents(getActivityTrackerEventsParams); + cloudantService.getCurrentThroughputInformation(getCurrentThroughputInformationParams); checkMediaHeaders(createRequestMock, userAccept, userContentType); }); test('should not have any problems when no parameters are passed in', () => { // invoke the method with no parameters - cloudantService.getActivityTrackerEvents({}); + cloudantService.getCurrentThroughputInformation({}); checkForSuccessfulExecution(createRequestMock); }); }); }); - describe('postActivityTrackerEvents', () => { + describe('getMembershipInformation', () => { describe('positive tests', () => { - function __postActivityTrackerEventsTest() { - // Construct the params object for operation postActivityTrackerEvents - const types = ['management', 'data']; - const postActivityTrackerEventsParams = { - types, - }; + function __getMembershipInformationTest() { + // Construct the params object for operation getMembershipInformation + const getMembershipInformationParams = {}; - const postActivityTrackerEventsResult = cloudantService.postActivityTrackerEvents(postActivityTrackerEventsParams); + const getMembershipInformationResult = cloudantService.getMembershipInformation(getMembershipInformationParams); // all methods should return a Promise - expectToBePromise(postActivityTrackerEventsResult); + expectToBePromise(getMembershipInformationResult); // assert that create request was called expect(createRequestMock).toHaveBeenCalledTimes(1); const mockRequestOptions = getOptions(createRequestMock); - checkUrlAndMethod(mockRequestOptions, '/_api/v2/user/activity_tracker/events', 'POST'); + checkUrlAndMethod(mockRequestOptions, '/_membership', 'GET'); const expectedAccept = 'application/json'; - const expectedContentType = 'application/json'; + const expectedContentType = undefined; checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); - expect(mockRequestOptions.body.types).toEqual(types); } test('should pass the right params to createRequest with enable and disable retries', () => { // baseline test - __postActivityTrackerEventsTest(); + __getMembershipInformationTest(); // enable retries and test again createRequestMock.mockClear(); cloudantService.enableRetries(); - __postActivityTrackerEventsTest(); + __getMembershipInformationTest(); // disable retries and test again createRequestMock.mockClear(); cloudantService.disableRetries(); - __postActivityTrackerEventsTest(); + __getMembershipInformationTest(); }); test('should prioritize user-given headers', () => { // parameters - const types = ['management', 'data']; const userAccept = 'fake/accept'; const userContentType = 'fake/contentType'; - const postActivityTrackerEventsParams = { - types, + const getMembershipInformationParams = { headers: { Accept: userAccept, 'Content-Type': userContentType, }, }; - cloudantService.postActivityTrackerEvents(postActivityTrackerEventsParams); + cloudantService.getMembershipInformation(getMembershipInformationParams); checkMediaHeaders(createRequestMock, userAccept, userContentType); }); - }); - - describe('negative tests', () => { - test('should enforce required parameters', async () => { - let err; - try { - await cloudantService.postActivityTrackerEvents({}); - } catch (e) { - err = e; - } - - expect(err.message).toMatch(/Missing required parameters/); - }); - test('should reject promise when required params are not given', async () => { - let err; - try { - await cloudantService.postActivityTrackerEvents(); - } catch (e) { - err = e; - } - - expect(err.message).toMatch(/Missing required parameters/); + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + cloudantService.getMembershipInformation({}); + checkForSuccessfulExecution(createRequestMock); }); }); }); - describe('getCurrentThroughputInformation', () => { + describe('getUpInformation', () => { describe('positive tests', () => { - function __getCurrentThroughputInformationTest() { - // Construct the params object for operation getCurrentThroughputInformation - const getCurrentThroughputInformationParams = {}; + function __getUpInformationTest() { + // Construct the params object for operation getUpInformation + const getUpInformationParams = {}; - const getCurrentThroughputInformationResult = cloudantService.getCurrentThroughputInformation(getCurrentThroughputInformationParams); + const getUpInformationResult = cloudantService.getUpInformation(getUpInformationParams); // all methods should return a Promise - expectToBePromise(getCurrentThroughputInformationResult); + expectToBePromise(getUpInformationResult); // assert that create request was called expect(createRequestMock).toHaveBeenCalledTimes(1); const mockRequestOptions = getOptions(createRequestMock); - checkUrlAndMethod(mockRequestOptions, '/_api/v2/user/current/throughput', 'GET'); + checkUrlAndMethod(mockRequestOptions, '/_up', 'GET'); const expectedAccept = 'application/json'; const expectedContentType = undefined; checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); @@ -10072,37 +10263,37 @@ describe('CloudantV1', () => { test('should pass the right params to createRequest with enable and disable retries', () => { // baseline test - __getCurrentThroughputInformationTest(); + __getUpInformationTest(); // enable retries and test again createRequestMock.mockClear(); cloudantService.enableRetries(); - __getCurrentThroughputInformationTest(); + __getUpInformationTest(); // disable retries and test again createRequestMock.mockClear(); cloudantService.disableRetries(); - __getCurrentThroughputInformationTest(); + __getUpInformationTest(); }); test('should prioritize user-given headers', () => { // parameters const userAccept = 'fake/accept'; const userContentType = 'fake/contentType'; - const getCurrentThroughputInformationParams = { + const getUpInformationParams = { headers: { Accept: userAccept, 'Content-Type': userContentType, }, }; - cloudantService.getCurrentThroughputInformation(getCurrentThroughputInformationParams); + cloudantService.getUpInformation(getUpInformationParams); checkMediaHeaders(createRequestMock, userAccept, userContentType); }); test('should not have any problems when no parameters are passed in', () => { // invoke the method with no parameters - cloudantService.getCurrentThroughputInformation({}); + cloudantService.getUpInformation({}); checkForSuccessfulExecution(createRequestMock); }); });