// 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;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;

/**
 * DeleteOption
 *
 * <p>Delete Option.
 */
@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "objectType",
    defaultImpl = DeleteOption.class)
@JsonTypeName("DeleteOption")
@JsonSubTypes({@JsonSubTypes.Type(name = "AbsoluteDeleteOption", value = AbsoluteDeleteOption.class)})
@Fluent
public class DeleteOption {
    /*
     * Duration of deletion after given timespan
     */
    @JsonProperty(value = "duration", required = true)
    private String duration;

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

    /**
     * Get the duration property: Duration of deletion after given timespan.
     *
     * @return the duration value.
     */
    public String duration() {
        return this.duration;
    }

    /**
     * Set the duration property: Duration of deletion after given timespan.
     *
     * @param duration the duration value to set.
     * @return the DeleteOption object itself.
     */
    public DeleteOption withDuration(String duration) {
        this.duration = duration;
        return this;
    }

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

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