/* 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 { DmsSession } from '../models';
/**
 * SessionApi - axios parameter creator
 * @export
 */
export const SessionApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * kill a session in cluster
         * @summary Kill cluster session
         * @param {string} engineName name of the engine
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the Cluster
         * @param {string} session session id
         * @param {boolean} [keep] if keep is true, the session will not be killed but only closed
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        killSession: async (engineName: string, orgName: string, clusterName: string, session: string, keep?: boolean, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'engineName' is not null or undefined
            assertParamExists('killSession', 'engineName', engineName)
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('killSession', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            assertParamExists('killSession', 'clusterName', clusterName)
            // verify required parameter 'session' is not null or undefined
            assertParamExists('killSession', 'session', session)
            const localVarPath = `/admin/v1/data/{engineName}/organizations/{orgName}/clusters/{clusterName}/sessions/{session}`
                .replace(`{${"engineName"}}`, encodeURIComponent(String(engineName)))
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"clusterName"}}`, encodeURIComponent(String(clusterName)))
                .replace(`{${"session"}}`, encodeURIComponent(String(session)));
            // 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)

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


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

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * list sessions in cluster
         * @summary List cluster sessions
         * @param {string} engineName name of the engine
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the Cluster
         * @param {boolean} [all] whether list all session includes sleep
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listSessions: async (engineName: string, orgName: string, clusterName: string, all?: boolean, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'engineName' is not null or undefined
            assertParamExists('listSessions', 'engineName', engineName)
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('listSessions', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            assertParamExists('listSessions', 'clusterName', clusterName)
            const localVarPath = `/admin/v1/data/{engineName}/organizations/{orgName}/clusters/{clusterName}/sessions`
                .replace(`{${"engineName"}}`, encodeURIComponent(String(engineName)))
                .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)

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


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

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

/**
 * SessionApi - functional programming interface
 * @export
 */
export const SessionApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = SessionApiAxiosParamCreator(configuration)
    return {
        /**
         * kill a session in cluster
         * @summary Kill cluster session
         * @param {string} engineName name of the engine
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the Cluster
         * @param {string} session session id
         * @param {boolean} [keep] if keep is true, the session will not be killed but only closed
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async killSession(engineName: string, orgName: string, clusterName: string, session: string, keep?: boolean, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.killSession(engineName, orgName, clusterName, session, keep, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SessionApi.killSession']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * list sessions in cluster
         * @summary List cluster sessions
         * @param {string} engineName name of the engine
         * @param {string} orgName name of the Org
         * @param {string} clusterName name of the Cluster
         * @param {boolean} [all] whether list all session includes sleep
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listSessions(engineName: string, orgName: string, clusterName: string, all?: boolean, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<DmsSession>>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listSessions(engineName, orgName, clusterName, all, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SessionApi.listSessions']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * SessionApi - factory interface
 * @export
 */
export const SessionApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = SessionApiFp(configuration)
    return {
        /**
         * kill a session in cluster
         * @summary Kill cluster session
         * @param {SessionApiKillSessionRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        killSession(requestParameters: SessionApiKillSessionRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.killSession(requestParameters.engineName, requestParameters.orgName, requestParameters.clusterName, requestParameters.session, requestParameters.keep, options).then((request) => request(axios, basePath));
        },
        /**
         * list sessions in cluster
         * @summary List cluster sessions
         * @param {SessionApiListSessionsRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listSessions(requestParameters: SessionApiListSessionsRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<DmsSession>> {
            return localVarFp.listSessions(requestParameters.engineName, requestParameters.orgName, requestParameters.clusterName, requestParameters.all, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * SessionApi - interface
 * @export
 * @interface SessionApi
 */
export interface SessionApiInterface {
    /**
     * kill a session in cluster
     * @summary Kill cluster session
     * @param {SessionApiKillSessionRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof SessionApiInterface
     */
    killSession(requestParameters: SessionApiKillSessionRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;

    /**
     * list sessions in cluster
     * @summary List cluster sessions
     * @param {SessionApiListSessionsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof SessionApiInterface
     */
    listSessions(requestParameters: SessionApiListSessionsRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<DmsSession>>;

}

/**
 * Request parameters for killSession operation in SessionApi.
 * @export
 * @interface SessionApiKillSessionRequest
 */
export interface SessionApiKillSessionRequest {
    /**
     * name of the engine
     * @type {string}
     * @memberof SessionApiKillSession
     */
    readonly engineName: string

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

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

    /**
     * session id
     * @type {string}
     * @memberof SessionApiKillSession
     */
    readonly session: string

    /**
     * if keep is true, the session will not be killed but only closed
     * @type {boolean}
     * @memberof SessionApiKillSession
     */
    readonly keep?: boolean
}

/**
 * Request parameters for listSessions operation in SessionApi.
 * @export
 * @interface SessionApiListSessionsRequest
 */
export interface SessionApiListSessionsRequest {
    /**
     * name of the engine
     * @type {string}
     * @memberof SessionApiListSessions
     */
    readonly engineName: string

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

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

    /**
     * whether list all session includes sleep
     * @type {boolean}
     * @memberof SessionApiListSessions
     */
    readonly all?: boolean
}

/**
 * SessionApi - object-oriented interface
 * @export
 * @class SessionApi
 * @extends {BaseAPI}
 */
export class SessionApi extends BaseAPI implements SessionApiInterface {
    /**
     * kill a session in cluster
     * @summary Kill cluster session
     * @param {SessionApiKillSessionRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof SessionApi
     */
    public killSession(requestParameters: SessionApiKillSessionRequest, options?: RawAxiosRequestConfig) {
        return SessionApiFp(this.configuration).killSession(requestParameters.engineName, requestParameters.orgName, requestParameters.clusterName, requestParameters.session, requestParameters.keep, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * list sessions in cluster
     * @summary List cluster sessions
     * @param {SessionApiListSessionsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof SessionApi
     */
    public listSessions(requestParameters: SessionApiListSessionsRequest, options?: RawAxiosRequestConfig) {
        return SessionApiFp(this.configuration).listSessions(requestParameters.engineName, requestParameters.orgName, requestParameters.clusterName, requestParameters.all, options).then((request) => request(this.axios, this.basePath));
    }
}

