Skip to content

Commit 6038f7d

Browse files
Add NetworkInterface object to effective cmdlets
1 parent 5293bf8 commit 6038f7d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/ResourceManager/Network/Commands.Network/NetworkInterface/EffectiveResources/GetAzureEffectiveNetworkSecurityGroupCommand.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,23 @@ public class GetAzureEffectiveNetworkSecurityGroupCommand : NetworkInterfaceBase
2626
[Parameter(
2727
Mandatory = true,
2828
ValueFromPipelineByPropertyName = true,
29+
ParameterSetName = "GetByResourceObject",
30+
HelpMessage = "The network interface.")]
31+
[ValidateNotNullOrEmpty]
32+
public PSNetworkInterface NetworkInterface { get; set; }
33+
34+
[Parameter(
35+
Mandatory = true,
36+
ValueFromPipelineByPropertyName = true,
37+
ParameterSetName = "GetByResourceName",
2938
HelpMessage = "The network interface name.")]
3039
[ValidateNotNullOrEmpty]
3140
public string NetworkInterfaceName { get; set; }
3241

3342
[Parameter(
3443
Mandatory = false,
3544
ValueFromPipelineByPropertyName = true,
45+
ParameterSetName = "GetByResourceName",
3646
HelpMessage = "The resource group name.")]
3747
[ValidateNotNullOrEmpty]
3848
public string ResourceGroupName { get; set; }
@@ -41,6 +51,12 @@ public override void Execute()
4151
{
4252
base.Execute();
4353

54+
if (ParameterSetName.Contains("GetByResourceObject"))
55+
{
56+
this.NetworkInterfaceName = this.NetworkInterface.Name;
57+
this.ResourceGroupName = this.NetworkInterface.ResourceGroupName;
58+
}
59+
4460
var getEffectiveNsgs = this.NetworkInterfaceClient.ListEffectiveNetworkSecurityGroups(this.ResourceGroupName, this.NetworkInterfaceName);
4561

4662
var psEffectiveNsgs = Mapper.Map<List<PSEffectiveNetworkSecurityGroup>>(getEffectiveNsgs.Value);

src/ResourceManager/Network/Commands.Network/NetworkInterface/EffectiveResources/GetAzureEffectiveRouteTableCommand.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,23 @@ public class GetAzureEffectiveRouteTableCommand : NetworkInterfaceBaseCmdlet
2626
[Parameter(
2727
Mandatory = true,
2828
ValueFromPipelineByPropertyName = true,
29+
ParameterSetName = "GetByResourceObject",
30+
HelpMessage = "The network interface.")]
31+
[ValidateNotNullOrEmpty]
32+
public PSNetworkInterface NetworkInterface { get; set; }
33+
34+
[Parameter(
35+
Mandatory = true,
36+
ValueFromPipelineByPropertyName = true,
37+
ParameterSetName = "GetByResourceName",
2938
HelpMessage = "The network interface name.")]
3039
[ValidateNotNullOrEmpty]
3140
public string NetworkInterfaceName { get; set; }
3241

3342
[Parameter(
3443
Mandatory = false,
3544
ValueFromPipelineByPropertyName = true,
45+
ParameterSetName = "GetByResourceName",
3646
HelpMessage = "The resource group name.")]
3747
[ValidateNotNullOrEmpty]
3848
public string ResourceGroupName { get; set; }
@@ -41,6 +51,12 @@ public override void Execute()
4151
{
4252
base.Execute();
4353

54+
if (ParameterSetName.Contains("GetByResourceObject"))
55+
{
56+
this.NetworkInterfaceName = this.NetworkInterface.Name;
57+
this.ResourceGroupName = this.NetworkInterface.ResourceGroupName;
58+
}
59+
4460
var getEffectiveRouteTable = this.NetworkInterfaceClient.GetEffectiveRouteTable(this.ResourceGroupName, this.NetworkInterfaceName);
4561

4662
var psEffectiveRouteTable = Mapper.Map<List<PSEffectiveRoute>>(getEffectiveRouteTable.Value);

0 commit comments

Comments
 (0)