/* 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 { Storage } from '../models';
/**
 * StorageApi - axios parameter creator
 * @export
 */
export const StorageApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * 
         * @summary Get a storage
         * @param {string} environmentName name of the environment
         * @param {string} storageName name of the storage
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getStorage: async (environmentName: string, storageName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentName' is not null or undefined
            assertParamExists('getStorage', 'environmentName', environmentName)
            // verify required parameter 'storageName' is not null or undefined
            assertParamExists('getStorage', 'storageName', storageName)
            const localVarPath = `/api/v1/environments/{environmentName}/storages/{storageName}`
                .replace(`{${"environmentName"}}`, encodeURIComponent(String(environmentName)))
                .replace(`{${"storageName"}}`, encodeURIComponent(String(storageName)));
            // 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,
            };
        },
        /**
         * 
         * @summary List storages
         * @param {string} environmentName name of the environment
         * @param {string} [name] the search key to search storage\&#39;s name
         * @param {string} [key] key to search storage\&#39;s tag
         * @param {string} [value] value to search storage\&#39;s tag
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listStorages: async (environmentName: string, name?: string, key?: string, value?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentName' is not null or undefined
            assertParamExists('listStorages', 'environmentName', environmentName)
            const localVarPath = `/api/v1/environments/{environmentName}/storages`
                .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)

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

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

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


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

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

/**
 * StorageApi - functional programming interface
 * @export
 */
export const StorageApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = StorageApiAxiosParamCreator(configuration)
    return {
        /**
         * 
         * @summary Get a storage
         * @param {string} environmentName name of the environment
         * @param {string} storageName name of the storage
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getStorage(environmentName: string, storageName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Storage>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getStorage(environmentName, storageName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['StorageApi.getStorage']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary List storages
         * @param {string} environmentName name of the environment
         * @param {string} [name] the search key to search storage\&#39;s name
         * @param {string} [key] key to search storage\&#39;s tag
         * @param {string} [value] value to search storage\&#39;s tag
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listStorages(environmentName: string, name?: string, key?: string, value?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Storage>>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listStorages(environmentName, name, key, value, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['StorageApi.listStorages']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * StorageApi - factory interface
 * @export
 */
export const StorageApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = StorageApiFp(configuration)
    return {
        /**
         * 
         * @summary Get a storage
         * @param {StorageApiGetStorageRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getStorage(requestParameters: StorageApiGetStorageRequest, options?: RawAxiosRequestConfig): AxiosPromise<Storage> {
            return localVarFp.getStorage(requestParameters.environmentName, requestParameters.storageName, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary List storages
         * @param {StorageApiListStoragesRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listStorages(requestParameters: StorageApiListStoragesRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<Storage>> {
            return localVarFp.listStorages(requestParameters.environmentName, requestParameters.name, requestParameters.key, requestParameters.value, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * StorageApi - interface
 * @export
 * @interface StorageApi
 */
export interface StorageApiInterface {
    /**
     * 
     * @summary Get a storage
     * @param {StorageApiGetStorageRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof StorageApiInterface
     */
    getStorage(requestParameters: StorageApiGetStorageRequest, options?: RawAxiosRequestConfig): AxiosPromise<Storage>;

    /**
     * 
     * @summary List storages
     * @param {StorageApiListStoragesRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof StorageApiInterface
     */
    listStorages(requestParameters: StorageApiListStoragesRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<Storage>>;

}

/**
 * Request parameters for getStorage operation in StorageApi.
 * @export
 * @interface StorageApiGetStorageRequest
 */
export interface StorageApiGetStorageRequest {
    /**
     * name of the environment
     * @type {string}
     * @memberof StorageApiGetStorage
     */
    readonly environmentName: string

    /**
     * name of the storage
     * @type {string}
     * @memberof StorageApiGetStorage
     */
    readonly storageName: string
}

/**
 * Request parameters for listStorages operation in StorageApi.
 * @export
 * @interface StorageApiListStoragesRequest
 */
export interface StorageApiListStoragesRequest {
    /**
     * name of the environment
     * @type {string}
     * @memberof StorageApiListStorages
     */
    readonly environmentName: string

    /**
     * the search key to search storage\&#39;s name
     * @type {string}
     * @memberof StorageApiListStorages
     */
    readonly name?: string

    /**
     * key to search storage\&#39;s tag
     * @type {string}
     * @memberof StorageApiListStorages
     */
    readonly key?: string

    /**
     * value to search storage\&#39;s tag
     * @type {string}
     * @memberof StorageApiListStorages
     */
    readonly value?: string
}

/**
 * StorageApi - object-oriented interface
 * @export
 * @class StorageApi
 * @extends {BaseAPI}
 */
export class StorageApi extends BaseAPI implements StorageApiInterface {
    /**
     * 
     * @summary Get a storage
     * @param {StorageApiGetStorageRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof StorageApi
     */
    public getStorage(requestParameters: StorageApiGetStorageRequest, options?: RawAxiosRequestConfig) {
        return StorageApiFp(this.configuration).getStorage(requestParameters.environmentName, requestParameters.storageName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary List storages
     * @param {StorageApiListStoragesRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof StorageApi
     */
    public listStorages(requestParameters: StorageApiListStoragesRequest, options?: RawAxiosRequestConfig) {
        return StorageApiFp(this.configuration).listStorages(requestParameters.environmentName, requestParameters.name, requestParameters.key, requestParameters.value, options).then((request) => request(this.axios, this.basePath));
    }
}

