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 @@ -29,7 +29,7 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets.DataSource
/// <summary>
/// Disable Azure Backup protection
/// </summary>
[Cmdlet(VerbsLifecycle.Disable, "AzureBackupProtection"), OutputType(typeof(OperationResponse))]
[Cmdlet(VerbsLifecycle.Disable, "AzureBackupProtection"), OutputType(typeof(Guid))]
public class DisableAzureBackupProtection : AzureBackupDSCmdletBase
{
[Parameter(Position = 1, Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.RemoveProtectionOption)]
Expand Down Expand Up @@ -59,31 +59,16 @@ public override void ExecuteCmdlet()
Reason = this.Reason,
Comments = this.Comments,
};

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

WriteVerbose("Received response");
WriteVerbose("Converting response");
WriteAzureBackupProtectionPolicy(disbaleAzureBackupProtection);
WriteVerbose("Received disable azure backup protection response");
jobId = disbaleAzureBackupProtection.OperationId;
this.WriteObject(jobId);
});
}

public void WriteAzureBackupProtectionPolicy(OperationResponse sourceOperationResponse)
{
}

public void WriteAzureBackupProtectionPolicy(IEnumerable<OperationResponse> sourceOperationResponseList)
{
List<OperationResponse> targetList = new List<OperationResponse>();

foreach (var sourceOperationResponse in sourceOperationResponseList)
{
targetList.Add(sourceOperationResponse);
}

this.WriteObject(targetList, true);
}

public enum RemoveProtectionOptions
{
[EnumMember]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
/// <summary>
/// Enable Azure Backup protection
/// </summary>
[Cmdlet(VerbsLifecycle.Enable, "AzureBackupProtection"), OutputType(typeof(OperationResponse))]
[Cmdlet(VerbsLifecycle.Enable, "AzureBackupProtection"), OutputType(typeof(Guid))]
public class EnableAzureBackupProtection : AzureBackupItemCmdletBase
{
[Parameter(Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.PolicyName)]
Expand Down Expand Up @@ -69,29 +69,15 @@ public override void ExecuteCmdlet()
throw new Exception("Uknown item type");
}

Guid jobId = Guid.Empty;
var enableAzureBackupProtection = AzureBackupClient.DataSource.EnableProtectionAsync(GetCustomRequestHeaders(), input, CmdletCancellationToken).Result;

WriteVerbose("Received response");
WriteVerbose("Converting response");
WriteAzureBackupProtectionPolicy(enableAzureBackupProtection);
WriteVerbose("Received enable azure backup protection response");
jobId = enableAzureBackupProtection.OperationId;
this.WriteObject(jobId);
});
}

public void WriteAzureBackupProtectionPolicy(OperationResponse sourceOperationResponse)
{
}

public void WriteAzureBackupProtectionPolicy(IEnumerable<OperationResponse> sourceOperationResponseList)
{
List<OperationResponse> targetList = new List<OperationResponse>();

foreach (var sourceOperationResponse in sourceOperationResponseList)
{
targetList.Add(sourceOperationResponse);
}

this.WriteObject(targetList, true);
}
public enum ContainerType
{
[EnumMember]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ public override void ExecuteCmdlet()
azureBackupPOObjects = azureBackupPOListResponse.ProtectableObject.Objects.Where(x => x.ContainerName.Equals(Container.ContainerUniqueName, System.StringComparison.InvariantCultureIgnoreCase)).ToList();
}

WriteVerbose("Received response");
WriteAzureBackupProtectionPolicy(azureBackupDatasourceObjects, azureBackupPOObjects, Container);
WriteVerbose("Received azure backup item response");
WriteAzureBackupItem(azureBackupDatasourceObjects, azureBackupPOObjects, Container);
});
}

public void WriteAzureBackupProtectionPolicy(DataSourceInfo sourceItem, AzureBackupContainer azureBackupItem)
public void WriteAzureBackupItem(DataSourceInfo sourceItem, AzureBackupContainer azureBackupItem)
{
this.WriteObject(new AzureBackupItem(sourceItem, azureBackupItem));
}

public void WriteAzureBackupProtectionPolicy(List<DataSourceInfo> sourceDataSourceList, List<ProtectableObjectInfo> sourcePOList, AzureBackupContainer azureBackupContainer)
public void WriteAzureBackupItem(List<DataSourceInfo> sourceDataSourceList, List<ProtectableObjectInfo> sourcePOList, AzureBackupContainer azureBackupContainer)
{
List<AzureBackupItem> targetList = new List<AzureBackupItem>();

Expand Down