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

package com.azure.resourcemanager.dnsresolver.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.ProxyResource;
import com.azure.core.management.SystemData;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.dnsresolver.models.ForwardingRuleState;
import com.azure.resourcemanager.dnsresolver.models.ProvisioningState;
import com.azure.resourcemanager.dnsresolver.models.TargetDnsServer;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;

/** Describes a forwarding rule within a DNS forwarding ruleset. */
@Fluent
public final class ForwardingRuleInner extends ProxyResource {
    /*
     * ETag of the forwarding rule.
     */
    @JsonProperty(value = "etag", access = JsonProperty.Access.WRITE_ONLY)
    private String etag;

    /*
     * Properties of the forwarding rule.
     */
    @JsonProperty(value = "properties", required = true)
    private ForwardingRuleProperties innerProperties = new ForwardingRuleProperties();

    /*
     * Metadata pertaining to creation and last modification of the resource.
     */
    @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY)
    private SystemData systemData;

    /**
     * Get the etag property: ETag of the forwarding rule.
     *
     * @return the etag value.
     */
    public String etag() {
        return this.etag;
    }

    /**
     * Get the innerProperties property: Properties of the forwarding rule.
     *
     * @return the innerProperties value.
     */
    private ForwardingRuleProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the systemData property: Metadata pertaining to creation and last modification of the resource.
     *
     * @return the systemData value.
     */
    public SystemData systemData() {
        return this.systemData;
    }

    /**
     * Get the domainName property: The domain name for the forwarding rule.
     *
     * @return the domainName value.
     */
    public String domainName() {
        return this.innerProperties() == null ? null : this.innerProperties().domainName();
    }

    /**
     * Set the domainName property: The domain name for the forwarding rule.
     *
     * @param domainName the domainName value to set.
     * @return the ForwardingRuleInner object itself.
     */
    public ForwardingRuleInner withDomainName(String domainName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ForwardingRuleProperties();
        }
        this.innerProperties().withDomainName(domainName);
        return this;
    }

    /**
     * Get the targetDnsServers property: DNS servers to forward the DNS query to.
     *
     * @return the targetDnsServers value.
     */
    public List<TargetDnsServer> targetDnsServers() {
        return this.innerProperties() == null ? null : this.innerProperties().targetDnsServers();
    }

    /**
     * Set the targetDnsServers property: DNS servers to forward the DNS query to.
     *
     * @param targetDnsServers the targetDnsServers value to set.
     * @return the ForwardingRuleInner object itself.
     */
    public ForwardingRuleInner withTargetDnsServers(List<TargetDnsServer> targetDnsServers) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ForwardingRuleProperties();
        }
        this.innerProperties().withTargetDnsServers(targetDnsServers);
        return this;
    }

    /**
     * Get the metadata property: Metadata attached to the forwarding rule.
     *
     * @return the metadata value.
     */
    public Map<String, String> metadata() {
        return this.innerProperties() == null ? null : this.innerProperties().metadata();
    }

    /**
     * Set the metadata property: Metadata attached to the forwarding rule.
     *
     * @param metadata the metadata value to set.
     * @return the ForwardingRuleInner object itself.
     */
    public ForwardingRuleInner withMetadata(Map<String, String> metadata) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ForwardingRuleProperties();
        }
        this.innerProperties().withMetadata(metadata);
        return this;
    }

    /**
     * Get the forwardingRuleState property: The state of forwarding rule.
     *
     * @return the forwardingRuleState value.
     */
    public ForwardingRuleState forwardingRuleState() {
        return this.innerProperties() == null ? null : this.innerProperties().forwardingRuleState();
    }

    /**
     * Set the forwardingRuleState property: The state of forwarding rule.
     *
     * @param forwardingRuleState the forwardingRuleState value to set.
     * @return the ForwardingRuleInner object itself.
     */
    public ForwardingRuleInner withForwardingRuleState(ForwardingRuleState forwardingRuleState) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ForwardingRuleProperties();
        }
        this.innerProperties().withForwardingRuleState(forwardingRuleState);
        return this;
    }

    /**
     * Get the provisioningState property: The current provisioning state of the forwarding rule. This is a read-only
     * property and any attempt to set this value will be ignored.
     *
     * @return the provisioningState value.
     */
    public ProvisioningState 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 ForwardingRuleInner"));
        } else {
            innerProperties().validate();
        }
    }

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