//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System.Collections.Generic;
using Microsoft.SqlTools.ServiceLayer.TaskServices;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Microsoft.SqlTools.Utility;
using Newtonsoft.Json.Linq;
namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.Contracts
{
///
/// Restore request parameters
///
public class RestoreParams : GeneralRequestDetails, IScriptableRequestParams
{
///
/// Restore session id. The parameter is optional and if passed, an existing plan will be used
///
internal string SessionId
{
get
{
return GetOptionValue(RestoreOptionsHelper.SessionId);
}
set
{
SetOptionValue(RestoreOptionsHelper.SessionId, value);
}
}
///
/// The Uri to find the connection to do the restore operations
///
public string OwnerUri { get; set; }
///
/// Comma delimited list of backup files
///
internal string BackupFilePaths
{
get
{
return GetOptionValue(RestoreOptionsHelper.BackupFilePaths);
}
set
{
SetOptionValue(RestoreOptionsHelper.BackupFilePaths, value);
}
}
internal int DeviceType
{
get
{
return GetOptionValue(RestoreOptionsHelper.DeviceType);
}
set
{
SetOptionValue(RestoreOptionsHelper.DeviceType, value);
}
}
///
/// Target Database name to restore to
///
internal string TargetDatabaseName
{
get
{
return GetOptionValue(RestoreOptionsHelper.TargetDatabaseName);
}
set
{
SetOptionValue(RestoreOptionsHelper.TargetDatabaseName, value);
}
}
///
/// Source Database name to restore from
///
internal string SourceDatabaseName
{
get
{
return GetOptionValue(RestoreOptionsHelper.SourceDatabaseName);
}
set
{
SetOptionValue(RestoreOptionsHelper.SourceDatabaseName, value);
}
}
///
/// If set to true, the db files will be relocated to default data location in the server
///
internal bool RelocateDbFiles
{
get
{
return GetOptionValue(RestoreOptionsHelper.RelocateDbFiles);
}
set
{
SetOptionValue(RestoreOptionsHelper.RelocateDbFiles, value);
}
}
///
/// If set to true, the backup files will be used to create restore plan otehrwise the source database name will be used
///
internal bool ReadHeaderFromMedia
{
get
{
//Default is true for now for backward compatibility
return Options.ContainsKey(RestoreOptionsHelper.ReadHeaderFromMedia) ? GetOptionValue(RestoreOptionsHelper.ReadHeaderFromMedia) : true;
}
set
{
SetOptionValue(RestoreOptionsHelper.ReadHeaderFromMedia, value);
}
}
///
/// Ids of the selected backup set to restore. If null, all backup sets will be selected. If empty list,
/// no backup sets will be selected
///
internal IEnumerable SelectedBackupSets
{
get
{
var selectedBackupSets = GetOptionValue