/* tslint:disable */
/* eslint-disable */
/**
 * KubeBlocks Cloud Internal API
 * The Internal API is using for interaction of ApeCloud platform microservices. 
 *
 * The version of the OpenAPI document: 1.0.0
 * 
 *
 * 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 { HttpBody } from '../models';
/**
 * EnvironmentApi - axios parameter creator
 * @export
 */
export const EnvironmentApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * 
         * @summary Delete Environment
         * @param {string} environmentName name of the environment
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteEnvironment: async (environmentName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentName' is not null or undefined
            assertParamExists('deleteEnvironment', 'environmentName', environmentName)
            const localVarPath = `/internal/v1/environments/{environmentName}`
                .replace(`{${"environmentName"}}`, encodeURIComponent(String(environmentName)));
            // 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 BasicAuth required
            // http basic authentication required
            setBasicAuthToObject(localVarRequestOptions, 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 environment kubeconfig
         * @param {string} environmentName name of the Environment
         * @param {string} [orgName] name of the Org
         * @param {string} [uid] the uid of the impersonating user
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getEnvironmentKubeconfigInternal: async (environmentName: string, orgName?: string, uid?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentName' is not null or undefined
            assertParamExists('getEnvironmentKubeconfigInternal', 'environmentName', environmentName)
            const localVarPath = `/internal/v1/environments/{environmentName}/kubeconfig`
                .replace(`{${"environmentName"}}`, encodeURIComponent(String(environmentName)));
            // 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 BasicAuth required
            // http basic authentication required
            setBasicAuthToObject(localVarRequestOptions, configuration)

            if (orgName !== undefined) {
                localVarQueryParameter['orgName'] = orgName;
            }

            if (uid !== undefined) {
                localVarQueryParameter['uid'] = uid;
            }


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

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

/**
 * EnvironmentApi - functional programming interface
 * @export
 */
export const EnvironmentApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = EnvironmentApiAxiosParamCreator(configuration)
    return {
        /**
         * 
         * @summary Delete Environment
         * @param {string} environmentName name of the environment
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async deleteEnvironment(environmentName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.deleteEnvironment(environmentName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['EnvironmentApi.deleteEnvironment']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Get environment kubeconfig
         * @param {string} environmentName name of the Environment
         * @param {string} [orgName] name of the Org
         * @param {string} [uid] the uid of the impersonating user
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getEnvironmentKubeconfigInternal(environmentName: string, orgName?: string, uid?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<HttpBody>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getEnvironmentKubeconfigInternal(environmentName, orgName, uid, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['EnvironmentApi.getEnvironmentKubeconfigInternal']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * EnvironmentApi - factory interface
 * @export
 */
export const EnvironmentApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = EnvironmentApiFp(configuration)
    return {
        /**
         * 
         * @summary Delete Environment
         * @param {EnvironmentApiDeleteEnvironmentRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteEnvironment(requestParameters: EnvironmentApiDeleteEnvironmentRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.deleteEnvironment(requestParameters.environmentName, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Get environment kubeconfig
         * @param {EnvironmentApiGetEnvironmentKubeconfigInternalRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getEnvironmentKubeconfigInternal(requestParameters: EnvironmentApiGetEnvironmentKubeconfigInternalRequest, options?: RawAxiosRequestConfig): AxiosPromise<HttpBody> {
            return localVarFp.getEnvironmentKubeconfigInternal(requestParameters.environmentName, requestParameters.orgName, requestParameters.uid, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * EnvironmentApi - interface
 * @export
 * @interface EnvironmentApi
 */
export interface EnvironmentApiInterface {
    /**
     * 
     * @summary Delete Environment
     * @param {EnvironmentApiDeleteEnvironmentRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof EnvironmentApiInterface
     */
    deleteEnvironment(requestParameters: EnvironmentApiDeleteEnvironmentRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;

    /**
     * 
     * @summary Get environment kubeconfig
     * @param {EnvironmentApiGetEnvironmentKubeconfigInternalRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof EnvironmentApiInterface
     */
    getEnvironmentKubeconfigInternal(requestParameters: EnvironmentApiGetEnvironmentKubeconfigInternalRequest, options?: RawAxiosRequestConfig): AxiosPromise<HttpBody>;

}

/**
 * Request parameters for deleteEnvironment operation in EnvironmentApi.
 * @export
 * @interface EnvironmentApiDeleteEnvironmentRequest
 */
export interface EnvironmentApiDeleteEnvironmentRequest {
    /**
     * name of the environment
     * @type {string}
     * @memberof EnvironmentApiDeleteEnvironment
     */
    readonly environmentName: string
}

/**
 * Request parameters for getEnvironmentKubeconfigInternal operation in EnvironmentApi.
 * @export
 * @interface EnvironmentApiGetEnvironmentKubeconfigInternalRequest
 */
export interface EnvironmentApiGetEnvironmentKubeconfigInternalRequest {
    /**
     * name of the Environment
     * @type {string}
     * @memberof EnvironmentApiGetEnvironmentKubeconfigInternal
     */
    readonly environmentName: string

    /**
     * name of the Org
     * @type {string}
     * @memberof EnvironmentApiGetEnvironmentKubeconfigInternal
     */
    readonly orgName?: string

    /**
     * the uid of the impersonating user
     * @type {string}
     * @memberof EnvironmentApiGetEnvironmentKubeconfigInternal
     */
    readonly uid?: string
}

/**
 * EnvironmentApi - object-oriented interface
 * @export
 * @class EnvironmentApi
 * @extends {BaseAPI}
 */
export class EnvironmentApi extends BaseAPI implements EnvironmentApiInterface {
    /**
     * 
     * @summary Delete Environment
     * @param {EnvironmentApiDeleteEnvironmentRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof EnvironmentApi
     */
    public deleteEnvironment(requestParameters: EnvironmentApiDeleteEnvironmentRequest, options?: RawAxiosRequestConfig) {
        return EnvironmentApiFp(this.configuration).deleteEnvironment(requestParameters.environmentName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Get environment kubeconfig
     * @param {EnvironmentApiGetEnvironmentKubeconfigInternalRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof EnvironmentApi
     */
    public getEnvironmentKubeconfigInternal(requestParameters: EnvironmentApiGetEnvironmentKubeconfigInternalRequest, options?: RawAxiosRequestConfig) {
        return EnvironmentApiFp(this.configuration).getEnvironmentKubeconfigInternal(requestParameters.environmentName, requestParameters.orgName, requestParameters.uid, options).then((request) => request(this.axios, this.basePath));
    }
}

