/* 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,
    Property,
    PropertyFromJSON,
    PropertyToJSON,
} from '../models';

export interface DeletePropertiesWithNameRequest {
    name: string;
    office: string;
    categoryId: string;
}

export interface GetPropertiesRequest {
    officeMask?: string;
    categoryId?: string;
    nameMask?: string;
}

export interface GetPropertiesWithNameRequest {
    name: string;
    office: string;
    categoryId: string;
    defaultValue?: string;
}

export interface PatchPropertiesWithNameRequest {
    name: string;
    property: Property;
}

export interface PostPropertiesRequest {
    property: Property;
}

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

    /**
     * Delete CWMS Property
     * Delete properties with name
     */
    async deletePropertiesWithNameRaw(requestParameters: DeletePropertiesWithNameRequest, 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 deletePropertiesWithName.');
        }

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

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

        const queryParameters: any = {};

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

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Delete CWMS Property
     * Delete properties with name
     */
    async deletePropertiesWithName(requestParameters: DeletePropertiesWithNameRequest, initOverrides?: RequestInit): Promise<void> {
        await this.deletePropertiesWithNameRaw(requestParameters, initOverrides);
    }

    /**
     * Returns matching CWMS Property Data.
     * Get properties
     */
    async getPropertiesRaw(requestParameters: GetPropertiesRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Array<Property>>> {
        const queryParameters: any = {};

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

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

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

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

    /**
     * Returns matching CWMS Property Data.
     * Get properties
     */
    async getProperties(requestParameters: GetPropertiesRequest = {}, initOverrides?: RequestInit): Promise<Array<Property>> {
        const response = await this.getPropertiesRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Returns CWMS Property Data
     * Get properties with name
     */
    async getPropertiesWithNameRaw(requestParameters: GetPropertiesWithNameRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Property>> {
        if (requestParameters.name === null || requestParameters.name === undefined) {
            throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling getPropertiesWithName.');
        }

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

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

        const queryParameters: any = {};

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

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

        if (requestParameters.defaultValue !== undefined) {
            queryParameters['default-value'] = requestParameters.defaultValue;
        }

        const headerParameters: runtime.HTTPHeaders = {};

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

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

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

    /**
     * Returns CWMS Property Data
     * Get properties with name
     */
    async getPropertiesWithName(requestParameters: GetPropertiesWithNameRequest, initOverrides?: RequestInit): Promise<Property> {
        const response = await this.getPropertiesWithNameRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Update CWMS Property
     * Patch properties with name
     */
    async patchPropertiesWithNameRaw(requestParameters: PatchPropertiesWithNameRequest, 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 patchPropertiesWithName.');
        }

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

        const queryParameters: any = {};

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Update CWMS Property
     * Patch properties with name
     */
    async patchPropertiesWithName(requestParameters: PatchPropertiesWithNameRequest, initOverrides?: RequestInit): Promise<void> {
        await this.patchPropertiesWithNameRaw(requestParameters, initOverrides);
    }

    /**
     * Create CWMS Property
     * Post properties
     */
    async postPropertiesRaw(requestParameters: PostPropertiesRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.property === null || requestParameters.property === undefined) {
            throw new runtime.RequiredError('property','Required parameter requestParameters.property was null or undefined when calling postProperties.');
        }

        const queryParameters: any = {};

        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: `/properties`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: PropertyToJSON(requestParameters.property),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Create CWMS Property
     * Post properties
     */
    async postProperties(requestParameters: PostPropertiesRequest, initOverrides?: RequestInit): Promise<void> {
        await this.postPropertiesRaw(requestParameters, initOverrides);
    }

}
