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

package com.azure.resourcemanager.databricks.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.databricks.models.AddressSpace;
import com.azure.resourcemanager.databricks.models.PeeringProvisioningState;
import com.azure.resourcemanager.databricks.models.PeeringState;
import com.azure.resourcemanager.databricks.models.VirtualNetworkPeeringPropertiesFormatDatabricksVirtualNetwork;
import com.azure.resourcemanager.databricks.models.VirtualNetworkPeeringPropertiesFormatRemoteVirtualNetwork;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Properties of the virtual network peering. */
@Fluent
public final class VirtualNetworkPeeringPropertiesFormat {
    /*
     * Whether the VMs in the local virtual network space would be able to access the VMs in remote virtual network
     * space.
     */
    @JsonProperty(value = "allowVirtualNetworkAccess")
    private Boolean allowVirtualNetworkAccess;

    /*
     * Whether the forwarded traffic from the VMs in the local virtual network will be allowed/disallowed in remote
     * virtual network.
     */
    @JsonProperty(value = "allowForwardedTraffic")
    private Boolean allowForwardedTraffic;

    /*
     * If gateway links can be used in remote virtual networking to link to this virtual network.
     */
    @JsonProperty(value = "allowGatewayTransit")
    private Boolean allowGatewayTransit;

    /*
     * If remote gateways can be used on this virtual network. If the flag is set to true, and allowGatewayTransit on
     * remote peering is also true, virtual network will use gateways of remote virtual network for transit. Only one
     * peering can have this flag set to true. This flag cannot be set if virtual network already has a gateway.
     */
    @JsonProperty(value = "useRemoteGateways")
    private Boolean useRemoteGateways;

    /*
     * The remote virtual network should be in the same region. See here to learn more
     * (https://docs.microsoft.com/en-us/azure/databricks/administration-guide/cloud-configurations/azure/vnet-peering).
     */
    @JsonProperty(value = "databricksVirtualNetwork")
    private VirtualNetworkPeeringPropertiesFormatDatabricksVirtualNetwork databricksVirtualNetwork;

    /*
     * The reference to the databricks virtual network address space.
     */
    @JsonProperty(value = "databricksAddressSpace")
    private AddressSpace databricksAddressSpace;

    /*
     * The remote virtual network should be in the same region. See here to learn more
     * (https://docs.microsoft.com/en-us/azure/databricks/administration-guide/cloud-configurations/azure/vnet-peering).
     */
    @JsonProperty(value = "remoteVirtualNetwork", required = true)
    private VirtualNetworkPeeringPropertiesFormatRemoteVirtualNetwork remoteVirtualNetwork;

    /*
     * The reference to the remote virtual network address space.
     */
    @JsonProperty(value = "remoteAddressSpace")
    private AddressSpace remoteAddressSpace;

    /*
     * The status of the virtual network peering.
     */
    @JsonProperty(value = "peeringState", access = JsonProperty.Access.WRITE_ONLY)
    private PeeringState peeringState;

    /*
     * The provisioning state of the virtual network peering resource.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private PeeringProvisioningState provisioningState;

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

    /**
     * Get the allowVirtualNetworkAccess property: Whether the VMs in the local virtual network space would be able to
     * access the VMs in remote virtual network space.
     *
     * @return the allowVirtualNetworkAccess value.
     */
    public Boolean allowVirtualNetworkAccess() {
        return this.allowVirtualNetworkAccess;
    }

    /**
     * Set the allowVirtualNetworkAccess property: Whether the VMs in the local virtual network space would be able to
     * access the VMs in remote virtual network space.
     *
     * @param allowVirtualNetworkAccess the allowVirtualNetworkAccess value to set.
     * @return the VirtualNetworkPeeringPropertiesFormat object itself.
     */
    public VirtualNetworkPeeringPropertiesFormat withAllowVirtualNetworkAccess(Boolean allowVirtualNetworkAccess) {
        this.allowVirtualNetworkAccess = allowVirtualNetworkAccess;
        return this;
    }

    /**
     * Get the allowForwardedTraffic property: Whether the forwarded traffic from the VMs in the local virtual network
     * will be allowed/disallowed in remote virtual network.
     *
     * @return the allowForwardedTraffic value.
     */
    public Boolean allowForwardedTraffic() {
        return this.allowForwardedTraffic;
    }

    /**
     * Set the allowForwardedTraffic property: Whether the forwarded traffic from the VMs in the local virtual network
     * will be allowed/disallowed in remote virtual network.
     *
     * @param allowForwardedTraffic the allowForwardedTraffic value to set.
     * @return the VirtualNetworkPeeringPropertiesFormat object itself.
     */
    public VirtualNetworkPeeringPropertiesFormat withAllowForwardedTraffic(Boolean allowForwardedTraffic) {
        this.allowForwardedTraffic = allowForwardedTraffic;
        return this;
    }

    /**
     * Get the allowGatewayTransit property: If gateway links can be used in remote virtual networking to link to this
     * virtual network.
     *
     * @return the allowGatewayTransit value.
     */
    public Boolean allowGatewayTransit() {
        return this.allowGatewayTransit;
    }

    /**
     * Set the allowGatewayTransit property: If gateway links can be used in remote virtual networking to link to this
     * virtual network.
     *
     * @param allowGatewayTransit the allowGatewayTransit value to set.
     * @return the VirtualNetworkPeeringPropertiesFormat object itself.
     */
    public VirtualNetworkPeeringPropertiesFormat withAllowGatewayTransit(Boolean allowGatewayTransit) {
        this.allowGatewayTransit = allowGatewayTransit;
        return this;
    }

    /**
     * Get the useRemoteGateways property: If remote gateways can be used on this virtual network. If the flag is set to
     * true, and allowGatewayTransit on remote peering is also true, virtual network will use gateways of remote virtual
     * network for transit. Only one peering can have this flag set to true. This flag cannot be set if virtual network
     * already has a gateway.
     *
     * @return the useRemoteGateways value.
     */
    public Boolean useRemoteGateways() {
        return this.useRemoteGateways;
    }

    /**
     * Set the useRemoteGateways property: If remote gateways can be used on this virtual network. If the flag is set to
     * true, and allowGatewayTransit on remote peering is also true, virtual network will use gateways of remote virtual
     * network for transit. Only one peering can have this flag set to true. This flag cannot be set if virtual network
     * already has a gateway.
     *
     * @param useRemoteGateways the useRemoteGateways value to set.
     * @return the VirtualNetworkPeeringPropertiesFormat object itself.
     */
    public VirtualNetworkPeeringPropertiesFormat withUseRemoteGateways(Boolean useRemoteGateways) {
        this.useRemoteGateways = useRemoteGateways;
        return this;
    }

    /**
     * Get the databricksVirtualNetwork property: The remote virtual network should be in the same region. See here to
     * learn more
     * (https://docs.microsoft.com/en-us/azure/databricks/administration-guide/cloud-configurations/azure/vnet-peering).
     *
     * @return the databricksVirtualNetwork value.
     */
    public VirtualNetworkPeeringPropertiesFormatDatabricksVirtualNetwork databricksVirtualNetwork() {
        return this.databricksVirtualNetwork;
    }

    /**
     * Set the databricksVirtualNetwork property: The remote virtual network should be in the same region. See here to
     * learn more
     * (https://docs.microsoft.com/en-us/azure/databricks/administration-guide/cloud-configurations/azure/vnet-peering).
     *
     * @param databricksVirtualNetwork the databricksVirtualNetwork value to set.
     * @return the VirtualNetworkPeeringPropertiesFormat object itself.
     */
    public VirtualNetworkPeeringPropertiesFormat withDatabricksVirtualNetwork(
        VirtualNetworkPeeringPropertiesFormatDatabricksVirtualNetwork databricksVirtualNetwork) {
        this.databricksVirtualNetwork = databricksVirtualNetwork;
        return this;
    }

    /**
     * Get the databricksAddressSpace property: The reference to the databricks virtual network address space.
     *
     * @return the databricksAddressSpace value.
     */
    public AddressSpace databricksAddressSpace() {
        return this.databricksAddressSpace;
    }

    /**
     * Set the databricksAddressSpace property: The reference to the databricks virtual network address space.
     *
     * @param databricksAddressSpace the databricksAddressSpace value to set.
     * @return the VirtualNetworkPeeringPropertiesFormat object itself.
     */
    public VirtualNetworkPeeringPropertiesFormat withDatabricksAddressSpace(AddressSpace databricksAddressSpace) {
        this.databricksAddressSpace = databricksAddressSpace;
        return this;
    }

    /**
     * Get the remoteVirtualNetwork property: The remote virtual network should be in the same region. See here to learn
     * more
     * (https://docs.microsoft.com/en-us/azure/databricks/administration-guide/cloud-configurations/azure/vnet-peering).
     *
     * @return the remoteVirtualNetwork value.
     */
    public VirtualNetworkPeeringPropertiesFormatRemoteVirtualNetwork remoteVirtualNetwork() {
        return this.remoteVirtualNetwork;
    }

    /**
     * Set the remoteVirtualNetwork property: The remote virtual network should be in the same region. See here to learn
     * more
     * (https://docs.microsoft.com/en-us/azure/databricks/administration-guide/cloud-configurations/azure/vnet-peering).
     *
     * @param remoteVirtualNetwork the remoteVirtualNetwork value to set.
     * @return the VirtualNetworkPeeringPropertiesFormat object itself.
     */
    public VirtualNetworkPeeringPropertiesFormat withRemoteVirtualNetwork(
        VirtualNetworkPeeringPropertiesFormatRemoteVirtualNetwork remoteVirtualNetwork) {
        this.remoteVirtualNetwork = remoteVirtualNetwork;
        return this;
    }

    /**
     * Get the remoteAddressSpace property: The reference to the remote virtual network address space.
     *
     * @return the remoteAddressSpace value.
     */
    public AddressSpace remoteAddressSpace() {
        return this.remoteAddressSpace;
    }

    /**
     * Set the remoteAddressSpace property: The reference to the remote virtual network address space.
     *
     * @param remoteAddressSpace the remoteAddressSpace value to set.
     * @return the VirtualNetworkPeeringPropertiesFormat object itself.
     */
    public VirtualNetworkPeeringPropertiesFormat withRemoteAddressSpace(AddressSpace remoteAddressSpace) {
        this.remoteAddressSpace = remoteAddressSpace;
        return this;
    }

    /**
     * Get the peeringState property: The status of the virtual network peering.
     *
     * @return the peeringState value.
     */
    public PeeringState peeringState() {
        return this.peeringState;
    }

    /**
     * Get the provisioningState property: The provisioning state of the virtual network peering resource.
     *
     * @return the provisioningState value.
     */
    public PeeringProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (databricksVirtualNetwork() != null) {
            databricksVirtualNetwork().validate();
        }
        if (databricksAddressSpace() != null) {
            databricksAddressSpace().validate();
        }
        if (remoteVirtualNetwork() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property remoteVirtualNetwork in model"
                            + " VirtualNetworkPeeringPropertiesFormat"));
        } else {
            remoteVirtualNetwork().validate();
        }
        if (remoteAddressSpace() != null) {
            remoteAddressSpace().validate();
        }
    }

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