cwmsjs
Version:
CWMS Data API Library for JavaScript/TypeScript created with OpenAPI generator for use with browser webapps
289 lines (231 loc) • 10.6 kB
text/typescript
/* 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,
Location,
LocationFromJSON,
LocationToJSON,
} from '../models';
export interface DeleteLocationsWithLocationIdRequest {
locationId: string;
office?: string;
}
export interface GetLocationsRequest {
names?: string;
office?: string;
unit?: string;
datum?: string;
format?: string;
}
export interface GetLocationsWithLocationIdRequest {
locationId: string;
office: string;
unit?: string;
includeAliases?: boolean;
}
export interface PatchLocationsWithLocationIdRequest {
locationId: string;
location: Location;
}
export interface PostLocationsRequest {
location: Location;
failIfExists?: boolean;
}
/**
*
*/
export class LocationsApi extends runtime.BaseAPI {
/**
* Delete CWMS Location
* Delete locations with locationId
*/
async deleteLocationsWithLocationIdRaw(requestParameters: DeleteLocationsWithLocationIdRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
if (requestParameters.locationId === null || requestParameters.locationId === undefined) {
throw new runtime.RequiredError('locationId','Required parameter requestParameters.locationId was null or undefined when calling deleteLocationsWithLocationId.');
}
const queryParameters: any = {};
if (requestParameters.office !== undefined) {
queryParameters['office'] = requestParameters.office;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/locations/{location-id}`.replace(`{${"location-id"}}`, encodeURIComponent(String(requestParameters.locationId))),
method: 'DELETE',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Delete CWMS Location
* Delete locations with locationId
*/
async deleteLocationsWithLocationId(requestParameters: DeleteLocationsWithLocationIdRequest, initOverrides?: RequestInit): Promise<void> {
await this.deleteLocationsWithLocationIdRaw(requestParameters, initOverrides);
}
/**
* Returns CWMS Location Data. The Catalog end-point is also capable of retrieving lists of locations and can filter on additional fields.
* Get locations
*/
async getLocationsRaw(requestParameters: GetLocationsRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Array<Location>>> {
const queryParameters: any = {};
if (requestParameters.names !== undefined) {
queryParameters['names'] = requestParameters.names;
}
if (requestParameters.office !== undefined) {
queryParameters['office'] = requestParameters.office;
}
if (requestParameters.unit !== undefined) {
queryParameters['unit'] = requestParameters.unit;
}
if (requestParameters.datum !== undefined) {
queryParameters['datum'] = requestParameters.datum;
}
if (requestParameters.format !== undefined) {
queryParameters['format'] = requestParameters.format;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/locations`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(LocationFromJSON));
}
/**
* Returns CWMS Location Data. The Catalog end-point is also capable of retrieving lists of locations and can filter on additional fields.
* Get locations
*/
async getLocations(requestParameters: GetLocationsRequest = {}, initOverrides?: RequestInit): Promise<Array<Location>> {
const response = await this.getLocationsRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Returns CWMS Location Data
* Get locations with locationId
*/
async getLocationsWithLocationIdRaw(requestParameters: GetLocationsWithLocationIdRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Location>> {
if (requestParameters.locationId === null || requestParameters.locationId === undefined) {
throw new runtime.RequiredError('locationId','Required parameter requestParameters.locationId was null or undefined when calling getLocationsWithLocationId.');
}
if (requestParameters.office === null || requestParameters.office === undefined) {
throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling getLocationsWithLocationId.');
}
const queryParameters: any = {};
if (requestParameters.office !== undefined) {
queryParameters['office'] = requestParameters.office;
}
if (requestParameters.unit !== undefined) {
queryParameters['unit'] = requestParameters.unit;
}
if (requestParameters.includeAliases !== undefined) {
queryParameters['include-aliases'] = requestParameters.includeAliases;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/locations/{location-id}`.replace(`{${"location-id"}}`, encodeURIComponent(String(requestParameters.locationId))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => LocationFromJSON(jsonValue));
}
/**
* Returns CWMS Location Data
* Get locations with locationId
*/
async getLocationsWithLocationId(requestParameters: GetLocationsWithLocationIdRequest, initOverrides?: RequestInit): Promise<Location> {
const response = await this.getLocationsWithLocationIdRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Update CWMS Location
* Patch locations with locationId
*/
async patchLocationsWithLocationIdRaw(requestParameters: PatchLocationsWithLocationIdRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
if (requestParameters.locationId === null || requestParameters.locationId === undefined) {
throw new runtime.RequiredError('locationId','Required parameter requestParameters.locationId was null or undefined when calling patchLocationsWithLocationId.');
}
if (requestParameters.location === null || requestParameters.location === undefined) {
throw new runtime.RequiredError('location','Required parameter requestParameters.location was null or undefined when calling patchLocationsWithLocationId.');
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/xml';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/locations/{location-id}`.replace(`{${"location-id"}}`, encodeURIComponent(String(requestParameters.locationId))),
method: 'PATCH',
headers: headerParameters,
query: queryParameters,
body: LocationToJSON(requestParameters.location),
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Update CWMS Location
* Patch locations with locationId
*/
async patchLocationsWithLocationId(requestParameters: PatchLocationsWithLocationIdRequest, initOverrides?: RequestInit): Promise<void> {
await this.patchLocationsWithLocationIdRaw(requestParameters, initOverrides);
}
/**
* Create new CWMS Location
* Post locations
*/
async postLocationsRaw(requestParameters: PostLocationsRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
if (requestParameters.location === null || requestParameters.location === undefined) {
throw new runtime.RequiredError('location','Required parameter requestParameters.location was null or undefined when calling postLocations.');
}
const queryParameters: any = {};
if (requestParameters.failIfExists !== undefined) {
queryParameters['fail-if-exists'] = requestParameters.failIfExists;
}
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/locations`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: LocationToJSON(requestParameters.location),
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Create new CWMS Location
* Post locations
*/
async postLocations(requestParameters: PostLocationsRequest, initOverrides?: RequestInit): Promise<void> {
await this.postLocationsRaw(requestParameters, initOverrides);
}
}