Skip to content

Fixing 7349803 in Provider and Service Client Adapter Layers #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public class DpmPsBackupProvider : IPsBackupProvider
Dictionary<System.Enum, object> ProviderData { get; set; }
ServiceClientAdapter ServiceClientAdapter { get; set; }

/// <summary>
/// Initializes the provider with the data recieved from the cmdlet layer
/// </summary>
/// <param name="providerData">Data from the cmdlet layer intended for the provider</param>
/// <param name="serviceClientAdapter">Service client adapter for communicating with the backend service</param>
public void Initialize(Dictionary<System.Enum, object> providerData, ServiceClientAdapter serviceClientAdapter)
{
this.ProviderData = providerData;
Expand Down Expand Up @@ -88,6 +93,10 @@ public ServiceClientModel.ProtectionPolicyResponse ModifyPolicy()
throw new NotImplementedException();
}

/// <summary>
/// Lists backup management servers registered with the recovery services vault
/// </summary>
/// <returns></returns>
public List<Models.BackupEngineBase> ListBackupManagementServers()
{
string name = (string)this.ProviderData[ContainerParams.Name];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,21 @@ public class IaasVmPsBackupProvider : IPsBackupProvider
Dictionary<System.Enum, object> ProviderData { get; set; }
ServiceClientAdapter ServiceClientAdapter { get; set; }

/// <summary>
/// Initializes the provider with the data recieved from the cmdlet layer
/// </summary>
/// <param name="providerData">Data from the cmdlet layer intended for the provider</param>
/// <param name="serviceClientAdapter">Service client adapter for communicating with the backend service</param>
public void Initialize(Dictionary<System.Enum, object> providerData, ServiceClientAdapter serviceClientAdapter)
{
this.ProviderData = providerData;
this.ServiceClientAdapter = serviceClientAdapter;
}

/// <summary>
/// Triggers the enable protection operation for the given item
/// </summary>
/// <returns>The job response returned from the service</returns>
public BaseRecoveryServicesJobResponse EnableProtection()
{
string azureVMName = (string)ProviderData[ItemParams.AzureVMName];
Expand Down Expand Up @@ -130,6 +139,10 @@ public BaseRecoveryServicesJobResponse EnableProtection()
serviceClientRequest);
}

/// <summary>
/// Triggers the disable protection operation for the given item
/// </summary>
/// <returns>The job response returned from the service</returns>
public BaseRecoveryServicesJobResponse DisableProtection()
{
bool deleteBackupData = (bool)ProviderData[ItemParams.DeleteBackupData];
Expand Down Expand Up @@ -189,6 +202,10 @@ public BaseRecoveryServicesJobResponse DisableProtection()
}
}

/// <summary>
/// Triggers the backup operation for the given item
/// </summary>
/// <returns>The job response returned from the service</returns>
public BaseRecoveryServicesJobResponse TriggerBackup()
{
ItemBase item = (ItemBase)ProviderData[ItemParams.Item];
Expand All @@ -197,6 +214,10 @@ public BaseRecoveryServicesJobResponse TriggerBackup()
IdUtils.GetValueByName(iaasVmItem.Id, IdUtils.IdNames.ProtectedItemName));
}

/// <summary>
/// Triggers the recovery operation for the given recovery point
/// </summary>
/// <returns>The job response returned from the service</returns>
public BaseRecoveryServicesJobResponse TriggerRestore()
{
AzureVmRecoveryPoint rp = ProviderData[RestoreBackupItemParams.RecoveryPoint]
Expand All @@ -216,6 +237,10 @@ public ProtectedItemResponse GetProtectedItem()
throw new NotImplementedException();
}

/// <summary>
/// Fetches the detail info for the given recovery point
/// </summary>
/// <returns>Recovery point detail as returned by the service</returns>
public CmdletModel.RecoveryPointBase GetRecoveryPointDetails()
{
AzureVmItem item = ProviderData[GetRecoveryPointParams.Item]
Expand All @@ -231,6 +256,10 @@ public CmdletModel.RecoveryPointBase GetRecoveryPointDetails()
return RecoveryPointConversions.GetPSAzureRecoveryPoints(rpResponse, item);
}

/// <summary>
/// Lists recovery points generated for the given item
/// </summary>
/// <returns>List of recovery point PowerShell model objects</returns>
public List<CmdletModel.RecoveryPointBase> ListRecoveryPoints()
{
DateTime startDate = (DateTime)(ProviderData[GetRecoveryPointParams.StartDate]);
Expand Down Expand Up @@ -258,6 +287,10 @@ public CmdletModel.RecoveryPointBase GetRecoveryPointDetails()
return RecoveryPointConversions.GetPSAzureRecoveryPoints(rpListResponse, item);
}

/// <summary>
/// Creates policy given the provider data
/// </summary>
/// <returns>Created policy object as returned by the service</returns>
public ProtectionPolicyResponse CreatePolicy()
{
string policyName = (string)ProviderData[PolicyParams.PolicyName];
Expand Down Expand Up @@ -312,6 +345,10 @@ public ProtectionPolicyResponse CreatePolicy()
serviceClientRequest);
}

/// <summary>
/// Modifies policy using the provider data
/// </summary>
/// <returns>Modified policy object as returned by the service</returns>
public ProtectionPolicyResponse ModifyPolicy()
{
RetentionPolicyBase retentionPolicy =
Expand Down Expand Up @@ -383,6 +420,10 @@ public ProtectionPolicyResponse ModifyPolicy()
serviceClientRequest);
}

/// <summary>
/// Lists protection containers according to the provider data
/// </summary>
/// <returns>List of protection containers</returns>
public List<ContainerBase> ListProtectionContainers()
{
Models.ContainerType containerType =
Expand Down Expand Up @@ -433,6 +474,10 @@ public List<ContainerBase> ListProtectionContainers()
throw new NotImplementedException();
}

/// <summary>
/// Lists protected items protected by the recovery services vault according to the provider data
/// </summary>
/// <returns>List of protected items</returns>
public List<ItemBase> ListProtectedItems()
{
ContainerBase container =
Expand Down Expand Up @@ -550,6 +595,10 @@ public List<ItemBase> ListProtectedItems()
return itemModels;
}

/// <summary>
/// Constructs the schedule policy object with default inits
/// </summary>
/// <returns>Default schedule policy object</returns>
public SchedulePolicyBase GetDefaultSchedulePolicyObject()
{
CmdletModel.SimpleSchedulePolicy defaultSchedule = new CmdletModel.SimpleSchedulePolicy();
Expand All @@ -566,6 +615,10 @@ public SchedulePolicyBase GetDefaultSchedulePolicyObject()
return defaultSchedule;
}

/// <summary>
/// Constructs the retention policy object with default inits
/// </summary>
/// <returns>Default retention policy object</returns>
public RetentionPolicyBase GetDefaultRetentionPolicyObject()
{
CmdletModel.LongTermRetentionPolicy defaultRetention = new CmdletModel.LongTermRetentionPolicy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public class MabPsBackupProvider : IPsBackupProvider
Dictionary<System.Enum, object> ProviderData { get; set; }
ServiceClientAdapter ServiceClientAdapter { get; set; }

/// <summary>
/// Initializes the provider with the data recieved from the cmdlet layer
/// </summary>
/// <param name="providerData">Data from the cmdlet layer intended for the provider</param>
/// <param name="serviceClientAdapter">Service client adapter for communicating with the backend service</param>
public void Initialize(Dictionary<System.Enum, object> providerData, ServiceClientAdapter serviceClientAdapter)
{
this.ProviderData = providerData;
Expand Down Expand Up @@ -85,6 +90,10 @@ public ProtectionPolicyResponse ModifyPolicy()
throw new NotImplementedException();
}

/// <summary>
/// Lists containers registered to the recovery services vault according to the provider data
/// </summary>
/// <returns>List of protection containers</returns>
public List<Models.ContainerBase> ListProtectionContainers()
{
string name = (string)this.ProviderData[ContainerParams.Name];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public PsBackupProviderManager(Dictionary<System.Enum, object> providerDataIn, S
serviceClientAdapter = serviceClientAdapterIn;
}

/// <summary>
/// Gets an instance of the provider based on the container type and backup management type (optional)
/// </summary>
/// <param name="containerType">Type of the container</param>
/// <param name="backupManagementType">Type of the backup management type (optional)</param>
/// <returns></returns>
public IPsBackupProvider GetProviderInstance
(
ContainerType containerType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public partial class ServiceClientAdapter
/// <summary>
/// Fetches protection containers in the vault according to the query params
/// </summary>
/// <param name="parameters"></param>
/// <returns></returns>
/// <param name="parameters">Query parameters</param>
/// <returns>List of protection containers</returns>
public IEnumerable<ProtectionContainerResource> ListContainers(
ProtectionContainerListQueryParams queryParams)
{
Expand All @@ -42,10 +42,10 @@ public IEnumerable<ProtectionContainerResource> ListContainers(
}

/// <summary>
/// Fetches backup engine in the vault according to the query params
/// Fetches backup engines in the vault according to the query params
/// </summary>
/// <param name="parameters"></param>
/// <returns></returns>
/// <param name="parameters">Query parameters</param>
/// <returns>List of backup engines</returns>
public IEnumerable<BackupEngineResource> ListBackupEngines(BackupEngineListQueryParams queryParams)
{
PaginationRequest paginationParam = new PaginationRequest();
Expand All @@ -63,7 +63,7 @@ public IEnumerable<BackupEngineResource> ListBackupEngines(BackupEngineListQuery
/// <summary>
/// Triggers refresh of container catalog in service
/// </summary>
/// <returns></returns>
/// <returns>Response of the job created in the service</returns>
public BaseRecoveryServicesJobResponse RefreshContainers()
{
string resourceName = BmsAdapter.GetResourceName();
Expand All @@ -78,9 +78,8 @@ public BaseRecoveryServicesJobResponse RefreshContainers()
}

/// <summary>
/// Unregister a container in service
/// Triggers unregister of a container in service
/// </summary>
/// <returns></returns>
public AzureOperationResponse UnregisterContainers(string containerName)
{
string resourceName = BmsAdapter.GetResourceName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ServiceClient
{
public partial class ServiceClientAdapter
{
/// <summary>
/// Creates a new protected item or updates an already existing protected item
/// </summary>
/// <param name="containerName">Name of the container which this item belongs to</param>
/// <param name="protectedItemName">Name of the item</param>
/// <param name="request">Protected item create or update request</param>
/// <returns>Job created in the service for this operation</returns>
public BaseRecoveryServicesJobResponse CreateOrUpdateProtectedItem(
string containerName,
string protectedItemName,
Expand All @@ -42,6 +49,12 @@ public BaseRecoveryServicesJobResponse CreateOrUpdateProtectedItem(
BmsAdapter.CmdletCancellationToken).Result;
}

/// <summary>
/// Deletes a protected item
/// </summary>
/// <param name="containerName">Name of the container which this item belongs to</param>
/// <param name="protectedItemName">Name of the item</param>
/// <returns>Job created in the service for this operation</returns>
public BaseRecoveryServicesJobResponse DeleteProtectedItem(
string containerName,
string protectedItemName)
Expand All @@ -59,6 +72,13 @@ public BaseRecoveryServicesJobResponse DeleteProtectedItem(
BmsAdapter.CmdletCancellationToken).Result;
}

/// <summary>
/// Gets a protected item
/// </summary>
/// <param name="containerName">Name of the container which this item belongs to</param>
/// <param name="protectedItemName">Name of the item</param>
/// <param name="queryFilter">Query filter</param>
/// <returns>Protected item</returns>
public ProtectedItemResponse GetProtectedItem(
string containerName,
string protectedItemName,
Expand All @@ -78,6 +98,13 @@ public ProtectedItemResponse GetProtectedItem(
BmsAdapter.CmdletCancellationToken).Result;
}

/// <summary>
/// List protected items protected by the Recovery Services vault according to the query params
/// and pagination params.
/// </summary>
/// <param name="queryFilter">Query params</param>
/// <param name="paginationParams">Pagination params</param>
/// <returns>List of protected items</returns>
public ProtectedItemListResponse ListProtectedItem(
ProtectedItemListQueryParam queryFilter,
PaginationRequest paginationParams = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ServiceClient
{
public partial class ServiceClientAdapter
{
/// <summary>
/// Gets a job
/// </summary>
/// <param name="jobId">ID of the job</param>
/// <returns>Job response returned by the service</returns>
public JobResponse GetJob(string jobId)
{
string resourceName = BmsAdapter.GetResourceName();
Expand All @@ -32,6 +37,18 @@ public JobResponse GetJob(string jobId)
BmsAdapter.CmdletCancellationToken).Result;
}

/// <summary>
/// Lists jobs according to the parameters
/// </summary>
/// <param name="jobId">ID of the job</param>
/// <param name="status">Status of the job</param>
/// <param name="operation">Operation represented by the job</param>
/// <param name="startTime">Time when the job started</param>
/// <param name="endTime">Time when the job finished</param>
/// <param name="backupManagementType">Backup management type of the item represented by the job</param>
/// <param name="top">Top pagination param</param>
/// <param name="skipToken">Skip token pagination param</param>
/// <returns>Job list response from the service</returns>
public JobListResponse GetJobs(
string jobId,
string status,
Expand Down Expand Up @@ -73,6 +90,11 @@ public JobListResponse GetJobs(
BmsAdapter.CmdletCancellationToken).Result;
}

/// <summary>
/// Cancels a job
/// </summary>
/// <param name="jobId">ID of the job to cancel</param>
/// <returns>Cancelled job response from the service</returns>
public BaseRecoveryServicesJobResponse CancelJob(string jobId)
{
string resourceName = BmsAdapter.GetResourceName();
Expand All @@ -86,6 +108,12 @@ public BaseRecoveryServicesJobResponse CancelJob(string jobId)
BmsAdapter.CmdletCancellationToken).Result;
}

/// <summary>
/// Gets the job operation status
/// </summary>
/// <param name="jobId">ID of the job</param>
/// <param name="operationId">ID of the operation associated with the job</param>
/// <returns>Job response returned by the service</returns>
public JobResponse GetJobOperationStatus(string jobId, string operationId)
{
string resourceName = BmsAdapter.GetResourceName();
Expand All @@ -102,6 +130,16 @@ public JobResponse GetJobOperationStatus(string jobId, string operationId)

#region private helpers

/// <summary>
/// Constructs the query object based on the input parameters
/// </summary>
/// <param name="backupManagementType">Backup management type of the item associated with the job</param>
/// <param name="startTime">Time when the job started</param>
/// <param name="endTime">Time when the job ended</param>
/// <param name="jobId">ID of the job</param>
/// <param name="status">Status of the job</param>
/// <param name="operation">ID of operation associated with the job</param>
/// <returns></returns>
public CommonJobQueryFilters GetQueryObject(
string backupManagementType,
DateTime startTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ServiceClient
{
public partial class ServiceClientAdapter
{
/// <summary>
/// Gets result of the refresh container operation using the operation tracking URL
/// </summary>
/// <param name="operationResultLink">Operation tracking URL</param>
/// <returns>Job response returned by the service</returns>
public BaseRecoveryServicesJobResponse GetRefreshContainerOperationResultByURL(
string operationResultLink)
{
Expand All @@ -34,6 +39,11 @@ public BaseRecoveryServicesJobResponse GetRefreshContainerOperationResultByURL(
BmsAdapter.CmdletCancellationToken).Result;
}

/// <summary>
/// Gets result of a generic operation on the protected item using the operation tracking URL
/// </summary>
/// <param name="operationResultLink">Operation tracking URL</param>
/// <returns>Operation status response returned by the service</returns>
public BackUpOperationStatusResponse GetProtectedItemOperationStatusByURL(
string operationResultLink)
{
Expand Down
Loading