"use strict";
/* tslint:disable */
/* eslint-disable */
/**
 * Admin API
 * The Admin API is used to manage the ApeCloud platform.
 *
 * The version of the OpenAPI document: 1.0.0
 * Contact: support@apecloud.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MongodbApi = exports.MongodbApiFactory = exports.MongodbApiFp = exports.MongodbApiAxiosParamCreator = void 0;
const axios_1 = __importDefault(require("axios"));
// Some imports not used depending on template conditions
// @ts-ignore
const common_1 = require("../common");
// @ts-ignore
const base_1 = require("../base");
/**
 * MongodbApi - axios parameter creator
 * @export
 */
const MongodbApiAxiosParamCreator = function (configuration) {
    return {
        /**
         * create an account in mongodb
         * @summary Create mongodb account
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the Cluster
         * @param {Account} body
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createMongoDBAccount: async (orgName, clusterName, body, options = {}) => {
            // verify required parameter 'orgName' is not null or undefined
            (0, common_1.assertParamExists)('createMongoDBAccount', 'orgName', orgName);
            // verify required parameter 'clusterName' is not null or undefined
            (0, common_1.assertParamExists)('createMongoDBAccount', 'clusterName', clusterName);
            // verify required parameter 'body' is not null or undefined
            (0, common_1.assertParamExists)('createMongoDBAccount', 'body', body);
            const localVarPath = `/admin/v1/data/mongodb/organizations/{orgName}/clusters/{clusterName}/accounts`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"clusterName"}}`, encodeURIComponent(String(clusterName)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }
            const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
            const localVarHeaderParameter = {};
            const localVarQueryParameter = {};
            // authentication BearerToken required
            // http bearer authentication required
            await (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration);
            // authentication DigestAuth required
            await (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "Authorization", configuration);
            localVarHeaderParameter['Content-Type'] = 'application/json';
            (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
            localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(body, localVarRequestOptions, configuration);
            return {
                url: (0, common_1.toPathString)(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * delete an account in mongodb
         * @summary Delete mongodb account
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the Cluster
         * @param {string} accountName name of the Cluster
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteMongoDBAccount: async (orgName, clusterName, accountName, options = {}) => {
            // verify required parameter 'orgName' is not null or undefined
            (0, common_1.assertParamExists)('deleteMongoDBAccount', 'orgName', orgName);
            // verify required parameter 'clusterName' is not null or undefined
            (0, common_1.assertParamExists)('deleteMongoDBAccount', 'clusterName', clusterName);
            // verify required parameter 'accountName' is not null or undefined
            (0, common_1.assertParamExists)('deleteMongoDBAccount', 'accountName', accountName);
            const localVarPath = `/admin/v1/data/mongodb/organizations/{orgName}/clusters/{clusterName}/accounts/{accountName}`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"clusterName"}}`, encodeURIComponent(String(clusterName)))
                .replace(`{${"accountName"}}`, encodeURIComponent(String(accountName)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }
            const localVarRequestOptions = Object.assign(Object.assign({ method: 'DELETE' }, baseOptions), options);
            const localVarHeaderParameter = {};
            const localVarQueryParameter = {};
            // authentication BearerToken required
            // http bearer authentication required
            await (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration);
            // authentication DigestAuth required
            await (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "Authorization", configuration);
            (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
            return {
                url: (0, common_1.toPathString)(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * list accounts in mongodb
         * @summary List mongodb accounts
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the Cluster
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listMongoDBAccounts: async (orgName, clusterName, options = {}) => {
            // verify required parameter 'orgName' is not null or undefined
            (0, common_1.assertParamExists)('listMongoDBAccounts', 'orgName', orgName);
            // verify required parameter 'clusterName' is not null or undefined
            (0, common_1.assertParamExists)('listMongoDBAccounts', 'clusterName', clusterName);
            const localVarPath = `/admin/v1/data/mongodb/organizations/{orgName}/clusters/{clusterName}/accounts`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"clusterName"}}`, encodeURIComponent(String(clusterName)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }
            const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
            const localVarHeaderParameter = {};
            const localVarQueryParameter = {};
            // authentication BearerToken required
            // http bearer authentication required
            await (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration);
            // authentication DigestAuth required
            await (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "Authorization", configuration);
            (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
            return {
                url: (0, common_1.toPathString)(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
    };
};
exports.MongodbApiAxiosParamCreator = MongodbApiAxiosParamCreator;
/**
 * MongodbApi - functional programming interface
 * @export
 */
const MongodbApiFp = function (configuration) {
    const localVarAxiosParamCreator = (0, exports.MongodbApiAxiosParamCreator)(configuration);
    return {
        /**
         * create an account in mongodb
         * @summary Create mongodb account
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the Cluster
         * @param {Account} body
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createMongoDBAccount(orgName, clusterName, body, options) {
            var _a, _b, _c;
            const localVarAxiosArgs = await localVarAxiosParamCreator.createMongoDBAccount(orgName, clusterName, body, options);
            const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
            const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['MongodbApi.createMongoDBAccount']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
            return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * delete an account in mongodb
         * @summary Delete mongodb account
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the Cluster
         * @param {string} accountName name of the Cluster
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async deleteMongoDBAccount(orgName, clusterName, accountName, options) {
            var _a, _b, _c;
            const localVarAxiosArgs = await localVarAxiosParamCreator.deleteMongoDBAccount(orgName, clusterName, accountName, options);
            const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
            const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['MongodbApi.deleteMongoDBAccount']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
            return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * list accounts in mongodb
         * @summary List mongodb accounts
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the Cluster
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listMongoDBAccounts(orgName, clusterName, options) {
            var _a, _b, _c;
            const localVarAxiosArgs = await localVarAxiosParamCreator.listMongoDBAccounts(orgName, clusterName, options);
            const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
            const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['MongodbApi.listMongoDBAccounts']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
            return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    };
};
exports.MongodbApiFp = MongodbApiFp;
/**
 * MongodbApi - factory interface
 * @export
 */
const MongodbApiFactory = function (configuration, basePath, axios) {
    const localVarFp = (0, exports.MongodbApiFp)(configuration);
    return {
        /**
         * create an account in mongodb
         * @summary Create mongodb account
         * @param {MongodbApiCreateMongoDBAccountRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createMongoDBAccount(requestParameters, options) {
            return localVarFp.createMongoDBAccount(requestParameters.orgName, requestParameters.clusterName, requestParameters.body, options).then((request) => request(axios, basePath));
        },
        /**
         * delete an account in mongodb
         * @summary Delete mongodb account
         * @param {MongodbApiDeleteMongoDBAccountRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteMongoDBAccount(requestParameters, options) {
            return localVarFp.deleteMongoDBAccount(requestParameters.orgName, requestParameters.clusterName, requestParameters.accountName, options).then((request) => request(axios, basePath));
        },
        /**
         * list accounts in mongodb
         * @summary List mongodb accounts
         * @param {MongodbApiListMongoDBAccountsRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listMongoDBAccounts(requestParameters, options) {
            return localVarFp.listMongoDBAccounts(requestParameters.orgName, requestParameters.clusterName, options).then((request) => request(axios, basePath));
        },
    };
};
exports.MongodbApiFactory = MongodbApiFactory;
/**
 * MongodbApi - object-oriented interface
 * @export
 * @class MongodbApi
 * @extends {BaseAPI}
 */
class MongodbApi extends base_1.BaseAPI {
    /**
     * create an account in mongodb
     * @summary Create mongodb account
     * @param {MongodbApiCreateMongoDBAccountRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof MongodbApi
     */
    createMongoDBAccount(requestParameters, options) {
        return (0, exports.MongodbApiFp)(this.configuration).createMongoDBAccount(requestParameters.orgName, requestParameters.clusterName, requestParameters.body, options).then((request) => request(this.axios, this.basePath));
    }
    /**
     * delete an account in mongodb
     * @summary Delete mongodb account
     * @param {MongodbApiDeleteMongoDBAccountRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof MongodbApi
     */
    deleteMongoDBAccount(requestParameters, options) {
        return (0, exports.MongodbApiFp)(this.configuration).deleteMongoDBAccount(requestParameters.orgName, requestParameters.clusterName, requestParameters.accountName, options).then((request) => request(this.axios, this.basePath));
    }
    /**
     * list accounts in mongodb
     * @summary List mongodb accounts
     * @param {MongodbApiListMongoDBAccountsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof MongodbApi
     */
    listMongoDBAccounts(requestParameters, options) {
        return (0, exports.MongodbApiFp)(this.configuration).listMongoDBAccounts(requestParameters.orgName, requestParameters.clusterName, options).then((request) => request(this.axios, this.basePath));
    }
}
exports.MongodbApi = MongodbApi;
//# sourceMappingURL=mongodb-api.js.map