NetboxPS/Functions/DCIM/Interfaces/Add-NetboxDCIMInterface.ps1

71 lines
1.6 KiB
PowerShell
Raw Normal View History

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

2020-03-23 12:18:01 -04:00
function Add-NetboxDCIMInterface {
[CmdletBinding()]
[OutputType([pscustomobject])]
param
(
[Parameter(Mandatory = $true)]
[uint16]$Device,
2020-03-23 12:18:01 -04:00
[Parameter(Mandatory = $true)]
[string]$Name,
2020-03-23 12:18:01 -04:00
[bool]$Enabled,
2020-03-23 12:18:01 -04:00
[object]$Form_Factor,
2020-03-23 12:18:01 -04:00
[uint16]$MTU,
2020-03-23 12:18:01 -04:00
[string]$MAC_Address,
2020-03-23 12:18:01 -04:00
[bool]$MGMT_Only,
2020-03-23 12:18:01 -04:00
[uint16]$LAG,
2020-03-23 12:18:01 -04:00
[string]$Description,
2020-03-23 12:18:01 -04:00
[ValidateSet('Access', 'Tagged', 'Tagged All', '100', '200', '300', IgnoreCase = $true)]
[string]$Mode,
2020-03-23 12:18:01 -04:00
[ValidateRange(1, 4094)]
[uint16]$Untagged_VLAN,
2020-03-23 12:18:01 -04:00
[ValidateRange(1, 4094)]
[uint16[]]$Tagged_VLANs
)
# if ($null -ne $Form_Factor) {
# $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
# }
2020-03-23 12:18:01 -04:00
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
$PSBoundParameters.Mode = switch ($Mode) {
'Access' {
100
break
}
2020-03-23 12:18:01 -04:00
'Tagged' {
200
break
}
2020-03-23 12:18:01 -04:00
'Tagged All' {
300
break
}
2020-03-23 12:18:01 -04:00
default {
$_
}
}
}
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
2020-03-23 12:18:01 -04:00
$URI = BuildNewURI -Segments $URIComponents.Segments
2020-03-23 12:18:01 -04:00
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
}