cwmsjs
Version:
CWMS Data API Library for JavaScript/TypeScript created with OpenAPI generator for use with browser webapps
507 lines (405 loc) • 21.2 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,
DeleteMethod,
DeleteMethodFromJSON,
DeleteMethodToJSON,
Turbine,
TurbineFromJSON,
TurbineToJSON,
TurbineChange,
TurbineChangeFromJSON,
TurbineChangeToJSON,
UnitSystem,
UnitSystemFromJSON,
UnitSystemToJSON,
} from '../models';
export interface DeleteProjectsTurbinesWithNameRequest {
name: string;
office: string;
method?: DeleteMethod;
}
export interface DeleteProjectsWithOfficeWithNameTurbineChangesRequest {
office: string;
name: string;
begin: string;
end: string;
overrideProtection?: boolean;
}
export interface GetProjectsTurbinesRequest {
office: string;
projectId: string;
}
export interface GetProjectsTurbinesWithNameRequest {
name: string;
office: string;
}
export interface GetProjectsWithOfficeWithNameTurbineChangesRequest {
office: string;
name: string;
begin: string;
end: string;
startTimeInclusive?: boolean;
endTimeInclusive?: boolean;
unitSystem?: UnitSystem;
pageSize?: number;
}
export interface PatchProjectsTurbinesWithNameRequest {
name: string;
name2: string;
office: string;
}
export interface PostProjectsTurbinesRequest {
turbine: Turbine;
failIfExists?: boolean;
}
export interface PostProjectsWithOfficeWithNameTurbineChangesRequest {
office: string;
name: string;
turbineChange: TurbineChange;
overrideProtection?: boolean;
}
/**
*
*/
export class TurbinesApi extends runtime.BaseAPI {
/**
* Delete CWMS Turbine
* Delete projects turbines with name
*/
async deleteProjectsTurbinesWithNameRaw(requestParameters: DeleteProjectsTurbinesWithNameRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
if (requestParameters.name === null || requestParameters.name === undefined) {
throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling deleteProjectsTurbinesWithName.');
}
if (requestParameters.office === null || requestParameters.office === undefined) {
throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling deleteProjectsTurbinesWithName.');
}
const queryParameters: any = {};
if (requestParameters.office !== undefined) {
queryParameters['office'] = requestParameters.office;
}
if (requestParameters.method !== undefined) {
queryParameters['method'] = requestParameters.method;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/projects/turbines/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))),
method: 'DELETE',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Delete CWMS Turbine
* Delete projects turbines with name
*/
async deleteProjectsTurbinesWithName(requestParameters: DeleteProjectsTurbinesWithNameRequest, initOverrides?: RequestInit): Promise<void> {
await this.deleteProjectsTurbinesWithNameRaw(requestParameters, initOverrides);
}
/**
* Delete CWMS Turbine Changes
* Delete projects with office with name turbineChanges
*/
async deleteProjectsWithOfficeWithNameTurbineChangesRaw(requestParameters: DeleteProjectsWithOfficeWithNameTurbineChangesRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
if (requestParameters.office === null || requestParameters.office === undefined) {
throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling deleteProjectsWithOfficeWithNameTurbineChanges.');
}
if (requestParameters.name === null || requestParameters.name === undefined) {
throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling deleteProjectsWithOfficeWithNameTurbineChanges.');
}
if (requestParameters.begin === null || requestParameters.begin === undefined) {
throw new runtime.RequiredError('begin','Required parameter requestParameters.begin was null or undefined when calling deleteProjectsWithOfficeWithNameTurbineChanges.');
}
if (requestParameters.end === null || requestParameters.end === undefined) {
throw new runtime.RequiredError('end','Required parameter requestParameters.end was null or undefined when calling deleteProjectsWithOfficeWithNameTurbineChanges.');
}
const queryParameters: any = {};
if (requestParameters.begin !== undefined) {
queryParameters['begin'] = requestParameters.begin;
}
if (requestParameters.end !== undefined) {
queryParameters['end'] = requestParameters.end;
}
if (requestParameters.overrideProtection !== undefined) {
queryParameters['override-protection'] = requestParameters.overrideProtection;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/projects/{office}/{name}/turbine-changes`.replace(`{${"office"}}`, encodeURIComponent(String(requestParameters.office))).replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))),
method: 'DELETE',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Delete CWMS Turbine Changes
* Delete projects with office with name turbineChanges
*/
async deleteProjectsWithOfficeWithNameTurbineChanges(requestParameters: DeleteProjectsWithOfficeWithNameTurbineChangesRequest, initOverrides?: RequestInit): Promise<void> {
await this.deleteProjectsWithOfficeWithNameTurbineChangesRaw(requestParameters, initOverrides);
}
/**
* Returns matching CWMS Turbine Data for a Reservoir Project.
* Get projects turbines
*/
async getProjectsTurbinesRaw(requestParameters: GetProjectsTurbinesRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Array<Turbine>>> {
if (requestParameters.office === null || requestParameters.office === undefined) {
throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling getProjectsTurbines.');
}
if (requestParameters.projectId === null || requestParameters.projectId === undefined) {
throw new runtime.RequiredError('projectId','Required parameter requestParameters.projectId was null or undefined when calling getProjectsTurbines.');
}
const queryParameters: any = {};
if (requestParameters.office !== undefined) {
queryParameters['office'] = requestParameters.office;
}
if (requestParameters.projectId !== undefined) {
queryParameters['project-id'] = requestParameters.projectId;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/projects/turbines`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(TurbineFromJSON));
}
/**
* Returns matching CWMS Turbine Data for a Reservoir Project.
* Get projects turbines
*/
async getProjectsTurbines(requestParameters: GetProjectsTurbinesRequest, initOverrides?: RequestInit): Promise<Array<Turbine>> {
const response = await this.getProjectsTurbinesRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Returns CWMS Turbine Data
* Get projects turbines with name
*/
async getProjectsTurbinesWithNameRaw(requestParameters: GetProjectsTurbinesWithNameRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Turbine>> {
if (requestParameters.name === null || requestParameters.name === undefined) {
throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling getProjectsTurbinesWithName.');
}
if (requestParameters.office === null || requestParameters.office === undefined) {
throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling getProjectsTurbinesWithName.');
}
const queryParameters: any = {};
if (requestParameters.office !== undefined) {
queryParameters['office'] = requestParameters.office;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/projects/turbines/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => TurbineFromJSON(jsonValue));
}
/**
* Returns CWMS Turbine Data
* Get projects turbines with name
*/
async getProjectsTurbinesWithName(requestParameters: GetProjectsTurbinesWithNameRequest, initOverrides?: RequestInit): Promise<Turbine> {
const response = await this.getProjectsTurbinesWithNameRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Returns matching CWMS Turbine Change Data for a Reservoir Project.
* Get projects with office with name turbineChanges
*/
async getProjectsWithOfficeWithNameTurbineChangesRaw(requestParameters: GetProjectsWithOfficeWithNameTurbineChangesRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Array<TurbineChange>>> {
if (requestParameters.office === null || requestParameters.office === undefined) {
throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling getProjectsWithOfficeWithNameTurbineChanges.');
}
if (requestParameters.name === null || requestParameters.name === undefined) {
throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling getProjectsWithOfficeWithNameTurbineChanges.');
}
if (requestParameters.begin === null || requestParameters.begin === undefined) {
throw new runtime.RequiredError('begin','Required parameter requestParameters.begin was null or undefined when calling getProjectsWithOfficeWithNameTurbineChanges.');
}
if (requestParameters.end === null || requestParameters.end === undefined) {
throw new runtime.RequiredError('end','Required parameter requestParameters.end was null or undefined when calling getProjectsWithOfficeWithNameTurbineChanges.');
}
const queryParameters: any = {};
if (requestParameters.begin !== undefined) {
queryParameters['begin'] = requestParameters.begin;
}
if (requestParameters.end !== undefined) {
queryParameters['end'] = requestParameters.end;
}
if (requestParameters.startTimeInclusive !== undefined) {
queryParameters['start-time-inclusive'] = requestParameters.startTimeInclusive;
}
if (requestParameters.endTimeInclusive !== undefined) {
queryParameters['end-time-inclusive'] = requestParameters.endTimeInclusive;
}
if (requestParameters.unitSystem !== undefined) {
queryParameters['unit-system'] = requestParameters.unitSystem;
}
if (requestParameters.pageSize !== undefined) {
queryParameters['page-size'] = requestParameters.pageSize;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/projects/{office}/{name}/turbine-changes`.replace(`{${"office"}}`, encodeURIComponent(String(requestParameters.office))).replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(TurbineChangeFromJSON));
}
/**
* Returns matching CWMS Turbine Change Data for a Reservoir Project.
* Get projects with office with name turbineChanges
*/
async getProjectsWithOfficeWithNameTurbineChanges(requestParameters: GetProjectsWithOfficeWithNameTurbineChangesRequest, initOverrides?: RequestInit): Promise<Array<TurbineChange>> {
const response = await this.getProjectsWithOfficeWithNameTurbineChangesRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Rename CWMS Turbine
* Patch projects turbines with name
*/
async patchProjectsTurbinesWithNameRaw(requestParameters: PatchProjectsTurbinesWithNameRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
if (requestParameters.name === null || requestParameters.name === undefined) {
throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling patchProjectsTurbinesWithName.');
}
if (requestParameters.name2 === null || requestParameters.name2 === undefined) {
throw new runtime.RequiredError('name2','Required parameter requestParameters.name2 was null or undefined when calling patchProjectsTurbinesWithName.');
}
if (requestParameters.office === null || requestParameters.office === undefined) {
throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling patchProjectsTurbinesWithName.');
}
const queryParameters: any = {};
if (requestParameters.name2 !== undefined) {
queryParameters['name'] = requestParameters.name2;
}
if (requestParameters.office !== undefined) {
queryParameters['office'] = requestParameters.office;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/projects/turbines/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))),
method: 'PATCH',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Rename CWMS Turbine
* Patch projects turbines with name
*/
async patchProjectsTurbinesWithName(requestParameters: PatchProjectsTurbinesWithNameRequest, initOverrides?: RequestInit): Promise<void> {
await this.patchProjectsTurbinesWithNameRaw(requestParameters, initOverrides);
}
/**
* Create CWMS Turbine
* Post projects turbines
*/
async postProjectsTurbinesRaw(requestParameters: PostProjectsTurbinesRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
if (requestParameters.turbine === null || requestParameters.turbine === undefined) {
throw new runtime.RequiredError('turbine','Required parameter requestParameters.turbine was null or undefined when calling postProjectsTurbines.');
}
const queryParameters: any = {};
if (requestParameters.failIfExists !== undefined) {
queryParameters['fail-if-exists'] = requestParameters.failIfExists;
}
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json;version=1';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/projects/turbines`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: TurbineToJSON(requestParameters.turbine),
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Create CWMS Turbine
* Post projects turbines
*/
async postProjectsTurbines(requestParameters: PostProjectsTurbinesRequest, initOverrides?: RequestInit): Promise<void> {
await this.postProjectsTurbinesRaw(requestParameters, initOverrides);
}
/**
* Create CWMS Turbine Changes
* Post projects with office with name turbineChanges
*/
async postProjectsWithOfficeWithNameTurbineChangesRaw(requestParameters: PostProjectsWithOfficeWithNameTurbineChangesRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
if (requestParameters.office === null || requestParameters.office === undefined) {
throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling postProjectsWithOfficeWithNameTurbineChanges.');
}
if (requestParameters.name === null || requestParameters.name === undefined) {
throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling postProjectsWithOfficeWithNameTurbineChanges.');
}
if (requestParameters.turbineChange === null || requestParameters.turbineChange === undefined) {
throw new runtime.RequiredError('turbineChange','Required parameter requestParameters.turbineChange was null or undefined when calling postProjectsWithOfficeWithNameTurbineChanges.');
}
const queryParameters: any = {};
if (requestParameters.overrideProtection !== undefined) {
queryParameters['override-protection'] = requestParameters.overrideProtection;
}
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json;version=1';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
}
const response = await this.request({
path: `/projects/{office}/{name}/turbine-changes`.replace(`{${"office"}}`, encodeURIComponent(String(requestParameters.office))).replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))),
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: TurbineChangeToJSON(requestParameters.turbineChange),
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
* Create CWMS Turbine Changes
* Post projects with office with name turbineChanges
*/
async postProjectsWithOfficeWithNameTurbineChanges(requestParameters: PostProjectsWithOfficeWithNameTurbineChangesRequest, initOverrides?: RequestInit): Promise<void> {
await this.postProjectsWithOfficeWithNameTurbineChangesRaw(requestParameters, initOverrides);
}
}