//
// 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.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.Contracts
{
///
/// Restore request parameters
///
public class RestoreParams : GeneralRequestDetails
{
///
/// 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);
}
}
///
/// 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);
}
}
///
/// Ids of the backup set to restore
///
internal string[] SelectedBackupSets
{
get
{
return GetOptionValue(RestoreOptionsHelper.SelectedBackupSets);
}
set
{
SetOptionValue(RestoreOptionsHelper.SelectedBackupSets, value);
}
}
}
///
/// Restore response
///
public class RestoreResponse
{
///
/// Indicates if the restore task created successfully
///
public bool Result { get; set; }
///
/// The task id assosiated witht the restore operation
///
public string TaskId { get; set; }
///
/// Errors occurred while creating the restore operation task
///
public string ErrorMessage { get; set; }
}
///
/// Database file info
///
public class RestoreDatabaseFileInfo
{
///
/// File type (Rows Data, Log ...)
///
public string FileType { get; set; }
///
/// Logical Name
///
public string LogicalFileName { get; set; }
///
/// Original location of the file to restore to
///
public string OriginalFileName { get; set; }
///
/// The file to restore to
///
public string RestoreAsFileName { get; set; }
}
///
/// Restore Plan Response
///
public class RestorePlanResponse
{
///
/// Restore session id, can be used in restore request to use an existing restore plan
///
public string SessionId { get; set; }
///
/// The list of backup sets to restore
///
public DatabaseFileInfo[] BackupSetsToRestore { get; set; }
///
/// Indicates whether the restore operation is supported
///
public bool CanRestore { get; set; }
///
/// Errors occurred while creating restore plan
///
public string ErrorMessage { get; set; }
///
/// The db files included in the backup file
///
public IEnumerable DbFiles { get; set; }
///
/// Database names extracted from backup sets
///
public string[] DatabaseNamesFromBackupSets { get; set; }
///
/// For testing purpose to verify the target database
///
internal string DatabaseName { get; set; }
///
/// Plan details
///
public Dictionary PlanDetails { get; set; }
}
public class RestoreRequest
{
public static readonly
RequestType Type =
RequestType.Create("disasterrecovery/restore");
}
public class RestorePlanRequest
{
public static readonly
RequestType Type =
RequestType.Create("disasterrecovery/restoreplan");
}
}