Skip to content

Commit 9374e9f

Browse files
committed
add shouldprocess to set cmdlets
1 parent 3eb5890 commit 9374e9f

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

src/ResourceManager/Sql/Commands.Sql/Database Backup/Cmdlet/SetAzureSqlDatabaseBackupLongTermRetentionPolicy.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ namespace Microsoft.Azure.Commands.Sql.Backup.Cmdlet
2424
/// <summary>
2525
/// Cmdlet to create or update a new Azure Sql Database backup archival policy
2626
/// </summary>
27-
[Cmdlet(VerbsCommon.Set, "AzureRmSqlDatabaseBackupLongTermRetentionPolicy")]
27+
[Cmdlet(VerbsCommon.Set, "AzureRmSqlDatabaseBackupLongTermRetentionPolicy",
28+
SupportsShouldProcess = true,
29+
ConfirmImpact = ConfirmImpact.Low)]
2830
public class SetAzureSqlDatabaseBackupLongTermRetentionPolicy : AzureSqlDatabaseBackupLongTermRetentionPolicyCmdletBase
2931
{
3032
/// <summary>
@@ -84,9 +86,16 @@ protected override IEnumerable<AzureSqlDatabaseBackupLongTermRetentionPolicyMode
8486
/// <returns>The input entity</returns>
8587
protected override IEnumerable<AzureSqlDatabaseBackupLongTermRetentionPolicyModel> PersistChanges(IEnumerable<AzureSqlDatabaseBackupLongTermRetentionPolicyModel> entity)
8688
{
87-
return new List<AzureSqlDatabaseBackupLongTermRetentionPolicyModel>() {
88-
ModelAdapter.SetDatabaseBackupLongTermRetentionPolicy(this.ResourceGroupName, this.ServerName, this.DatabaseName, entity.First())
89-
};
89+
if (ShouldProcess(DatabaseName))
90+
{
91+
return new List<AzureSqlDatabaseBackupLongTermRetentionPolicyModel>() {
92+
ModelAdapter.SetDatabaseBackupLongTermRetentionPolicy(this.ResourceGroupName, this.ServerName, this.DatabaseName, entity.First())
93+
};
94+
}
95+
else
96+
{
97+
return null;
98+
}
9099
}
91100
}
92101
}

src/ResourceManager/Sql/Commands.Sql/Database Backup/Cmdlet/SetAzureSqlServerBackupLongTermRetentionVault.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ namespace Microsoft.Azure.Commands.Sql.Backup.Cmdlet
2424
/// <summary>
2525
/// Cmdlet to create or update a new Azure Sql Server backup archival vault
2626
/// </summary>
27-
[Cmdlet(VerbsCommon.Set, "AzureRmSqlServerBackupLongTermRetentionVault")]
27+
[Cmdlet(VerbsCommon.Set, "AzureRmSqlServerBackupLongTermRetentionVault",
28+
SupportsShouldProcess = true,
29+
ConfirmImpact = ConfirmImpact.Low)]
2830
public class SetAzureSqlServerBackupLongTermRetentionVault : AzureSqlServerBackupLongTermRetentionVaultCmdletBase
2931
{
3032
/// <summary>
@@ -76,9 +78,16 @@ protected override IEnumerable<AzureSqlServerBackupLongTermRetentionVaultModel>
7678
protected override IEnumerable<AzureSqlServerBackupLongTermRetentionVaultModel> PersistChanges(
7779
IEnumerable<AzureSqlServerBackupLongTermRetentionVaultModel> entity)
7880
{
79-
return new List<AzureSqlServerBackupLongTermRetentionVaultModel>() {
80-
ModelAdapter.SetBackupLongTermRetentionVault(this.ResourceGroupName, this.ServerName, entity.First())
81-
};
81+
if (ShouldProcess(ServerName))
82+
{
83+
return new List<AzureSqlServerBackupLongTermRetentionVaultModel>() {
84+
ModelAdapter.SetBackupLongTermRetentionVault(this.ResourceGroupName, this.ServerName, entity.First())
85+
};
86+
}
87+
else
88+
{
89+
return null;
90+
}
8291
}
8392
}
8493
}

0 commit comments

Comments
 (0)