"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.PostgresqlApi = exports.PostgresqlApiFactory = exports.PostgresqlApiFp = exports.PostgresqlApiAxiosParamCreator = 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");
/**
 * PostgresqlApi - axios parameter creator
 * @export
 */
const PostgresqlApiAxiosParamCreator = function (configuration) {
    return {
        /**
         * create PostgreSQL extension
         * @summary create PostgreSQL extension
         * @param {string} orgName Organization name
         * @param {string} clusterName name of the cluster
         * @param {PgCreateExtensionOpt} pgCreateExtensionOpt
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createPGExtension: async (orgName, clusterName, pgCreateExtensionOpt, options = {}) => {
            // verify required parameter 'orgName' is not null or undefined
            (0, common_1.assertParamExists)('createPGExtension', 'orgName', orgName);
            // verify required parameter 'clusterName' is not null or undefined
            (0, common_1.assertParamExists)('createPGExtension', 'clusterName', clusterName);
            // verify required parameter 'pgCreateExtensionOpt' is not null or undefined
            (0, common_1.assertParamExists)('createPGExtension', 'pgCreateExtensionOpt', pgCreateExtensionOpt);
            const localVarPath = `/admin/v1/data/postgresql/organizations/{orgName}/clusters/{clusterName}/extensions`
                .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)(pgCreateExtensionOpt, localVarRequestOptions, configuration);
            return {
                url: (0, common_1.toPathString)(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * drop PostgreSQL extension
         * @summary drop PostgreSQL extension
         * @param {string} orgName Organization name
         * @param {string} clusterName name of the cluster
         * @param {string} extensionName The name of the PostgreSQL extension to uninstall.
         * @param {string} database The database where the extension is installed.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        dropPGExtension: async (orgName, clusterName, extensionName, database, options = {}) => {
            // verify required parameter 'orgName' is not null or undefined
            (0, common_1.assertParamExists)('dropPGExtension', 'orgName', orgName);
            // verify required parameter 'clusterName' is not null or undefined
            (0, common_1.assertParamExists)('dropPGExtension', 'clusterName', clusterName);
            // verify required parameter 'extensionName' is not null or undefined
            (0, common_1.assertParamExists)('dropPGExtension', 'extensionName', extensionName);
            // verify required parameter 'database' is not null or undefined
            (0, common_1.assertParamExists)('dropPGExtension', 'database', database);
            const localVarPath = `/admin/v1/data/postgresql/organizations/{orgName}/clusters/{clusterName}/extensions/{extensionName}`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"clusterName"}}`, encodeURIComponent(String(clusterName)))
                .replace(`{${"extensionName"}}`, encodeURIComponent(String(extensionName)));
            // 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);
            if (database !== undefined) {
                localVarQueryParameter['database'] = database;
            }
            (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 PostgreSQL extensions
         * @summary List PostgreSQL extensions
         * @param {string} orgName Organization name
         * @param {string} clusterName name of the cluster
         * @param {string} [status] extension status, if set to &#x60;installed&#x60;, only installed extensions will be returned. If not specified, all available extensions will be returned.
         * @param {string} [database] database name. This parameter is only used when status is installed; if not specified, all databases installed extensions will be returned.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listPGExtensions: async (orgName, clusterName, status, database, options = {}) => {
            // verify required parameter 'orgName' is not null or undefined
            (0, common_1.assertParamExists)('listPGExtensions', 'orgName', orgName);
            // verify required parameter 'clusterName' is not null or undefined
            (0, common_1.assertParamExists)('listPGExtensions', 'clusterName', clusterName);
            const localVarPath = `/admin/v1/data/postgresql/organizations/{orgName}/clusters/{clusterName}/extensions`
                .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);
            if (status !== undefined) {
                localVarQueryParameter['status'] = status;
            }
            if (database !== undefined) {
                localVarQueryParameter['database'] = database;
            }
            (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.PostgresqlApiAxiosParamCreator = PostgresqlApiAxiosParamCreator;
/**
 * PostgresqlApi - functional programming interface
 * @export
 */
const PostgresqlApiFp = function (configuration) {
    const localVarAxiosParamCreator = (0, exports.PostgresqlApiAxiosParamCreator)(configuration);
    return {
        /**
         * create PostgreSQL extension
         * @summary create PostgreSQL extension
         * @param {string} orgName Organization name
         * @param {string} clusterName name of the cluster
         * @param {PgCreateExtensionOpt} pgCreateExtensionOpt
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createPGExtension(orgName, clusterName, pgCreateExtensionOpt, options) {
            var _a, _b, _c;
            const localVarAxiosArgs = await localVarAxiosParamCreator.createPGExtension(orgName, clusterName, pgCreateExtensionOpt, 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['PostgresqlApi.createPGExtension']) === 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);
        },
        /**
         * drop PostgreSQL extension
         * @summary drop PostgreSQL extension
         * @param {string} orgName Organization name
         * @param {string} clusterName name of the cluster
         * @param {string} extensionName The name of the PostgreSQL extension to uninstall.
         * @param {string} database The database where the extension is installed.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async dropPGExtension(orgName, clusterName, extensionName, database, options) {
            var _a, _b, _c;
            const localVarAxiosArgs = await localVarAxiosParamCreator.dropPGExtension(orgName, clusterName, extensionName, database, 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['PostgresqlApi.dropPGExtension']) === 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 PostgreSQL extensions
         * @summary List PostgreSQL extensions
         * @param {string} orgName Organization name
         * @param {string} clusterName name of the cluster
         * @param {string} [status] extension status, if set to &#x60;installed&#x60;, only installed extensions will be returned. If not specified, all available extensions will be returned.
         * @param {string} [database] database name. This parameter is only used when status is installed; if not specified, all databases installed extensions will be returned.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listPGExtensions(orgName, clusterName, status, database, options) {
            var _a, _b, _c;
            const localVarAxiosArgs = await localVarAxiosParamCreator.listPGExtensions(orgName, clusterName, status, database, 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['PostgresqlApi.listPGExtensions']) === 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.PostgresqlApiFp = PostgresqlApiFp;
/**
 * PostgresqlApi - factory interface
 * @export
 */
const PostgresqlApiFactory = function (configuration, basePath, axios) {
    const localVarFp = (0, exports.PostgresqlApiFp)(configuration);
    return {
        /**
         * create PostgreSQL extension
         * @summary create PostgreSQL extension
         * @param {PostgresqlApiCreatePGExtensionRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createPGExtension(requestParameters, options) {
            return localVarFp.createPGExtension(requestParameters.orgName, requestParameters.clusterName, requestParameters.pgCreateExtensionOpt, options).then((request) => request(axios, basePath));
        },
        /**
         * drop PostgreSQL extension
         * @summary drop PostgreSQL extension
         * @param {PostgresqlApiDropPGExtensionRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        dropPGExtension(requestParameters, options) {
            return localVarFp.dropPGExtension(requestParameters.orgName, requestParameters.clusterName, requestParameters.extensionName, requestParameters.database, options).then((request) => request(axios, basePath));
        },
        /**
         * List PostgreSQL extensions
         * @summary List PostgreSQL extensions
         * @param {PostgresqlApiListPGExtensionsRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listPGExtensions(requestParameters, options) {
            return localVarFp.listPGExtensions(requestParameters.orgName, requestParameters.clusterName, requestParameters.status, requestParameters.database, options).then((request) => request(axios, basePath));
        },
    };
};
exports.PostgresqlApiFactory = PostgresqlApiFactory;
/**
 * PostgresqlApi - object-oriented interface
 * @export
 * @class PostgresqlApi
 * @extends {BaseAPI}
 */
class PostgresqlApi extends base_1.BaseAPI {
    /**
     * create PostgreSQL extension
     * @summary create PostgreSQL extension
     * @param {PostgresqlApiCreatePGExtensionRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof PostgresqlApi
     */
    createPGExtension(requestParameters, options) {
        return (0, exports.PostgresqlApiFp)(this.configuration).createPGExtension(requestParameters.orgName, requestParameters.clusterName, requestParameters.pgCreateExtensionOpt, options).then((request) => request(this.axios, this.basePath));
    }
    /**
     * drop PostgreSQL extension
     * @summary drop PostgreSQL extension
     * @param {PostgresqlApiDropPGExtensionRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof PostgresqlApi
     */
    dropPGExtension(requestParameters, options) {
        return (0, exports.PostgresqlApiFp)(this.configuration).dropPGExtension(requestParameters.orgName, requestParameters.clusterName, requestParameters.extensionName, requestParameters.database, options).then((request) => request(this.axios, this.basePath));
    }
    /**
     * List PostgreSQL extensions
     * @summary List PostgreSQL extensions
     * @param {PostgresqlApiListPGExtensionsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof PostgresqlApi
     */
    listPGExtensions(requestParameters, options) {
        return (0, exports.PostgresqlApiFp)(this.configuration).listPGExtensions(requestParameters.orgName, requestParameters.clusterName, requestParameters.status, requestParameters.database, options).then((request) => request(this.axios, this.basePath));
    }
}
exports.PostgresqlApi = PostgresqlApi;
//# sourceMappingURL=postgresql-api.js.map