Skip to content

Commit c631d70

Browse files
gitlwhWeiheng Li
andauthored
Adding new parameters for CustomIpPrefix (#15333)
* Adding new parameters for CustomIpPrefix * fix md * fix * fix * fix * fix Co-authored-by: Weiheng Li <[email protected]>
1 parent 2416771 commit c631d70

File tree

10 files changed

+290
-94
lines changed

10 files changed

+290
-94
lines changed

src/Network/Network/BYOIP/CustomIpPrefix/NewAzureCustomIpPrefixCommand.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ public class NewAzureCustomIpPrefixCommand : CustomIpPrefixBaseCmdlet
5757
[ValidateNotNullOrEmpty]
5858
public string Cidr { get; set; }
5959

60+
[Parameter(
61+
Mandatory = false,
62+
HelpMessage = "Signed message for WAN validation.",
63+
ValueFromPipelineByPropertyName = true)]
64+
public string SignedMessage { get; set; }
65+
66+
[Parameter(
67+
Mandatory = false,
68+
HelpMessage = "Authorization message for WAN validation.",
69+
ValueFromPipelineByPropertyName = true)]
70+
public string AuthorizationMessage { get; set; }
71+
72+
[Parameter(
73+
Mandatory = false,
74+
HelpMessage = "Parent CustomIpPrefix for /64 IPv6 CustomIpPrefix",
75+
ValueFromPipelineByPropertyName = true)]
76+
public PSCustomIpPrefix CustomIpPrefixParent { get; set; }
77+
6078
[Parameter(
6179
Mandatory = false,
6280
HelpMessage = "A list of availability zones denoting the IP allocated for the resource needs to come from.",
@@ -97,9 +115,12 @@ private PSCustomIpPrefix CreateCustomIpPrefix()
97115
ResourceGroupName = this.ResourceGroupName,
98116
Location = this.Location,
99117
Cidr = this.Cidr,
100-
Zones = this.Zone?.ToList()
118+
Zones = this.Zone?.ToList(),
119+
SignedMessage = this.SignedMessage,
120+
AuthorizationMessage = this.AuthorizationMessage,
121+
CustomIpPrefixParent = this.CustomIpPrefixParent
101122
};
102-
123+
103124
var sdkModel = NetworkResourceManagerProfile.Mapper.Map<MNM.CustomIpPrefix>(psModel);
104125

105126
sdkModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);

src/Network/Network/BYOIP/CustomIpPrefix/UpdateAzureCustomIpPrefixCommand.cs

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,25 @@ public class UpdateAzureCustomIpPrefixCommand : CustomIpPrefixBaseCmdlet
6363
[SupportsWildcards]
6464
public virtual string ResourceId { get; set; }
6565

66-
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
66+
[Parameter(Mandatory = false, HelpMessage = "start commissioning process.")]
6767
public SwitchParameter Commission { get; set; }
6868

69-
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
70-
public SwitchParameter Decomission { get; set; }
69+
[Alias("Decomission")]
70+
[Parameter(Mandatory = false, HelpMessage = "start decommissioning process.")]
71+
public SwitchParameter Decommission { get; set; }
72+
73+
[Parameter(Mandatory = false, HelpMessage = "start provisioning process.")]
74+
public SwitchParameter Provision { get; set; }
75+
76+
[Parameter(Mandatory = false, HelpMessage = "start deprovisioning process.")]
77+
public SwitchParameter Deprovision { get; set; }
78+
79+
[Parameter(
80+
Mandatory = false,
81+
ValueFromPipelineByPropertyName = true,
82+
HelpMessage = "The customIpPrefix CIDR.")]
83+
[ValidateNotNullOrEmpty]
84+
public string Cidr { get; set; }
7185

7286
[Parameter(
7387
Mandatory = false,
@@ -103,7 +117,7 @@ public override void Execute()
103117
throw new ArgumentException(Microsoft.Azure.Commands.Network.Properties.Resources.ResourceNotFound);
104118
}
105119

106-
if (Commission && Decomission)
120+
if ((Commission ? 1 : 0) + (Decommission ? 1 : 0) + (Provision ? 1 : 0) + (Deprovision ? 1 : 0) > 1)
107121
{
108122
throw new ArgumentException(Microsoft.Azure.Commands.Network.Properties.Resources.CommissioningStateConflict);
109123
}
@@ -115,9 +129,26 @@ public override void Execute()
115129
throw new PSArgumentException(Properties.Resources.ResourceNotFound, this.Name);
116130
}
117131

118-
if (Commission || Decomission)
132+
if (Commission)
133+
{
134+
customIpPrefixToUpdate.CommissionedState = "Commissioning";
135+
}
136+
else if (Decommission)
137+
{
138+
customIpPrefixToUpdate.CommissionedState = "Decommissioning";
139+
}
140+
else if (Provision)
141+
{
142+
customIpPrefixToUpdate.CommissionedState = "Provisioning";
143+
}
144+
else if (Deprovision)
145+
{
146+
customIpPrefixToUpdate.CommissionedState = "Deprovisioning";
147+
}
148+
149+
if (this.Cidr != null)
119150
{
120-
customIpPrefixToUpdate.CommissionedState = Commission ? "Commissioning" : "Decomissioning";
151+
customIpPrefixToUpdate.Cidr = this.Cidr;
121152
}
122153

123154
var sdkModel = NetworkResourceManagerProfile.Mapper.Map<MNM.CustomIpPrefix>(customIpPrefixToUpdate);

src/Network/Network/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
## Upcoming Release
2222
* Updated cmdlets to enable processing of available zones on AzureFirewalll
2323
- `New-AzFirewall`
24+
* Updated cmdlets to add properties for new BYOIP features.
25+
- `New-AzCustomIpPrefix`
26+
- `Update-AzCustomIpPrefix`
2427

2528
## Version 4.9.0
2629
* Updated cmdlets for route server for a more stable way to add IP configuration.

src/Network/Network/Models/BYOIP/PSCustomIpPrefix.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,30 @@ public class PSCustomIpPrefix : PSTopLevelResource
2929

3030
public string ProvisioningState { get; set; }
3131

32+
public string SignedMessage { get; set; }
33+
34+
public string AuthorizationMessage { get; set; }
35+
36+
public PSCustomIpPrefix CustomIpPrefixParent { get; set; }
37+
38+
public List<PSResourceId> ChildCustomIpPrefixes { get; set; }
39+
3240
[JsonIgnore]
3341
public string PublicIpPrefixesText
3442
{
3543
get { return JsonConvert.SerializeObject(PublicIpPrefixes, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
3644
}
45+
46+
[JsonIgnore]
47+
public string CustomIpPrefixParentText
48+
{
49+
get { return JsonConvert.SerializeObject(new PSResourceId() { Id = CustomIpPrefixParent.Id }, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
50+
}
51+
52+
[JsonIgnore]
53+
public string ChildCustomIpPrefixesText
54+
{
55+
get { return JsonConvert.SerializeObject(ChildCustomIpPrefixes, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
56+
}
3757
}
3858
}

src/Network/Network/Network.format.ps1xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1632,14 +1632,30 @@
16321632
<Label>CommissionedState</Label>
16331633
<PropertyName>CommissionedState</PropertyName>
16341634
</ListItem>
1635-
<ListItem>
1635+
<ListItem>
16361636
<Label>PublicIpPrefixes</Label>
16371637
<PropertyName>PublicIpPrefixesText</PropertyName>
16381638
</ListItem>
16391639
<ListItem>
16401640
<Label>Zones</Label>
16411641
<PropertyName>Zones</PropertyName>
16421642
</ListItem>
1643+
<ListItem>
1644+
<Label>SignedMessage</Label>
1645+
<PropertyName>SignedMessage</PropertyName>
1646+
</ListItem>
1647+
<ListItem>
1648+
<Label>AuthorizationMessage</Label>
1649+
<PropertyName>AuthorizationMessage</PropertyName>
1650+
</ListItem>
1651+
<ListItem>
1652+
<Label>CustomIpPrefixParent</Label>
1653+
<PropertyName>CustomIpPrefixParentText</PropertyName>
1654+
</ListItem>
1655+
<ListItem>
1656+
<Label>ChildCustomIpPrefixes</Label>
1657+
<PropertyName>childCustomIpPrefixesText</PropertyName>
1658+
</ListItem>
16431659
</ListItems>
16441660
</ListEntry>
16451661
</ListEntries>

src/Network/Network/Properties/Resources.Designer.cs

Lines changed: 64 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)