/* 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 { AggregationGroupType } from '../models';
// @ts-ignore
import type { AggregationTimeType } from '../models';
// @ts-ignore
import type { BasicTask } from '../models';
// @ts-ignore
import type { BillList } from '../models';
/**
 * BillingApi - axios parameter creator
 * @export
 */
export const BillingApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * 
         * @summary List bills
         * @param {AggregationTimeType} aggregationTime The type of aggregation time
         * @param {AggregationGroupType} aggregationGroup The type of aggregation group
         * @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} [billID] The ID of the bill
         * @param {string} [clusterID] The ID of the cluster
         * @param {string} [orgName] name of the organization
         * @param {string} [projectName] name of the project
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listBills: async (aggregationTime: AggregationTimeType, aggregationGroup: AggregationGroupType, start: number, end: number, billID?: string, clusterID?: string, orgName?: string, projectName?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'aggregationTime' is not null or undefined
            assertParamExists('listBills', 'aggregationTime', aggregationTime)
            // verify required parameter 'aggregationGroup' is not null or undefined
            assertParamExists('listBills', 'aggregationGroup', aggregationGroup)
            // verify required parameter 'start' is not null or undefined
            assertParamExists('listBills', 'start', start)
            // verify required parameter 'end' is not null or undefined
            assertParamExists('listBills', 'end', end)
            const localVarPath = `/admin/v1/bills`;
            // 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 (billID !== undefined) {
                localVarQueryParameter['billID'] = billID;
            }

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

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

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

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

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

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

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


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

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * 
         * @summary Refresh bill
         * @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 {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        refreshBills: async (start: number, end: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'start' is not null or undefined
            assertParamExists('refreshBills', 'start', start)
            // verify required parameter 'end' is not null or undefined
            assertParamExists('refreshBills', 'end', end)
            const localVarPath = `/admin/v1/bills/refresh`;
            // 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)

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

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


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

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

/**
 * BillingApi - functional programming interface
 * @export
 */
export const BillingApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = BillingApiAxiosParamCreator(configuration)
    return {
        /**
         * 
         * @summary List bills
         * @param {AggregationTimeType} aggregationTime The type of aggregation time
         * @param {AggregationGroupType} aggregationGroup The type of aggregation group
         * @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} [billID] The ID of the bill
         * @param {string} [clusterID] The ID of the cluster
         * @param {string} [orgName] name of the organization
         * @param {string} [projectName] name of the project
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listBills(aggregationTime: AggregationTimeType, aggregationGroup: AggregationGroupType, start: number, end: number, billID?: string, clusterID?: string, orgName?: string, projectName?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<BillList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listBills(aggregationTime, aggregationGroup, start, end, billID, clusterID, orgName, projectName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['BillingApi.listBills']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Refresh bill
         * @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 {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async refreshBills(start: number, end: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<BasicTask>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.refreshBills(start, end, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['BillingApi.refreshBills']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * BillingApi - factory interface
 * @export
 */
export const BillingApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = BillingApiFp(configuration)
    return {
        /**
         * 
         * @summary List bills
         * @param {BillingApiListBillsRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listBills(requestParameters: BillingApiListBillsRequest, options?: RawAxiosRequestConfig): AxiosPromise<BillList> {
            return localVarFp.listBills(requestParameters.aggregationTime, requestParameters.aggregationGroup, requestParameters.start, requestParameters.end, requestParameters.billID, requestParameters.clusterID, requestParameters.orgName, requestParameters.projectName, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Refresh bill
         * @param {BillingApiRefreshBillsRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        refreshBills(requestParameters: BillingApiRefreshBillsRequest, options?: RawAxiosRequestConfig): AxiosPromise<BasicTask> {
            return localVarFp.refreshBills(requestParameters.start, requestParameters.end, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * BillingApi - interface
 * @export
 * @interface BillingApi
 */
export interface BillingApiInterface {
    /**
     * 
     * @summary List bills
     * @param {BillingApiListBillsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof BillingApiInterface
     */
    listBills(requestParameters: BillingApiListBillsRequest, options?: RawAxiosRequestConfig): AxiosPromise<BillList>;

    /**
     * 
     * @summary Refresh bill
     * @param {BillingApiRefreshBillsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof BillingApiInterface
     */
    refreshBills(requestParameters: BillingApiRefreshBillsRequest, options?: RawAxiosRequestConfig): AxiosPromise<BasicTask>;

}

/**
 * Request parameters for listBills operation in BillingApi.
 * @export
 * @interface BillingApiListBillsRequest
 */
export interface BillingApiListBillsRequest {
    /**
     * The type of aggregation time
     * @type {AggregationTimeType}
     * @memberof BillingApiListBills
     */
    readonly aggregationTime: AggregationTimeType

    /**
     * The type of aggregation group
     * @type {AggregationGroupType}
     * @memberof BillingApiListBills
     */
    readonly aggregationGroup: AggregationGroupType

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

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

    /**
     * The ID of the bill
     * @type {string}
     * @memberof BillingApiListBills
     */
    readonly billID?: string

    /**
     * The ID of the cluster
     * @type {string}
     * @memberof BillingApiListBills
     */
    readonly clusterID?: string

    /**
     * name of the organization
     * @type {string}
     * @memberof BillingApiListBills
     */
    readonly orgName?: string

    /**
     * name of the project
     * @type {string}
     * @memberof BillingApiListBills
     */
    readonly projectName?: string
}

/**
 * Request parameters for refreshBills operation in BillingApi.
 * @export
 * @interface BillingApiRefreshBillsRequest
 */
export interface BillingApiRefreshBillsRequest {
    /**
     * The start of the time range for the query, unit is seconds.
     * @type {number}
     * @memberof BillingApiRefreshBills
     */
    readonly start: number

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

/**
 * BillingApi - object-oriented interface
 * @export
 * @class BillingApi
 * @extends {BaseAPI}
 */
export class BillingApi extends BaseAPI implements BillingApiInterface {
    /**
     * 
     * @summary List bills
     * @param {BillingApiListBillsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof BillingApi
     */
    public listBills(requestParameters: BillingApiListBillsRequest, options?: RawAxiosRequestConfig) {
        return BillingApiFp(this.configuration).listBills(requestParameters.aggregationTime, requestParameters.aggregationGroup, requestParameters.start, requestParameters.end, requestParameters.billID, requestParameters.clusterID, requestParameters.orgName, requestParameters.projectName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Refresh bill
     * @param {BillingApiRefreshBillsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof BillingApi
     */
    public refreshBills(requestParameters: BillingApiRefreshBillsRequest, options?: RawAxiosRequestConfig) {
        return BillingApiFp(this.configuration).refreshBills(requestParameters.start, requestParameters.end, options).then((request) => request(this.axios, this.basePath));
    }
}

