NetboxPS/Functions/IPAM/Prefix/New-NetboxIPAMPrefix.ps1
2022-12-06 13:34:52 -05:00

50 lines
No EOL
1.2 KiB
PowerShell

function New-NetboxIPAMPrefix {
[CmdletBinding(ConfirmImpact = 'low',
SupportsShouldProcess = $true)]
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[string]$Prefix,
[object]$Status = 'Active',
[uint16]$Tenant,
[object]$Role,
[bool]$IsPool,
[string]$Description,
[uint16]$Site,
[uint16]$VRF,
[uint16]$VLAN,
[hashtable]$Custom_Fields,
[switch]$Raw
)
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
<#
# As of 2018/10/18, this does not appear to be a validated IPAM choice
if ($null -ne $Role) {
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -PrefixRole
}
#>
$segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
$URI = BuildNewURI -Segments $URIComponents.Segments
if ($PSCmdlet.ShouldProcess($Prefix, 'Create new Prefix')) {
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
}
}