/* tslint:disable */
/* eslint-disable */
/**
 * KubeBlocks Cloud Internal API
 * The Internal API is using for interaction of ApeCloud platform microservices. 
 *
 * The version of the OpenAPI document: 1.0.0
 * 
 *
 * 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 { GrafanaDatasource } from '../models';
// @ts-ignore
import type { GrafanaDatasourceCreate } from '../models';
/**
 * DatasourceApi - axios parameter creator
 * @export
 */
export const DatasourceApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Create a new datasource configuration for Grafana
         * @summary Create a new Grafana datasource
         * @param {GrafanaDatasourceCreate} grafanaDatasourceCreate 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        grafanaDataSourceCreate: async (grafanaDatasourceCreate: GrafanaDatasourceCreate, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'grafanaDatasourceCreate' is not null or undefined
            assertParamExists('grafanaDataSourceCreate', 'grafanaDatasourceCreate', grafanaDatasourceCreate)
            const localVarPath = `/internal/v1/datasources`;
            // 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 BasicAuth required
            // http basic authentication required
            setBasicAuthToObject(localVarRequestOptions, 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(grafanaDatasourceCreate, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Update a new datasource configuration for Grafana
         * @summary Update a new Grafana datasource
         * @param {string} environmentID id of the Environment
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        grafanaDataSourceUpdate: async (environmentID: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentID' is not null or undefined
            assertParamExists('grafanaDataSourceUpdate', 'environmentID', environmentID)
            const localVarPath = `/internal/v1/datasource/environments/{environmentID}`
                .replace(`{${"environmentID"}}`, encodeURIComponent(String(environmentID)));
            // 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 BasicAuth required
            // http basic authentication required
            setBasicAuthToObject(localVarRequestOptions, configuration)


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

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

/**
 * DatasourceApi - functional programming interface
 * @export
 */
export const DatasourceApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = DatasourceApiAxiosParamCreator(configuration)
    return {
        /**
         * Create a new datasource configuration for Grafana
         * @summary Create a new Grafana datasource
         * @param {GrafanaDatasourceCreate} grafanaDatasourceCreate 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async grafanaDataSourceCreate(grafanaDatasourceCreate: GrafanaDatasourceCreate, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GrafanaDatasource>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.grafanaDataSourceCreate(grafanaDatasourceCreate, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['DatasourceApi.grafanaDataSourceCreate']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Update a new datasource configuration for Grafana
         * @summary Update a new Grafana datasource
         * @param {string} environmentID id of the Environment
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async grafanaDataSourceUpdate(environmentID: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GrafanaDatasource>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.grafanaDataSourceUpdate(environmentID, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['DatasourceApi.grafanaDataSourceUpdate']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * DatasourceApi - factory interface
 * @export
 */
export const DatasourceApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = DatasourceApiFp(configuration)
    return {
        /**
         * Create a new datasource configuration for Grafana
         * @summary Create a new Grafana datasource
         * @param {DatasourceApiGrafanaDataSourceCreateRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        grafanaDataSourceCreate(requestParameters: DatasourceApiGrafanaDataSourceCreateRequest, options?: RawAxiosRequestConfig): AxiosPromise<GrafanaDatasource> {
            return localVarFp.grafanaDataSourceCreate(requestParameters.grafanaDatasourceCreate, options).then((request) => request(axios, basePath));
        },
        /**
         * Update a new datasource configuration for Grafana
         * @summary Update a new Grafana datasource
         * @param {DatasourceApiGrafanaDataSourceUpdateRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        grafanaDataSourceUpdate(requestParameters: DatasourceApiGrafanaDataSourceUpdateRequest, options?: RawAxiosRequestConfig): AxiosPromise<GrafanaDatasource> {
            return localVarFp.grafanaDataSourceUpdate(requestParameters.environmentID, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * DatasourceApi - interface
 * @export
 * @interface DatasourceApi
 */
export interface DatasourceApiInterface {
    /**
     * Create a new datasource configuration for Grafana
     * @summary Create a new Grafana datasource
     * @param {DatasourceApiGrafanaDataSourceCreateRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DatasourceApiInterface
     */
    grafanaDataSourceCreate(requestParameters: DatasourceApiGrafanaDataSourceCreateRequest, options?: RawAxiosRequestConfig): AxiosPromise<GrafanaDatasource>;

    /**
     * Update a new datasource configuration for Grafana
     * @summary Update a new Grafana datasource
     * @param {DatasourceApiGrafanaDataSourceUpdateRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DatasourceApiInterface
     */
    grafanaDataSourceUpdate(requestParameters: DatasourceApiGrafanaDataSourceUpdateRequest, options?: RawAxiosRequestConfig): AxiosPromise<GrafanaDatasource>;

}

/**
 * Request parameters for grafanaDataSourceCreate operation in DatasourceApi.
 * @export
 * @interface DatasourceApiGrafanaDataSourceCreateRequest
 */
export interface DatasourceApiGrafanaDataSourceCreateRequest {
    /**
     * 
     * @type {GrafanaDatasourceCreate}
     * @memberof DatasourceApiGrafanaDataSourceCreate
     */
    readonly grafanaDatasourceCreate: GrafanaDatasourceCreate
}

/**
 * Request parameters for grafanaDataSourceUpdate operation in DatasourceApi.
 * @export
 * @interface DatasourceApiGrafanaDataSourceUpdateRequest
 */
export interface DatasourceApiGrafanaDataSourceUpdateRequest {
    /**
     * id of the Environment
     * @type {string}
     * @memberof DatasourceApiGrafanaDataSourceUpdate
     */
    readonly environmentID: string
}

/**
 * DatasourceApi - object-oriented interface
 * @export
 * @class DatasourceApi
 * @extends {BaseAPI}
 */
export class DatasourceApi extends BaseAPI implements DatasourceApiInterface {
    /**
     * Create a new datasource configuration for Grafana
     * @summary Create a new Grafana datasource
     * @param {DatasourceApiGrafanaDataSourceCreateRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DatasourceApi
     */
    public grafanaDataSourceCreate(requestParameters: DatasourceApiGrafanaDataSourceCreateRequest, options?: RawAxiosRequestConfig) {
        return DatasourceApiFp(this.configuration).grafanaDataSourceCreate(requestParameters.grafanaDatasourceCreate, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Update a new datasource configuration for Grafana
     * @summary Update a new Grafana datasource
     * @param {DatasourceApiGrafanaDataSourceUpdateRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DatasourceApi
     */
    public grafanaDataSourceUpdate(requestParameters: DatasourceApiGrafanaDataSourceUpdateRequest, options?: RawAxiosRequestConfig) {
        return DatasourceApiFp(this.configuration).grafanaDataSourceUpdate(requestParameters.environmentID, options).then((request) => request(this.axios, this.basePath));
    }
}

