Skip to content
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 @@ -30,15 +30,15 @@ public abstract class AzureBackupContainerCmdletBase : AzureBackupCmdletBase
{
[Parameter(Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.AzureBackupContainer, ValueFromPipeline = true)]
[ValidateNotNullOrEmpty]
public AzureBackupContainer container { get; set; }
public AzureBackupContainer Container { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}, Location: {2}", container.ResourceGroupName, container.ResourceName, container.Location));
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}, Location: {2}", Container.ResourceGroupName, Container.ResourceName, Container.Location));

InitializeAzureBackupCmdlet(container.ResourceGroupName, container.ResourceName, container.Location);
InitializeAzureBackupCmdlet(Container.ResourceGroupName, Container.ResourceName, Container.Location);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public abstract class AzureBackupDSCmdletBase : AzureBackupCmdletBase
{
[Parameter(Position = 0, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.AzureBackUpItem, ValueFromPipeline = true)]
[ValidateNotNullOrEmpty]
public AzureBackupItem item { get; set; }
public AzureBackupItem Item { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}", item.ResourceGroupName, item.ResourceName));
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}", Item.ResourceGroupName, Item.ResourceName));

InitializeAzureBackupCmdlet(item.ResourceGroupName, item.ResourceName, item.Location);
InitializeAzureBackupCmdlet(Item.ResourceGroupName, Item.ResourceName, Item.Location);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public abstract class AzureBackupItemCmdletBase : AzureBackupCmdletBase
{
[Parameter(Position = 0, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.AzureBackupItem, ValueFromPipeline = true)]
[ValidateNotNullOrEmpty]
public AzureBackupContainerContextObject item { get; set; }
public AzureBackupContainerContextObject Item { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}, Location: {2}", item.ResourceGroupName, item.ResourceName, item.Location));
InitializeAzureBackupCmdlet(item.ResourceGroupName, item.ResourceName, item.Location);
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}, Location: {2}", Item.ResourceGroupName, Item.ResourceName, Item.Location));
InitializeAzureBackupCmdlet(Item.ResourceGroupName, Item.ResourceName, Item.Location);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public override void ExecuteCmdlet()
Guid jobId = Guid.Empty;
MBS.OperationResponse triggerBackUpInfo =
AzureBackupClient.BackUp.TriggerBackUpAsync(GetCustomRequestHeaders(),
item.ContainerUniqueName,
item.Type,
item.DataSourceId,
Item.ContainerUniqueName,
Item.Type,
Item.DataSourceId,
CmdletCancellationToken).Result;

WriteVerbose("Received backup response");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets.DataSource
public class DisableAzureBackupProtection : AzureBackupDSCmdletBase
{
[Parameter(Position = 1, Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.RemoveProtectionOption)]
[ValidateSet("RetainBackupData", "DeleteBackupData")]
public string RemoveProtectionOption { get; set; }
public SwitchParameter RemoveRecoveryPoints
{
get { return DeleteBackupData; }
set { DeleteBackupData = value; }
}
private bool DeleteBackupData;

[Parameter(Position = 2, Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.Reason)]
public string Reason { get; set; }
Expand All @@ -51,12 +55,12 @@ public override void ExecuteCmdlet()
WriteVerbose("Making client call");
RemoveProtectionRequestInput input = new RemoveProtectionRequestInput()
{
RemoveProtectionOption = this.RemoveProtectionOption == null ? "RetainBackupData" : this.RemoveProtectionOption,
RemoveProtectionOption = this.DeleteBackupData ? RemoveProtectionOptions.DeleteBackupData.ToString() : RemoveProtectionOptions.RetainBackupData.ToString(),
Reason = this.Reason,
Comments = this.Comments,
};

var disbaleAzureBackupProtection = AzureBackupClient.DataSource.DisableProtectionAsync(GetCustomRequestHeaders(), item.ContainerUniqueName, item.Type, item.DataSourceId, input, CmdletCancellationToken).Result;
WriteVerbose("RemoveProtectionOption is = " + input.RemoveProtectionOption);
var disbaleAzureBackupProtection = AzureBackupClient.DataSource.DisableProtectionAsync(GetCustomRequestHeaders(), Item.ContainerUniqueName, Item.Type, Item.DataSourceId, input, CmdletCancellationToken).Result;

WriteVerbose("Received response");
WriteVerbose("Converting response");
Expand All @@ -79,5 +83,14 @@ public void WriteAzureBackupProtectionPolicy(IEnumerable<OperationResponse> sour

this.WriteObject(targetList, true);
}

public enum RemoveProtectionOptions
{
[EnumMember]
DeleteBackupData,

[EnumMember]
RetainBackupData
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ public override void ExecuteCmdlet()
WriteVerbose("Making client call");
SetProtectionRequestInput input = new SetProtectionRequestInput();
input.PolicyId = Policy.InstanceId;
if (item.GetType() == typeof(AzureBackupItem))
if (Item.GetType() == typeof(AzureBackupItem))
{
input.ProtectableObjectType = (item as AzureBackupItem).Type;
input.ProtectableObjects.Add((item as AzureBackupItem).Name);
input.ProtectableObjectType = (Item as AzureBackupItem).Type;
input.ProtectableObjects.Add((Item as AzureBackupItem).Name);
}
else if (item.GetType() == typeof(AzureBackupContainer))
else if (Item.GetType() == typeof(AzureBackupContainer))
{
WriteVerbose("Input is container Type = "+item.GetType());
if((item as AzureBackupContainer).ContainerType == ContainerType.IaasVMContainer.ToString())
WriteVerbose("Input is container Type = "+Item.GetType());
if((Item as AzureBackupContainer).ContainerType == ContainerType.IaasVMContainer.ToString())
{
WriteVerbose("container Type = " + (item as AzureBackupContainer).ContainerType);
WriteVerbose("container Type = " + (Item as AzureBackupContainer).ContainerType);
input.ProtectableObjectType = DataSourceType.VM.ToString();
input.ProtectableObjects.Add((item as AzureBackupContainer).ContainerUniqueName);
input.ProtectableObjects.Add((Item as AzureBackupContainer).ContainerUniqueName);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ public override void ExecuteCmdlet()
};

azureBackupDatasourceListResponse = AzureBackupClient.DataSource.ListAsync(DSQueryParam, GetCustomRequestHeaders(), CmdletCancellationToken).Result;
azureBackupDatasourceObjects = azureBackupDatasourceListResponse.DataSources.Objects.Where(x => x.ContainerName.Equals(container.ContainerUniqueName, System.StringComparison.InvariantCultureIgnoreCase)).ToList();
azureBackupDatasourceObjects = azureBackupDatasourceListResponse.DataSources.Objects.Where(x => x.ContainerName.Equals(Container.ContainerUniqueName, System.StringComparison.InvariantCultureIgnoreCase)).ToList();

if (this.Status == null)
{
azureBackupPOListResponse = AzureBackupClient.ProtectableObject.ListAsync(POQueryParam, GetCustomRequestHeaders(), CmdletCancellationToken).Result;
azureBackupPOObjects = azureBackupPOListResponse.ProtectableObject.Objects.Where(x => x.ContainerName.Equals(container.ContainerUniqueName, System.StringComparison.InvariantCultureIgnoreCase)).ToList();
azureBackupPOObjects = azureBackupPOListResponse.ProtectableObject.Objects.Where(x => x.ContainerName.Equals(Container.ContainerUniqueName, System.StringComparison.InvariantCultureIgnoreCase)).ToList();
}

WriteVerbose("Received response");
WriteAzureBackupProtectionPolicy(azureBackupDatasourceObjects, azureBackupPOObjects, container);
WriteAzureBackupProtectionPolicy(azureBackupDatasourceObjects, azureBackupPOObjects, Container);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public override void ExecuteCmdlet()

RecoveryPointListResponse recoveryPointListResponse =
AzureBackupClient.RecoveryPoint.ListAsync(GetCustomRequestHeaders(),
item.ContainerUniqueName,
item.Type,
item.DataSourceId,
Item.ContainerUniqueName,
Item.Type,
Item.DataSourceId,
CmdletCancellationToken).Result;

WriteVerbose("Received recovery point response");
Expand All @@ -57,7 +57,7 @@ public override void ExecuteCmdlet()
{
WriteVerbose("Converting response");
recoveryPointObject = recoveryPointObjects.FirstOrDefault<RecoveryPointInfo>();
WriteAzureBackupRecoveryPoint(recoveryPointObject, item);
WriteAzureBackupRecoveryPoint(recoveryPointObject, Item);
}
else
{
Expand All @@ -68,7 +68,7 @@ public override void ExecuteCmdlet()
{
WriteVerbose("Converting response");
recoveryPointObjects = recoveryPointListResponse.RecoveryPoints.Objects.OrderByDescending(x => x.RecoveryPointTime);
WriteAzureBackupRecoveryPoint(recoveryPointObjects, item);
WriteAzureBackupRecoveryPoint(recoveryPointObjects, Item);
}
});
}
Expand Down