// 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;

/** Class encapsulating target details, used where the destination is not a datasource. */
@Fluent
public final class TargetDetails {
    /*
     * Restore operation may create multiple files inside location pointed by Url
     * Below will be the common prefix for all of them
     */
    @JsonProperty(value = "filePrefix", required = true)
    private String filePrefix;

    /*
     * Denotes the target location where the data will be restored,
     * string value for the enum
     * {Microsoft.Internal.AzureBackup.DataProtection.Common.Interface.RestoreTargetLocationType}
     */
    @JsonProperty(value = "restoreTargetLocationType", required = true)
    private RestoreTargetLocationType restoreTargetLocationType;

    /*
     * Url denoting the restore destination. It can point to container / file share etc
     */
    @JsonProperty(value = "url", required = true)
    private String url;

    /*
     * Full ARM Id denoting the restore destination. It is the ARM Id pointing to container / file share
     * This is optional if the target subscription can be identified with the URL field. If not
     * then this is needed if CrossSubscriptionRestore field of BackupVault is in any of the disabled states
     */
    @JsonProperty(value = "targetResourceArmId")
    private String targetResourceArmId;

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

    /**
     * Get the filePrefix property: Restore operation may create multiple files inside location pointed by Url Below
     * will be the common prefix for all of them.
     *
     * @return the filePrefix value.
     */
    public String filePrefix() {
        return this.filePrefix;
    }

    /**
     * Set the filePrefix property: Restore operation may create multiple files inside location pointed by Url Below
     * will be the common prefix for all of them.
     *
     * @param filePrefix the filePrefix value to set.
     * @return the TargetDetails object itself.
     */
    public TargetDetails withFilePrefix(String filePrefix) {
        this.filePrefix = filePrefix;
        return this;
    }

    /**
     * Get the restoreTargetLocationType property: Denotes the target location where the data will be restored, string
     * value for the enum {Microsoft.Internal.AzureBackup.DataProtection.Common.Interface.RestoreTargetLocationType}.
     *
     * @return the restoreTargetLocationType value.
     */
    public RestoreTargetLocationType restoreTargetLocationType() {
        return this.restoreTargetLocationType;
    }

    /**
     * Set the restoreTargetLocationType property: Denotes the target location where the data will be restored, string
     * value for the enum {Microsoft.Internal.AzureBackup.DataProtection.Common.Interface.RestoreTargetLocationType}.
     *
     * @param restoreTargetLocationType the restoreTargetLocationType value to set.
     * @return the TargetDetails object itself.
     */
    public TargetDetails withRestoreTargetLocationType(RestoreTargetLocationType restoreTargetLocationType) {
        this.restoreTargetLocationType = restoreTargetLocationType;
        return this;
    }

    /**
     * Get the url property: Url denoting the restore destination. It can point to container / file share etc.
     *
     * @return the url value.
     */
    public String url() {
        return this.url;
    }

    /**
     * Set the url property: Url denoting the restore destination. It can point to container / file share etc.
     *
     * @param url the url value to set.
     * @return the TargetDetails object itself.
     */
    public TargetDetails withUrl(String url) {
        this.url = url;
        return this;
    }

    /**
     * Get the targetResourceArmId property: Full ARM Id denoting the restore destination. It is the ARM Id pointing to
     * container / file share This is optional if the target subscription can be identified with the URL field. If not
     * then this is needed if CrossSubscriptionRestore field of BackupVault is in any of the disabled states.
     *
     * @return the targetResourceArmId value.
     */
    public String targetResourceArmId() {
        return this.targetResourceArmId;
    }

    /**
     * Set the targetResourceArmId property: Full ARM Id denoting the restore destination. It is the ARM Id pointing to
     * container / file share This is optional if the target subscription can be identified with the URL field. If not
     * then this is needed if CrossSubscriptionRestore field of BackupVault is in any of the disabled states.
     *
     * @param targetResourceArmId the targetResourceArmId value to set.
     * @return the TargetDetails object itself.
     */
    public TargetDetails withTargetResourceArmId(String targetResourceArmId) {
        this.targetResourceArmId = targetResourceArmId;
        return this;
    }

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

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