Skip to content
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

recoverypoint5 #70

Merged
merged 1 commit into from
Jul 18, 2015
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 @@ -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.