// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.networkcloud.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** IpAddressPool represents a pool of IP addresses that can be allocated to a service. */
@Fluent
public final class IpAddressPool {
    /*
     * The list of IP address ranges. Each range can be a either a subnet in CIDR format or an explicit start-end range
     * of IP addresses.
     */
    @JsonProperty(value = "addresses", required = true)
    private List<String> addresses;

    /*
     * The indicator to determine if automatic allocation from the pool should occur.
     */
    @JsonProperty(value = "autoAssign")
    private BfdEnabled autoAssign;

    /*
     * The name used to identify this IP address pool for association with a BGP advertisement.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * The indicator to prevent the use of IP addresses ending with .0 and .255 for this pool. Enabling this option
     * will only use IP addresses between .1 and .254 inclusive.
     */
    @JsonProperty(value = "onlyUseHostIps")
    private BfdEnabled onlyUseHostIps;

    /** Creates an instance of IpAddressPool class. */
    public IpAddressPool() {
    }

    /**
     * Get the addresses property: The list of IP address ranges. Each range can be a either a subnet in CIDR format or
     * an explicit start-end range of IP addresses.
     *
     * @return the addresses value.
     */
    public List<String> addresses() {
        return this.addresses;
    }

    /**
     * Set the addresses property: The list of IP address ranges. Each range can be a either a subnet in CIDR format or
     * an explicit start-end range of IP addresses.
     *
     * @param addresses the addresses value to set.
     * @return the IpAddressPool object itself.
     */
    public IpAddressPool withAddresses(List<String> addresses) {
        this.addresses = addresses;
        return this;
    }

    /**
     * Get the autoAssign property: The indicator to determine if automatic allocation from the pool should occur.
     *
     * @return the autoAssign value.
     */
    public BfdEnabled autoAssign() {
        return this.autoAssign;
    }

    /**
     * Set the autoAssign property: The indicator to determine if automatic allocation from the pool should occur.
     *
     * @param autoAssign the autoAssign value to set.
     * @return the IpAddressPool object itself.
     */
    public IpAddressPool withAutoAssign(BfdEnabled autoAssign) {
        this.autoAssign = autoAssign;
        return this;
    }

    /**
     * Get the name property: The name used to identify this IP address pool for association with a BGP advertisement.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: The name used to identify this IP address pool for association with a BGP advertisement.
     *
     * @param name the name value to set.
     * @return the IpAddressPool object itself.
     */
    public IpAddressPool withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the onlyUseHostIps property: The indicator to prevent the use of IP addresses ending with .0 and .255 for
     * this pool. Enabling this option will only use IP addresses between .1 and .254 inclusive.
     *
     * @return the onlyUseHostIps value.
     */
    public BfdEnabled onlyUseHostIps() {
        return this.onlyUseHostIps;
    }

    /**
     * Set the onlyUseHostIps property: The indicator to prevent the use of IP addresses ending with .0 and .255 for
     * this pool. Enabling this option will only use IP addresses between .1 and .254 inclusive.
     *
     * @param onlyUseHostIps the onlyUseHostIps value to set.
     * @return the IpAddressPool object itself.
     */
    public IpAddressPool withOnlyUseHostIps(BfdEnabled onlyUseHostIps) {
        this.onlyUseHostIps = onlyUseHostIps;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (addresses() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property addresses in model IpAddressPool"));
        }
        if (name() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property name in model IpAddressPool"));
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(IpAddressPool.class);
}
