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

package com.azure.resourcemanager.datalakestore.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.datalakestore.fluent.models.CreateOrUpdateVirtualNetworkRuleProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/** The parameters used to create a new virtual network rule while creating a new Data Lake Store account. */
@Fluent
public final class CreateVirtualNetworkRuleWithAccountParameters {
    /*
     * The unique name of the virtual network rule to create.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * The virtual network rule properties to use when creating a new virtual network rule.
     */
    @JsonProperty(value = "properties", required = true)
    private CreateOrUpdateVirtualNetworkRuleProperties innerProperties =
        new CreateOrUpdateVirtualNetworkRuleProperties();

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

    /**
     * Get the name property: The unique name of the virtual network rule to create.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: The unique name of the virtual network rule to create.
     *
     * @param name the name value to set.
     * @return the CreateVirtualNetworkRuleWithAccountParameters object itself.
     */
    public CreateVirtualNetworkRuleWithAccountParameters withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the innerProperties property: The virtual network rule properties to use when creating a new virtual network
     * rule.
     *
     * @return the innerProperties value.
     */
    private CreateOrUpdateVirtualNetworkRuleProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the subnetId property: The resource identifier for the subnet.
     *
     * @return the subnetId value.
     */
    public String subnetId() {
        return this.innerProperties() == null ? null : this.innerProperties().subnetId();
    }

    /**
     * Set the subnetId property: The resource identifier for the subnet.
     *
     * @param subnetId the subnetId value to set.
     * @return the CreateVirtualNetworkRuleWithAccountParameters object itself.
     */
    public CreateVirtualNetworkRuleWithAccountParameters withSubnetId(String subnetId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CreateOrUpdateVirtualNetworkRuleProperties();
        }
        this.innerProperties().withSubnetId(subnetId);
        return this;
    }

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

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