// 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 JitNetworkAccessPolicyInitiateRequest model. */
@Fluent
public final class JitNetworkAccessPolicyInitiateRequest {
    /*
     * A list of virtual machines & ports to open access for
     */
    @JsonProperty(value = "virtualMachines", required = true)
    private List<JitNetworkAccessPolicyInitiateVirtualMachine> virtualMachines;

    /*
     * The justification for making the initiate request
     */
    @JsonProperty(value = "justification")
    private String justification;

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

    /**
     * Get the virtualMachines property: A list of virtual machines &amp; ports to open access for.
     *
     * @return the virtualMachines value.
     */
    public List<JitNetworkAccessPolicyInitiateVirtualMachine> virtualMachines() {
        return this.virtualMachines;
    }

    /**
     * Set the virtualMachines property: A list of virtual machines &amp; ports to open access for.
     *
     * @param virtualMachines the virtualMachines value to set.
     * @return the JitNetworkAccessPolicyInitiateRequest object itself.
     */
    public JitNetworkAccessPolicyInitiateRequest withVirtualMachines(
        List<JitNetworkAccessPolicyInitiateVirtualMachine> virtualMachines) {
        this.virtualMachines = virtualMachines;
        return this;
    }

    /**
     * Get the justification property: The justification for making the initiate request.
     *
     * @return the justification value.
     */
    public String justification() {
        return this.justification;
    }

    /**
     * Set the justification property: The justification for making the initiate request.
     *
     * @param justification the justification value to set.
     * @return the JitNetworkAccessPolicyInitiateRequest object itself.
     */
    public JitNetworkAccessPolicyInitiateRequest withJustification(String justification) {
        this.justification = justification;
        return this;
    }

    /**
     * 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 JitNetworkAccessPolicyInitiateRequest"));
        } else {
            virtualMachines().forEach(e -> e.validate());
        }
    }

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