cwmsjs
Version:
CWMS Data API Library for JavaScript/TypeScript created with OpenAPI generator for use with browser webapps
572 lines (470 loc) • 21.8 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,
DeleteMethod,
Turbine,
TurbineChange,
UnitSystem,
} from '../models/index';
import {
CdaErrorFromJSON,
CdaErrorToJSON,
DeleteMethodFromJSON,
DeleteMethodToJSON,
TurbineFromJSON,
TurbineToJSON,
TurbineChangeFromJSON,
TurbineChangeToJSON,
UnitSystemFromJSON,
UnitSystemToJSON,
} from '../models/index';
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 cwmsData projects turbines with name
*/
async deleteProjectsTurbinesWithNameRaw(requestParameters: DeleteProjectsTurbinesWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
if (requestParameters['name'] == null) {
throw new runtime.RequiredError(
'name',
'Required parameter "name" was null or undefined when calling deleteProjectsTurbinesWithName().'
);
}
if (requestParameters['office'] == null) {
throw new runtime.RequiredError(
'office',
'Required parameter "office" was null or undefined when calling deleteProjectsTurbinesWithName().'
);
}
const queryParameters: any = {};
if (requestParameters['office'] != null) {
queryParameters['office'] = requestParameters['office'];
}
if (requestParameters['method'] != null) {
queryParameters['method'] = requestParameters['method'];
}
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: `/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 cwmsData projects turbines with name
*/
async deleteProjectsTurbinesWithName(requestParameters: DeleteProjectsTurbinesWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.deleteProjectsTurbinesWithNameRaw(requestParameters, initOverrides);
}
/**
* Delete CWMS Turbine Changes
* Delete cwmsData projects with office with name turbineChanges
*/
async deleteProjectsWithOfficeWithNameTurbineChangesRaw(requestParameters: DeleteProjectsWithOfficeWithNameTurbineChangesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
if (requestParameters['office'] == null) {
throw new runtime.RequiredError(
'office',
'Required parameter "office" was null or undefined when calling deleteProjectsWithOfficeWithNameTurbineChanges().'
);
}
if (requestParameters['name'] == null) {
throw new runtime.RequiredError(
'name',
'Required parameter "name" was null or undefined when calling deleteProjectsWithOfficeWithNameTurbineChanges().'
);
}
if (requestParameters['begin'] == null) {
throw new runtime.RequiredError(
'begin',
'Required parameter "begin" was null or undefined when calling deleteProjectsWithOfficeWithNameTurbineChanges().'
);
}
if (requestParameters['end'] == null) {
throw new runtime.RequiredError(
'end',
'Required parameter "end" was null or undefined when calling deleteProjectsWithOfficeWithNameTurbineChanges().'
);
}
const queryParameters: any = {};
if (requestParameters['begin'] != null) {
queryParameters['begin'] = requestParameters['begin'];
}
if (requestParameters['end'] != null) {
queryParameters['end'] = requestParameters['end'];
}
if (requestParameters['overrideProtection'] != null) {
queryParameters['override-protection'] = requestParameters['overrideProtection'];
}
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: `/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 cwmsData projects with office with name turbineChanges
*/
async deleteProjectsWithOfficeWithNameTurbineChanges(requestParameters: DeleteProjectsWithOfficeWithNameTurbineChangesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.deleteProjectsWithOfficeWithNameTurbineChangesRaw(requestParameters, initOverrides);
}
/**
* Returns matching CWMS Turbine Data for a Reservoir Project.
* Get cwmsData projects turbines
*/
async getProjectsTurbinesRaw(requestParameters: GetProjectsTurbinesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<Turbine>>> {
if (requestParameters['office'] == null) {
throw new runtime.RequiredError(
'office',
'Required parameter "office" was null or undefined when calling getProjectsTurbines().'
);
}
if (requestParameters['projectId'] == null) {
throw new runtime.RequiredError(
'projectId',
'Required parameter "projectId" was null or undefined when calling getProjectsTurbines().'
);
}
const queryParameters: any = {};
if (requestParameters['office'] != null) {
queryParameters['office'] = requestParameters['office'];
}
if (requestParameters['projectId'] != null) {
queryParameters['project-id'] = requestParameters['projectId'];
}
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: `/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 cwmsData projects turbines
*/
async getProjectsTurbines(requestParameters: GetProjectsTurbinesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<Turbine>> {
const response = await this.getProjectsTurbinesRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Returns CWMS Turbine Data
* Get cwmsData projects turbines with name
*/
async getProjectsTurbinesWithNameRaw(requestParameters: GetProjectsTurbinesWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Turbine>> {
if (requestParameters['name'] == null) {
throw new runtime.RequiredError(
'name',
'Required parameter "name" was null or undefined when calling getProjectsTurbinesWithName().'
);
}
if (requestParameters['office'] == null) {
throw new runtime.RequiredError(
'office',
'Required parameter "office" was null or undefined when calling getProjectsTurbinesWithName().'
);
}
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: `/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 cwmsData projects turbines with name
*/
async getProjectsTurbinesWithName(requestParameters: GetProjectsTurbinesWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Turbine> {
const response = await this.getProjectsTurbinesWithNameRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Returns matching CWMS Turbine Change Data for a Reservoir Project.
* Get cwmsData projects with office with name turbineChanges
*/
async getProjectsWithOfficeWithNameTurbineChangesRaw(requestParameters: GetProjectsWithOfficeWithNameTurbineChangesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<TurbineChange>>> {
if (requestParameters['office'] == null) {
throw new runtime.RequiredError(
'office',
'Required parameter "office" was null or undefined when calling getProjectsWithOfficeWithNameTurbineChanges().'
);
}
if (requestParameters['name'] == null) {
throw new runtime.RequiredError(
'name',
'Required parameter "name" was null or undefined when calling getProjectsWithOfficeWithNameTurbineChanges().'
);
}
if (requestParameters['begin'] == null) {
throw new runtime.RequiredError(
'begin',
'Required parameter "begin" was null or undefined when calling getProjectsWithOfficeWithNameTurbineChanges().'
);
}
if (requestParameters['end'] == null) {
throw new runtime.RequiredError(
'end',
'Required parameter "end" was null or undefined when calling getProjectsWithOfficeWithNameTurbineChanges().'
);
}
const queryParameters: any = {};
if (requestParameters['begin'] != null) {
queryParameters['begin'] = requestParameters['begin'];
}
if (requestParameters['end'] != null) {
queryParameters['end'] = requestParameters['end'];
}
if (requestParameters['startTimeInclusive'] != null) {
queryParameters['start-time-inclusive'] = requestParameters['startTimeInclusive'];
}
if (requestParameters['endTimeInclusive'] != null) {
queryParameters['end-time-inclusive'] = requestParameters['endTimeInclusive'];
}
if (requestParameters['unitSystem'] != null) {
queryParameters['unit-system'] = requestParameters['unitSystem'];
}
if (requestParameters['pageSize'] != null) {
queryParameters['page-size'] = requestParameters['pageSize'];
}
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: `/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 cwmsData projects with office with name turbineChanges
*/
async getProjectsWithOfficeWithNameTurbineChanges(requestParameters: GetProjectsWithOfficeWithNameTurbineChangesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<TurbineChange>> {
const response = await this.getProjectsWithOfficeWithNameTurbineChangesRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Rename CWMS Turbine
* Patch cwmsData projects turbines with name
*/
async patchProjectsTurbinesWithNameRaw(requestParameters: PatchProjectsTurbinesWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
if (requestParameters['name'] == null) {
throw new runtime.RequiredError(
'name',
'Required parameter "name" was null or undefined when calling patchProjectsTurbinesWithName().'
);
}
if (requestParameters['name2'] == null) {
throw new runtime.RequiredError(
'name2',
'Required parameter "name2" was null or undefined when calling patchProjectsTurbinesWithName().'
);
}
if (requestParameters['office'] == null) {
throw new runtime.RequiredError(
'office',
'Required parameter "office" was null or undefined when calling patchProjectsTurbinesWithName().'
);
}
const queryParameters: any = {};
if (requestParameters['name2'] != null) {
queryParameters['name'] = requestParameters['name2'];
}
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: `/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 cwmsData projects turbines with name
*/
async patchProjectsTurbinesWithName(requestParameters: PatchProjectsTurbinesWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.patchProjectsTurbinesWithNameRaw(requestParameters, initOverrides);
}
/**
* Create CWMS Turbine
* Post cwmsData projects turbines
*/
async postProjectsTurbinesRaw(requestParameters: PostProjectsTurbinesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
if (requestParameters['turbine'] == null) {
throw new runtime.RequiredError(
'turbine',
'Required parameter "turbine" was null or undefined when calling postProjectsTurbines().'
);
}
const queryParameters: any = {};
if (requestParameters['failIfExists'] != null) {
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"] = await 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 cwmsData projects turbines
*/
async postProjectsTurbines(requestParameters: PostProjectsTurbinesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.postProjectsTurbinesRaw(requestParameters, initOverrides);
}
/**
* Create CWMS Turbine Changes
* Post cwmsData projects with office with name turbineChanges
*/
async postProjectsWithOfficeWithNameTurbineChangesRaw(requestParameters: PostProjectsWithOfficeWithNameTurbineChangesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
if (requestParameters['office'] == null) {
throw new runtime.RequiredError(
'office',
'Required parameter "office" was null or undefined when calling postProjectsWithOfficeWithNameTurbineChanges().'
);
}
if (requestParameters['name'] == null) {
throw new runtime.RequiredError(
'name',
'Required parameter "name" was null or undefined when calling postProjectsWithOfficeWithNameTurbineChanges().'
);
}
if (requestParameters['turbineChange'] == null) {
throw new runtime.RequiredError(
'turbineChange',
'Required parameter "turbineChange" was null or undefined when calling postProjectsWithOfficeWithNameTurbineChanges().'
);
}
const queryParameters: any = {};
if (requestParameters['overrideProtection'] != null) {
queryParameters['override-protection'] = requestParameters['overrideProtection'];
}
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json;version=1';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = await 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 cwmsData projects with office with name turbineChanges
*/
async postProjectsWithOfficeWithNameTurbineChanges(requestParameters: PostProjectsWithOfficeWithNameTurbineChangesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.postProjectsWithOfficeWithNameTurbineChangesRaw(requestParameters, initOverrides);
}
}