/* tslint:disable */
/* eslint-disable */
/**
 * KubeBlocks Cloud API
 * KubeBlocks Cloud API is a RESTful API for managing KubeBlocks Cloud resources.  The API is organized around REST.  Our API has predictable resource-oriented URLs, accepts `JSON-encoded` request bodies, returns `JSON-encoded` responses, and uses standard HTTP response codes, authentication, and verbs.  We use standard HTTP authentication and provide API keys to identify who you are. Your API keys carry many privileges, so be sure to keep them secret! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth. 
 *
 * 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 { TlsCert } from '../models';
// @ts-ignore
import type { TlsRequest } from '../models';
/**
 * TlsApi - axios parameter creator
 * @export
 */
export const TlsApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * 
         * @summary Get cluster TLS certificate
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the cluster
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getTLSCertificate: async (orgName: string, clusterName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('getTLSCertificate', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            assertParamExists('getTLSCertificate', 'clusterName', clusterName)
            const localVarPath = `/api/v1/organizations/{orgName}/clusters/{clusterName}/tls`
                .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,
            };
        },
        /**
         * 
         * @summary Enable or disable cluster TLS
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the cluster
         * @param {TlsRequest} body Enable TLS or not
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        tlsSwitcher: async (orgName: string, clusterName: string, body: TlsRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('tlsSwitcher', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            assertParamExists('tlsSwitcher', 'clusterName', clusterName)
            // verify required parameter 'body' is not null or undefined
            assertParamExists('tlsSwitcher', 'body', body)
            const localVarPath = `/api/v1/organizations/{orgName}/clusters/{clusterName}/tls`
                .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,
            };
        },
    }
};

/**
 * TlsApi - functional programming interface
 * @export
 */
export const TlsApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = TlsApiAxiosParamCreator(configuration)
    return {
        /**
         * 
         * @summary Get cluster TLS certificate
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the cluster
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getTLSCertificate(orgName: string, clusterName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<TlsCert>>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getTLSCertificate(orgName, clusterName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['TlsApi.getTLSCertificate']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Enable or disable cluster TLS
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the cluster
         * @param {TlsRequest} body Enable TLS or not
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async tlsSwitcher(orgName: string, clusterName: string, body: TlsRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.tlsSwitcher(orgName, clusterName, body, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['TlsApi.tlsSwitcher']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * TlsApi - factory interface
 * @export
 */
export const TlsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = TlsApiFp(configuration)
    return {
        /**
         * 
         * @summary Get cluster TLS certificate
         * @param {TlsApiGetTLSCertificateRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getTLSCertificate(requestParameters: TlsApiGetTLSCertificateRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<TlsCert>> {
            return localVarFp.getTLSCertificate(requestParameters.orgName, requestParameters.clusterName, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Enable or disable cluster TLS
         * @param {TlsApiTlsSwitcherRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        tlsSwitcher(requestParameters: TlsApiTlsSwitcherRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.tlsSwitcher(requestParameters.orgName, requestParameters.clusterName, requestParameters.body, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * TlsApi - interface
 * @export
 * @interface TlsApi
 */
export interface TlsApiInterface {
    /**
     * 
     * @summary Get cluster TLS certificate
     * @param {TlsApiGetTLSCertificateRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof TlsApiInterface
     */
    getTLSCertificate(requestParameters: TlsApiGetTLSCertificateRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<TlsCert>>;

    /**
     * 
     * @summary Enable or disable cluster TLS
     * @param {TlsApiTlsSwitcherRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof TlsApiInterface
     */
    tlsSwitcher(requestParameters: TlsApiTlsSwitcherRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;

}

/**
 * Request parameters for getTLSCertificate operation in TlsApi.
 * @export
 * @interface TlsApiGetTLSCertificateRequest
 */
export interface TlsApiGetTLSCertificateRequest {
    /**
     * name of the Org
     * @type {string}
     * @memberof TlsApiGetTLSCertificate
     */
    readonly orgName: string

    /**
     * name of the cluster
     * @type {string}
     * @memberof TlsApiGetTLSCertificate
     */
    readonly clusterName: string
}

/**
 * Request parameters for tlsSwitcher operation in TlsApi.
 * @export
 * @interface TlsApiTlsSwitcherRequest
 */
export interface TlsApiTlsSwitcherRequest {
    /**
     * name of the Org
     * @type {string}
     * @memberof TlsApiTlsSwitcher
     */
    readonly orgName: string

    /**
     * name of the cluster
     * @type {string}
     * @memberof TlsApiTlsSwitcher
     */
    readonly clusterName: string

    /**
     * Enable TLS or not
     * @type {TlsRequest}
     * @memberof TlsApiTlsSwitcher
     */
    readonly body: TlsRequest
}

/**
 * TlsApi - object-oriented interface
 * @export
 * @class TlsApi
 * @extends {BaseAPI}
 */
export class TlsApi extends BaseAPI implements TlsApiInterface {
    /**
     * 
     * @summary Get cluster TLS certificate
     * @param {TlsApiGetTLSCertificateRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof TlsApi
     */
    public getTLSCertificate(requestParameters: TlsApiGetTLSCertificateRequest, options?: RawAxiosRequestConfig) {
        return TlsApiFp(this.configuration).getTLSCertificate(requestParameters.orgName, requestParameters.clusterName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Enable or disable cluster TLS
     * @param {TlsApiTlsSwitcherRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof TlsApi
     */
    public tlsSwitcher(requestParameters: TlsApiTlsSwitcherRequest, options?: RawAxiosRequestConfig) {
        return TlsApiFp(this.configuration).tlsSwitcher(requestParameters.orgName, requestParameters.clusterName, requestParameters.body, options).then((request) => request(this.axios, this.basePath));
    }
}

