UNPKG

cwmsjs

Version:

CWMS Data API Library for JavaScript/TypeScript created with OpenAPI generator for use with browser webapps

648 lines (516 loc) 26.2 kB
/* tslint:disable */ /* eslint-disable */ /** * CWMS Data API * CWMS REST API for Data Retrieval * * The version of the OpenAPI document: 2.4.0-2026.3.16 * * * 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 { CdaError, CdaErrorFromJSON, CdaErrorToJSON, DeleteMethod, DeleteMethodFromJSON, DeleteMethodToJSON, ForecastInstance, ForecastInstanceFromJSON, ForecastInstanceToJSON, ForecastSpec, ForecastSpecFromJSON, ForecastSpecToJSON, } from '../models'; 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 forecastInstance with name */ async deleteForecastInstanceWithNameRaw(requestParameters: DeleteForecastInstanceWithNameRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> { if (requestParameters.name === null || requestParameters.name === undefined) { throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling deleteForecastInstanceWithName.'); } if (requestParameters.forecastDate === null || requestParameters.forecastDate === undefined) { throw new runtime.RequiredError('forecastDate','Required parameter requestParameters.forecastDate was null or undefined when calling deleteForecastInstanceWithName.'); } if (requestParameters.issueDate === null || requestParameters.issueDate === undefined) { throw new runtime.RequiredError('issueDate','Required parameter requestParameters.issueDate was null or undefined when calling deleteForecastInstanceWithName.'); } if (requestParameters.office === null || requestParameters.office === undefined) { throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling deleteForecastInstanceWithName.'); } const queryParameters: any = {}; if (requestParameters.forecastDate !== undefined) { queryParameters['forecast-date'] = requestParameters.forecastDate; } if (requestParameters.issueDate !== undefined) { queryParameters['issue-date'] = requestParameters.issueDate; } if (requestParameters.office !== undefined) { queryParameters['office'] = requestParameters.office; } if (requestParameters.designator !== undefined) { queryParameters['designator'] = requestParameters.designator; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = 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 forecastInstance with name */ async deleteForecastInstanceWithName(requestParameters: DeleteForecastInstanceWithNameRequest, initOverrides?: RequestInit): Promise<void> { await this.deleteForecastInstanceWithNameRaw(requestParameters, initOverrides); } /** * Used to delete forecast spec data based on unique fields * Delete forecastSpec with name */ async deleteForecastSpecWithNameRaw(requestParameters: DeleteForecastSpecWithNameRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> { if (requestParameters.name === null || requestParameters.name === undefined) { throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling deleteForecastSpecWithName.'); } if (requestParameters.office === null || requestParameters.office === undefined) { throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling deleteForecastSpecWithName.'); } const queryParameters: any = {}; if (requestParameters.office !== undefined) { queryParameters['office'] = requestParameters.office; } if (requestParameters.designator !== undefined) { queryParameters['designator'] = requestParameters.designator; } if (requestParameters.method !== undefined) { queryParameters['method'] = requestParameters.method; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = 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 forecastSpec with name */ async deleteForecastSpecWithName(requestParameters: DeleteForecastSpecWithNameRequest, initOverrides?: RequestInit): Promise<void> { await this.deleteForecastSpecWithNameRaw(requestParameters, initOverrides); } /** * Used to get all forecast instances for a given forecast spec * Get forecastInstance */ async getForecastInstanceRaw(requestParameters: GetForecastInstanceRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<ForecastInstance>> { const queryParameters: any = {}; if (requestParameters.office !== undefined) { queryParameters['office'] = requestParameters.office; } if (requestParameters.name !== undefined) { queryParameters['name'] = requestParameters.name; } if (requestParameters.designator !== undefined) { queryParameters['designator'] = requestParameters.designator; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = 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 forecastInstance */ async getForecastInstance(requestParameters: GetForecastInstanceRequest = {}, initOverrides?: RequestInit): 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 forecastInstance with name */ async getForecastInstanceWithNameRaw(requestParameters: GetForecastInstanceWithNameRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<ForecastInstance>> { if (requestParameters.name === null || requestParameters.name === undefined) { throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling getForecastInstanceWithName.'); } if (requestParameters.forecastDate === null || requestParameters.forecastDate === undefined) { throw new runtime.RequiredError('forecastDate','Required parameter requestParameters.forecastDate was null or undefined when calling getForecastInstanceWithName.'); } if (requestParameters.issueDate === null || requestParameters.issueDate === undefined) { throw new runtime.RequiredError('issueDate','Required parameter requestParameters.issueDate was null or undefined when calling getForecastInstanceWithName.'); } if (requestParameters.office === null || requestParameters.office === undefined) { throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling getForecastInstanceWithName.'); } const queryParameters: any = {}; if (requestParameters.forecastDate !== undefined) { queryParameters['forecast-date'] = requestParameters.forecastDate; } if (requestParameters.issueDate !== undefined) { queryParameters['issue-date'] = requestParameters.issueDate; } if (requestParameters.office !== undefined) { queryParameters['office'] = requestParameters.office; } if (requestParameters.designator !== undefined) { queryParameters['designator'] = requestParameters.designator; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = 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 forecastInstance with name */ async getForecastInstanceWithName(requestParameters: GetForecastInstanceWithNameRequest, initOverrides?: RequestInit): Promise<ForecastInstance> { const response = await this.getForecastInstanceWithNameRaw(requestParameters, initOverrides); return await response.value(); } /** * Used to download forecast file for the given parameters * Get forecastInstance with name fileData */ async getForecastInstanceWithNameFileDataRaw(requestParameters: GetForecastInstanceWithNameFileDataRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Blob>> { if (requestParameters.name === null || requestParameters.name === undefined) { throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling getForecastInstanceWithNameFileData.'); } if (requestParameters.forecastDate === null || requestParameters.forecastDate === undefined) { throw new runtime.RequiredError('forecastDate','Required parameter requestParameters.forecastDate was null or undefined when calling getForecastInstanceWithNameFileData.'); } if (requestParameters.issueDate === null || requestParameters.issueDate === undefined) { throw new runtime.RequiredError('issueDate','Required parameter requestParameters.issueDate was null or undefined when calling getForecastInstanceWithNameFileData.'); } if (requestParameters.office === null || requestParameters.office === undefined) { throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling getForecastInstanceWithNameFileData.'); } const queryParameters: any = {}; if (requestParameters.forecastDate !== undefined) { queryParameters['forecast-date'] = requestParameters.forecastDate; } if (requestParameters.issueDate !== undefined) { queryParameters['issue-date'] = requestParameters.issueDate; } if (requestParameters.office !== undefined) { queryParameters['office'] = requestParameters.office; } if (requestParameters.designator !== undefined) { queryParameters['designator'] = requestParameters.designator; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = 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 forecastInstance with name fileData */ async getForecastInstanceWithNameFileData(requestParameters: GetForecastInstanceWithNameFileDataRequest, initOverrides?: RequestInit): Promise<Blob> { const response = await this.getForecastInstanceWithNameFileDataRaw(requestParameters, initOverrides); return await response.value(); } /** * Used to query multiple forecast specs * Get forecastSpec */ async getForecastSpecRaw(requestParameters: GetForecastSpecRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<ForecastSpec>> { const queryParameters: any = {}; if (requestParameters.office !== undefined) { queryParameters['office'] = requestParameters.office; } if (requestParameters.idMask !== undefined) { queryParameters['id-mask'] = requestParameters.idMask; } if (requestParameters.designatorMask !== undefined) { queryParameters['designator-mask'] = requestParameters.designatorMask; } if (requestParameters.sourceEntity !== undefined) { queryParameters['source-entity'] = requestParameters.sourceEntity; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = 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 forecastSpec */ async getForecastSpec(requestParameters: GetForecastSpecRequest = {}, initOverrides?: RequestInit): Promise<ForecastSpec> { const response = await this.getForecastSpecRaw(requestParameters, initOverrides); return await response.value(); } /** * Used to query a single forecast spec record * Get forecastSpec with name */ async getForecastSpecWithNameRaw(requestParameters: GetForecastSpecWithNameRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<ForecastSpec>> { if (requestParameters.name === null || requestParameters.name === undefined) { throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling getForecastSpecWithName.'); } if (requestParameters.office === null || requestParameters.office === undefined) { throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling getForecastSpecWithName.'); } const queryParameters: any = {}; if (requestParameters.office !== undefined) { queryParameters['office'] = requestParameters.office; } if (requestParameters.designator !== undefined) { queryParameters['designator'] = requestParameters.designator; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = 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 forecastSpec with name */ async getForecastSpecWithName(requestParameters: GetForecastSpecWithNameRequest, initOverrides?: RequestInit): 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 forecastInstance with name */ async patchForecastInstanceWithNameRaw(requestParameters: PatchForecastInstanceWithNameRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> { if (requestParameters.name === null || requestParameters.name === undefined) { throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling patchForecastInstanceWithName.'); } if (requestParameters.forecastInstance === null || requestParameters.forecastInstance === undefined) { throw new runtime.RequiredError('forecastInstance','Required parameter requestParameters.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"] = 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 forecastInstance with name */ async patchForecastInstanceWithName(requestParameters: PatchForecastInstanceWithNameRequest, initOverrides?: RequestInit): Promise<void> { await this.patchForecastInstanceWithNameRaw(requestParameters, initOverrides); } /** * Update a forecast spec with provided values * Patch forecastSpec with name */ async patchForecastSpecWithNameRaw(requestParameters: PatchForecastSpecWithNameRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> { if (requestParameters.name === null || requestParameters.name === undefined) { throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling patchForecastSpecWithName.'); } if (requestParameters.forecastSpec === null || requestParameters.forecastSpec === undefined) { throw new runtime.RequiredError('forecastSpec','Required parameter requestParameters.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"] = 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 forecastSpec with name */ async patchForecastSpecWithName(requestParameters: PatchForecastSpecWithNameRequest, initOverrides?: RequestInit): Promise<void> { await this.patchForecastSpecWithNameRaw(requestParameters, initOverrides); } /** * Used to create and save a forecast instance * Post forecastInstance */ async postForecastInstanceRaw(requestParameters: PostForecastInstanceRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> { if (requestParameters.forecastInstance === null || requestParameters.forecastInstance === undefined) { throw new runtime.RequiredError('forecastInstance','Required parameter requestParameters.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"] = 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 forecastInstance */ async postForecastInstance(requestParameters: PostForecastInstanceRequest, initOverrides?: RequestInit): Promise<void> { await this.postForecastInstanceRaw(requestParameters, initOverrides); } /** * Used to create and save forecast spec data * Post forecastSpec */ async postForecastSpecRaw(requestParameters: PostForecastSpecRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> { if (requestParameters.forecastSpec === null || requestParameters.forecastSpec === undefined) { throw new runtime.RequiredError('forecastSpec','Required parameter requestParameters.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"] = 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 forecastSpec */ async postForecastSpec(requestParameters: PostForecastSpecRequest, initOverrides?: RequestInit): Promise<void> { await this.postForecastSpecRaw(requestParameters, initOverrides); } }