// 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.resourcemanager.dnsresolver.models.ForwardingRuleState;
import com.azure.resourcemanager.dnsresolver.models.TargetDnsServer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;

/** Represents the updatable properties of a forwarding rule within a DNS forwarding ruleset. */
@Fluent
public final class ForwardingRulePatchProperties {
    /*
     * DNS servers to forward the DNS query to.
     */
    @JsonProperty(value = "targetDnsServers")
    private List<TargetDnsServer> targetDnsServers;

    /*
     * Metadata attached to the forwarding rule.
     */
    @JsonProperty(value = "metadata")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, String> metadata;

    /*
     * The state of forwarding rule.
     */
    @JsonProperty(value = "forwardingRuleState")
    private ForwardingRuleState forwardingRuleState;

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

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

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

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

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

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

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (targetDnsServers() != null) {
            targetDnsServers().forEach(e -> e.validate());
        }
    }
}
