/* tslint:disable */
/* eslint-disable */
/**
 * Montelo
 * Documentation for the Montelo API.
 *
 * The version of the OpenAPI document: 1.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 * as runtime from '../runtime';
import type {
  ExperimentAnalyticsDto,
  ExperimentDto,
  PaginatedExperimentWithDatapointRunsDto,
  PaginatedExperimentsDto,
} from '../models/index';
import {
    ExperimentAnalyticsDtoFromJSON,
    ExperimentAnalyticsDtoToJSON,
    ExperimentDtoFromJSON,
    ExperimentDtoToJSON,
    PaginatedExperimentWithDatapointRunsDtoFromJSON,
    PaginatedExperimentWithDatapointRunsDtoToJSON,
    PaginatedExperimentsDtoFromJSON,
    PaginatedExperimentsDtoToJSON,
} from '../models/index';

export interface ExperimentControllerGetAnalyticsForExperimentRequest {
    experimentId: string;
}

export interface ExperimentControllerGetExperimentsForDatasetRequest {
    datasetId: string;
}

export interface ExperimentControllerGetPaginatedExperimentWithDatapointRunsRequest {
    experimentId: string;
    take?: string;
    skip?: string;
}

export interface ExperimentControllerGetPaginatedExperimentsForEnvironmentRequest {
    envId: string;
    take?: string;
    skip?: string;
}

/**
 * 
 */
export class ExperimentApi extends runtime.BaseAPI {

    /**
     */
    async experimentControllerGetAnalyticsForExperimentRaw(requestParameters: ExperimentControllerGetAnalyticsForExperimentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ExperimentAnalyticsDto>> {
        if (requestParameters.experimentId === null || requestParameters.experimentId === undefined) {
            throw new runtime.RequiredError('experimentId','Required parameter requestParameters.experimentId was null or undefined when calling experimentControllerGetAnalyticsForExperiment.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/experiment/{experimentId}/analytics`.replace(`{${"experimentId"}}`, encodeURIComponent(String(requestParameters.experimentId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => ExperimentAnalyticsDtoFromJSON(jsonValue));
    }

    /**
     */
    async experimentControllerGetAnalyticsForExperiment(requestParameters: ExperimentControllerGetAnalyticsForExperimentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ExperimentAnalyticsDto> {
        const response = await this.experimentControllerGetAnalyticsForExperimentRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async experimentControllerGetExperimentsForDatasetRaw(requestParameters: ExperimentControllerGetExperimentsForDatasetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ExperimentDto>>> {
        if (requestParameters.datasetId === null || requestParameters.datasetId === undefined) {
            throw new runtime.RequiredError('datasetId','Required parameter requestParameters.datasetId was null or undefined when calling experimentControllerGetExperimentsForDataset.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/dataset/{datasetId}/experiment`.replace(`{${"datasetId"}}`, encodeURIComponent(String(requestParameters.datasetId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(ExperimentDtoFromJSON));
    }

    /**
     */
    async experimentControllerGetExperimentsForDataset(requestParameters: ExperimentControllerGetExperimentsForDatasetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ExperimentDto>> {
        const response = await this.experimentControllerGetExperimentsForDatasetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async experimentControllerGetPaginatedExperimentWithDatapointRunsRaw(requestParameters: ExperimentControllerGetPaginatedExperimentWithDatapointRunsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<PaginatedExperimentWithDatapointRunsDto>> {
        if (requestParameters.experimentId === null || requestParameters.experimentId === undefined) {
            throw new runtime.RequiredError('experimentId','Required parameter requestParameters.experimentId was null or undefined when calling experimentControllerGetPaginatedExperimentWithDatapointRuns.');
        }

        const queryParameters: any = {};

        if (requestParameters.take !== undefined) {
            queryParameters['take'] = requestParameters.take;
        }

        if (requestParameters.skip !== undefined) {
            queryParameters['skip'] = requestParameters.skip;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/experiment/{experimentId}`.replace(`{${"experimentId"}}`, encodeURIComponent(String(requestParameters.experimentId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => PaginatedExperimentWithDatapointRunsDtoFromJSON(jsonValue));
    }

    /**
     */
    async experimentControllerGetPaginatedExperimentWithDatapointRuns(requestParameters: ExperimentControllerGetPaginatedExperimentWithDatapointRunsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<PaginatedExperimentWithDatapointRunsDto> {
        const response = await this.experimentControllerGetPaginatedExperimentWithDatapointRunsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async experimentControllerGetPaginatedExperimentsForEnvironmentRaw(requestParameters: ExperimentControllerGetPaginatedExperimentsForEnvironmentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<PaginatedExperimentsDto>> {
        if (requestParameters.envId === null || requestParameters.envId === undefined) {
            throw new runtime.RequiredError('envId','Required parameter requestParameters.envId was null or undefined when calling experimentControllerGetPaginatedExperimentsForEnvironment.');
        }

        const queryParameters: any = {};

        if (requestParameters.take !== undefined) {
            queryParameters['take'] = requestParameters.take;
        }

        if (requestParameters.skip !== undefined) {
            queryParameters['skip'] = requestParameters.skip;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/env/{envId}/experiment`.replace(`{${"envId"}}`, encodeURIComponent(String(requestParameters.envId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => PaginatedExperimentsDtoFromJSON(jsonValue));
    }

    /**
     */
    async experimentControllerGetPaginatedExperimentsForEnvironment(requestParameters: ExperimentControllerGetPaginatedExperimentsForEnvironmentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<PaginatedExperimentsDto> {
        const response = await this.experimentControllerGetPaginatedExperimentsForEnvironmentRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
