/* 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 { Key } from '../models';
// @ts-ignore
import type { KeyList } from '../models';
/**
 * KeyApi - axios parameter creator
 * @export
 */
export const KeyApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Store a new key in the system.
         * @summary Create a new key
         * @param {Key} [key] 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createKey: async (key?: Key, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/admin/v1/keys`;
            // 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(key, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * 
         * @summary Delete a specific key
         * @param {string} keyName the name of key
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteKey: async (keyName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'keyName' is not null or undefined
            assertParamExists('deleteKey', 'keyName', keyName)
            const localVarPath = `/admin/v1/keys/{keyName}`
                .replace(`{${"keyName"}}`, encodeURIComponent(String(keyName)));
            // 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,
            };
        },
        /**
         * 
         * @summary get an existing key
         * @param {string} keyName the name of key
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getKey: async (keyName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'keyName' is not null or undefined
            assertParamExists('getKey', 'keyName', keyName)
            const localVarPath = `/admin/v1/keys/{keyName}`
                .replace(`{${"keyName"}}`, encodeURIComponent(String(keyName)));
            // 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,
            };
        },
        /**
         * 
         * @summary List Keys
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listKeys: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/admin/v1/keys`;
            // 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,
            };
        },
        /**
         * 
         * @summary Update an existing key
         * @param {string} keyName the name of key
         * @param {Key} key 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        updateKey: async (keyName: string, key: Key, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'keyName' is not null or undefined
            assertParamExists('updateKey', 'keyName', keyName)
            // verify required parameter 'key' is not null or undefined
            assertParamExists('updateKey', 'key', key)
            const localVarPath = `/admin/v1/keys/{keyName}`
                .replace(`{${"keyName"}}`, encodeURIComponent(String(keyName)));
            // 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: 'PATCH', ...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(key, localVarRequestOptions, configuration)

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

/**
 * KeyApi - functional programming interface
 * @export
 */
export const KeyApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = KeyApiAxiosParamCreator(configuration)
    return {
        /**
         * Store a new key in the system.
         * @summary Create a new key
         * @param {Key} [key] 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createKey(key?: Key, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Key>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createKey(key, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['KeyApi.createKey']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Delete a specific key
         * @param {string} keyName the name of key
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async deleteKey(keyName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.deleteKey(keyName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['KeyApi.deleteKey']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary get an existing key
         * @param {string} keyName the name of key
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getKey(keyName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Key>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getKey(keyName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['KeyApi.getKey']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary List Keys
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listKeys(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<KeyList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listKeys(options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['KeyApi.listKeys']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Update an existing key
         * @param {string} keyName the name of key
         * @param {Key} key 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async updateKey(keyName: string, key: Key, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Key>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.updateKey(keyName, key, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['KeyApi.updateKey']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * KeyApi - factory interface
 * @export
 */
export const KeyApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = KeyApiFp(configuration)
    return {
        /**
         * Store a new key in the system.
         * @summary Create a new key
         * @param {KeyApiCreateKeyRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createKey(requestParameters: KeyApiCreateKeyRequest = {}, options?: RawAxiosRequestConfig): AxiosPromise<Key> {
            return localVarFp.createKey(requestParameters.key, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Delete a specific key
         * @param {KeyApiDeleteKeyRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteKey(requestParameters: KeyApiDeleteKeyRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.deleteKey(requestParameters.keyName, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary get an existing key
         * @param {KeyApiGetKeyRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getKey(requestParameters: KeyApiGetKeyRequest, options?: RawAxiosRequestConfig): AxiosPromise<Key> {
            return localVarFp.getKey(requestParameters.keyName, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary List Keys
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listKeys(options?: RawAxiosRequestConfig): AxiosPromise<KeyList> {
            return localVarFp.listKeys(options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Update an existing key
         * @param {KeyApiUpdateKeyRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        updateKey(requestParameters: KeyApiUpdateKeyRequest, options?: RawAxiosRequestConfig): AxiosPromise<Key> {
            return localVarFp.updateKey(requestParameters.keyName, requestParameters.key, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * KeyApi - interface
 * @export
 * @interface KeyApi
 */
export interface KeyApiInterface {
    /**
     * Store a new key in the system.
     * @summary Create a new key
     * @param {KeyApiCreateKeyRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof KeyApiInterface
     */
    createKey(requestParameters?: KeyApiCreateKeyRequest, options?: RawAxiosRequestConfig): AxiosPromise<Key>;

    /**
     * 
     * @summary Delete a specific key
     * @param {KeyApiDeleteKeyRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof KeyApiInterface
     */
    deleteKey(requestParameters: KeyApiDeleteKeyRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;

    /**
     * 
     * @summary get an existing key
     * @param {KeyApiGetKeyRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof KeyApiInterface
     */
    getKey(requestParameters: KeyApiGetKeyRequest, options?: RawAxiosRequestConfig): AxiosPromise<Key>;

    /**
     * 
     * @summary List Keys
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof KeyApiInterface
     */
    listKeys(options?: RawAxiosRequestConfig): AxiosPromise<KeyList>;

    /**
     * 
     * @summary Update an existing key
     * @param {KeyApiUpdateKeyRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof KeyApiInterface
     */
    updateKey(requestParameters: KeyApiUpdateKeyRequest, options?: RawAxiosRequestConfig): AxiosPromise<Key>;

}

/**
 * Request parameters for createKey operation in KeyApi.
 * @export
 * @interface KeyApiCreateKeyRequest
 */
export interface KeyApiCreateKeyRequest {
    /**
     * 
     * @type {Key}
     * @memberof KeyApiCreateKey
     */
    readonly key?: Key
}

/**
 * Request parameters for deleteKey operation in KeyApi.
 * @export
 * @interface KeyApiDeleteKeyRequest
 */
export interface KeyApiDeleteKeyRequest {
    /**
     * the name of key
     * @type {string}
     * @memberof KeyApiDeleteKey
     */
    readonly keyName: string
}

/**
 * Request parameters for getKey operation in KeyApi.
 * @export
 * @interface KeyApiGetKeyRequest
 */
export interface KeyApiGetKeyRequest {
    /**
     * the name of key
     * @type {string}
     * @memberof KeyApiGetKey
     */
    readonly keyName: string
}

/**
 * Request parameters for updateKey operation in KeyApi.
 * @export
 * @interface KeyApiUpdateKeyRequest
 */
export interface KeyApiUpdateKeyRequest {
    /**
     * the name of key
     * @type {string}
     * @memberof KeyApiUpdateKey
     */
    readonly keyName: string

    /**
     * 
     * @type {Key}
     * @memberof KeyApiUpdateKey
     */
    readonly key: Key
}

/**
 * KeyApi - object-oriented interface
 * @export
 * @class KeyApi
 * @extends {BaseAPI}
 */
export class KeyApi extends BaseAPI implements KeyApiInterface {
    /**
     * Store a new key in the system.
     * @summary Create a new key
     * @param {KeyApiCreateKeyRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof KeyApi
     */
    public createKey(requestParameters: KeyApiCreateKeyRequest = {}, options?: RawAxiosRequestConfig) {
        return KeyApiFp(this.configuration).createKey(requestParameters.key, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Delete a specific key
     * @param {KeyApiDeleteKeyRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof KeyApi
     */
    public deleteKey(requestParameters: KeyApiDeleteKeyRequest, options?: RawAxiosRequestConfig) {
        return KeyApiFp(this.configuration).deleteKey(requestParameters.keyName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary get an existing key
     * @param {KeyApiGetKeyRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof KeyApi
     */
    public getKey(requestParameters: KeyApiGetKeyRequest, options?: RawAxiosRequestConfig) {
        return KeyApiFp(this.configuration).getKey(requestParameters.keyName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary List Keys
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof KeyApi
     */
    public listKeys(options?: RawAxiosRequestConfig) {
        return KeyApiFp(this.configuration).listKeys(options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Update an existing key
     * @param {KeyApiUpdateKeyRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof KeyApi
     */
    public updateKey(requestParameters: KeyApiUpdateKeyRequest, options?: RawAxiosRequestConfig) {
        return KeyApiFp(this.configuration).updateKey(requestParameters.keyName, requestParameters.key, options).then((request) => request(this.axios, this.basePath));
    }
}

