UNPKG

cwmsjs

Version:

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

158 lines (157 loc) 6.95 kB
/* 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. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 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) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import * as runtime from '../runtime'; import { ApiKeyFromJSON, ApiKeyToJSON, } from '../models/index'; /** * */ export class AuthorizationApi extends runtime.BaseAPI { /** * Delete API key for a user * Delete cwmsData auth keys with keyName */ deleteAuthKeysWithKeyNameRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { if (requestParameters['keyName'] == null) { throw new runtime.RequiredError('keyName', 'Required parameter "keyName" was null or undefined when calling deleteAuthKeysWithKeyName().'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization"); // ApiKey authentication } const response = yield this.request({ path: `/auth/keys/{key-name}`.replace(`{${"key-name"}}`, encodeURIComponent(String(requestParameters['keyName']))), method: 'DELETE', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ApiKeyFromJSON(jsonValue)); }); } /** * Delete API key for a user * Delete cwmsData auth keys with keyName */ deleteAuthKeysWithKeyName(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.deleteAuthKeysWithKeyNameRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * View all keys for the current user * Get cwmsData auth keys */ getAuthKeysRaw(initOverrides) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization"); // ApiKey authentication } const response = yield this.request({ path: `/auth/keys`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(ApiKeyFromJSON)); }); } /** * View all keys for the current user * Get cwmsData auth keys */ getAuthKeys(initOverrides) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.getAuthKeysRaw(initOverrides); return yield response.value(); }); } /** * View specific key * Get cwmsData auth keys with keyName */ getAuthKeysWithKeyNameRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { if (requestParameters['keyName'] == null) { throw new runtime.RequiredError('keyName', 'Required parameter "keyName" was null or undefined when calling getAuthKeysWithKeyName().'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization"); // ApiKey authentication } const response = yield this.request({ path: `/auth/keys/{key-name}`.replace(`{${"key-name"}}`, encodeURIComponent(String(requestParameters['keyName']))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ApiKeyFromJSON(jsonValue)); }); } /** * View specific key * Get cwmsData auth keys with keyName */ getAuthKeysWithKeyName(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.getAuthKeysWithKeyNameRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * Create a new API Key for user. The randomly generated key is returned to the caller. A provided key will be ignored. * Post cwmsData auth keys */ postAuthKeysRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = yield this.configuration.apiKey("Authorization"); // ApiKey authentication } const response = yield this.request({ path: `/auth/keys`, method: 'POST', headers: headerParameters, query: queryParameters, body: ApiKeyToJSON(requestParameters['apiKey']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ApiKeyFromJSON(jsonValue)); }); } /** * Create a new API Key for user. The randomly generated key is returned to the caller. A provided key will be ignored. * Post cwmsData auth keys */ postAuthKeys(requestParameters = {}, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.postAuthKeysRaw(requestParameters, initOverrides); return yield response.value(); }); } }