UNPKG

cwmsjs

Version:

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

231 lines (230 loc) 10.9 kB
"use strict"; /* 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. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const runtime = require("../runtime"); const models_1 = require("../models"); /** * */ class LocationsApi extends runtime.BaseAPI { /** * Delete CWMS Location * Delete locations with locationId */ deleteLocationsWithLocationIdRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { 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 = {}; if (requestParameters.office !== undefined) { queryParameters['office'] = requestParameters.office; } const headerParameters = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication } const response = yield 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 */ deleteLocationsWithLocationId(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { yield 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 */ getLocationsRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = {}; 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 = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication } const response = yield this.request({ path: `/locations`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(models_1.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 */ getLocations(requestParameters = {}, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.getLocationsRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * Returns CWMS Location Data * Get locations with locationId */ getLocationsWithLocationIdRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { 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 = {}; 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 = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication } const response = yield 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) => models_1.LocationFromJSON(jsonValue)); }); } /** * Returns CWMS Location Data * Get locations with locationId */ getLocationsWithLocationId(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.getLocationsWithLocationIdRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * Update CWMS Location * Patch locations with locationId */ patchLocationsWithLocationIdRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { 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 = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/xml'; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication } const response = yield this.request({ path: `/locations/{location-id}`.replace(`{${"location-id"}}`, encodeURIComponent(String(requestParameters.locationId))), method: 'PATCH', headers: headerParameters, query: queryParameters, body: models_1.LocationToJSON(requestParameters.location), }, initOverrides); return new runtime.VoidApiResponse(response); }); } /** * Update CWMS Location * Patch locations with locationId */ patchLocationsWithLocationId(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { yield this.patchLocationsWithLocationIdRaw(requestParameters, initOverrides); }); } /** * Create new CWMS Location * Post locations */ postLocationsRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { 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 = {}; if (requestParameters.failIfExists !== undefined) { queryParameters['fail-if-exists'] = requestParameters.failIfExists; } const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication } const response = yield this.request({ path: `/locations`, method: 'POST', headers: headerParameters, query: queryParameters, body: models_1.LocationToJSON(requestParameters.location), }, initOverrides); return new runtime.VoidApiResponse(response); }); } /** * Create new CWMS Location * Post locations */ postLocations(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { yield this.postLocationsRaw(requestParameters, initOverrides); }); } } exports.LocationsApi = LocationsApi;