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

package com.azure.resourcemanager.dataprotection.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * AdHocBackupRuleOptions
 *
 * <p>Adhoc backup rules.
 */
@Fluent
public final class AdHocBackupRuleOptions {
    /*
     * The ruleName property.
     */
    @JsonProperty(value = "ruleName", required = true)
    private String ruleName;

    /*
     * AdhocBackupTriggerOption
     *
     * Adhoc backup trigger option
     */
    @JsonProperty(value = "triggerOption", required = true)
    private AdhocBackupTriggerOption triggerOption;

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

    /**
     * Get the ruleName property: The ruleName property.
     *
     * @return the ruleName value.
     */
    public String ruleName() {
        return this.ruleName;
    }

    /**
     * Set the ruleName property: The ruleName property.
     *
     * @param ruleName the ruleName value to set.
     * @return the AdHocBackupRuleOptions object itself.
     */
    public AdHocBackupRuleOptions withRuleName(String ruleName) {
        this.ruleName = ruleName;
        return this;
    }

    /**
     * Get the triggerOption property: AdhocBackupTriggerOption
     *
     * <p>Adhoc backup trigger option.
     *
     * @return the triggerOption value.
     */
    public AdhocBackupTriggerOption triggerOption() {
        return this.triggerOption;
    }

    /**
     * Set the triggerOption property: AdhocBackupTriggerOption
     *
     * <p>Adhoc backup trigger option.
     *
     * @param triggerOption the triggerOption value to set.
     * @return the AdHocBackupRuleOptions object itself.
     */
    public AdHocBackupRuleOptions withTriggerOption(AdhocBackupTriggerOption triggerOption) {
        this.triggerOption = triggerOption;
        return this;
    }

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

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