/* 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.
 */


import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import type { APIErrorResponse } from '../models';
// @ts-ignore
import type { Account } from '../models';
// @ts-ignore
import type { AccountListItem } from '../models';
/**
 * MongodbApi - axios parameter creator
 * @export
 */
export const MongodbApiAxiosParamCreator = function (configuration?: 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: string, clusterName: string, body: Account, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('createMongoDBAccount', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            assertParamExists('createMongoDBAccount', 'clusterName', clusterName)
            // verify required parameter 'body' is not null or undefined
            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, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication BearerToken required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            // authentication DigestAuth required
            await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)


    
            localVarHeaderParameter['Content-Type'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration)

            return {
                url: 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: string, clusterName: string, accountName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('deleteMongoDBAccount', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            assertParamExists('deleteMongoDBAccount', 'clusterName', clusterName)
            // verify required parameter 'accountName' is not null or undefined
            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, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication BearerToken required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            // authentication DigestAuth required
            await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)


    
            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: 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: string, clusterName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('listMongoDBAccounts', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            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, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication BearerToken required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            // authentication DigestAuth required
            await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)


    
            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
    }
};

/**
 * MongodbApi - functional programming interface
 * @export
 */
export const MongodbApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = 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: string, clusterName: string, body: Account, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Account>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createMongoDBAccount(orgName, clusterName, body, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['MongodbApi.createMongoDBAccount']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, 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: string, clusterName: string, accountName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.deleteMongoDBAccount(orgName, clusterName, accountName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['MongodbApi.deleteMongoDBAccount']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, 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: string, clusterName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<AccountListItem>>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listMongoDBAccounts(orgName, clusterName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['MongodbApi.listMongoDBAccounts']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * MongodbApi - factory interface
 * @export
 */
export const MongodbApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = 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: MongodbApiCreateMongoDBAccountRequest, options?: RawAxiosRequestConfig): AxiosPromise<Account> {
            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: MongodbApiDeleteMongoDBAccountRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            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: MongodbApiListMongoDBAccountsRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<AccountListItem>> {
            return localVarFp.listMongoDBAccounts(requestParameters.orgName, requestParameters.clusterName, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * MongodbApi - interface
 * @export
 * @interface MongodbApi
 */
export interface MongodbApiInterface {
    /**
     * create an account in mongodb
     * @summary Create mongodb account
     * @param {MongodbApiCreateMongoDBAccountRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof MongodbApiInterface
     */
    createMongoDBAccount(requestParameters: MongodbApiCreateMongoDBAccountRequest, options?: RawAxiosRequestConfig): AxiosPromise<Account>;

    /**
     * delete an account in mongodb
     * @summary Delete mongodb account
     * @param {MongodbApiDeleteMongoDBAccountRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof MongodbApiInterface
     */
    deleteMongoDBAccount(requestParameters: MongodbApiDeleteMongoDBAccountRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;

    /**
     * list accounts in mongodb
     * @summary List mongodb accounts
     * @param {MongodbApiListMongoDBAccountsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof MongodbApiInterface
     */
    listMongoDBAccounts(requestParameters: MongodbApiListMongoDBAccountsRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<AccountListItem>>;

}

/**
 * Request parameters for createMongoDBAccount operation in MongodbApi.
 * @export
 * @interface MongodbApiCreateMongoDBAccountRequest
 */
export interface MongodbApiCreateMongoDBAccountRequest {
    /**
     * name of the Org
     * @type {string}
     * @memberof MongodbApiCreateMongoDBAccount
     */
    readonly orgName: string

    /**
     * name of the Cluster
     * @type {string}
     * @memberof MongodbApiCreateMongoDBAccount
     */
    readonly clusterName: string

    /**
     * 
     * @type {Account}
     * @memberof MongodbApiCreateMongoDBAccount
     */
    readonly body: Account
}

/**
 * Request parameters for deleteMongoDBAccount operation in MongodbApi.
 * @export
 * @interface MongodbApiDeleteMongoDBAccountRequest
 */
export interface MongodbApiDeleteMongoDBAccountRequest {
    /**
     * name of the Org
     * @type {string}
     * @memberof MongodbApiDeleteMongoDBAccount
     */
    readonly orgName: string

    /**
     * name of the Cluster
     * @type {string}
     * @memberof MongodbApiDeleteMongoDBAccount
     */
    readonly clusterName: string

    /**
     * name of the Cluster
     * @type {string}
     * @memberof MongodbApiDeleteMongoDBAccount
     */
    readonly accountName: string
}

/**
 * Request parameters for listMongoDBAccounts operation in MongodbApi.
 * @export
 * @interface MongodbApiListMongoDBAccountsRequest
 */
export interface MongodbApiListMongoDBAccountsRequest {
    /**
     * name of the Org
     * @type {string}
     * @memberof MongodbApiListMongoDBAccounts
     */
    readonly orgName: string

    /**
     * name of the Cluster
     * @type {string}
     * @memberof MongodbApiListMongoDBAccounts
     */
    readonly clusterName: string
}

/**
 * MongodbApi - object-oriented interface
 * @export
 * @class MongodbApi
 * @extends {BaseAPI}
 */
export class MongodbApi extends BaseAPI implements MongodbApiInterface {
    /**
     * create an account in mongodb
     * @summary Create mongodb account
     * @param {MongodbApiCreateMongoDBAccountRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof MongodbApi
     */
    public createMongoDBAccount(requestParameters: MongodbApiCreateMongoDBAccountRequest, options?: RawAxiosRequestConfig) {
        return 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
     */
    public deleteMongoDBAccount(requestParameters: MongodbApiDeleteMongoDBAccountRequest, options?: RawAxiosRequestConfig) {
        return 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
     */
    public listMongoDBAccounts(requestParameters: MongodbApiListMongoDBAccountsRequest, options?: RawAxiosRequestConfig) {
        return MongodbApiFp(this.configuration).listMongoDBAccounts(requestParameters.orgName, requestParameters.clusterName, options).then((request) => request(this.axios, this.basePath));
    }
}

