Skip to content

Adding new parameters for CustomIpPrefix #15333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ public class NewAzureCustomIpPrefixCommand : CustomIpPrefixBaseCmdlet
[ValidateNotNullOrEmpty]
public string Cidr { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Signed message for WAN validation.",
ValueFromPipelineByPropertyName = true)]
public string SignedMessage { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Authorization message for WAN validation.",
ValueFromPipelineByPropertyName = true)]
public string AuthorizationMessage { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Parent CustomIpPrefix for /64 IPv6 CustomIpPrefix",
ValueFromPipelineByPropertyName = true)]
public PSCustomIpPrefix CustomIpPrefixParent { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "A list of availability zones denoting the IP allocated for the resource needs to come from.",
Expand Down Expand Up @@ -97,9 +115,12 @@ private PSCustomIpPrefix CreateCustomIpPrefix()
ResourceGroupName = this.ResourceGroupName,
Location = this.Location,
Cidr = this.Cidr,
Zones = this.Zone?.ToList()
Zones = this.Zone?.ToList(),
SignedMessage = this.SignedMessage,
AuthorizationMessage = this.AuthorizationMessage,
CustomIpPrefixParent = this.CustomIpPrefixParent
};

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

sdkModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,25 @@ public class UpdateAzureCustomIpPrefixCommand : CustomIpPrefixBaseCmdlet
[SupportsWildcards]
public virtual string ResourceId { get; set; }

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

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter Decomission { get; set; }
[Alias("Decomission")]
[Parameter(Mandatory = false, HelpMessage = "start decommissioning process.")]
public SwitchParameter Decommission { get; set; }

[Parameter(Mandatory = false, HelpMessage = "start provisioning process.")]
public SwitchParameter Provision { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I recommend using bool as the type of Provision so that we needn't two parameters for one function.
  • Please update the help message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type would change behavior of our command because we need to use like
'''-Provision $true''' right?


[Parameter(Mandatory = false, HelpMessage = "start deprovisioning process.")]
public SwitchParameter Deprovision { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The customIpPrefix CIDR.")]
[ValidateNotNullOrEmpty]
public string Cidr { get; set; }

[Parameter(
Mandatory = false,
Expand Down Expand Up @@ -103,7 +117,7 @@ public override void Execute()
throw new ArgumentException(Microsoft.Azure.Commands.Network.Properties.Resources.ResourceNotFound);
}

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

if (Commission || Decomission)
if (Commission)
{
customIpPrefixToUpdate.CommissionedState = "Commissioning";
}
else if (Decommission)
{
customIpPrefixToUpdate.CommissionedState = "Decommissioning";
}
else if (Provision)
{
customIpPrefixToUpdate.CommissionedState = "Provisioning";
}
else if (Deprovision)
{
customIpPrefixToUpdate.CommissionedState = "Deprovisioning";
}

if (this.Cidr != null)
{
customIpPrefixToUpdate.CommissionedState = Commission ? "Commissioning" : "Decomissioning";
customIpPrefixToUpdate.Cidr = this.Cidr;
}

var sdkModel = NetworkResourceManagerProfile.Mapper.Map<MNM.CustomIpPrefix>(customIpPrefixToUpdate);
Expand Down
3 changes: 3 additions & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
## Upcoming Release
* Updated cmdlets to enable processing of available zones on AzureFirewalll
- `New-AzFirewall`
* Updated cmdlets to add properties for new BYOIP features.
- `New-AzCustomIpPrefix`
- `Update-AzCustomIpPrefix`

## Version 4.9.0
* Updated cmdlets for route server for a more stable way to add IP configuration.
Expand Down
20 changes: 20 additions & 0 deletions src/Network/Network/Models/BYOIP/PSCustomIpPrefix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,30 @@ public class PSCustomIpPrefix : PSTopLevelResource

public string ProvisioningState { get; set; }

public string SignedMessage { get; set; }

public string AuthorizationMessage { get; set; }

public PSCustomIpPrefix CustomIpPrefixParent { get; set; }

public List<PSResourceId> ChildCustomIpPrefixes { get; set; }

[JsonIgnore]
public string PublicIpPrefixesText
{
get { return JsonConvert.SerializeObject(PublicIpPrefixes, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

[JsonIgnore]
public string CustomIpPrefixParentText
{
get { return JsonConvert.SerializeObject(new PSResourceId() { Id = CustomIpPrefixParent.Id }, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

[JsonIgnore]
public string ChildCustomIpPrefixesText
{
get { return JsonConvert.SerializeObject(ChildCustomIpPrefixes, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}
}
}
18 changes: 17 additions & 1 deletion src/Network/Network/Network.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -1632,14 +1632,30 @@
<Label>CommissionedState</Label>
<PropertyName>CommissionedState</PropertyName>
</ListItem>
<ListItem>
<ListItem>
<Label>PublicIpPrefixes</Label>
<PropertyName>PublicIpPrefixesText</PropertyName>
</ListItem>
<ListItem>
<Label>Zones</Label>
<PropertyName>Zones</PropertyName>
</ListItem>
<ListItem>
<Label>SignedMessage</Label>
<PropertyName>SignedMessage</PropertyName>
</ListItem>
<ListItem>
<Label>AuthorizationMessage</Label>
<PropertyName>AuthorizationMessage</PropertyName>
</ListItem>
<ListItem>
<Label>CustomIpPrefixParent</Label>
<PropertyName>CustomIpPrefixParentText</PropertyName>
</ListItem>
<ListItem>
<Label>ChildCustomIpPrefixes</Label>
<PropertyName>childCustomIpPrefixesText</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
Expand Down
141 changes: 64 additions & 77 deletions src/Network/Network/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading