UNPKG

cwmsjs

Version:

CWMS Data API Library for JavaScript/TypeScript created with OpenAPI generator for use with browser webapps

437 lines (350 loc) 16.1 kB
/* 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, Project, ProjectFromJSON, ProjectToJSON, ProjectChildLocations, ProjectChildLocationsFromJSON, ProjectChildLocationsToJSON, Projects, ProjectsFromJSON, ProjectsToJSON, } from '../models'; export interface DeleteProjectsWithNameRequest { name: string; office: string; method?: DeleteMethod; } export interface GetProjectsRequest { office?: string; idMask?: string; page?: string; pageSize?: number; } export interface GetProjectsLocationsRequest { office: string; projectLike?: string; locationKindLike?: string; } export interface GetProjectsWithNameRequest { name: string; office: string; } export interface PatchProjectsWithNameRequest { name: string; name2: string; project: Project; office?: string; } export interface PostProjectsRequest { project: Project; failIfExists?: boolean; } export interface PostProjectsStatusUpdateWithNameRequest { name: string; office: string; applicationId: string; sourceId?: string; timeseriesId?: string; begin?: string; end?: string; } /** * */ export class ProjectsApi extends runtime.BaseAPI { /** * Deletes requested reservoir project * Delete projects with name */ async deleteProjectsWithNameRaw(requestParameters: DeleteProjectsWithNameRequest, 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 deleteProjectsWithName.'); } if (requestParameters.office === null || requestParameters.office === undefined) { throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling deleteProjectsWithName.'); } 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/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))), method: 'DELETE', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Deletes requested reservoir project * Delete projects with name */ async deleteProjectsWithName(requestParameters: DeleteProjectsWithNameRequest, initOverrides?: RequestInit): Promise<void> { await this.deleteProjectsWithNameRaw(requestParameters, initOverrides); } /** * Returns Projects Data * Get projects */ async getProjectsRaw(requestParameters: GetProjectsRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Projects>> { const queryParameters: any = {}; if (requestParameters.office !== undefined) { queryParameters['office'] = requestParameters.office; } if (requestParameters.idMask !== undefined) { queryParameters['id-mask'] = requestParameters.idMask; } if (requestParameters.page !== undefined) { queryParameters['page'] = requestParameters.page; } 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`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ProjectsFromJSON(jsonValue)); } /** * Returns Projects Data * Get projects */ async getProjects(requestParameters: GetProjectsRequest = {}, initOverrides?: RequestInit): Promise<Projects> { const response = await this.getProjectsRaw(requestParameters, initOverrides); return await response.value(); } /** * Get a list of project child locations * Get projects locations */ async getProjectsLocationsRaw(requestParameters: GetProjectsLocationsRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Array<ProjectChildLocations>>> { if (requestParameters.office === null || requestParameters.office === undefined) { throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling getProjectsLocations.'); } const queryParameters: any = {}; if (requestParameters.office !== undefined) { queryParameters['office'] = requestParameters.office; } if (requestParameters.projectLike !== undefined) { queryParameters['project-like'] = requestParameters.projectLike; } if (requestParameters.locationKindLike !== undefined) { queryParameters['location-kind-like'] = requestParameters.locationKindLike; } 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/locations`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(ProjectChildLocationsFromJSON)); } /** * Get a list of project child locations * Get projects locations */ async getProjectsLocations(requestParameters: GetProjectsLocationsRequest, initOverrides?: RequestInit): Promise<Array<ProjectChildLocations>> { const response = await this.getProjectsLocationsRaw(requestParameters, initOverrides); return await response.value(); } /** * Retrieves requested Project * Get projects with name */ async getProjectsWithNameRaw(requestParameters: GetProjectsWithNameRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Project>> { if (requestParameters.name === null || requestParameters.name === undefined) { throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling getProjectsWithName.'); } if (requestParameters.office === null || requestParameters.office === undefined) { throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling getProjectsWithName.'); } 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/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ProjectFromJSON(jsonValue)); } /** * Retrieves requested Project * Get projects with name */ async getProjectsWithName(requestParameters: GetProjectsWithNameRequest, initOverrides?: RequestInit): Promise<Project> { const response = await this.getProjectsWithNameRaw(requestParameters, initOverrides); return await response.value(); } /** * Rename a project * Patch projects with name */ async patchProjectsWithNameRaw(requestParameters: PatchProjectsWithNameRequest, 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 patchProjectsWithName.'); } if (requestParameters.name2 === null || requestParameters.name2 === undefined) { throw new runtime.RequiredError('name2','Required parameter requestParameters.name2 was null or undefined when calling patchProjectsWithName.'); } if (requestParameters.project === null || requestParameters.project === undefined) { throw new runtime.RequiredError('project','Required parameter requestParameters.project was null or undefined when calling patchProjectsWithName.'); } const queryParameters: any = {}; if (requestParameters.name2 !== undefined) { queryParameters['name'] = requestParameters.name2; } 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: `/projects/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))), method: 'PATCH', headers: headerParameters, query: queryParameters, body: ProjectToJSON(requestParameters.project), }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Rename a project * Patch projects with name */ async patchProjectsWithName(requestParameters: PatchProjectsWithNameRequest, initOverrides?: RequestInit): Promise<void> { await this.patchProjectsWithNameRaw(requestParameters, initOverrides); } /** * Create new Project * Post projects */ async postProjectsRaw(requestParameters: PostProjectsRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> { if (requestParameters.project === null || requestParameters.project === undefined) { throw new runtime.RequiredError('project','Required parameter requestParameters.project was null or undefined when calling postProjects.'); } 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`, method: 'POST', headers: headerParameters, query: queryParameters, body: ProjectToJSON(requestParameters.project), }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Create new Project * Post projects */ async postProjects(requestParameters: PostProjectsRequest, initOverrides?: RequestInit): Promise<void> { await this.postProjectsRaw(requestParameters, initOverrides); } /** * Publishes a message on the office\'s STATUS queue that a project has been updated for a specified application * Post projects statusUpdate with name */ async postProjectsStatusUpdateWithNameRaw(requestParameters: PostProjectsStatusUpdateWithNameRequest, 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 postProjectsStatusUpdateWithName.'); } if (requestParameters.office === null || requestParameters.office === undefined) { throw new runtime.RequiredError('office','Required parameter requestParameters.office was null or undefined when calling postProjectsStatusUpdateWithName.'); } if (requestParameters.applicationId === null || requestParameters.applicationId === undefined) { throw new runtime.RequiredError('applicationId','Required parameter requestParameters.applicationId was null or undefined when calling postProjectsStatusUpdateWithName.'); } const queryParameters: any = {}; if (requestParameters.office !== undefined) { queryParameters['office'] = requestParameters.office; } if (requestParameters.applicationId !== undefined) { queryParameters['application-id'] = requestParameters.applicationId; } if (requestParameters.sourceId !== undefined) { queryParameters['source-id'] = requestParameters.sourceId; } if (requestParameters.timeseriesId !== undefined) { queryParameters['timeseries-id'] = requestParameters.timeseriesId; } if (requestParameters.begin !== undefined) { queryParameters['begin'] = requestParameters.begin; } if (requestParameters.end !== undefined) { queryParameters['end'] = requestParameters.end; } 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/status-update/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Publishes a message on the office\'s STATUS queue that a project has been updated for a specified application * Post projects statusUpdate with name */ async postProjectsStatusUpdateWithName(requestParameters: PostProjectsStatusUpdateWithNameRequest, initOverrides?: RequestInit): Promise<void> { await this.postProjectsStatusUpdateWithNameRaw(requestParameters, initOverrides); } }