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

package com.azure.resourcemanager.datalakeanalytics.models;

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

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

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

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

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

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

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

    /**
     * Get the startIpAddress property: The start IP address for the firewall rule. This can be either ipv4 or ipv6.
     * Start and End should be in the same protocol.
     *
     * @return the startIpAddress value.
     */
    public String startIpAddress() {
        return this.innerProperties() == null ? null : this.innerProperties().startIpAddress();
    }

    /**
     * Set the startIpAddress property: The start IP address for the firewall rule. This can be either ipv4 or ipv6.
     * Start and End should be in the same protocol.
     *
     * @param startIpAddress the startIpAddress value to set.
     * @return the CreateFirewallRuleWithAccountParameters object itself.
     */
    public CreateFirewallRuleWithAccountParameters withStartIpAddress(String startIpAddress) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CreateOrUpdateFirewallRuleProperties();
        }
        this.innerProperties().withStartIpAddress(startIpAddress);
        return this;
    }

    /**
     * Get the endIpAddress property: The end IP address for the firewall rule. This can be either ipv4 or ipv6. Start
     * and End should be in the same protocol.
     *
     * @return the endIpAddress value.
     */
    public String endIpAddress() {
        return this.innerProperties() == null ? null : this.innerProperties().endIpAddress();
    }

    /**
     * Set the endIpAddress property: The end IP address for the firewall rule. This can be either ipv4 or ipv6. Start
     * and End should be in the same protocol.
     *
     * @param endIpAddress the endIpAddress value to set.
     * @return the CreateFirewallRuleWithAccountParameters object itself.
     */
    public CreateFirewallRuleWithAccountParameters withEndIpAddress(String endIpAddress) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CreateOrUpdateFirewallRuleProperties();
        }
        this.innerProperties().withEndIpAddress(endIpAddress);
        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 CreateFirewallRuleWithAccountParameters"));
        }
        if (innerProperties() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property innerProperties in model CreateFirewallRuleWithAccountParameters"));
        } else {
            innerProperties().validate();
        }
    }

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