/* 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,
    ProjectLock,
    ProjectLockFromJSON,
    ProjectLockToJSON,
    ProjectLockId,
    ProjectLockIdFromJSON,
    ProjectLockIdToJSON,
} from '../models';

export interface DeleteProjectLocksWithNameRequest {
    name: string;
    office: string;
    revokeTimeout?: number;
}

export interface GetProjectLocksRequest {
    officeMask: string;
    projectMask?: string;
    applicationMask?: string;
}

export interface GetProjectLocksWithNameRequest {
    name: string;
    office: string;
    applicationId: string;
}

export interface PostProjectLocksRequest {
    projectLock: ProjectLock;
    revokeExisting?: boolean;
    revokeTimeout?: number;
}

export interface PostProjectLocksDenyRequest {
    lockId: string;
}

export interface PostProjectLocksReleaseRequest {
    office: string;
    lockId: string;
}

/**
 * 
 */
export class ProjectLocksApi extends runtime.BaseAPI {

    /**
     * Revokes a project lock, if successful the lock is deleted
     * Delete projectLocks with name
     */
    async deleteProjectLocksWithNameRaw(requestParameters: DeleteProjectLocksWithNameRequest, 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 deleteProjectLocksWithName.');
        }

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

        const queryParameters: any = {};

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

        if (requestParameters.revokeTimeout !== undefined) {
            queryParameters['revoke-timeout'] = requestParameters.revokeTimeout;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/project-locks/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Revokes a project lock, if successful the lock is deleted
     * Delete projectLocks with name
     */
    async deleteProjectLocksWithName(requestParameters: DeleteProjectLocksWithNameRequest, initOverrides?: RequestInit): Promise<void> {
        await this.deleteProjectLocksWithNameRaw(requestParameters, initOverrides);
    }

    /**
     * Get a list of project locks
     * Get projectLocks
     */
    async getProjectLocksRaw(requestParameters: GetProjectLocksRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<ProjectLock>> {
        if (requestParameters.officeMask === null || requestParameters.officeMask === undefined) {
            throw new runtime.RequiredError('officeMask','Required parameter requestParameters.officeMask was null or undefined when calling getProjectLocks.');
        }

        const queryParameters: any = {};

        if (requestParameters.officeMask !== undefined) {
            queryParameters['office-mask'] = requestParameters.officeMask;
        }

        if (requestParameters.projectMask !== undefined) {
            queryParameters['project-mask'] = requestParameters.projectMask;
        }

        if (requestParameters.applicationMask !== undefined) {
            queryParameters['application-mask'] = requestParameters.applicationMask;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/project-locks`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Get a list of project locks
     * Get projectLocks
     */
    async getProjectLocks(requestParameters: GetProjectLocksRequest, initOverrides?: RequestInit): Promise<ProjectLock> {
        const response = await this.getProjectLocksRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Return a lock if the specified project is locked. Otherwise 404
     * Get projectLocks with name
     */
    async getProjectLocksWithNameRaw(requestParameters: GetProjectLocksWithNameRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<ProjectLock>> {
        if (requestParameters.name === null || requestParameters.name === undefined) {
            throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling getProjectLocksWithName.');
        }

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

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

        const queryParameters: any = {};

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

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

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/project-locks/{name}`.replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Return a lock if the specified project is locked. Otherwise 404
     * Get projectLocks with name
     */
    async getProjectLocksWithName(requestParameters: GetProjectLocksWithNameRequest, initOverrides?: RequestInit): Promise<ProjectLock> {
        const response = await this.getProjectLocksWithNameRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Requests the creation of a new Reservoir Project Lock
     * Post projectLocks
     */
    async postProjectLocksRaw(requestParameters: PostProjectLocksRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<ProjectLockId>> {
        if (requestParameters.projectLock === null || requestParameters.projectLock === undefined) {
            throw new runtime.RequiredError('projectLock','Required parameter requestParameters.projectLock was null or undefined when calling postProjectLocks.');
        }

        const queryParameters: any = {};

        if (requestParameters.revokeExisting !== undefined) {
            queryParameters['revoke-existing'] = requestParameters.revokeExisting;
        }

        if (requestParameters.revokeTimeout !== undefined) {
            queryParameters['revoke-timeout'] = requestParameters.revokeTimeout;
        }

        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: `/project-locks`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: ProjectLockToJSON(requestParameters.projectLock),
        }, initOverrides);

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

    /**
     * Requests the creation of a new Reservoir Project Lock
     * Post projectLocks
     */
    async postProjectLocks(requestParameters: PostProjectLocksRequest, initOverrides?: RequestInit): Promise<ProjectLockId> {
        const response = await this.postProjectLocksRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Deny a Lock revoke request.
     * Post projectLocks deny
     */
    async postProjectLocksDenyRaw(requestParameters: PostProjectLocksDenyRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.lockId === null || requestParameters.lockId === undefined) {
            throw new runtime.RequiredError('lockId','Required parameter requestParameters.lockId was null or undefined when calling postProjectLocksDeny.');
        }

        const queryParameters: any = {};

        if (requestParameters.lockId !== undefined) {
            queryParameters['lock-id'] = requestParameters.lockId;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/project-locks/deny`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Deny a Lock revoke request.
     * Post projectLocks deny
     */
    async postProjectLocksDeny(requestParameters: PostProjectLocksDenyRequest, initOverrides?: RequestInit): Promise<void> {
        await this.postProjectLocksDenyRaw(requestParameters, initOverrides);
    }

    /**
     * Releases a project lock
     * Post projectLocks release
     */
    async postProjectLocksReleaseRaw(requestParameters: PostProjectLocksReleaseRequest, 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 postProjectLocksRelease.');
        }

        if (requestParameters.lockId === null || requestParameters.lockId === undefined) {
            throw new runtime.RequiredError('lockId','Required parameter requestParameters.lockId was null or undefined when calling postProjectLocksRelease.');
        }

        const queryParameters: any = {};

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

        if (requestParameters.lockId !== undefined) {
            queryParameters['lock-id'] = requestParameters.lockId;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication
        }

        const response = await this.request({
            path: `/project-locks/release`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Releases a project lock
     * Post projectLocks release
     */
    async postProjectLocksRelease(requestParameters: PostProjectLocksReleaseRequest, initOverrides?: RequestInit): Promise<void> {
        await this.postProjectLocksReleaseRaw(requestParameters, initOverrides);
    }

}
