/* 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 { Provider } from '../models';
// @ts-ignore
import type { ProviderCreate } from '../models';
// @ts-ignore
import type { ProviderList } from '../models';
// @ts-ignore
import type { ProviderUpdate } from '../models';
/**
 * ProviderApi - axios parameter creator
 * @export
 */
export const ProviderApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Create a cloud provider
         * @summary Create a cloud provider
         * @param {ProviderCreate} providerCreate 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createCloudProvider: async (providerCreate: ProviderCreate, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'providerCreate' is not null or undefined
            assertParamExists('createCloudProvider', 'providerCreate', providerCreate)
            const localVarPath = `/admin/v1/providers`;
            // 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(providerCreate, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Delete a cloud provider
         * @summary Delete a cloud provider
         * @param {string} providerName Name of the cloud provider
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteCloudProvider: async (providerName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'providerName' is not null or undefined
            assertParamExists('deleteCloudProvider', 'providerName', providerName)
            const localVarPath = `/admin/v1/providers/{providerName}`
                .replace(`{${"providerName"}}`, encodeURIComponent(String(providerName)));
            // 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)


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

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Get cloud provider
         * @summary Get cloud provider
         * @param {string} providerName Name of the cloud provider
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getCloudProvider: async (providerName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'providerName' is not null or undefined
            assertParamExists('getCloudProvider', 'providerName', providerName)
            const localVarPath = `/admin/v1/providers/{providerName}`
                .replace(`{${"providerName"}}`, encodeURIComponent(String(providerName)));
            // 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 cloud providers
         * @summary List cloud providers
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listCloudProviders: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/admin/v1/providers`;
            // 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,
            };
        },
        /**
         * Update a cloud provider
         * @summary Update a cloud provider
         * @param {string} providerName Name of the cloud provider
         * @param {ProviderUpdate} providerUpdate 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        updateCloudProvider: async (providerName: string, providerUpdate: ProviderUpdate, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'providerName' is not null or undefined
            assertParamExists('updateCloudProvider', 'providerName', providerName)
            // verify required parameter 'providerUpdate' is not null or undefined
            assertParamExists('updateCloudProvider', 'providerUpdate', providerUpdate)
            const localVarPath = `/admin/v1/providers/{providerName}`
                .replace(`{${"providerName"}}`, encodeURIComponent(String(providerName)));
            // 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(providerUpdate, localVarRequestOptions, configuration)

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

/**
 * ProviderApi - functional programming interface
 * @export
 */
export const ProviderApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = ProviderApiAxiosParamCreator(configuration)
    return {
        /**
         * Create a cloud provider
         * @summary Create a cloud provider
         * @param {ProviderCreate} providerCreate 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createCloudProvider(providerCreate: ProviderCreate, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Provider>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createCloudProvider(providerCreate, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ProviderApi.createCloudProvider']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Delete a cloud provider
         * @summary Delete a cloud provider
         * @param {string} providerName Name of the cloud provider
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async deleteCloudProvider(providerName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.deleteCloudProvider(providerName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ProviderApi.deleteCloudProvider']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Get cloud provider
         * @summary Get cloud provider
         * @param {string} providerName Name of the cloud provider
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getCloudProvider(providerName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Provider>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getCloudProvider(providerName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ProviderApi.getCloudProvider']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * List cloud providers
         * @summary List cloud providers
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listCloudProviders(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ProviderList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listCloudProviders(options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ProviderApi.listCloudProviders']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Update a cloud provider
         * @summary Update a cloud provider
         * @param {string} providerName Name of the cloud provider
         * @param {ProviderUpdate} providerUpdate 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async updateCloudProvider(providerName: string, providerUpdate: ProviderUpdate, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Provider>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.updateCloudProvider(providerName, providerUpdate, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ProviderApi.updateCloudProvider']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * ProviderApi - factory interface
 * @export
 */
export const ProviderApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = ProviderApiFp(configuration)
    return {
        /**
         * Create a cloud provider
         * @summary Create a cloud provider
         * @param {ProviderApiCreateCloudProviderRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createCloudProvider(requestParameters: ProviderApiCreateCloudProviderRequest, options?: RawAxiosRequestConfig): AxiosPromise<Provider> {
            return localVarFp.createCloudProvider(requestParameters.providerCreate, options).then((request) => request(axios, basePath));
        },
        /**
         * Delete a cloud provider
         * @summary Delete a cloud provider
         * @param {ProviderApiDeleteCloudProviderRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteCloudProvider(requestParameters: ProviderApiDeleteCloudProviderRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.deleteCloudProvider(requestParameters.providerName, options).then((request) => request(axios, basePath));
        },
        /**
         * Get cloud provider
         * @summary Get cloud provider
         * @param {ProviderApiGetCloudProviderRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getCloudProvider(requestParameters: ProviderApiGetCloudProviderRequest, options?: RawAxiosRequestConfig): AxiosPromise<Provider> {
            return localVarFp.getCloudProvider(requestParameters.providerName, options).then((request) => request(axios, basePath));
        },
        /**
         * List cloud providers
         * @summary List cloud providers
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listCloudProviders(options?: RawAxiosRequestConfig): AxiosPromise<ProviderList> {
            return localVarFp.listCloudProviders(options).then((request) => request(axios, basePath));
        },
        /**
         * Update a cloud provider
         * @summary Update a cloud provider
         * @param {ProviderApiUpdateCloudProviderRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        updateCloudProvider(requestParameters: ProviderApiUpdateCloudProviderRequest, options?: RawAxiosRequestConfig): AxiosPromise<Provider> {
            return localVarFp.updateCloudProvider(requestParameters.providerName, requestParameters.providerUpdate, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * ProviderApi - interface
 * @export
 * @interface ProviderApi
 */
export interface ProviderApiInterface {
    /**
     * Create a cloud provider
     * @summary Create a cloud provider
     * @param {ProviderApiCreateCloudProviderRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProviderApiInterface
     */
    createCloudProvider(requestParameters: ProviderApiCreateCloudProviderRequest, options?: RawAxiosRequestConfig): AxiosPromise<Provider>;

    /**
     * Delete a cloud provider
     * @summary Delete a cloud provider
     * @param {ProviderApiDeleteCloudProviderRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProviderApiInterface
     */
    deleteCloudProvider(requestParameters: ProviderApiDeleteCloudProviderRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;

    /**
     * Get cloud provider
     * @summary Get cloud provider
     * @param {ProviderApiGetCloudProviderRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProviderApiInterface
     */
    getCloudProvider(requestParameters: ProviderApiGetCloudProviderRequest, options?: RawAxiosRequestConfig): AxiosPromise<Provider>;

    /**
     * List cloud providers
     * @summary List cloud providers
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProviderApiInterface
     */
    listCloudProviders(options?: RawAxiosRequestConfig): AxiosPromise<ProviderList>;

    /**
     * Update a cloud provider
     * @summary Update a cloud provider
     * @param {ProviderApiUpdateCloudProviderRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProviderApiInterface
     */
    updateCloudProvider(requestParameters: ProviderApiUpdateCloudProviderRequest, options?: RawAxiosRequestConfig): AxiosPromise<Provider>;

}

/**
 * Request parameters for createCloudProvider operation in ProviderApi.
 * @export
 * @interface ProviderApiCreateCloudProviderRequest
 */
export interface ProviderApiCreateCloudProviderRequest {
    /**
     * 
     * @type {ProviderCreate}
     * @memberof ProviderApiCreateCloudProvider
     */
    readonly providerCreate: ProviderCreate
}

/**
 * Request parameters for deleteCloudProvider operation in ProviderApi.
 * @export
 * @interface ProviderApiDeleteCloudProviderRequest
 */
export interface ProviderApiDeleteCloudProviderRequest {
    /**
     * Name of the cloud provider
     * @type {string}
     * @memberof ProviderApiDeleteCloudProvider
     */
    readonly providerName: string
}

/**
 * Request parameters for getCloudProvider operation in ProviderApi.
 * @export
 * @interface ProviderApiGetCloudProviderRequest
 */
export interface ProviderApiGetCloudProviderRequest {
    /**
     * Name of the cloud provider
     * @type {string}
     * @memberof ProviderApiGetCloudProvider
     */
    readonly providerName: string
}

/**
 * Request parameters for updateCloudProvider operation in ProviderApi.
 * @export
 * @interface ProviderApiUpdateCloudProviderRequest
 */
export interface ProviderApiUpdateCloudProviderRequest {
    /**
     * Name of the cloud provider
     * @type {string}
     * @memberof ProviderApiUpdateCloudProvider
     */
    readonly providerName: string

    /**
     * 
     * @type {ProviderUpdate}
     * @memberof ProviderApiUpdateCloudProvider
     */
    readonly providerUpdate: ProviderUpdate
}

/**
 * ProviderApi - object-oriented interface
 * @export
 * @class ProviderApi
 * @extends {BaseAPI}
 */
export class ProviderApi extends BaseAPI implements ProviderApiInterface {
    /**
     * Create a cloud provider
     * @summary Create a cloud provider
     * @param {ProviderApiCreateCloudProviderRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProviderApi
     */
    public createCloudProvider(requestParameters: ProviderApiCreateCloudProviderRequest, options?: RawAxiosRequestConfig) {
        return ProviderApiFp(this.configuration).createCloudProvider(requestParameters.providerCreate, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Delete a cloud provider
     * @summary Delete a cloud provider
     * @param {ProviderApiDeleteCloudProviderRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProviderApi
     */
    public deleteCloudProvider(requestParameters: ProviderApiDeleteCloudProviderRequest, options?: RawAxiosRequestConfig) {
        return ProviderApiFp(this.configuration).deleteCloudProvider(requestParameters.providerName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Get cloud provider
     * @summary Get cloud provider
     * @param {ProviderApiGetCloudProviderRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProviderApi
     */
    public getCloudProvider(requestParameters: ProviderApiGetCloudProviderRequest, options?: RawAxiosRequestConfig) {
        return ProviderApiFp(this.configuration).getCloudProvider(requestParameters.providerName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * List cloud providers
     * @summary List cloud providers
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProviderApi
     */
    public listCloudProviders(options?: RawAxiosRequestConfig) {
        return ProviderApiFp(this.configuration).listCloudProviders(options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Update a cloud provider
     * @summary Update a cloud provider
     * @param {ProviderApiUpdateCloudProviderRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProviderApi
     */
    public updateCloudProvider(requestParameters: ProviderApiUpdateCloudProviderRequest, options?: RawAxiosRequestConfig) {
        return ProviderApiFp(this.configuration).updateCloudProvider(requestParameters.providerName, requestParameters.providerUpdate, options).then((request) => request(this.axios, this.basePath));
    }
}

