/* 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,
  Project,
  ProjectChildLocations,
  Projects,
} from '../models/index';
import {
    CdaErrorFromJSON,
    CdaErrorToJSON,
    DeleteMethodFromJSON,
    DeleteMethodToJSON,
    ProjectFromJSON,
    ProjectToJSON,
    ProjectChildLocationsFromJSON,
    ProjectChildLocationsToJSON,
    ProjectsFromJSON,
    ProjectsToJSON,
} from '../models/index';

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 cwmsData projects with name
     */
    async deleteProjectsWithNameRaw(requestParameters: DeleteProjectsWithNameRequest, 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 deleteProjectsWithName().'
            );
        }

        if (requestParameters['office'] == null) {
            throw new runtime.RequiredError(
                'office',
                'Required parameter "office" was null or undefined when calling deleteProjectsWithName().'
            );
        }

        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/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters['name']))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Deletes requested reservoir project
     * Delete cwmsData projects with name
     */
    async deleteProjectsWithName(requestParameters: DeleteProjectsWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.deleteProjectsWithNameRaw(requestParameters, initOverrides);
    }

    /**
     * Returns Projects Data
     * Get cwmsData projects
     */
    async getProjectsRaw(requestParameters: GetProjectsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Projects>> {
        const queryParameters: any = {};

        if (requestParameters['office'] != null) {
            queryParameters['office'] = requestParameters['office'];
        }

        if (requestParameters['idMask'] != null) {
            queryParameters['id-mask'] = requestParameters['idMask'];
        }

        if (requestParameters['page'] != null) {
            queryParameters['page'] = requestParameters['page'];
        }

        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`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => ProjectsFromJSON(jsonValue));
    }

    /**
     * Returns Projects Data
     * Get cwmsData projects
     */
    async getProjects(requestParameters: GetProjectsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Projects> {
        const response = await this.getProjectsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Get a list of project child locations
     * Get cwmsData projects locations
     */
    async getProjectsLocationsRaw(requestParameters: GetProjectsLocationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ProjectChildLocations>>> {
        if (requestParameters['office'] == null) {
            throw new runtime.RequiredError(
                'office',
                'Required parameter "office" was null or undefined when calling getProjectsLocations().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['office'] != null) {
            queryParameters['office'] = requestParameters['office'];
        }

        if (requestParameters['projectLike'] != null) {
            queryParameters['project-like'] = requestParameters['projectLike'];
        }

        if (requestParameters['locationKindLike'] != null) {
            queryParameters['location-kind-like'] = requestParameters['locationKindLike'];
        }

        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/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 cwmsData projects locations
     */
    async getProjectsLocations(requestParameters: GetProjectsLocationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ProjectChildLocations>> {
        const response = await this.getProjectsLocationsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Retrieves requested Project
     * Get cwmsData projects with name
     */
    async getProjectsWithNameRaw(requestParameters: GetProjectsWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Project>> {
        if (requestParameters['name'] == null) {
            throw new runtime.RequiredError(
                'name',
                'Required parameter "name" was null or undefined when calling getProjectsWithName().'
            );
        }

        if (requestParameters['office'] == null) {
            throw new runtime.RequiredError(
                'office',
                'Required parameter "office" was null or undefined when calling getProjectsWithName().'
            );
        }

        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/{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 cwmsData projects with name
     */
    async getProjectsWithName(requestParameters: GetProjectsWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Project> {
        const response = await this.getProjectsWithNameRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Rename a project
     * Patch cwmsData projects with name
     */
    async patchProjectsWithNameRaw(requestParameters: PatchProjectsWithNameRequest, 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 patchProjectsWithName().'
            );
        }

        if (requestParameters['name2'] == null) {
            throw new runtime.RequiredError(
                'name2',
                'Required parameter "name2" was null or undefined when calling patchProjectsWithName().'
            );
        }

        if (requestParameters['project'] == null) {
            throw new runtime.RequiredError(
                'project',
                'Required parameter "project" was null or undefined when calling patchProjectsWithName().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['name2'] != null) {
            queryParameters['name'] = requestParameters['name2'];
        }

        if (requestParameters['office'] != null) {
            queryParameters['office'] = requestParameters['office'];
        }

        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: `/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 cwmsData projects with name
     */
    async patchProjectsWithName(requestParameters: PatchProjectsWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.patchProjectsWithNameRaw(requestParameters, initOverrides);
    }

    /**
     * Create new Project
     * Post cwmsData projects
     */
    async postProjectsRaw(requestParameters: PostProjectsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['project'] == null) {
            throw new runtime.RequiredError(
                'project',
                'Required parameter "project" was null or undefined when calling postProjects().'
            );
        }

        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`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: ProjectToJSON(requestParameters['project']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Create new Project
     * Post cwmsData projects
     */
    async postProjects(requestParameters: PostProjectsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): 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 cwmsData projects statusUpdate with name
     */
    async postProjectsStatusUpdateWithNameRaw(requestParameters: PostProjectsStatusUpdateWithNameRequest, 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 postProjectsStatusUpdateWithName().'
            );
        }

        if (requestParameters['office'] == null) {
            throw new runtime.RequiredError(
                'office',
                'Required parameter "office" was null or undefined when calling postProjectsStatusUpdateWithName().'
            );
        }

        if (requestParameters['applicationId'] == null) {
            throw new runtime.RequiredError(
                'applicationId',
                'Required parameter "applicationId" was null or undefined when calling postProjectsStatusUpdateWithName().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['office'] != null) {
            queryParameters['office'] = requestParameters['office'];
        }

        if (requestParameters['applicationId'] != null) {
            queryParameters['application-id'] = requestParameters['applicationId'];
        }

        if (requestParameters['sourceId'] != null) {
            queryParameters['source-id'] = requestParameters['sourceId'];
        }

        if (requestParameters['timeseriesId'] != null) {
            queryParameters['timeseries-id'] = requestParameters['timeseriesId'];
        }

        if (requestParameters['begin'] != null) {
            queryParameters['begin'] = requestParameters['begin'];
        }

        if (requestParameters['end'] != null) {
            queryParameters['end'] = requestParameters['end'];
        }

        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/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 cwmsData projects statusUpdate with name
     */
    async postProjectsStatusUpdateWithName(requestParameters: PostProjectsStatusUpdateWithNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.postProjectsStatusUpdateWithNameRaw(requestParameters, initOverrides);
    }

}
