/* 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,
  StreamLocation,
} from '../models/index';
import {
    CdaErrorFromJSON,
    CdaErrorToJSON,
    StreamLocationFromJSON,
    StreamLocationToJSON,
} from '../models/index';

export interface DeleteStreamLocationsWithNameRequest {
    name: string;
    office: string;
    streamId: string;
}

export interface GetStreamLocationsRequest {
    officeMask?: string;
    streamIdMask?: string;
    nameMask?: string;
    stationUnit?: string;
    stageUnit?: string;
    areaUnit?: string;
}

export interface GetStreamLocationsWithNameRequest {
    name: string;
    office: string;
    streamId: string;
    stationUnit?: string;
    stageUnit?: string;
    areaUnit?: string;
}

export interface GetStreamLocationsWithOfficeWithNameDownstreamLocationsRequest {
    office: string;
    name: string;
    allDownstream?: boolean;
    sameStreamOnly?: boolean;
    stationUnit?: string;
    stageUnit?: string;
    areaUnit?: string;
}

export interface GetStreamLocationsWithOfficeWithNameUpstreamLocationsRequest {
    office: string;
    name: string;
    allUpstream?: boolean;
    sameStreamOnly?: boolean;
    stationUnit?: string;
    stageUnit?: string;
    areaUnit?: string;
}

export interface PatchStreamLocationsWithNameRequest {
    name: string;
    streamLocation: StreamLocation;
}

export interface PostStreamLocationsRequest {
    streamLocation: StreamLocation;
    failIfExists?: boolean;
}

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

    /**
     * Delete CWMS Stream Location
     * Delete cwmsData streamLocations with name
     */
    async deleteStreamLocationsWithNameRaw(requestParameters: DeleteStreamLocationsWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['name'] == null) {
            throw new runtime.RequiredError(
                'name',
                'Required parameter "name" was null or undefined when calling deleteStreamLocationsWithName().'
            );
        }

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

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

        const queryParameters: any = {};

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

        if (requestParameters['streamId'] != null) {
            queryParameters['stream-id'] = requestParameters['streamId'];
        }

        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: `/stream-locations/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters['name']))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Delete CWMS Stream Location
     * Delete cwmsData streamLocations with name
     */
    async deleteStreamLocationsWithName(requestParameters: DeleteStreamLocationsWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.deleteStreamLocationsWithNameRaw(requestParameters, initOverrides);
    }

    /**
     * Returns matching CWMS Stream Location Data for a Reservoir Project.
     * Get cwmsData streamLocations
     */
    async getStreamLocationsRaw(requestParameters: GetStreamLocationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<StreamLocation>>> {
        const queryParameters: any = {};

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

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

        if (requestParameters['nameMask'] != null) {
            queryParameters['name-mask'] = requestParameters['nameMask'];
        }

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

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

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

        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: `/stream-locations`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Returns matching CWMS Stream Location Data for a Reservoir Project.
     * Get cwmsData streamLocations
     */
    async getStreamLocations(requestParameters: GetStreamLocationsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<StreamLocation>> {
        const response = await this.getStreamLocationsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Returns CWMS Stream Location Data
     * Get cwmsData streamLocations with name
     */
    async getStreamLocationsWithNameRaw(requestParameters: GetStreamLocationsWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<StreamLocation>>> {
        if (requestParameters['name'] == null) {
            throw new runtime.RequiredError(
                'name',
                'Required parameter "name" was null or undefined when calling getStreamLocationsWithName().'
            );
        }

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

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

        const queryParameters: any = {};

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

        if (requestParameters['streamId'] != null) {
            queryParameters['stream-id'] = requestParameters['streamId'];
        }

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

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

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

        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: `/stream-locations/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters['name']))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Returns CWMS Stream Location Data
     * Get cwmsData streamLocations with name
     */
    async getStreamLocationsWithName(requestParameters: GetStreamLocationsWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<StreamLocation>> {
        const response = await this.getStreamLocationsWithNameRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Returns matching downstream stream locations.
     * Get cwmsData streamLocations with office with name downstreamLocations
     */
    async getStreamLocationsWithOfficeWithNameDownstreamLocationsRaw(requestParameters: GetStreamLocationsWithOfficeWithNameDownstreamLocationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<StreamLocation>>> {
        if (requestParameters['office'] == null) {
            throw new runtime.RequiredError(
                'office',
                'Required parameter "office" was null or undefined when calling getStreamLocationsWithOfficeWithNameDownstreamLocations().'
            );
        }

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

        const queryParameters: any = {};

        if (requestParameters['allDownstream'] != null) {
            queryParameters['all-downstream'] = requestParameters['allDownstream'];
        }

        if (requestParameters['sameStreamOnly'] != null) {
            queryParameters['same-stream-only'] = requestParameters['sameStreamOnly'];
        }

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

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

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

        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: `/stream-locations/{office}/{name}/downstream-locations`.replace(`{${"office"}}`, encodeURIComponent(String(requestParameters['office']))).replace(`{${"name"}}`, encodeURIComponent(String(requestParameters['name']))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Returns matching downstream stream locations.
     * Get cwmsData streamLocations with office with name downstreamLocations
     */
    async getStreamLocationsWithOfficeWithNameDownstreamLocations(requestParameters: GetStreamLocationsWithOfficeWithNameDownstreamLocationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<StreamLocation>> {
        const response = await this.getStreamLocationsWithOfficeWithNameDownstreamLocationsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Returns matching upstream stream locations.
     * Get cwmsData streamLocations with office with name upstreamLocations
     */
    async getStreamLocationsWithOfficeWithNameUpstreamLocationsRaw(requestParameters: GetStreamLocationsWithOfficeWithNameUpstreamLocationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<StreamLocation>>> {
        if (requestParameters['office'] == null) {
            throw new runtime.RequiredError(
                'office',
                'Required parameter "office" was null or undefined when calling getStreamLocationsWithOfficeWithNameUpstreamLocations().'
            );
        }

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

        const queryParameters: any = {};

        if (requestParameters['allUpstream'] != null) {
            queryParameters['all-upstream'] = requestParameters['allUpstream'];
        }

        if (requestParameters['sameStreamOnly'] != null) {
            queryParameters['same-stream-only'] = requestParameters['sameStreamOnly'];
        }

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

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

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

        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: `/stream-locations/{office}/{name}/upstream-locations`.replace(`{${"office"}}`, encodeURIComponent(String(requestParameters['office']))).replace(`{${"name"}}`, encodeURIComponent(String(requestParameters['name']))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Returns matching upstream stream locations.
     * Get cwmsData streamLocations with office with name upstreamLocations
     */
    async getStreamLocationsWithOfficeWithNameUpstreamLocations(requestParameters: GetStreamLocationsWithOfficeWithNameUpstreamLocationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<StreamLocation>> {
        const response = await this.getStreamLocationsWithOfficeWithNameUpstreamLocationsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Update CWMS Stream Location
     * Patch cwmsData streamLocations with name
     */
    async patchStreamLocationsWithNameRaw(requestParameters: PatchStreamLocationsWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['name'] == null) {
            throw new runtime.RequiredError(
                'name',
                'Required parameter "name" was null or undefined when calling patchStreamLocationsWithName().'
            );
        }

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

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

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

        const response = await this.request({
            path: `/stream-locations/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters['name']))),
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: StreamLocationToJSON(requestParameters['streamLocation']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Update CWMS Stream Location
     * Patch cwmsData streamLocations with name
     */
    async patchStreamLocationsWithName(requestParameters: PatchStreamLocationsWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.patchStreamLocationsWithNameRaw(requestParameters, initOverrides);
    }

    /**
     * Create CWMS Stream Location
     * Post cwmsData streamLocations
     */
    async postStreamLocationsRaw(requestParameters: PostStreamLocationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['streamLocation'] == null) {
            throw new runtime.RequiredError(
                'streamLocation',
                'Required parameter "streamLocation" was null or undefined when calling postStreamLocations().'
            );
        }

        const queryParameters: any = {};

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

        const response = await this.request({
            path: `/stream-locations`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: StreamLocationToJSON(requestParameters['streamLocation']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Create CWMS Stream Location
     * Post cwmsData streamLocations
     */
    async postStreamLocations(requestParameters: PostStreamLocationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.postStreamLocationsRaw(requestParameters, initOverrides);
    }

}
