/* 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 { Task } from '../models';
// @ts-ignore
import type { TaskList } from '../models';
// @ts-ignore
import type { TaskTypeList } from '../models';
/**
 * TaskApi - axios parameter creator
 * @export
 */
export const TaskApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Cancel a task by taskID within the organization.
         * @summary Cancel a task
         * @param {string} orgName name of the Org
         * @param {string} taskId ID of the task
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        cancelTask: async (orgName: string, taskId: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('cancelTask', 'orgName', orgName)
            // verify required parameter 'taskId' is not null or undefined
            assertParamExists('cancelTask', 'taskId', taskId)
            const localVarPath = `/api/v1/organizations/{orgName}/tasks/{taskId}/cancel`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"taskId"}}`, encodeURIComponent(String(taskId)));
            // 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)


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

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Get task
         * @summary Get task detail
         * @param {string} orgName Organization name
         * @param {string} taskId ID of the task
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getTask: async (orgName: string, taskId: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('getTask', 'orgName', orgName)
            // verify required parameter 'taskId' is not null or undefined
            assertParamExists('getTask', 'taskId', taskId)
            const localVarPath = `/api/v1/organizations/{orgName}/tasks/{taskId}`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"taskId"}}`, encodeURIComponent(String(taskId)));
            // 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,
            };
        },
        /**
         * List task types
         * @summary List task types
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listTaskTypes: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/api/v1/taskTypes`;
            // 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,
            };
        },
        /**
         * List tasks
         * @summary List task
         * @param {string} orgName name of the Org
         * @param {number} start The start of the time range for the query, unit is seconds.
         * @param {number} end The end of the time range for the query, unit is seconds.
         * @param {string} [resourceId] Filter by resource ID (such as cluster ID, environment ID, etc.)
         * @param {string} [resourceType] Filter by resource type
         * @param {string} [taskType] Filter by task type (supports multiple task types separated by commas, e.g., \&quot;cluster-scale,cluster-upgrade\&quot;)
         * @param {string} [status] Filter by task status (supports multiple statuses separated by commas, e.g., \&quot;Running,Pending\&quot;)
         * @param {number} [pageNumber] The pageNumber of the query
         * @param {number} [pageSize] The pageSize of the query
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listTasks: async (orgName: string, start: number, end: number, resourceId?: string, resourceType?: string, taskType?: string, status?: string, pageNumber?: number, pageSize?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('listTasks', 'orgName', orgName)
            // verify required parameter 'start' is not null or undefined
            assertParamExists('listTasks', 'start', start)
            // verify required parameter 'end' is not null or undefined
            assertParamExists('listTasks', 'end', end)
            const localVarPath = `/api/v1/organizations/{orgName}/tasks`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)));
            // 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 (resourceId !== undefined) {
                localVarQueryParameter['resourceId'] = resourceId;
            }

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

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

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

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

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

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

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


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

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

/**
 * TaskApi - functional programming interface
 * @export
 */
export const TaskApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = TaskApiAxiosParamCreator(configuration)
    return {
        /**
         * Cancel a task by taskID within the organization.
         * @summary Cancel a task
         * @param {string} orgName name of the Org
         * @param {string} taskId ID of the task
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async cancelTask(orgName: string, taskId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.cancelTask(orgName, taskId, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['TaskApi.cancelTask']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Get task
         * @summary Get task detail
         * @param {string} orgName Organization name
         * @param {string} taskId ID of the task
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getTask(orgName: string, taskId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Task>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getTask(orgName, taskId, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['TaskApi.getTask']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * List task types
         * @summary List task types
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listTaskTypes(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<TaskTypeList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listTaskTypes(options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['TaskApi.listTaskTypes']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * List tasks
         * @summary List task
         * @param {string} orgName name of the Org
         * @param {number} start The start of the time range for the query, unit is seconds.
         * @param {number} end The end of the time range for the query, unit is seconds.
         * @param {string} [resourceId] Filter by resource ID (such as cluster ID, environment ID, etc.)
         * @param {string} [resourceType] Filter by resource type
         * @param {string} [taskType] Filter by task type (supports multiple task types separated by commas, e.g., \&quot;cluster-scale,cluster-upgrade\&quot;)
         * @param {string} [status] Filter by task status (supports multiple statuses separated by commas, e.g., \&quot;Running,Pending\&quot;)
         * @param {number} [pageNumber] The pageNumber of the query
         * @param {number} [pageSize] The pageSize of the query
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listTasks(orgName: string, start: number, end: number, resourceId?: string, resourceType?: string, taskType?: string, status?: string, pageNumber?: number, pageSize?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<TaskList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listTasks(orgName, start, end, resourceId, resourceType, taskType, status, pageNumber, pageSize, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['TaskApi.listTasks']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * TaskApi - factory interface
 * @export
 */
export const TaskApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = TaskApiFp(configuration)
    return {
        /**
         * Cancel a task by taskID within the organization.
         * @summary Cancel a task
         * @param {TaskApiCancelTaskRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        cancelTask(requestParameters: TaskApiCancelTaskRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.cancelTask(requestParameters.orgName, requestParameters.taskId, options).then((request) => request(axios, basePath));
        },
        /**
         * Get task
         * @summary Get task detail
         * @param {TaskApiGetTaskRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getTask(requestParameters: TaskApiGetTaskRequest, options?: RawAxiosRequestConfig): AxiosPromise<Task> {
            return localVarFp.getTask(requestParameters.orgName, requestParameters.taskId, options).then((request) => request(axios, basePath));
        },
        /**
         * List task types
         * @summary List task types
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listTaskTypes(options?: RawAxiosRequestConfig): AxiosPromise<TaskTypeList> {
            return localVarFp.listTaskTypes(options).then((request) => request(axios, basePath));
        },
        /**
         * List tasks
         * @summary List task
         * @param {TaskApiListTasksRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listTasks(requestParameters: TaskApiListTasksRequest, options?: RawAxiosRequestConfig): AxiosPromise<TaskList> {
            return localVarFp.listTasks(requestParameters.orgName, requestParameters.start, requestParameters.end, requestParameters.resourceId, requestParameters.resourceType, requestParameters.taskType, requestParameters.status, requestParameters.pageNumber, requestParameters.pageSize, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * TaskApi - interface
 * @export
 * @interface TaskApi
 */
export interface TaskApiInterface {
    /**
     * Cancel a task by taskID within the organization.
     * @summary Cancel a task
     * @param {TaskApiCancelTaskRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof TaskApiInterface
     */
    cancelTask(requestParameters: TaskApiCancelTaskRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;

    /**
     * Get task
     * @summary Get task detail
     * @param {TaskApiGetTaskRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof TaskApiInterface
     */
    getTask(requestParameters: TaskApiGetTaskRequest, options?: RawAxiosRequestConfig): AxiosPromise<Task>;

    /**
     * List task types
     * @summary List task types
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof TaskApiInterface
     */
    listTaskTypes(options?: RawAxiosRequestConfig): AxiosPromise<TaskTypeList>;

    /**
     * List tasks
     * @summary List task
     * @param {TaskApiListTasksRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof TaskApiInterface
     */
    listTasks(requestParameters: TaskApiListTasksRequest, options?: RawAxiosRequestConfig): AxiosPromise<TaskList>;

}

/**
 * Request parameters for cancelTask operation in TaskApi.
 * @export
 * @interface TaskApiCancelTaskRequest
 */
export interface TaskApiCancelTaskRequest {
    /**
     * name of the Org
     * @type {string}
     * @memberof TaskApiCancelTask
     */
    readonly orgName: string

    /**
     * ID of the task
     * @type {string}
     * @memberof TaskApiCancelTask
     */
    readonly taskId: string
}

/**
 * Request parameters for getTask operation in TaskApi.
 * @export
 * @interface TaskApiGetTaskRequest
 */
export interface TaskApiGetTaskRequest {
    /**
     * Organization name
     * @type {string}
     * @memberof TaskApiGetTask
     */
    readonly orgName: string

    /**
     * ID of the task
     * @type {string}
     * @memberof TaskApiGetTask
     */
    readonly taskId: string
}

/**
 * Request parameters for listTasks operation in TaskApi.
 * @export
 * @interface TaskApiListTasksRequest
 */
export interface TaskApiListTasksRequest {
    /**
     * name of the Org
     * @type {string}
     * @memberof TaskApiListTasks
     */
    readonly orgName: string

    /**
     * The start of the time range for the query, unit is seconds.
     * @type {number}
     * @memberof TaskApiListTasks
     */
    readonly start: number

    /**
     * The end of the time range for the query, unit is seconds.
     * @type {number}
     * @memberof TaskApiListTasks
     */
    readonly end: number

    /**
     * Filter by resource ID (such as cluster ID, environment ID, etc.)
     * @type {string}
     * @memberof TaskApiListTasks
     */
    readonly resourceId?: string

    /**
     * Filter by resource type
     * @type {string}
     * @memberof TaskApiListTasks
     */
    readonly resourceType?: string

    /**
     * Filter by task type (supports multiple task types separated by commas, e.g., \&quot;cluster-scale,cluster-upgrade\&quot;)
     * @type {string}
     * @memberof TaskApiListTasks
     */
    readonly taskType?: string

    /**
     * Filter by task status (supports multiple statuses separated by commas, e.g., \&quot;Running,Pending\&quot;)
     * @type {string}
     * @memberof TaskApiListTasks
     */
    readonly status?: string

    /**
     * The pageNumber of the query
     * @type {number}
     * @memberof TaskApiListTasks
     */
    readonly pageNumber?: number

    /**
     * The pageSize of the query
     * @type {number}
     * @memberof TaskApiListTasks
     */
    readonly pageSize?: number
}

/**
 * TaskApi - object-oriented interface
 * @export
 * @class TaskApi
 * @extends {BaseAPI}
 */
export class TaskApi extends BaseAPI implements TaskApiInterface {
    /**
     * Cancel a task by taskID within the organization.
     * @summary Cancel a task
     * @param {TaskApiCancelTaskRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof TaskApi
     */
    public cancelTask(requestParameters: TaskApiCancelTaskRequest, options?: RawAxiosRequestConfig) {
        return TaskApiFp(this.configuration).cancelTask(requestParameters.orgName, requestParameters.taskId, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Get task
     * @summary Get task detail
     * @param {TaskApiGetTaskRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof TaskApi
     */
    public getTask(requestParameters: TaskApiGetTaskRequest, options?: RawAxiosRequestConfig) {
        return TaskApiFp(this.configuration).getTask(requestParameters.orgName, requestParameters.taskId, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * List task types
     * @summary List task types
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof TaskApi
     */
    public listTaskTypes(options?: RawAxiosRequestConfig) {
        return TaskApiFp(this.configuration).listTaskTypes(options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * List tasks
     * @summary List task
     * @param {TaskApiListTasksRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof TaskApi
     */
    public listTasks(requestParameters: TaskApiListTasksRequest, options?: RawAxiosRequestConfig) {
        return TaskApiFp(this.configuration).listTasks(requestParameters.orgName, requestParameters.start, requestParameters.end, requestParameters.resourceId, requestParameters.resourceType, requestParameters.taskType, requestParameters.status, requestParameters.pageNumber, requestParameters.pageSize, options).then((request) => request(this.axios, this.basePath));
    }
}

