/* 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,
  DeleteMethod,
  ForecastInstance,
  ForecastSpec,
} from '../models/index';
import {
    CdaErrorFromJSON,
    CdaErrorToJSON,
    DeleteMethodFromJSON,
    DeleteMethodToJSON,
    ForecastInstanceFromJSON,
    ForecastInstanceToJSON,
    ForecastSpecFromJSON,
    ForecastSpecToJSON,
} from '../models/index';

export interface DeleteForecastInstanceWithNameRequest {
    name: string;
    forecastDate: string;
    issueDate: string;
    office: string;
    designator: string;
}

export interface DeleteForecastSpecWithNameRequest {
    name: string;
    office: string;
    designator: string;
    method?: DeleteMethod;
}

export interface GetForecastInstanceRequest {
    office?: string;
    name?: string;
    designator?: string;
}

export interface GetForecastInstanceWithNameRequest {
    name: string;
    forecastDate: string;
    issueDate: string;
    office: string;
    designator: string;
}

export interface GetForecastInstanceWithNameFileDataRequest {
    name: string;
    forecastDate: string;
    issueDate: string;
    office: string;
    designator: string;
}

export interface GetForecastSpecRequest {
    office?: string;
    idMask?: string;
    designatorMask?: string;
    sourceEntity?: string;
}

export interface GetForecastSpecWithNameRequest {
    name: string;
    office: string;
    designator: string;
}

export interface PatchForecastInstanceWithNameRequest {
    name: string;
    forecastInstance: ForecastInstance;
}

export interface PatchForecastSpecWithNameRequest {
    name: string;
    forecastSpec: ForecastSpec;
}

export interface PostForecastInstanceRequest {
    forecastInstance: ForecastInstance;
}

export interface PostForecastSpecRequest {
    forecastSpec: ForecastSpec;
}

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

    /**
     * Used to delete forecast instance data based on unique fields
     * Delete cwmsData forecastInstance with name
     */
    async deleteForecastInstanceWithNameRaw(requestParameters: DeleteForecastInstanceWithNameRequest, 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 deleteForecastInstanceWithName().'
            );
        }

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

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

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

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

        const queryParameters: any = {};

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

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

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

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

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Used to delete forecast instance data based on unique fields
     * Delete cwmsData forecastInstance with name
     */
    async deleteForecastInstanceWithName(requestParameters: DeleteForecastInstanceWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.deleteForecastInstanceWithNameRaw(requestParameters, initOverrides);
    }

    /**
     * Used to delete forecast spec data based on unique fields
     * Delete cwmsData forecastSpec with name
     */
    async deleteForecastSpecWithNameRaw(requestParameters: DeleteForecastSpecWithNameRequest, 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 deleteForecastSpecWithName().'
            );
        }

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

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

        const queryParameters: any = {};

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

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

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

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Used to delete forecast spec data based on unique fields
     * Delete cwmsData forecastSpec with name
     */
    async deleteForecastSpecWithName(requestParameters: DeleteForecastSpecWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.deleteForecastSpecWithNameRaw(requestParameters, initOverrides);
    }

    /**
     * Used to get all forecast instances for a given forecast spec
     * Get cwmsData forecastInstance
     */
    async getForecastInstanceRaw(requestParameters: GetForecastInstanceRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ForecastInstance>> {
        const queryParameters: any = {};

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

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

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

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

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

    /**
     * Used to get all forecast instances for a given forecast spec
     * Get cwmsData forecastInstance
     */
    async getForecastInstance(requestParameters: GetForecastInstanceRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ForecastInstance> {
        const response = await this.getForecastInstanceRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Used to get all forecast instances for a given forecast spec
     * Get cwmsData forecastInstance with name
     */
    async getForecastInstanceWithNameRaw(requestParameters: GetForecastInstanceWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ForecastInstance>> {
        if (requestParameters['name'] == null) {
            throw new runtime.RequiredError(
                'name',
                'Required parameter "name" was null or undefined when calling getForecastInstanceWithName().'
            );
        }

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

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

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

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

        const queryParameters: any = {};

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

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

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

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

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

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

    /**
     * Used to get all forecast instances for a given forecast spec
     * Get cwmsData forecastInstance with name
     */
    async getForecastInstanceWithName(requestParameters: GetForecastInstanceWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ForecastInstance> {
        const response = await this.getForecastInstanceWithNameRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Used to download forecast file for the given parameters
     * Get cwmsData forecastInstance with name fileData
     */
    async getForecastInstanceWithNameFileDataRaw(requestParameters: GetForecastInstanceWithNameFileDataRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>> {
        if (requestParameters['name'] == null) {
            throw new runtime.RequiredError(
                'name',
                'Required parameter "name" was null or undefined when calling getForecastInstanceWithNameFileData().'
            );
        }

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

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

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

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

        const queryParameters: any = {};

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

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

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

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

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

        return new runtime.BlobApiResponse(response);
    }

    /**
     * Used to download forecast file for the given parameters
     * Get cwmsData forecastInstance with name fileData
     */
    async getForecastInstanceWithNameFileData(requestParameters: GetForecastInstanceWithNameFileDataRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob> {
        const response = await this.getForecastInstanceWithNameFileDataRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Used to query multiple forecast specs
     * Get cwmsData forecastSpec
     */
    async getForecastSpecRaw(requestParameters: GetForecastSpecRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ForecastSpec>> {
        const queryParameters: any = {};

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

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

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

        if (requestParameters['sourceEntity'] != null) {
            queryParameters['source-entity'] = requestParameters['sourceEntity'];
        }

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

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

    /**
     * Used to query multiple forecast specs
     * Get cwmsData forecastSpec
     */
    async getForecastSpec(requestParameters: GetForecastSpecRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ForecastSpec> {
        const response = await this.getForecastSpecRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Used to query a single forecast spec record
     * Get cwmsData forecastSpec with name
     */
    async getForecastSpecWithNameRaw(requestParameters: GetForecastSpecWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ForecastSpec>> {
        if (requestParameters['name'] == null) {
            throw new runtime.RequiredError(
                'name',
                'Required parameter "name" was null or undefined when calling getForecastSpecWithName().'
            );
        }

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

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

        const queryParameters: any = {};

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

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

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

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

    /**
     * Used to query a single forecast spec record
     * Get cwmsData forecastSpec with name
     */
    async getForecastSpecWithName(requestParameters: GetForecastSpecWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ForecastSpec> {
        const response = await this.getForecastSpecWithNameRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Update a forecast instance with new max age, notes, forecast fileand forecast info key/value pairs.
     * Patch cwmsData forecastInstance with name
     */
    async patchForecastInstanceWithNameRaw(requestParameters: PatchForecastInstanceWithNameRequest, 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 patchForecastInstanceWithName().'
            );
        }

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

        const queryParameters: any = {};

        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: `/forecast-instance/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters['name']))),
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: ForecastInstanceToJSON(requestParameters['forecastInstance']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Update a forecast instance with new max age, notes, forecast fileand forecast info key/value pairs.
     * Patch cwmsData forecastInstance with name
     */
    async patchForecastInstanceWithName(requestParameters: PatchForecastInstanceWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.patchForecastInstanceWithNameRaw(requestParameters, initOverrides);
    }

    /**
     * Update a forecast spec with provided values
     * Patch cwmsData forecastSpec with name
     */
    async patchForecastSpecWithNameRaw(requestParameters: PatchForecastSpecWithNameRequest, 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 patchForecastSpecWithName().'
            );
        }

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

        const queryParameters: any = {};

        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: `/forecast-spec/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters['name']))),
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: ForecastSpecToJSON(requestParameters['forecastSpec']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Update a forecast spec with provided values
     * Patch cwmsData forecastSpec with name
     */
    async patchForecastSpecWithName(requestParameters: PatchForecastSpecWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.patchForecastSpecWithNameRaw(requestParameters, initOverrides);
    }

    /**
     * Used to create and save a forecast instance
     * Post cwmsData forecastInstance
     */
    async postForecastInstanceRaw(requestParameters: PostForecastInstanceRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['forecastInstance'] == null) {
            throw new runtime.RequiredError(
                'forecastInstance',
                'Required parameter "forecastInstance" was null or undefined when calling postForecastInstance().'
            );
        }

        const queryParameters: any = {};

        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: `/forecast-instance`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: ForecastInstanceToJSON(requestParameters['forecastInstance']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Used to create and save a forecast instance
     * Post cwmsData forecastInstance
     */
    async postForecastInstance(requestParameters: PostForecastInstanceRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.postForecastInstanceRaw(requestParameters, initOverrides);
    }

    /**
     * Used to create and save forecast spec data
     * Post cwmsData forecastSpec
     */
    async postForecastSpecRaw(requestParameters: PostForecastSpecRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['forecastSpec'] == null) {
            throw new runtime.RequiredError(
                'forecastSpec',
                'Required parameter "forecastSpec" was null or undefined when calling postForecastSpec().'
            );
        }

        const queryParameters: any = {};

        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: `/forecast-spec`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: ForecastSpecToJSON(requestParameters['forecastSpec']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Used to create and save forecast spec data
     * Post cwmsData forecastSpec
     */
    async postForecastSpec(requestParameters: PostForecastSpecRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.postForecastSpecRaw(requestParameters, initOverrides);
    }

}
