Skip to content

Commit 8478f47

Browse files
author
Khushboo Baheti
committed
ConnChanges
1 parent 86108ab commit 8478f47

File tree

4 files changed

+90
-4
lines changed

4 files changed

+90
-4
lines changed

src/Network/Network/Models/PSVirtualNetworkGatewayConnection.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ public class PSVirtualNetworkGatewayConnection : PSTopLevelResource
7575
[Ps1Xml(Target = ViewControl.Table)]
7676
public string ConnectionProtocol { get; set; }
7777

78+
[Ps1Xml(Label = "IngressNatRules", Target = ViewControl.Table)]
79+
public List<PSResourceId> IngressNatRules { get; set; }
80+
81+
[Ps1Xml(Label = "EgressNatRules", Target = ViewControl.Table)]
82+
public List<PSResourceId> EgressNatRules { get; set; }
83+
7884
[JsonIgnore]
7985
public string VirtualNetworkGateway1Text
8086
{
@@ -104,5 +110,17 @@ public string TunnelConnectionStatusText
104110
{
105111
get { return TunnelConnectionStatus == null ? string.Empty : JsonConvert.SerializeObject(TunnelConnectionStatus, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
106112
}
113+
114+
[JsonIgnore]
115+
public string IngressNatRulesText
116+
{
117+
get { return IngressNatRules == null ? string.Empty : JsonConvert.SerializeObject(IngressNatRules, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
118+
}
119+
120+
[JsonIgnore]
121+
public string EgressNatRulesText
122+
{
123+
get { return IngressNatRules == null ? string.Empty : JsonConvert.SerializeObject(EgressNatRules, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
124+
}
107125
}
108126
}

src/Network/Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,6 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway()
527527
{
528528
vnetGateway.NatRules = this.NatRule?.ToList();
529529
}
530-
else
531-
{
532-
vnetGateway.NatRules = null;
533-
}
534530

535531
// Set the EnableBgpRouteTranslationForNat, if it is specified by customer.
536532
vnetGateway.EnableBgpRouteTranslationForNat = EnableBgpRouteTranslationForNatFlag.IsPresent;

src/Network/Network/VirtualNetworkGatewayConnection/NewAzureVirtualNetworkGatewayConnectionCommand.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@ public class NewAzureVirtualNetworkGatewayConnectionCommand : VirtualNetworkGate
177177
IgnoreCase = true)]
178178
public string ConnectionProtocol { get; set; }
179179

180+
[Parameter(
181+
Mandatory = false,
182+
HelpMessage = "The list of ingress NAT rules that are associated with this Connection.")]
183+
public PSResourceId[] IngressNatRule { get; set; }
184+
185+
[Parameter(
186+
Mandatory = false,
187+
HelpMessage = "The list of egress NAT rules that are associated with this Connection.")]
188+
public PSResourceId[] EgressNatRule { get; set; }
189+
180190
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
181191
public SwitchParameter AsJob { get; set; }
182192

@@ -256,6 +266,32 @@ private PSVirtualNetworkGatewayConnection CreateVirtualNetworkGatewayConnection(
256266
vnetGatewayConnection.TrafficSelectorPolicies = this.TrafficSelectorPolicy?.ToList();
257267
}
258268

269+
if (this.IngressNatRule != null && this.IngressNatRule?.ToList().Count > 0)
270+
{
271+
vnetGatewayConnection.IngressNatRules = new List<PSResourceId>();
272+
foreach (var resource in this.IngressNatRule)
273+
{
274+
vnetGatewayConnection.IngressNatRules.Add(
275+
new PSResourceId()
276+
{
277+
Id = resource.Id
278+
});
279+
}
280+
}
281+
282+
if (this.EgressNatRule != null && this.EgressNatRule?.ToList().Count > 0)
283+
{
284+
vnetGatewayConnection.EgressNatRules = new List<PSResourceId>();
285+
foreach (var resource in this.EgressNatRule)
286+
{
287+
vnetGatewayConnection.EgressNatRules.Add(
288+
new PSResourceId()
289+
{
290+
Id = resource.Id
291+
});
292+
}
293+
}
294+
259295
// Map to the sdk object
260296
var vnetGatewayConnectionModel = NetworkResourceManagerProfile.Mapper.Map<MNM.VirtualNetworkGatewayConnection>(vnetGatewayConnection);
261297
vnetGatewayConnectionModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);

src/Network/Network/VirtualNetworkGatewayConnection/UpdateAzureVirtualNetworkGatewayConnectionCommand.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ public class SetAzureVirtualNetworkGatewayConnectionCommand : VirtualNetworkGate
7777
HelpMessage = "A list of traffic selector policies.")]
7878
public PSTrafficSelectorPolicy[] TrafficSelectorPolicy { get; set; }
7979

80+
[Parameter(
81+
Mandatory = false,
82+
HelpMessage = "The list of ingress NAT rules that are associated with this Connection.")]
83+
public PSResourceId[] IngressNatRule { get; set; }
84+
85+
[Parameter(
86+
Mandatory = false,
87+
HelpMessage = "The list of egress NAT rules that are associated with this Connection.")]
88+
public PSResourceId[] EgressNatRule { get; set; }
89+
8090
[Parameter(
8191
Mandatory = true,
8292
ParameterSetName = VirtualNetworkGatewayParameterSets.UpdateResourceWithTags,
@@ -142,6 +152,32 @@ public override void Execute()
142152
this.VirtualNetworkGatewayConnection.TrafficSelectorPolicies = this.TrafficSelectorPolicy?.ToList();
143153
}
144154

155+
if (this.IngressNatRule != null)
156+
{
157+
this.VirtualNetworkGatewayConnection.IngressNatRules = new List<PSResourceId>();
158+
foreach (var resource in this.IngressNatRule)
159+
{
160+
this.VirtualNetworkGatewayConnection.IngressNatRules.Add(
161+
new PSResourceId()
162+
{
163+
Id = resource.Id
164+
});
165+
}
166+
}
167+
168+
if (this.EgressNatRule != null)
169+
{
170+
this.VirtualNetworkGatewayConnection.IngressNatRules = new List<PSResourceId>();
171+
foreach (var resource in this.IngressNatRule)
172+
{
173+
this.VirtualNetworkGatewayConnection.IngressNatRules.Add(
174+
new PSResourceId()
175+
{
176+
Id = resource.Id
177+
});
178+
}
179+
}
180+
145181
var vnetGatewayConnectionModel = NetworkResourceManagerProfile.Mapper.Map<MNM.VirtualNetworkGatewayConnection>(this.VirtualNetworkGatewayConnection);
146182

147183
vnetGatewayConnectionModel.Tags =

0 commit comments

Comments
 (0)