cwmsjs
Version:
CWMS Data API Library for JavaScript/TypeScript created with OpenAPI generator for use with browser webapps
233 lines (190 loc) • 8.59 kB
text/typescript
/* 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.
*/
import * as runtime from '../runtime';
import type {
CdaError,
LocationCategory,
} from '../models/index';
import {
CdaErrorFromJSON,
CdaErrorToJSON,
LocationCategoryFromJSON,
LocationCategoryToJSON,
} from '../models/index';
export interface DeleteLocationCategoryWithCategoryIdRequest {
categoryId: string;
office: string;
cascadeDelete?: boolean;
}
export interface GetLocationCategoryRequest {
office?: string;
}
export interface GetLocationCategoryWithCategoryIdRequest {
categoryId: string;
office: string;
}
export interface PostLocationCategoryRequest {
locationCategory: LocationCategory;
}
/**
*
*/
export class LocationCategoriesApi extends runtime.BaseAPI {
/**
* Deletes requested location category
* Delete cwmsData location category with categoryId
*/
async deleteLocationCategoryWithCategoryIdRaw(requestParameters: DeleteLocationCategoryWithCategoryIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
if (requestParameters['categoryId'] == null) {
throw new runtime.RequiredError(
'categoryId',
'Required parameter "categoryId" was null or undefined when calling deleteLocationCategoryWithCategoryId().'
);
}
if (requestParameters['office'] == null) {
throw new runtime.RequiredError(
'office',
'Required parameter "office" was null or undefined when calling deleteLocationCategoryWithCategoryId().'
);
}
const queryParameters: any = {};
if (requestParameters['office'] != null) {
queryParameters['office'] = requestParameters['office'];
}
if (requestParameters['cascadeDelete'] != null) {
queryParameters['cascade-delete'] = requestParameters['cascadeDelete'];
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/location/category/{category-id}`.replace(`{${"category-id"}}`, encodeURIComponent(String(requestParameters['categoryId']))),
method: 'DELETE',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Deletes requested location category
* Delete cwmsData location category with categoryId
*/
async deleteLocationCategoryWithCategoryId(requestParameters: DeleteLocationCategoryWithCategoryIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.deleteLocationCategoryWithCategoryIdRaw(requestParameters, initOverrides);
}
/**
* Returns CWMS Location Category Data
* Get cwmsData location category
*/
async getLocationCategoryRaw(requestParameters: GetLocationCategoryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<LocationCategory>>> {
const queryParameters: any = {};
if (requestParameters['office'] != null) {
queryParameters['office'] = requestParameters['office'];
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/location/category`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(LocationCategoryFromJSON));
}
/**
* Returns CWMS Location Category Data
* Get cwmsData location category
*/
async getLocationCategory(requestParameters: GetLocationCategoryRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<LocationCategory>> {
const response = await this.getLocationCategoryRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Retrieves requested Location Category
* Get cwmsData location category with categoryId
*/
async getLocationCategoryWithCategoryIdRaw(requestParameters: GetLocationCategoryWithCategoryIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LocationCategory>> {
if (requestParameters['categoryId'] == null) {
throw new runtime.RequiredError(
'categoryId',
'Required parameter "categoryId" was null or undefined when calling getLocationCategoryWithCategoryId().'
);
}
if (requestParameters['office'] == null) {
throw new runtime.RequiredError(
'office',
'Required parameter "office" was null or undefined when calling getLocationCategoryWithCategoryId().'
);
}
const queryParameters: any = {};
if (requestParameters['office'] != null) {
queryParameters['office'] = requestParameters['office'];
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/location/category/{category-id}`.replace(`{${"category-id"}}`, encodeURIComponent(String(requestParameters['categoryId']))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => LocationCategoryFromJSON(jsonValue));
}
/**
* Retrieves requested Location Category
* Get cwmsData location category with categoryId
*/
async getLocationCategoryWithCategoryId(requestParameters: GetLocationCategoryWithCategoryIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LocationCategory> {
const response = await this.getLocationCategoryWithCategoryIdRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Create new LocationCategory
* Post cwmsData location category
*/
async postLocationCategoryRaw(requestParameters: PostLocationCategoryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
if (requestParameters['locationCategory'] == null) {
throw new runtime.RequiredError(
'locationCategory',
'Required parameter "locationCategory" was null or undefined when calling postLocationCategory().'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/location/category`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: LocationCategoryToJSON(requestParameters['locationCategory']),
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Create new LocationCategory
* Post cwmsData location category
*/
async postLocationCategory(requestParameters: PostLocationCategoryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.postLocationCategoryRaw(requestParameters, initOverrides);
}
}