// 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.fluent.models;

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

/** The JitNetworkAccessPolicyProperties model. */
@Fluent
public final class JitNetworkAccessPolicyProperties {
    /*
     * Configurations for Microsoft.Compute/virtualMachines resource type.
     */
    @JsonProperty(value = "virtualMachines", required = true)
    private List<JitNetworkAccessPolicyVirtualMachine> virtualMachines;

    /*
     * The requests property.
     */
    @JsonProperty(value = "requests")
    private List<JitNetworkAccessRequestInner> requests;

    /*
     * Gets the provisioning state of the Just-in-Time policy.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private String provisioningState;

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

    /**
     * Get the virtualMachines property: Configurations for Microsoft.Compute/virtualMachines resource type.
     *
     * @return the virtualMachines value.
     */
    public List<JitNetworkAccessPolicyVirtualMachine> virtualMachines() {
        return this.virtualMachines;
    }

    /**
     * Set the virtualMachines property: Configurations for Microsoft.Compute/virtualMachines resource type.
     *
     * @param virtualMachines the virtualMachines value to set.
     * @return the JitNetworkAccessPolicyProperties object itself.
     */
    public JitNetworkAccessPolicyProperties withVirtualMachines(
        List<JitNetworkAccessPolicyVirtualMachine> virtualMachines) {
        this.virtualMachines = virtualMachines;
        return this;
    }

    /**
     * Get the requests property: The requests property.
     *
     * @return the requests value.
     */
    public List<JitNetworkAccessRequestInner> requests() {
        return this.requests;
    }

    /**
     * Set the requests property: The requests property.
     *
     * @param requests the requests value to set.
     * @return the JitNetworkAccessPolicyProperties object itself.
     */
    public JitNetworkAccessPolicyProperties withRequests(List<JitNetworkAccessRequestInner> requests) {
        this.requests = requests;
        return this;
    }

    /**
     * Get the provisioningState property: Gets the provisioning state of the Just-in-Time policy.
     *
     * @return the provisioningState value.
     */
    public String provisioningState() {
        return this.provisioningState;
    }

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

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