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

package com.azure.resourcemanager.security.models;

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

/** The JitNetworkAccessPolicyVirtualMachine model. */
@Fluent
public final class JitNetworkAccessPolicyVirtualMachine {
    /*
     * Resource ID of the virtual machine that is linked to this policy
     */
    @JsonProperty(value = "id", required = true)
    private String id;

    /*
     * Port configurations for the virtual machine
     */
    @JsonProperty(value = "ports", required = true)
    private List<JitNetworkAccessPortRule> ports;

    /*
     * Public IP address of the Azure Firewall that is linked to this policy, if applicable
     */
    @JsonProperty(value = "publicIpAddress")
    private String publicIpAddress;

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

    /**
     * Get the id property: Resource ID of the virtual machine that is linked to this policy.
     *
     * @return the id value.
     */
    public String id() {
        return this.id;
    }

    /**
     * Set the id property: Resource ID of the virtual machine that is linked to this policy.
     *
     * @param id the id value to set.
     * @return the JitNetworkAccessPolicyVirtualMachine object itself.
     */
    public JitNetworkAccessPolicyVirtualMachine withId(String id) {
        this.id = id;
        return this;
    }

    /**
     * Get the ports property: Port configurations for the virtual machine.
     *
     * @return the ports value.
     */
    public List<JitNetworkAccessPortRule> ports() {
        return this.ports;
    }

    /**
     * Set the ports property: Port configurations for the virtual machine.
     *
     * @param ports the ports value to set.
     * @return the JitNetworkAccessPolicyVirtualMachine object itself.
     */
    public JitNetworkAccessPolicyVirtualMachine withPorts(List<JitNetworkAccessPortRule> ports) {
        this.ports = ports;
        return this;
    }

    /**
     * Get the publicIpAddress property: Public IP address of the Azure Firewall that is linked to this policy, if
     * applicable.
     *
     * @return the publicIpAddress value.
     */
    public String publicIpAddress() {
        return this.publicIpAddress;
    }

    /**
     * Set the publicIpAddress property: Public IP address of the Azure Firewall that is linked to this policy, if
     * applicable.
     *
     * @param publicIpAddress the publicIpAddress value to set.
     * @return the JitNetworkAccessPolicyVirtualMachine object itself.
     */
    public JitNetworkAccessPolicyVirtualMachine withPublicIpAddress(String publicIpAddress) {
        this.publicIpAddress = publicIpAddress;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (id() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property id in model JitNetworkAccessPolicyVirtualMachine"));
        }
        if (ports() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property ports in model JitNetworkAccessPolicyVirtualMachine"));
        } else {
            ports().forEach(e -> e.validate());
        }
    }

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