Skip to content

Commit

Permalink
Merge pull request #70 from MabOneSdk/csm-panbha1
Browse files Browse the repository at this point in the history
recoverypoint5
  • Loading branch information
panbha committed Jul 18, 2015
2 parents f54c81b + 99e6ae2 commit f9ae9e9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ public IEnumerable<CSMRecoveryPointResponse> ListRecoveryPoints(string container
return (response != null) ? response.CSMRecoveryPointListResponse.Value : null;
}

/// <summary>
/// Lists recovery points for specified item
/// </summary>
/// <param name="containerName"></param>
/// <param name="itemName"></param>
/// <returns></returns>
public CSMRecoveryPointResponse GetRecoveryPoint(string containerName, string itemName, string recoveryPointName)
{
var response = AzureBackupClient.RecoveryPoint.GetAsync(GetCustomRequestHeaders(), containerName, itemName, recoveryPointName, CmdletCancellationToken).Result;
return (response != null) ? response.Value : null;
}

/// <summary>
/// Lists recovery points for specified item
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,34 @@ public override void ExecuteCmdlet()
{
WriteDebug("Making client call");

var recoveryPointListResponse = AzureBackupClient.ListRecoveryPoints(Item.ContainerUniqueName, Item.ItemName);

if (recoveryPointListResponse != null)
if (Id != null)
{
WriteDebug("Received recovery point response");

IEnumerable<CSMRecoveryPointResponse> recoveryPointObjects = null;
if (Id != null)
CSMRecoveryPointResponse recoveryPointObject = AzureBackupClient.GetRecoveryPoint(Item.ContainerUniqueName, Item.ItemName, Id);
if (recoveryPointObject != null)
{
WriteAzureBackupRecoveryPoint(recoveryPointObject, Item);
}
else
{
WriteDebug(string.Format("{0}{1}", "No recovery point exist with Id := ", Id));
}
}
else
{
IEnumerable<CSMRecoveryPointResponse> recoveryPointListResponse = AzureBackupClient.ListRecoveryPoints(Item.ContainerUniqueName, Item.ItemName);
if (recoveryPointListResponse != null &&
recoveryPointListResponse.Count<CSMRecoveryPointResponse>() > 0)
{
CSMRecoveryPointResponse recoveryPointObject = null;
recoveryPointObjects = recoveryPointListResponse.Where(x => x.Name.Equals(Id, System.StringComparison.InvariantCultureIgnoreCase));
if (recoveryPointObjects != null && recoveryPointObjects.Any<CSMRecoveryPointResponse>())
IEnumerable<CSMRecoveryPointResponse> recoveryPointObjects = recoveryPointListResponse.OrderByDescending(x => x.Properties.RecoveryPointTime);
if (recoveryPointObjects.Count<CSMRecoveryPointResponse>() > 1)
{
WriteDebug("Converting response");
recoveryPointObject = recoveryPointObjects.FirstOrDefault<CSMRecoveryPointResponse>();
WriteAzureBackupRecoveryPoint(recoveryPointObject, Item);
WriteAzureBackupRecoveryPoint(recoveryPointObjects, Item);
}
else
{
WriteDebug(string.Format("{0}{1}", "No recovery point exist with Id := ", Id));
WriteAzureBackupRecoveryPoint(recoveryPointObjects.FirstOrDefault<CSMRecoveryPointResponse>(), Item);
}
}
else
{
WriteDebug("Converting response");
recoveryPointObjects = recoveryPointListResponse.OrderByDescending(x => x.Properties.RecoveryPointTime);
WriteAzureBackupRecoveryPoint(recoveryPointObjects, Item);
}
}
});
}
Expand Down
Binary file not shown.

0 comments on commit f9ae9e9

Please sign in to comment.