NetboxPS/Functions/IPAM/Prefix/New-NetboxIPAMPrefix.ps1

50 lines
1.2 KiB
PowerShell
Raw Normal View History

2022-12-06 13:34:52 -05:00

2020-03-23 12:18:01 -04:00
function New-NetboxIPAMPrefix {
[CmdletBinding(ConfirmImpact = 'low',
SupportsShouldProcess = $true)]
2020-03-23 12:18:01 -04:00
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[string]$Prefix,
2020-03-23 12:18:01 -04:00
[object]$Status = 'Active',
[uint64]$Tenant,
2020-03-23 12:18:01 -04:00
[object]$Role,
2020-03-23 12:18:01 -04:00
[bool]$IsPool,
2020-03-23 12:18:01 -04:00
[string]$Description,
[uint64]$Site,
[uint64]$VRF,
[uint64]$VLAN,
2020-03-23 12:18:01 -04:00
[hashtable]$Custom_Fields,
2020-03-23 12:18:01 -04:00
[switch]$Raw
)
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
2020-03-23 12:18:01 -04:00
<#
# 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
}
#>
2020-03-23 12:18:01 -04:00
$segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
2020-03-23 12:18:01 -04:00
$URI = BuildNewURI -Segments $URIComponents.Segments
if ($PSCmdlet.ShouldProcess($Prefix, 'Create new Prefix')) {
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
}
2020-03-23 12:18:01 -04:00
}