// 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.management.ProxyResource;
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 JitNetworkAccessPolicy model. */
@Fluent
public final class JitNetworkAccessPolicyInner extends ProxyResource {
    /*
     * The properties property.
     */
    @JsonProperty(value = "properties", required = true)
    private JitNetworkAccessPolicyProperties innerProperties = new JitNetworkAccessPolicyProperties();

    /*
     * Kind of the resource
     */
    @JsonProperty(value = "kind")
    private String kind;

    /*
     * Location where the resource is stored
     */
    @JsonProperty(value = "location", access = JsonProperty.Access.WRITE_ONLY)
    private String location;

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

    /**
     * Get the innerProperties property: The properties property.
     *
     * @return the innerProperties value.
     */
    private JitNetworkAccessPolicyProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the kind property: Kind of the resource.
     *
     * @return the kind value.
     */
    public String kind() {
        return this.kind;
    }

    /**
     * Set the kind property: Kind of the resource.
     *
     * @param kind the kind value to set.
     * @return the JitNetworkAccessPolicyInner object itself.
     */
    public JitNetworkAccessPolicyInner withKind(String kind) {
        this.kind = kind;
        return this;
    }

    /**
     * Get the location property: Location where the resource is stored.
     *
     * @return the location value.
     */
    public String location() {
        return this.location;
    }

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

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

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

    /**
     * Set the requests property: The requests property.
     *
     * @param requests the requests value to set.
     * @return the JitNetworkAccessPolicyInner object itself.
     */
    public JitNetworkAccessPolicyInner withRequests(List<JitNetworkAccessRequestInner> requests) {
        if (this.innerProperties() == null) {
            this.innerProperties = new JitNetworkAccessPolicyProperties();
        }
        this.innerProperties().withRequests(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.innerProperties() == null ? null : this.innerProperties().provisioningState();
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (innerProperties() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property innerProperties in model JitNetworkAccessPolicyInner"));
        } else {
            innerProperties().validate();
        }
    }

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