"use strict";
/* 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.
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatasourceApi = exports.DatasourceApiFactory = exports.DatasourceApiFp = exports.DatasourceApiAxiosParamCreator = void 0;
const axios_1 = __importDefault(require("axios"));
// Some imports not used depending on template conditions
// @ts-ignore
const common_1 = require("../common");
// @ts-ignore
const base_1 = require("../base");
/**
 * DatasourceApi - axios parameter creator
 * @export
 */
const DatasourceApiAxiosParamCreator = function (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, options = {}) => {
            // verify required parameter 'grafanaDatasourceCreate' is not null or undefined
            (0, common_1.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, common_1.DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }
            const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
            const localVarHeaderParameter = {};
            const localVarQueryParameter = {};
            // authentication BasicAuth required
            // http basic authentication required
            (0, common_1.setBasicAuthToObject)(localVarRequestOptions, configuration);
            localVarHeaderParameter['Content-Type'] = 'application/json';
            (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
            localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(grafanaDatasourceCreate, localVarRequestOptions, configuration);
            return {
                url: (0, common_1.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, options = {}) => {
            // verify required parameter 'environmentID' is not null or undefined
            (0, common_1.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, common_1.DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }
            const localVarRequestOptions = Object.assign(Object.assign({ method: 'PATCH' }, baseOptions), options);
            const localVarHeaderParameter = {};
            const localVarQueryParameter = {};
            // authentication BasicAuth required
            // http basic authentication required
            (0, common_1.setBasicAuthToObject)(localVarRequestOptions, configuration);
            (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
            return {
                url: (0, common_1.toPathString)(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
    };
};
exports.DatasourceApiAxiosParamCreator = DatasourceApiAxiosParamCreator;
/**
 * DatasourceApi - functional programming interface
 * @export
 */
const DatasourceApiFp = function (configuration) {
    const localVarAxiosParamCreator = (0, exports.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, options) {
            var _a, _b, _c;
            const localVarAxiosArgs = await localVarAxiosParamCreator.grafanaDataSourceCreate(grafanaDatasourceCreate, options);
            const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
            const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['DatasourceApi.grafanaDataSourceCreate']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
            return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.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, options) {
            var _a, _b, _c;
            const localVarAxiosArgs = await localVarAxiosParamCreator.grafanaDataSourceUpdate(environmentID, options);
            const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
            const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['DatasourceApi.grafanaDataSourceUpdate']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
            return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    };
};
exports.DatasourceApiFp = DatasourceApiFp;
/**
 * DatasourceApi - factory interface
 * @export
 */
const DatasourceApiFactory = function (configuration, basePath, axios) {
    const localVarFp = (0, exports.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, options) {
            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, options) {
            return localVarFp.grafanaDataSourceUpdate(requestParameters.environmentID, options).then((request) => request(axios, basePath));
        },
    };
};
exports.DatasourceApiFactory = DatasourceApiFactory;
/**
 * DatasourceApi - object-oriented interface
 * @export
 * @class DatasourceApi
 * @extends {BaseAPI}
 */
class DatasourceApi extends base_1.BaseAPI {
    /**
     * 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
     */
    grafanaDataSourceCreate(requestParameters, options) {
        return (0, exports.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
     */
    grafanaDataSourceUpdate(requestParameters, options) {
        return (0, exports.DatasourceApiFp)(this.configuration).grafanaDataSourceUpdate(requestParameters.environmentID, options).then((request) => request(this.axios, this.basePath));
    }
}
exports.DatasourceApi = DatasourceApi;
//# sourceMappingURL=datasource-api.js.map