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

63 lines
1.6 KiB
PowerShell
Raw Normal View History

<#
2020-03-23 12:18:01 -04:00
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
Created on: 3/19/2020 11:52
Created by: Claussen
Organization: NEOnet
Filename: New-NetboxIPAMPrefix.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
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',
2020-03-23 12:18:01 -04:00
[uint16]$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,
2020-03-23 12:18:01 -04:00
[uint16]$Site,
2020-03-23 12:18:01 -04:00
[uint16]$VRF,
2020-03-23 12:18:01 -04:00
[uint16]$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
}