/* 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 { Class } from '../models';
// @ts-ignore
import type { ClassBatch } from '../models';
/**
 * ClassApi - axios parameter creator
 * @export
 */
export const ClassApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * 
         * @summary batch update class over-commit
         * @param {ClassBatch} [classBatch] 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        batchClass: async (classBatch?: ClassBatch, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/admin/v1/classes/batch`;
            // 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(classBatch, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * 
         * @summary Create class
         * @param {Class} [_class] 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createClass: async (_class?: Class, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/admin/v1/classes`;
            // 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(_class, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * 
         * @summary Delete class
         * @param {string} code code
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteClass: async (code: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'code' is not null or undefined
            assertParamExists('deleteClass', 'code', code)
            const localVarPath = `/admin/v1/classes`;
            // 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 (code !== undefined) {
                localVarQueryParameter['code'] = code;
            }


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

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * 
         * @summary List classes
         * @param {string} [engineName] filter by engine name
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listClasses: async (engineName?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/admin/v1/classes`;
            // 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 (engineName !== undefined) {
                localVarQueryParameter['engineName'] = engineName;
            }


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

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * 
         * @summary Patch class
         * @param {Class} [_class] 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        patchClass: async (_class?: Class, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/admin/v1/classes`;
            // 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(_class, localVarRequestOptions, configuration)

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

/**
 * ClassApi - functional programming interface
 * @export
 */
export const ClassApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = ClassApiAxiosParamCreator(configuration)
    return {
        /**
         * 
         * @summary batch update class over-commit
         * @param {ClassBatch} [classBatch] 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async batchClass(classBatch?: ClassBatch, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.batchClass(classBatch, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ClassApi.batchClass']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Create class
         * @param {Class} [_class] 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createClass(_class?: Class, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Class>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createClass(_class, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ClassApi.createClass']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Delete class
         * @param {string} code code
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async deleteClass(code: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<object>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.deleteClass(code, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ClassApi.deleteClass']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary List classes
         * @param {string} [engineName] filter by engine name
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listClasses(engineName?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Class>>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listClasses(engineName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ClassApi.listClasses']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Patch class
         * @param {Class} [_class] 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async patchClass(_class?: Class, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Class>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.patchClass(_class, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ClassApi.patchClass']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * ClassApi - factory interface
 * @export
 */
export const ClassApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = ClassApiFp(configuration)
    return {
        /**
         * 
         * @summary batch update class over-commit
         * @param {ClassApiBatchClassRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        batchClass(requestParameters: ClassApiBatchClassRequest = {}, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.batchClass(requestParameters.classBatch, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Create class
         * @param {ClassApiCreateClassRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createClass(requestParameters: ClassApiCreateClassRequest = {}, options?: RawAxiosRequestConfig): AxiosPromise<Class> {
            return localVarFp.createClass(requestParameters._class, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Delete class
         * @param {ClassApiDeleteClassRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteClass(requestParameters: ClassApiDeleteClassRequest, options?: RawAxiosRequestConfig): AxiosPromise<object> {
            return localVarFp.deleteClass(requestParameters.code, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary List classes
         * @param {ClassApiListClassesRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listClasses(requestParameters: ClassApiListClassesRequest = {}, options?: RawAxiosRequestConfig): AxiosPromise<Array<Class>> {
            return localVarFp.listClasses(requestParameters.engineName, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Patch class
         * @param {ClassApiPatchClassRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        patchClass(requestParameters: ClassApiPatchClassRequest = {}, options?: RawAxiosRequestConfig): AxiosPromise<Class> {
            return localVarFp.patchClass(requestParameters._class, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * ClassApi - interface
 * @export
 * @interface ClassApi
 */
export interface ClassApiInterface {
    /**
     * 
     * @summary batch update class over-commit
     * @param {ClassApiBatchClassRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ClassApiInterface
     */
    batchClass(requestParameters?: ClassApiBatchClassRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;

    /**
     * 
     * @summary Create class
     * @param {ClassApiCreateClassRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ClassApiInterface
     */
    createClass(requestParameters?: ClassApiCreateClassRequest, options?: RawAxiosRequestConfig): AxiosPromise<Class>;

    /**
     * 
     * @summary Delete class
     * @param {ClassApiDeleteClassRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ClassApiInterface
     */
    deleteClass(requestParameters: ClassApiDeleteClassRequest, options?: RawAxiosRequestConfig): AxiosPromise<object>;

    /**
     * 
     * @summary List classes
     * @param {ClassApiListClassesRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ClassApiInterface
     */
    listClasses(requestParameters?: ClassApiListClassesRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<Class>>;

    /**
     * 
     * @summary Patch class
     * @param {ClassApiPatchClassRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ClassApiInterface
     */
    patchClass(requestParameters?: ClassApiPatchClassRequest, options?: RawAxiosRequestConfig): AxiosPromise<Class>;

}

/**
 * Request parameters for batchClass operation in ClassApi.
 * @export
 * @interface ClassApiBatchClassRequest
 */
export interface ClassApiBatchClassRequest {
    /**
     * 
     * @type {ClassBatch}
     * @memberof ClassApiBatchClass
     */
    readonly classBatch?: ClassBatch
}

/**
 * Request parameters for createClass operation in ClassApi.
 * @export
 * @interface ClassApiCreateClassRequest
 */
export interface ClassApiCreateClassRequest {
    /**
     * 
     * @type {Class}
     * @memberof ClassApiCreateClass
     */
    readonly _class?: Class
}

/**
 * Request parameters for deleteClass operation in ClassApi.
 * @export
 * @interface ClassApiDeleteClassRequest
 */
export interface ClassApiDeleteClassRequest {
    /**
     * code
     * @type {string}
     * @memberof ClassApiDeleteClass
     */
    readonly code: string
}

/**
 * Request parameters for listClasses operation in ClassApi.
 * @export
 * @interface ClassApiListClassesRequest
 */
export interface ClassApiListClassesRequest {
    /**
     * filter by engine name
     * @type {string}
     * @memberof ClassApiListClasses
     */
    readonly engineName?: string
}

/**
 * Request parameters for patchClass operation in ClassApi.
 * @export
 * @interface ClassApiPatchClassRequest
 */
export interface ClassApiPatchClassRequest {
    /**
     * 
     * @type {Class}
     * @memberof ClassApiPatchClass
     */
    readonly _class?: Class
}

/**
 * ClassApi - object-oriented interface
 * @export
 * @class ClassApi
 * @extends {BaseAPI}
 */
export class ClassApi extends BaseAPI implements ClassApiInterface {
    /**
     * 
     * @summary batch update class over-commit
     * @param {ClassApiBatchClassRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ClassApi
     */
    public batchClass(requestParameters: ClassApiBatchClassRequest = {}, options?: RawAxiosRequestConfig) {
        return ClassApiFp(this.configuration).batchClass(requestParameters.classBatch, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Create class
     * @param {ClassApiCreateClassRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ClassApi
     */
    public createClass(requestParameters: ClassApiCreateClassRequest = {}, options?: RawAxiosRequestConfig) {
        return ClassApiFp(this.configuration).createClass(requestParameters._class, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Delete class
     * @param {ClassApiDeleteClassRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ClassApi
     */
    public deleteClass(requestParameters: ClassApiDeleteClassRequest, options?: RawAxiosRequestConfig) {
        return ClassApiFp(this.configuration).deleteClass(requestParameters.code, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary List classes
     * @param {ClassApiListClassesRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ClassApi
     */
    public listClasses(requestParameters: ClassApiListClassesRequest = {}, options?: RawAxiosRequestConfig) {
        return ClassApiFp(this.configuration).listClasses(requestParameters.engineName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Patch class
     * @param {ClassApiPatchClassRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ClassApi
     */
    public patchClass(requestParameters: ClassApiPatchClassRequest = {}, options?: RawAxiosRequestConfig) {
        return ClassApiFp(this.configuration).patchClass(requestParameters._class, options).then((request) => request(this.axios, this.basePath));
    }
}

