/* tslint:disable */
/* eslint-disable */
/**
 * CWMS Data API
 * CWMS REST API for Data Retrieval
 *
 * The version of the OpenAPI document: 2.3.2-2025.03.19
 * 
 *
 * 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 {
  CdaError,
  LocationLevel,
  LocationLevels,
  SpecifiedLevel,
  TimeSeries,
} from '../models/index';
import {
    CdaErrorFromJSON,
    CdaErrorToJSON,
    LocationLevelFromJSON,
    LocationLevelToJSON,
    LocationLevelsFromJSON,
    LocationLevelsToJSON,
    SpecifiedLevelFromJSON,
    SpecifiedLevelToJSON,
    TimeSeriesFromJSON,
    TimeSeriesToJSON,
} from '../models/index';

export interface DeleteLevelsWithLevelIdRequest {
    levelId: string;
    cascadeDelete?: boolean;
    office?: string;
    effectiveDate?: string;
    timezone?: string;
}

export interface DeleteSpecifiedLevelsWithSpecifiedLevelIdRequest {
    specifiedLevelId: string;
    office: string;
}

export interface GetLevelsRequest {
    levelIdMask?: string;
    office?: string;
    unit?: string;
    datum?: string;
    begin?: string;
    end?: string;
    timezone?: string;
    format?: string;
    page?: string;
    pageSize?: number;
}

export interface GetLevelsWithLevelIdRequest {
    levelId: string;
    office: string;
    effectiveDate: string;
    timezone?: string;
    unit?: string;
}

export interface GetLevelsWithLevelIdTimeSeriesRequest {
    levelId: string;
    office: string;
    unit: string;
    interval?: string;
    begin?: string;
    end?: string;
    timezone?: string;
}

export interface GetSpecifiedLevelsRequest {
    office?: string;
    templateIdMask?: string;
}

export interface PatchLevelsWithLevelIdRequest {
    levelId: string;
    locationLevel: LocationLevel;
    effectiveDate?: string;
}

export interface PatchSpecifiedLevelsWithSpecifiedLevelIdRequest {
    specifiedLevelId: string;
    specifiedLevelId2: string;
    office: string;
}

export interface PostLevelsRequest {
    locationLevel: LocationLevel;
}

export interface PostSpecifiedLevelsRequest {
    specifiedLevel: SpecifiedLevel;
    failIfExists?: boolean;
}

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

    /**
     * Delete CWMS Location Level
     * Delete cwmsData levels with levelId
     */
    async deleteLevelsWithLevelIdRaw(requestParameters: DeleteLevelsWithLevelIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['levelId'] == null) {
            throw new runtime.RequiredError(
                'levelId',
                'Required parameter "levelId" was null or undefined when calling deleteLevelsWithLevelId().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['cascadeDelete'] != null) {
            queryParameters['cascade-delete'] = requestParameters['cascadeDelete'];
        }

        if (requestParameters['office'] != null) {
            queryParameters['office'] = requestParameters['office'];
        }

        if (requestParameters['effectiveDate'] != null) {
            queryParameters['effective-date'] = requestParameters['effectiveDate'];
        }

        if (requestParameters['timezone'] != null) {
            queryParameters['timezone'] = requestParameters['timezone'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/levels/{level-id}`.replace(`{${"level-id"}}`, encodeURIComponent(String(requestParameters['levelId']))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Delete CWMS Location Level
     * Delete cwmsData levels with levelId
     */
    async deleteLevelsWithLevelId(requestParameters: DeleteLevelsWithLevelIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.deleteLevelsWithLevelIdRaw(requestParameters, initOverrides);
    }

    /**
     * Deletes requested specified level id
     * Delete cwmsData specifiedLevels with specifiedLevelId
     */
    async deleteSpecifiedLevelsWithSpecifiedLevelIdRaw(requestParameters: DeleteSpecifiedLevelsWithSpecifiedLevelIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['specifiedLevelId'] == null) {
            throw new runtime.RequiredError(
                'specifiedLevelId',
                'Required parameter "specifiedLevelId" was null or undefined when calling deleteSpecifiedLevelsWithSpecifiedLevelId().'
            );
        }

        if (requestParameters['office'] == null) {
            throw new runtime.RequiredError(
                'office',
                'Required parameter "office" was null or undefined when calling deleteSpecifiedLevelsWithSpecifiedLevelId().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['office'] != null) {
            queryParameters['office'] = requestParameters['office'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/specified-levels/{specified-level-id}`.replace(`{${"specified-level-id"}}`, encodeURIComponent(String(requestParameters['specifiedLevelId']))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Deletes requested specified level id
     * Delete cwmsData specifiedLevels with specifiedLevelId
     */
    async deleteSpecifiedLevelsWithSpecifiedLevelId(requestParameters: DeleteSpecifiedLevelsWithSpecifiedLevelIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.deleteSpecifiedLevelsWithSpecifiedLevelIdRaw(requestParameters, initOverrides);
    }

    /**
     * Get cwmsData levels
     */
    async getLevelsRaw(requestParameters: GetLevelsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<object>> {
        const queryParameters: any = {};

        if (requestParameters['levelIdMask'] != null) {
            queryParameters['level-id-mask'] = requestParameters['levelIdMask'];
        }

        if (requestParameters['office'] != null) {
            queryParameters['office'] = requestParameters['office'];
        }

        if (requestParameters['unit'] != null) {
            queryParameters['unit'] = requestParameters['unit'];
        }

        if (requestParameters['datum'] != null) {
            queryParameters['datum'] = requestParameters['datum'];
        }

        if (requestParameters['begin'] != null) {
            queryParameters['begin'] = requestParameters['begin'];
        }

        if (requestParameters['end'] != null) {
            queryParameters['end'] = requestParameters['end'];
        }

        if (requestParameters['timezone'] != null) {
            queryParameters['timezone'] = requestParameters['timezone'];
        }

        if (requestParameters['format'] != null) {
            queryParameters['format'] = requestParameters['format'];
        }

        if (requestParameters['page'] != null) {
            queryParameters['page'] = requestParameters['page'];
        }

        if (requestParameters['pageSize'] != null) {
            queryParameters['page-size'] = requestParameters['pageSize'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/levels`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse<any>(response);
    }

    /**
     * Get cwmsData levels
     */
    async getLevels(requestParameters: GetLevelsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<object> {
        const response = await this.getLevelsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Retrieves requested Location Level
     * Get cwmsData levels with levelId
     */
    async getLevelsWithLevelIdRaw(requestParameters: GetLevelsWithLevelIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LocationLevel>> {
        if (requestParameters['levelId'] == null) {
            throw new runtime.RequiredError(
                'levelId',
                'Required parameter "levelId" was null or undefined when calling getLevelsWithLevelId().'
            );
        }

        if (requestParameters['office'] == null) {
            throw new runtime.RequiredError(
                'office',
                'Required parameter "office" was null or undefined when calling getLevelsWithLevelId().'
            );
        }

        if (requestParameters['effectiveDate'] == null) {
            throw new runtime.RequiredError(
                'effectiveDate',
                'Required parameter "effectiveDate" was null or undefined when calling getLevelsWithLevelId().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['office'] != null) {
            queryParameters['office'] = requestParameters['office'];
        }

        if (requestParameters['effectiveDate'] != null) {
            queryParameters['effective-date'] = requestParameters['effectiveDate'];
        }

        if (requestParameters['timezone'] != null) {
            queryParameters['timezone'] = requestParameters['timezone'];
        }

        if (requestParameters['unit'] != null) {
            queryParameters['unit'] = requestParameters['unit'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/levels/{level-id}`.replace(`{${"level-id"}}`, encodeURIComponent(String(requestParameters['levelId']))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Retrieves requested Location Level
     * Get cwmsData levels with levelId
     */
    async getLevelsWithLevelId(requestParameters: GetLevelsWithLevelIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LocationLevel> {
        const response = await this.getLevelsWithLevelIdRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Retrieves requested Location Level
     * Get cwmsData levels with levelId timeseries
     */
    async getLevelsWithLevelIdTimeSeriesRaw(requestParameters: GetLevelsWithLevelIdTimeSeriesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<TimeSeries>> {
        if (requestParameters['levelId'] == null) {
            throw new runtime.RequiredError(
                'levelId',
                'Required parameter "levelId" was null or undefined when calling getLevelsWithLevelIdTimeSeries().'
            );
        }

        if (requestParameters['office'] == null) {
            throw new runtime.RequiredError(
                'office',
                'Required parameter "office" was null or undefined when calling getLevelsWithLevelIdTimeSeries().'
            );
        }

        if (requestParameters['unit'] == null) {
            throw new runtime.RequiredError(
                'unit',
                'Required parameter "unit" was null or undefined when calling getLevelsWithLevelIdTimeSeries().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['office'] != null) {
            queryParameters['office'] = requestParameters['office'];
        }

        if (requestParameters['interval'] != null) {
            queryParameters['interval'] = requestParameters['interval'];
        }

        if (requestParameters['begin'] != null) {
            queryParameters['begin'] = requestParameters['begin'];
        }

        if (requestParameters['end'] != null) {
            queryParameters['end'] = requestParameters['end'];
        }

        if (requestParameters['timezone'] != null) {
            queryParameters['timezone'] = requestParameters['timezone'];
        }

        if (requestParameters['unit'] != null) {
            queryParameters['unit'] = requestParameters['unit'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/levels/{level-id}/timeseries`.replace(`{${"level-id"}}`, encodeURIComponent(String(requestParameters['levelId']))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Retrieves requested Location Level
     * Get cwmsData levels with levelId timeseries
     */
    async getLevelsWithLevelIdTimeSeries(requestParameters: GetLevelsWithLevelIdTimeSeriesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TimeSeries> {
        const response = await this.getLevelsWithLevelIdTimeSeriesRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Get cwmsData specifiedLevels
     */
    async getSpecifiedLevelsRaw(requestParameters: GetSpecifiedLevelsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SpecifiedLevel>> {
        const queryParameters: any = {};

        if (requestParameters['office'] != null) {
            queryParameters['office'] = requestParameters['office'];
        }

        if (requestParameters['templateIdMask'] != null) {
            queryParameters['template-id-mask'] = requestParameters['templateIdMask'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/specified-levels`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Get cwmsData specifiedLevels
     */
    async getSpecifiedLevels(requestParameters: GetSpecifiedLevelsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SpecifiedLevel> {
        const response = await this.getSpecifiedLevelsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Update CWMS Location Level
     * Patch cwmsData levels with levelId
     */
    async patchLevelsWithLevelIdRaw(requestParameters: PatchLevelsWithLevelIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['levelId'] == null) {
            throw new runtime.RequiredError(
                'levelId',
                'Required parameter "levelId" was null or undefined when calling patchLevelsWithLevelId().'
            );
        }

        if (requestParameters['locationLevel'] == null) {
            throw new runtime.RequiredError(
                'locationLevel',
                'Required parameter "locationLevel" was null or undefined when calling patchLevelsWithLevelId().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['effectiveDate'] != null) {
            queryParameters['effective-date'] = requestParameters['effectiveDate'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/levels/{level-id}`.replace(`{${"level-id"}}`, encodeURIComponent(String(requestParameters['levelId']))),
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: LocationLevelToJSON(requestParameters['locationLevel']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Update CWMS Location Level
     * Patch cwmsData levels with levelId
     */
    async patchLevelsWithLevelId(requestParameters: PatchLevelsWithLevelIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.patchLevelsWithLevelIdRaw(requestParameters, initOverrides);
    }

    /**
     * Renames the requested specified level id
     * Patch cwmsData specifiedLevels with specifiedLevelId
     */
    async patchSpecifiedLevelsWithSpecifiedLevelIdRaw(requestParameters: PatchSpecifiedLevelsWithSpecifiedLevelIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['specifiedLevelId'] == null) {
            throw new runtime.RequiredError(
                'specifiedLevelId',
                'Required parameter "specifiedLevelId" was null or undefined when calling patchSpecifiedLevelsWithSpecifiedLevelId().'
            );
        }

        if (requestParameters['specifiedLevelId2'] == null) {
            throw new runtime.RequiredError(
                'specifiedLevelId2',
                'Required parameter "specifiedLevelId2" was null or undefined when calling patchSpecifiedLevelsWithSpecifiedLevelId().'
            );
        }

        if (requestParameters['office'] == null) {
            throw new runtime.RequiredError(
                'office',
                'Required parameter "office" was null or undefined when calling patchSpecifiedLevelsWithSpecifiedLevelId().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['specifiedLevelId2'] != null) {
            queryParameters['specified-level-id'] = requestParameters['specifiedLevelId2'];
        }

        if (requestParameters['office'] != null) {
            queryParameters['office'] = requestParameters['office'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/specified-levels/{specified-level-id}`.replace(`{${"specified-level-id"}}`, encodeURIComponent(String(requestParameters['specifiedLevelId']))),
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Renames the requested specified level id
     * Patch cwmsData specifiedLevels with specifiedLevelId
     */
    async patchSpecifiedLevelsWithSpecifiedLevelId(requestParameters: PatchSpecifiedLevelsWithSpecifiedLevelIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.patchSpecifiedLevelsWithSpecifiedLevelIdRaw(requestParameters, initOverrides);
    }

    /**
     * Create new CWMS Location Level
     * Post cwmsData levels
     */
    async postLevelsRaw(requestParameters: PostLevelsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['locationLevel'] == null) {
            throw new runtime.RequiredError(
                'locationLevel',
                'Required parameter "locationLevel" was null or undefined when calling postLevels().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/levels`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: LocationLevelToJSON(requestParameters['locationLevel']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Create new CWMS Location Level
     * Post cwmsData levels
     */
    async postLevels(requestParameters: PostLevelsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.postLevelsRaw(requestParameters, initOverrides);
    }

    /**
     * Create new SpecifiedLevel
     * Post cwmsData specifiedLevels
     */
    async postSpecifiedLevelsRaw(requestParameters: PostSpecifiedLevelsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['specifiedLevel'] == null) {
            throw new runtime.RequiredError(
                'specifiedLevel',
                'Required parameter "specifiedLevel" was null or undefined when calling postSpecifiedLevels().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['failIfExists'] != null) {
            queryParameters['fail-if-exists'] = requestParameters['failIfExists'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json;version=2';

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/specified-levels`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: SpecifiedLevelToJSON(requestParameters['specifiedLevel']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Create new SpecifiedLevel
     * Post cwmsData specifiedLevels
     */
    async postSpecifiedLevels(requestParameters: PostSpecifiedLevelsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.postSpecifiedLevelsRaw(requestParameters, initOverrides);
    }

}
