cwmsjs
Version:
CWMS Data API Library for JavaScript/TypeScript created with OpenAPI generator for use with browser webapps
160 lines (159 loc) • 7.01 kB
JavaScript
;
/* 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 AuthorizationApi extends runtime.BaseAPI {
/**
* Delete API key for a user
* Delete auth keys with keyName
*/
deleteAuthKeysWithKeyNameRaw(requestParameters, initOverrides) {
return __awaiter(this, void 0, void 0, function* () {
if (requestParameters.keyName === null || requestParameters.keyName === undefined) {
throw new runtime.RequiredError('keyName', 'Required parameter requestParameters.keyName was null or undefined when calling deleteAuthKeysWithKeyName.');
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = 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) => models_1.ApiKeyFromJSON(jsonValue));
});
}
/**
* Delete API key for a user
* Delete 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 auth keys
*/
getAuthKeysRaw(initOverrides) {
return __awaiter(this, void 0, void 0, function* () {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = 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(models_1.ApiKeyFromJSON));
});
}
/**
* View all keys for the current user
* Get 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 auth keys with keyName
*/
getAuthKeysWithKeyNameRaw(requestParameters, initOverrides) {
return __awaiter(this, void 0, void 0, function* () {
if (requestParameters.keyName === null || requestParameters.keyName === undefined) {
throw new runtime.RequiredError('keyName', 'Required parameter requestParameters.keyName was null or undefined when calling getAuthKeysWithKeyName.');
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = 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) => models_1.ApiKeyFromJSON(jsonValue));
});
}
/**
* View specific key
* Get 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 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"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = yield this.request({
path: `/auth/keys`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: models_1.ApiKeyToJSON(requestParameters.apiKey),
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => models_1.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 auth keys
*/
postAuthKeys(requestParameters = {}, initOverrides) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.postAuthKeysRaw(requestParameters, initOverrides);
return yield response.value();
});
}
}
exports.AuthorizationApi = AuthorizationApi;