/* 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 { EnvironmentResourceStats } from '../models';
// @ts-ignore
import type { InstanceResourceStatsList } from '../models';
// @ts-ignore
import type { NodeResourceStatsList } from '../models';
/**
 * ResourceStatsApi - axios parameter creator
 * @export
 */
export const ResourceStatsApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Triggers an immediate collection of resource statistics for the specified environment.
         * @summary Collect resource statistics of environment
         * @param {string} environmentName The name of the environment
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        collectResourceStats: async (environmentName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentName' is not null or undefined
            assertParamExists('collectResourceStats', 'environmentName', environmentName)
            const localVarPath = `/admin/v1/environments/{environmentName}/resourceStats/collect`
                .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: '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,
            };
        },
        /**
         * Returns aggregated resource statistics for the specified environment within an organization.
         * @summary Get resource statistics of environment
         * @param {string} environmentName The name of the environment
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getResourceStats: async (environmentName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentName' is not null or undefined
            assertParamExists('getResourceStats', 'environmentName', environmentName)
            const localVarPath = `/admin/v1/environments/{environmentName}/resourceStats`
                .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 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,
            };
        },
        /**
         * Returns aggregated resource statistics for the specified node.
         * @summary Get resource statistics of instances
         * @param {string} environmentName The name of the environment
         * @param {string} nodeName The name of the node
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listInstancesResourceStats: async (environmentName: string, nodeName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentName' is not null or undefined
            assertParamExists('listInstancesResourceStats', 'environmentName', environmentName)
            // verify required parameter 'nodeName' is not null or undefined
            assertParamExists('listInstancesResourceStats', 'nodeName', nodeName)
            const localVarPath = `/admin/v1/environments/{environmentName}/nodes/{nodeName}/instances/resourceStats`
                .replace(`{${"environmentName"}}`, encodeURIComponent(String(environmentName)))
                .replace(`{${"nodeName"}}`, encodeURIComponent(String(nodeName)));
            // 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,
            };
        },
        /**
         * Returns aggregated resource statistics for the specified environment within an organization.
         * @summary Get resource statistics of nodes
         * @param {string} environmentName The name of the environment
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listNodesResourceStats: async (environmentName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentName' is not null or undefined
            assertParamExists('listNodesResourceStats', 'environmentName', environmentName)
            const localVarPath = `/admin/v1/environments/{environmentName}/nodes/resourceStats`
                .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 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,
            };
        },
    }
};

/**
 * ResourceStatsApi - functional programming interface
 * @export
 */
export const ResourceStatsApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = ResourceStatsApiAxiosParamCreator(configuration)
    return {
        /**
         * Triggers an immediate collection of resource statistics for the specified environment.
         * @summary Collect resource statistics of environment
         * @param {string} environmentName The name of the environment
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async collectResourceStats(environmentName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.collectResourceStats(environmentName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ResourceStatsApi.collectResourceStats']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns aggregated resource statistics for the specified environment within an organization.
         * @summary Get resource statistics of environment
         * @param {string} environmentName The name of the environment
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getResourceStats(environmentName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<EnvironmentResourceStats>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getResourceStats(environmentName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ResourceStatsApi.getResourceStats']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns aggregated resource statistics for the specified node.
         * @summary Get resource statistics of instances
         * @param {string} environmentName The name of the environment
         * @param {string} nodeName The name of the node
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listInstancesResourceStats(environmentName: string, nodeName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<InstanceResourceStatsList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listInstancesResourceStats(environmentName, nodeName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ResourceStatsApi.listInstancesResourceStats']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns aggregated resource statistics for the specified environment within an organization.
         * @summary Get resource statistics of nodes
         * @param {string} environmentName The name of the environment
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listNodesResourceStats(environmentName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<NodeResourceStatsList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listNodesResourceStats(environmentName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ResourceStatsApi.listNodesResourceStats']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * ResourceStatsApi - factory interface
 * @export
 */
export const ResourceStatsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = ResourceStatsApiFp(configuration)
    return {
        /**
         * Triggers an immediate collection of resource statistics for the specified environment.
         * @summary Collect resource statistics of environment
         * @param {ResourceStatsApiCollectResourceStatsRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        collectResourceStats(requestParameters: ResourceStatsApiCollectResourceStatsRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.collectResourceStats(requestParameters.environmentName, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns aggregated resource statistics for the specified environment within an organization.
         * @summary Get resource statistics of environment
         * @param {ResourceStatsApiGetResourceStatsRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getResourceStats(requestParameters: ResourceStatsApiGetResourceStatsRequest, options?: RawAxiosRequestConfig): AxiosPromise<EnvironmentResourceStats> {
            return localVarFp.getResourceStats(requestParameters.environmentName, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns aggregated resource statistics for the specified node.
         * @summary Get resource statistics of instances
         * @param {ResourceStatsApiListInstancesResourceStatsRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listInstancesResourceStats(requestParameters: ResourceStatsApiListInstancesResourceStatsRequest, options?: RawAxiosRequestConfig): AxiosPromise<InstanceResourceStatsList> {
            return localVarFp.listInstancesResourceStats(requestParameters.environmentName, requestParameters.nodeName, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns aggregated resource statistics for the specified environment within an organization.
         * @summary Get resource statistics of nodes
         * @param {ResourceStatsApiListNodesResourceStatsRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listNodesResourceStats(requestParameters: ResourceStatsApiListNodesResourceStatsRequest, options?: RawAxiosRequestConfig): AxiosPromise<NodeResourceStatsList> {
            return localVarFp.listNodesResourceStats(requestParameters.environmentName, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * ResourceStatsApi - interface
 * @export
 * @interface ResourceStatsApi
 */
export interface ResourceStatsApiInterface {
    /**
     * Triggers an immediate collection of resource statistics for the specified environment.
     * @summary Collect resource statistics of environment
     * @param {ResourceStatsApiCollectResourceStatsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ResourceStatsApiInterface
     */
    collectResourceStats(requestParameters: ResourceStatsApiCollectResourceStatsRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;

    /**
     * Returns aggregated resource statistics for the specified environment within an organization.
     * @summary Get resource statistics of environment
     * @param {ResourceStatsApiGetResourceStatsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ResourceStatsApiInterface
     */
    getResourceStats(requestParameters: ResourceStatsApiGetResourceStatsRequest, options?: RawAxiosRequestConfig): AxiosPromise<EnvironmentResourceStats>;

    /**
     * Returns aggregated resource statistics for the specified node.
     * @summary Get resource statistics of instances
     * @param {ResourceStatsApiListInstancesResourceStatsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ResourceStatsApiInterface
     */
    listInstancesResourceStats(requestParameters: ResourceStatsApiListInstancesResourceStatsRequest, options?: RawAxiosRequestConfig): AxiosPromise<InstanceResourceStatsList>;

    /**
     * Returns aggregated resource statistics for the specified environment within an organization.
     * @summary Get resource statistics of nodes
     * @param {ResourceStatsApiListNodesResourceStatsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ResourceStatsApiInterface
     */
    listNodesResourceStats(requestParameters: ResourceStatsApiListNodesResourceStatsRequest, options?: RawAxiosRequestConfig): AxiosPromise<NodeResourceStatsList>;

}

/**
 * Request parameters for collectResourceStats operation in ResourceStatsApi.
 * @export
 * @interface ResourceStatsApiCollectResourceStatsRequest
 */
export interface ResourceStatsApiCollectResourceStatsRequest {
    /**
     * The name of the environment
     * @type {string}
     * @memberof ResourceStatsApiCollectResourceStats
     */
    readonly environmentName: string
}

/**
 * Request parameters for getResourceStats operation in ResourceStatsApi.
 * @export
 * @interface ResourceStatsApiGetResourceStatsRequest
 */
export interface ResourceStatsApiGetResourceStatsRequest {
    /**
     * The name of the environment
     * @type {string}
     * @memberof ResourceStatsApiGetResourceStats
     */
    readonly environmentName: string
}

/**
 * Request parameters for listInstancesResourceStats operation in ResourceStatsApi.
 * @export
 * @interface ResourceStatsApiListInstancesResourceStatsRequest
 */
export interface ResourceStatsApiListInstancesResourceStatsRequest {
    /**
     * The name of the environment
     * @type {string}
     * @memberof ResourceStatsApiListInstancesResourceStats
     */
    readonly environmentName: string

    /**
     * The name of the node
     * @type {string}
     * @memberof ResourceStatsApiListInstancesResourceStats
     */
    readonly nodeName: string
}

/**
 * Request parameters for listNodesResourceStats operation in ResourceStatsApi.
 * @export
 * @interface ResourceStatsApiListNodesResourceStatsRequest
 */
export interface ResourceStatsApiListNodesResourceStatsRequest {
    /**
     * The name of the environment
     * @type {string}
     * @memberof ResourceStatsApiListNodesResourceStats
     */
    readonly environmentName: string
}

/**
 * ResourceStatsApi - object-oriented interface
 * @export
 * @class ResourceStatsApi
 * @extends {BaseAPI}
 */
export class ResourceStatsApi extends BaseAPI implements ResourceStatsApiInterface {
    /**
     * Triggers an immediate collection of resource statistics for the specified environment.
     * @summary Collect resource statistics of environment
     * @param {ResourceStatsApiCollectResourceStatsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ResourceStatsApi
     */
    public collectResourceStats(requestParameters: ResourceStatsApiCollectResourceStatsRequest, options?: RawAxiosRequestConfig) {
        return ResourceStatsApiFp(this.configuration).collectResourceStats(requestParameters.environmentName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns aggregated resource statistics for the specified environment within an organization.
     * @summary Get resource statistics of environment
     * @param {ResourceStatsApiGetResourceStatsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ResourceStatsApi
     */
    public getResourceStats(requestParameters: ResourceStatsApiGetResourceStatsRequest, options?: RawAxiosRequestConfig) {
        return ResourceStatsApiFp(this.configuration).getResourceStats(requestParameters.environmentName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns aggregated resource statistics for the specified node.
     * @summary Get resource statistics of instances
     * @param {ResourceStatsApiListInstancesResourceStatsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ResourceStatsApi
     */
    public listInstancesResourceStats(requestParameters: ResourceStatsApiListInstancesResourceStatsRequest, options?: RawAxiosRequestConfig) {
        return ResourceStatsApiFp(this.configuration).listInstancesResourceStats(requestParameters.environmentName, requestParameters.nodeName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns aggregated resource statistics for the specified environment within an organization.
     * @summary Get resource statistics of nodes
     * @param {ResourceStatsApiListNodesResourceStatsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ResourceStatsApi
     */
    public listNodesResourceStats(requestParameters: ResourceStatsApiListNodesResourceStatsRequest, options?: RawAxiosRequestConfig) {
        return ResourceStatsApiFp(this.configuration).listNodesResourceStats(requestParameters.environmentName, options).then((request) => request(this.axios, this.basePath));
    }
}

