// This file was autogenerated. Please do not change.
// All changes will be overwrited on commit.
export interface IDhcpConfigV4 {
    gateway_ip?: string;
    lease_duration?: number;
    range_end?: string;
    range_start?: string;
    subnet_mask?: string;
}

export default class DhcpConfigV4 {
    readonly _gateway_ip: string | undefined;

    /**
     * Description: undefined
     * Example: 192.168.1.1
     */
    get gatewayIp(): string | undefined {
        return this._gateway_ip;
    }

    readonly _lease_duration: number | undefined;

    get leaseDuration(): number | undefined {
        return this._lease_duration;
    }

    readonly _range_end: string | undefined;

    /**
     * Description: undefined
     * Example: 192.168.10.50
     */
    get rangeEnd(): string | undefined {
        return this._range_end;
    }

    readonly _range_start: string | undefined;

    /**
     * Description: undefined
     * Example: 192.168.1.2
     */
    get rangeStart(): string | undefined {
        return this._range_start;
    }

    readonly _subnet_mask: string | undefined;

    /**
     * Description: undefined
     * Example: 255.255.255.0
     */
    get subnetMask(): string | undefined {
        return this._subnet_mask;
    }

    constructor(props: IDhcpConfigV4) {
        if (typeof props.gateway_ip === 'string') {
            this._gateway_ip = props.gateway_ip.trim();
        }
        if (typeof props.lease_duration === 'number') {
            this._lease_duration = props.lease_duration;
        }
        if (typeof props.range_end === 'string') {
            this._range_end = props.range_end.trim();
        }
        if (typeof props.range_start === 'string') {
            this._range_start = props.range_start.trim();
        }
        if (typeof props.subnet_mask === 'string') {
            this._subnet_mask = props.subnet_mask.trim();
        }
    }

    serialize(): IDhcpConfigV4 {
        const data: IDhcpConfigV4 = {
        };
        if (typeof this._gateway_ip !== 'undefined') {
            data.gateway_ip = this._gateway_ip;
        }
        if (typeof this._lease_duration !== 'undefined') {
            data.lease_duration = this._lease_duration;
        }
        if (typeof this._range_end !== 'undefined') {
            data.range_end = this._range_end;
        }
        if (typeof this._range_start !== 'undefined') {
            data.range_start = this._range_start;
        }
        if (typeof this._subnet_mask !== 'undefined') {
            data.subnet_mask = this._subnet_mask;
        }
        return data;
    }

    validate(): string[] {
        const validate = {
            gateway_ip: !this._gateway_ip ? true : typeof this._gateway_ip === 'string' && !this._gateway_ip ? true : this._gateway_ip,
            subnet_mask: !this._subnet_mask ? true : typeof this._subnet_mask === 'string' && !this._subnet_mask ? true : this._subnet_mask,
            range_start: !this._range_start ? true : typeof this._range_start === 'string' && !this._range_start ? true : this._range_start,
            range_end: !this._range_end ? true : typeof this._range_end === 'string' && !this._range_end ? true : this._range_end,
            lease_duration: !this._lease_duration ? true : typeof this._lease_duration === 'number',
        };
        const isError: string[] = [];
        Object.keys(validate).forEach((key) => {
            if (!(validate as any)[key]) {
                isError.push(key);
            }
        });
        return isError;
    }

    update(props: Partial<IDhcpConfigV4>): DhcpConfigV4 {
        return new DhcpConfigV4({ ...this.serialize(), ...props });
    }
}
