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

package com.azure.resourcemanager.paloaltonetworks.ngfw.models;

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

/** Network settings for Firewall. */
@Fluent
public final class NetworkProfile {
    /*
     * Vnet configurations
     */
    @JsonProperty(value = "vnetConfiguration")
    private VnetConfiguration vnetConfiguration;

    /*
     * Vwan configurations
     */
    @JsonProperty(value = "vwanConfiguration")
    private VwanConfiguration vwanConfiguration;

    /*
     * vnet or vwan, cannot be updated
     */
    @JsonProperty(value = "networkType", required = true)
    private NetworkType networkType;

    /*
     * List of IPs associated with the Firewall
     */
    @JsonProperty(value = "publicIps", required = true)
    private List<IpAddress> publicIps;

    /*
     * Enable egress NAT, enabled by default
     */
    @JsonProperty(value = "enableEgressNat", required = true)
    private EgressNat enableEgressNat;

    /*
     * Egress nat IP to use
     */
    @JsonProperty(value = "egressNatIp")
    private List<IpAddress> egressNatIp;

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

    /**
     * Get the vnetConfiguration property: Vnet configurations.
     *
     * @return the vnetConfiguration value.
     */
    public VnetConfiguration vnetConfiguration() {
        return this.vnetConfiguration;
    }

    /**
     * Set the vnetConfiguration property: Vnet configurations.
     *
     * @param vnetConfiguration the vnetConfiguration value to set.
     * @return the NetworkProfile object itself.
     */
    public NetworkProfile withVnetConfiguration(VnetConfiguration vnetConfiguration) {
        this.vnetConfiguration = vnetConfiguration;
        return this;
    }

    /**
     * Get the vwanConfiguration property: Vwan configurations.
     *
     * @return the vwanConfiguration value.
     */
    public VwanConfiguration vwanConfiguration() {
        return this.vwanConfiguration;
    }

    /**
     * Set the vwanConfiguration property: Vwan configurations.
     *
     * @param vwanConfiguration the vwanConfiguration value to set.
     * @return the NetworkProfile object itself.
     */
    public NetworkProfile withVwanConfiguration(VwanConfiguration vwanConfiguration) {
        this.vwanConfiguration = vwanConfiguration;
        return this;
    }

    /**
     * Get the networkType property: vnet or vwan, cannot be updated.
     *
     * @return the networkType value.
     */
    public NetworkType networkType() {
        return this.networkType;
    }

    /**
     * Set the networkType property: vnet or vwan, cannot be updated.
     *
     * @param networkType the networkType value to set.
     * @return the NetworkProfile object itself.
     */
    public NetworkProfile withNetworkType(NetworkType networkType) {
        this.networkType = networkType;
        return this;
    }

    /**
     * Get the publicIps property: List of IPs associated with the Firewall.
     *
     * @return the publicIps value.
     */
    public List<IpAddress> publicIps() {
        return this.publicIps;
    }

    /**
     * Set the publicIps property: List of IPs associated with the Firewall.
     *
     * @param publicIps the publicIps value to set.
     * @return the NetworkProfile object itself.
     */
    public NetworkProfile withPublicIps(List<IpAddress> publicIps) {
        this.publicIps = publicIps;
        return this;
    }

    /**
     * Get the enableEgressNat property: Enable egress NAT, enabled by default.
     *
     * @return the enableEgressNat value.
     */
    public EgressNat enableEgressNat() {
        return this.enableEgressNat;
    }

    /**
     * Set the enableEgressNat property: Enable egress NAT, enabled by default.
     *
     * @param enableEgressNat the enableEgressNat value to set.
     * @return the NetworkProfile object itself.
     */
    public NetworkProfile withEnableEgressNat(EgressNat enableEgressNat) {
        this.enableEgressNat = enableEgressNat;
        return this;
    }

    /**
     * Get the egressNatIp property: Egress nat IP to use.
     *
     * @return the egressNatIp value.
     */
    public List<IpAddress> egressNatIp() {
        return this.egressNatIp;
    }

    /**
     * Set the egressNatIp property: Egress nat IP to use.
     *
     * @param egressNatIp the egressNatIp value to set.
     * @return the NetworkProfile object itself.
     */
    public NetworkProfile withEgressNatIp(List<IpAddress> egressNatIp) {
        this.egressNatIp = egressNatIp;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (vnetConfiguration() != null) {
            vnetConfiguration().validate();
        }
        if (vwanConfiguration() != null) {
            vwanConfiguration().validate();
        }
        if (networkType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property networkType in model NetworkProfile"));
        }
        if (publicIps() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property publicIps in model NetworkProfile"));
        } else {
            publicIps().forEach(e -> e.validate());
        }
        if (enableEgressNat() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property enableEgressNat in model NetworkProfile"));
        }
        if (egressNatIp() != null) {
            egressNatIp().forEach(e -> e.validate());
        }
    }

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