mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-09 01:32:38 -05:00
* Enabled backup to and restore from URL * Created RPC, but when process tries to load Microsoft.Azure.Storage.Blob.dll, it crashes * Added create shared access token * Code refactor * Minor changes * Changed RPC path * Moved createSas RPC to the newly created BlobService, fixed PR comments * Added sas expiration date parameter to the RPC * Added copyright headers * Removed ConnectionInstance property from BlobService * Removed unhelpful comment * Removed unused using statements * Changed copy/paste comments * Disposable objects fix * Small formatting fix * Changed backup to/restore from url supported device types * Added backup to url integration test * Created restore integration test. Test are now getting azure blob params from env variables instead of file. * Culture invariant epiration date param, fixed comment, and typo * Updated headers * PR comments fix * Changed supported device type logic * string localization fix * String formatting fix * build failure fix * Typo * Updated supported restore device types
179 lines
5.5 KiB
C#
179 lines
5.5 KiB
C#
//
|
|
// 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
|
|
{
|
|
/// <summary>
|
|
/// Restore request parameters
|
|
/// </summary>
|
|
public class RestoreParams : GeneralRequestDetails, IScriptableRequestParams
|
|
{
|
|
/// <summary>
|
|
/// Restore session id. The parameter is optional and if passed, an existing plan will be used
|
|
/// </summary>
|
|
internal string SessionId
|
|
{
|
|
get
|
|
{
|
|
return GetOptionValue<string>(RestoreOptionsHelper.SessionId);
|
|
}
|
|
set
|
|
{
|
|
SetOptionValue(RestoreOptionsHelper.SessionId, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// The Uri to find the connection to do the restore operations
|
|
/// </summary>
|
|
public string OwnerUri { get; set; }
|
|
|
|
/// <summary>
|
|
/// Comma delimited list of backup files
|
|
/// </summary>
|
|
internal string BackupFilePaths
|
|
{
|
|
get
|
|
{
|
|
return GetOptionValue<string>(RestoreOptionsHelper.BackupFilePaths);
|
|
}
|
|
set
|
|
{
|
|
SetOptionValue(RestoreOptionsHelper.BackupFilePaths, value);
|
|
}
|
|
}
|
|
|
|
internal int DeviceType
|
|
{
|
|
get
|
|
{
|
|
return GetOptionValue<int>(RestoreOptionsHelper.DeviceType);
|
|
}
|
|
set
|
|
{
|
|
SetOptionValue(RestoreOptionsHelper.DeviceType, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Target Database name to restore to
|
|
/// </summary>
|
|
internal string TargetDatabaseName
|
|
{
|
|
get
|
|
{
|
|
return GetOptionValue<string>(RestoreOptionsHelper.TargetDatabaseName);
|
|
}
|
|
set
|
|
{
|
|
SetOptionValue(RestoreOptionsHelper.TargetDatabaseName, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Source Database name to restore from
|
|
/// </summary>
|
|
internal string SourceDatabaseName
|
|
{
|
|
get
|
|
{
|
|
return GetOptionValue<string>(RestoreOptionsHelper.SourceDatabaseName);
|
|
}
|
|
set
|
|
{
|
|
SetOptionValue(RestoreOptionsHelper.SourceDatabaseName, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// If set to true, the db files will be relocated to default data location in the server
|
|
/// </summary>
|
|
internal bool RelocateDbFiles
|
|
{
|
|
get
|
|
{
|
|
return GetOptionValue<bool>(RestoreOptionsHelper.RelocateDbFiles);
|
|
}
|
|
set
|
|
{
|
|
SetOptionValue(RestoreOptionsHelper.RelocateDbFiles, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// If set to true, the backup files will be used to create restore plan otehrwise the source database name will be used
|
|
/// </summary>
|
|
internal bool ReadHeaderFromMedia
|
|
{
|
|
get
|
|
{
|
|
//Default is true for now for backward compatibility
|
|
return Options.ContainsKey(RestoreOptionsHelper.ReadHeaderFromMedia) ? GetOptionValue<bool>(RestoreOptionsHelper.ReadHeaderFromMedia) : true;
|
|
}
|
|
set
|
|
{
|
|
SetOptionValue(RestoreOptionsHelper.ReadHeaderFromMedia, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
internal IEnumerable<string> SelectedBackupSets
|
|
{
|
|
get
|
|
{
|
|
var selectedBackupSets = GetOptionValue<object>(RestoreOptionsHelper.SelectedBackupSets);
|
|
if (selectedBackupSets != null)
|
|
{
|
|
JArray array = selectedBackupSets as JArray;
|
|
if(array != null)
|
|
{
|
|
return array.ToObject<IEnumerable<string>>();
|
|
}
|
|
else
|
|
{
|
|
IEnumerable<string> list = selectedBackupSets as IEnumerable<string>;
|
|
return list;
|
|
}
|
|
|
|
}
|
|
return null;
|
|
}
|
|
set
|
|
{
|
|
SetOptionValue(RestoreOptionsHelper.SelectedBackupSets, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// The executation mode for the operation. default is execution
|
|
/// </summary>
|
|
public TaskExecutionMode TaskExecutionMode { get; set; }
|
|
|
|
/// <summary>
|
|
/// Optional parameter which indicates whether to overwrite target database by source database name.
|
|
/// </summary>
|
|
internal bool OverwriteTargetDatabase
|
|
{
|
|
get
|
|
{
|
|
return Options.ContainsKey(RestoreOptionsHelper.OverwriteTargetDatabase) ? GetOptionValue<bool>(RestoreOptionsHelper.OverwriteTargetDatabase) : false;
|
|
}
|
|
set
|
|
{
|
|
SetOptionValue(RestoreOptionsHelper.OverwriteTargetDatabase, value);
|
|
}
|
|
}
|
|
}
|
|
}
|