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

package com.azure.resourcemanager.dnsresolver.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.SubResource;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;

/** IP configuration. */
@Fluent
public final class IpConfiguration {
    /*
     * The reference to the subnet bound to the IP configuration.
     */
    @JsonProperty(value = "subnet", required = true)
    private SubResource subnet;

    /*
     * Private IP address of the IP configuration.
     */
    @JsonProperty(value = "privateIpAddress")
    private String privateIpAddress;

    /*
     * Private IP address allocation method.
     */
    @JsonProperty(value = "privateIpAllocationMethod")
    private IpAllocationMethod privateIpAllocationMethod;

    /**
     * Get the subnet property: The reference to the subnet bound to the IP configuration.
     *
     * @return the subnet value.
     */
    public SubResource subnet() {
        return this.subnet;
    }

    /**
     * Set the subnet property: The reference to the subnet bound to the IP configuration.
     *
     * @param subnet the subnet value to set.
     * @return the IpConfiguration object itself.
     */
    public IpConfiguration withSubnet(SubResource subnet) {
        this.subnet = subnet;
        return this;
    }

    /**
     * Get the privateIpAddress property: Private IP address of the IP configuration.
     *
     * @return the privateIpAddress value.
     */
    public String privateIpAddress() {
        return this.privateIpAddress;
    }

    /**
     * Set the privateIpAddress property: Private IP address of the IP configuration.
     *
     * @param privateIpAddress the privateIpAddress value to set.
     * @return the IpConfiguration object itself.
     */
    public IpConfiguration withPrivateIpAddress(String privateIpAddress) {
        this.privateIpAddress = privateIpAddress;
        return this;
    }

    /**
     * Get the privateIpAllocationMethod property: Private IP address allocation method.
     *
     * @return the privateIpAllocationMethod value.
     */
    public IpAllocationMethod privateIpAllocationMethod() {
        return this.privateIpAllocationMethod;
    }

    /**
     * Set the privateIpAllocationMethod property: Private IP address allocation method.
     *
     * @param privateIpAllocationMethod the privateIpAllocationMethod value to set.
     * @return the IpConfiguration object itself.
     */
    public IpConfiguration withPrivateIpAllocationMethod(IpAllocationMethod privateIpAllocationMethod) {
        this.privateIpAllocationMethod = privateIpAllocationMethod;
        return this;
    }

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

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