22
22
23
23
namespace Microsoft . Azure . Commands . Network
24
24
{
25
- [ Cmdlet ( "Set" , ResourceManager . Common . AzureRMConstants . AzureRMPrefix + "NetworkSecurityGroup" ) , OutputType ( typeof ( PSNetworkSecurityGroup ) ) ]
25
+ [ Cmdlet ( "Set" , ResourceManager . Common . AzureRMConstants . AzureRMPrefix + "NetworkSecurityGroup" , SupportsShouldProcess = true ) , OutputType ( typeof ( PSNetworkSecurityGroup ) ) ]
26
26
public class SetAzureNetworkSecurityGroupCommand : NetworkSecurityGroupBaseCmdlet
27
27
{
28
28
[ Parameter (
@@ -36,25 +36,28 @@ public class SetAzureNetworkSecurityGroupCommand : NetworkSecurityGroupBaseCmdle
36
36
37
37
public override void Execute ( )
38
38
{
39
- base . Execute ( ) ;
40
-
41
- if ( ! this . IsNetworkSecurityGroupPresent ( this . NetworkSecurityGroup . ResourceGroupName , this . NetworkSecurityGroup . Name ) )
39
+ if ( this . ShouldProcess ( NetworkSecurityGroup . Name , VerbsLifecycle . Restart ) )
42
40
{
43
- throw new ArgumentException ( Microsoft . Azure . Commands . Network . Properties . Resources . ResourceNotFound ) ;
44
- }
41
+ base . Execute ( ) ;
45
42
46
- // Map to the sdk object
47
- var nsgModel = NetworkResourceManagerProfile . Mapper . Map < MNM . NetworkSecurityGroup > ( this . NetworkSecurityGroup ) ;
43
+ if ( ! this . IsNetworkSecurityGroupPresent ( this . NetworkSecurityGroup . ResourceGroupName , this . NetworkSecurityGroup . Name ) )
44
+ {
45
+ throw new ArgumentException ( Microsoft . Azure . Commands . Network . Properties . Resources . ResourceNotFound ) ;
46
+ }
48
47
49
- this . NullifyApplicationSecurityGroupsIfAbsent ( nsgModel ) ;
48
+ // Map to the sdk object
49
+ var nsgModel = NetworkResourceManagerProfile . Mapper . Map < MNM . NetworkSecurityGroup > ( this . NetworkSecurityGroup ) ;
50
50
51
- nsgModel . Tags = TagsConversionHelper . CreateTagDictionary ( this . NetworkSecurityGroup . Tag , validate : true ) ;
51
+ this . NullifyApplicationSecurityGroupsIfAbsent ( nsgModel ) ;
52
52
53
- // Execute the PUT NetworkSecurityGroup call
54
- this . NetworkSecurityGroupClient . CreateOrUpdate ( this . NetworkSecurityGroup . ResourceGroupName , this . NetworkSecurityGroup . Name , nsgModel ) ;
53
+ nsgModel . Tags = TagsConversionHelper . CreateTagDictionary ( this . NetworkSecurityGroup . Tag , validate : true ) ;
55
54
56
- var getNetworkSecurityGroup = this . GetNetworkSecurityGroup ( this . NetworkSecurityGroup . ResourceGroupName , this . NetworkSecurityGroup . Name ) ;
57
- WriteObject ( getNetworkSecurityGroup ) ;
55
+ // Execute the PUT NetworkSecurityGroup call
56
+ this . NetworkSecurityGroupClient . CreateOrUpdate ( this . NetworkSecurityGroup . ResourceGroupName , this . NetworkSecurityGroup . Name , nsgModel ) ;
57
+
58
+ var getNetworkSecurityGroup = this . GetNetworkSecurityGroup ( this . NetworkSecurityGroup . ResourceGroupName , this . NetworkSecurityGroup . Name ) ;
59
+ WriteObject ( getNetworkSecurityGroup ) ;
60
+ }
58
61
}
59
62
}
60
63
}
0 commit comments