cwmsjs
Version:
CWMS Data API Library for JavaScript/TypeScript created with OpenAPI generator for use with browser webapps
341 lines (271 loc) • 14.4 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,
LocationGroup,
LocationGroupFromJSON,
LocationGroupToJSON,
} from '../models';
export interface DeleteLocationGroupWithGroupIdRequest {
groupId: string;
categoryId: string;
office: string;
cascadeDelete?: boolean;
}
export interface GetLocationGroupRequest {
categoryOfficeId: string;
locationOfficeId: string;
office?: string;
includeAssigned?: boolean;
locationCategoryLike?: string;
}
export interface GetLocationGroupWithGroupIdRequest {
groupId: string;
office: string;
groupOfficeId: string;
categoryOfficeId: string;
categoryId: string;
}
export interface PatchLocationGroupWithGroupIdRequest {
groupId: string;
office: string;
locationGroup: LocationGroup;
replaceAssignedLocs?: boolean;
}
export interface PostLocationGroupRequest {
locationGroup: LocationGroup;
}
/**
*
*/
export class LocationGroupsApi extends runtime.BaseAPI {
/**
* Deletes requested location group
* Delete location group with groupId
*/
async deleteLocationGroupWithGroupIdRaw(requestParameters: DeleteLocationGroupWithGroupIdRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
if (requestParameters.groupId === null || requestParameters.groupId === undefined) {
throw new runtime.RequiredError('groupId','Required parameter requestParameters.groupId was null or undefined when calling deleteLocationGroupWithGroupId.');
}
if (requestParameters.categoryId === null || requestParameters.categoryId === undefined) {
throw new runtime.RequiredError('categoryId','Required parameter requestParameters.categoryId was null or undefined when calling deleteLocationGroupWithGroupId.');
}
if (requestParameters.office === null || requestParameters.office === undefined) {
throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling deleteLocationGroupWithGroupId.');
}
const queryParameters: any = {};
if (requestParameters.categoryId !== undefined) {
queryParameters['category-id'] = requestParameters.categoryId;
}
if (requestParameters.office !== undefined) {
queryParameters['office'] = requestParameters.office;
}
if (requestParameters.cascadeDelete !== undefined) {
queryParameters['cascade-delete'] = requestParameters.cascadeDelete;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/location/group/{group-id}`.replace(`{${"group-id"}}`, encodeURIComponent(String(requestParameters.groupId))),
method: 'DELETE',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Deletes requested location group
* Delete location group with groupId
*/
async deleteLocationGroupWithGroupId(requestParameters: DeleteLocationGroupWithGroupIdRequest, initOverrides?: RequestInit): Promise<void> {
await this.deleteLocationGroupWithGroupIdRaw(requestParameters, initOverrides);
}
/**
* Returns CWMS Location Groups Data
* Get location group
*/
async getLocationGroupRaw(requestParameters: GetLocationGroupRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Array<LocationGroup>>> {
if (requestParameters.categoryOfficeId === null || requestParameters.categoryOfficeId === undefined) {
throw new runtime.RequiredError('categoryOfficeId','Required parameter requestParameters.categoryOfficeId was null or undefined when calling getLocationGroup.');
}
if (requestParameters.locationOfficeId === null || requestParameters.locationOfficeId === undefined) {
throw new runtime.RequiredError('locationOfficeId','Required parameter requestParameters.locationOfficeId was null or undefined when calling getLocationGroup.');
}
const queryParameters: any = {};
if (requestParameters.office !== undefined) {
queryParameters['office'] = requestParameters.office;
}
if (requestParameters.includeAssigned !== undefined) {
queryParameters['include-assigned'] = requestParameters.includeAssigned;
}
if (requestParameters.locationCategoryLike !== undefined) {
queryParameters['location-category-like'] = requestParameters.locationCategoryLike;
}
if (requestParameters.categoryOfficeId !== undefined) {
queryParameters['category-office-id'] = requestParameters.categoryOfficeId;
}
if (requestParameters.locationOfficeId !== undefined) {
queryParameters['location-office-id'] = requestParameters.locationOfficeId;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/location/group`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(LocationGroupFromJSON));
}
/**
* Returns CWMS Location Groups Data
* Get location group
*/
async getLocationGroup(requestParameters: GetLocationGroupRequest, initOverrides?: RequestInit): Promise<Array<LocationGroup>> {
const response = await this.getLocationGroupRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Retrieves requested Location Group. This endpoint supports GEO JSON responses with application/geo+json.For more information about accept header usage, <a href=\"legacy-format/\">see this page.</a>
* Get location group with groupId
*/
async getLocationGroupWithGroupIdRaw(requestParameters: GetLocationGroupWithGroupIdRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<LocationGroup>> {
if (requestParameters.groupId === null || requestParameters.groupId === undefined) {
throw new runtime.RequiredError('groupId','Required parameter requestParameters.groupId was null or undefined when calling getLocationGroupWithGroupId.');
}
if (requestParameters.office === null || requestParameters.office === undefined) {
throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling getLocationGroupWithGroupId.');
}
if (requestParameters.groupOfficeId === null || requestParameters.groupOfficeId === undefined) {
throw new runtime.RequiredError('groupOfficeId','Required parameter requestParameters.groupOfficeId was null or undefined when calling getLocationGroupWithGroupId.');
}
if (requestParameters.categoryOfficeId === null || requestParameters.categoryOfficeId === undefined) {
throw new runtime.RequiredError('categoryOfficeId','Required parameter requestParameters.categoryOfficeId was null or undefined when calling getLocationGroupWithGroupId.');
}
if (requestParameters.categoryId === null || requestParameters.categoryId === undefined) {
throw new runtime.RequiredError('categoryId','Required parameter requestParameters.categoryId was null or undefined when calling getLocationGroupWithGroupId.');
}
const queryParameters: any = {};
if (requestParameters.office !== undefined) {
queryParameters['office'] = requestParameters.office;
}
if (requestParameters.groupOfficeId !== undefined) {
queryParameters['group-office-id'] = requestParameters.groupOfficeId;
}
if (requestParameters.categoryOfficeId !== undefined) {
queryParameters['category-office-id'] = requestParameters.categoryOfficeId;
}
if (requestParameters.categoryId !== undefined) {
queryParameters['category-id'] = requestParameters.categoryId;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/location/group/{group-id}`.replace(`{${"group-id"}}`, encodeURIComponent(String(requestParameters.groupId))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => LocationGroupFromJSON(jsonValue));
}
/**
* Retrieves requested Location Group. This endpoint supports GEO JSON responses with application/geo+json.For more information about accept header usage, <a href=\"legacy-format/\">see this page.</a>
* Get location group with groupId
*/
async getLocationGroupWithGroupId(requestParameters: GetLocationGroupWithGroupIdRequest, initOverrides?: RequestInit): Promise<LocationGroup> {
const response = await this.getLocationGroupWithGroupIdRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Update existing LocationGroup. Allows for renaming group, assigning new locations, and unassigning all locations from the group.
* Patch location group with groupId
*/
async patchLocationGroupWithGroupIdRaw(requestParameters: PatchLocationGroupWithGroupIdRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
if (requestParameters.groupId === null || requestParameters.groupId === undefined) {
throw new runtime.RequiredError('groupId','Required parameter requestParameters.groupId was null or undefined when calling patchLocationGroupWithGroupId.');
}
if (requestParameters.office === null || requestParameters.office === undefined) {
throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling patchLocationGroupWithGroupId.');
}
if (requestParameters.locationGroup === null || requestParameters.locationGroup === undefined) {
throw new runtime.RequiredError('locationGroup','Required parameter requestParameters.locationGroup was null or undefined when calling patchLocationGroupWithGroupId.');
}
const queryParameters: any = {};
if (requestParameters.replaceAssignedLocs !== undefined) {
queryParameters['replace-assigned-locs'] = requestParameters.replaceAssignedLocs;
}
if (requestParameters.office !== undefined) {
queryParameters['office'] = requestParameters.office;
}
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: `/location/group/{group-id}`.replace(`{${"group-id"}}`, encodeURIComponent(String(requestParameters.groupId))),
method: 'PATCH',
headers: headerParameters,
query: queryParameters,
body: LocationGroupToJSON(requestParameters.locationGroup),
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Update existing LocationGroup. Allows for renaming group, assigning new locations, and unassigning all locations from the group.
* Patch location group with groupId
*/
async patchLocationGroupWithGroupId(requestParameters: PatchLocationGroupWithGroupIdRequest, initOverrides?: RequestInit): Promise<void> {
await this.patchLocationGroupWithGroupIdRaw(requestParameters, initOverrides);
}
/**
* Create new LocationGroup
* Post location group
*/
async postLocationGroupRaw(requestParameters: PostLocationGroupRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
if (requestParameters.locationGroup === null || requestParameters.locationGroup === undefined) {
throw new runtime.RequiredError('locationGroup','Required parameter requestParameters.locationGroup was null or undefined when calling postLocationGroup.');
}
const queryParameters: any = {};
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: `/location/group`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: LocationGroupToJSON(requestParameters.locationGroup),
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Create new LocationGroup
* Post location group
*/
async postLocationGroup(requestParameters: PostLocationGroupRequest, initOverrides?: RequestInit): Promise<void> {
await this.postLocationGroupRaw(requestParameters, initOverrides);
}
}