NetboxPS/Functions/DCIM/Interfaces/Set-NetboxDCIMInterface.ps1
2023-07-28 16:17:23 -04:00

88 lines
No EOL
3.6 KiB
PowerShell

function Set-NetboxDCIMInterface {
[CmdletBinding(ConfirmImpact = 'Medium',
SupportsShouldProcess = $true)]
[OutputType([pscustomobject])]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint64[]]$Id,
[uint64]$Device,
[string]$Name,
[bool]$Enabled,
[object]$Form_Factor,
[ValidateSet('virtual', 'bridge', 'lag', '100base-tx', '1000base-t', '2.5gbase-t', '5gbase-t', '10gbase-t', '10gbase-cx4', '1000base-x-gbic', '1000base-x-sfp', '10gbase-x-sfpp', '10gbase-x-xfp', '10gbase-x-xenpak', '10gbase-x-x2', '25gbase-x-sfp28', '50gbase-x-sfp56', '40gbase-x-qsfpp', '50gbase-x-sfp28', '100gbase-x-cfp', '100gbase-x-cfp2', '200gbase-x-cfp2', '100gbase-x-cfp4', '100gbase-x-cpak', '100gbase-x-qsfp28', '200gbase-x-qsfp56', '400gbase-x-qsfpdd', '400gbase-x-osfp', '1000base-kx', '10gbase-kr', '10gbase-kx4', '25gbase-kr', '40gbase-kr4', '50gbase-kr', '100gbase-kp4', '100gbase-kr2', '100gbase-kr4', 'ieee802.11a', 'ieee802.11g', 'ieee802.11n', 'ieee802.11ac', 'ieee802.11ad', 'ieee802.11ax', 'ieee802.11ay', 'ieee802.15.1', 'other-wireless', 'gsm', 'cdma', 'lte', 'sonet-oc3', 'sonet-oc12', 'sonet-oc48', 'sonet-oc192', 'sonet-oc768', 'sonet-oc1920', 'sonet-oc3840', '1gfc-sfp', '2gfc-sfp', '4gfc-sfp', '8gfc-sfpp', '16gfc-sfpp', '32gfc-sfp28', '64gfc-qsfpp', '128gfc-qsfp28', 'infiniband-sdr', 'infiniband-ddr', 'infiniband-qdr', 'infiniband-fdr10', 'infiniband-fdr', 'infiniband-edr', 'infiniband-hdr', 'infiniband-ndr', 'infiniband-xdr', 't1', 'e1', 't3', 'e3', 'xdsl', 'docsis', 'gpon', 'xg-pon', 'xgs-pon', 'ng-pon2', 'epon', '10g-epon', 'cisco-stackwise', 'cisco-stackwise-plus', 'cisco-flexstack', 'cisco-flexstack-plus', 'cisco-stackwise-80', 'cisco-stackwise-160', 'cisco-stackwise-320', 'cisco-stackwise-480', 'juniper-vcp', 'extreme-summitstack', 'extreme-summitstack-128', 'extreme-summitstack-256', 'extreme-summitstack-512', 'other', IgnoreCase = $true)]
[string]$Type,
[uint16]$MTU,
[string]$MAC_Address,
[bool]$MGMT_Only,
[uint64]$LAG,
[string]$Description,
[ValidateSet('Access', 'Tagged', 'Tagged All', '100', '200', '300', IgnoreCase = $true)]
[string]$Mode,
[ValidateRange(1, 4094)]
[uint16]$Untagged_VLAN,
[ValidateRange(1, 4094)]
[uint16[]]$Tagged_VLANs,
[switch]$Force
)
begin {
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
$PSBoundParameters.Mode = switch ($Mode) {
'Access' {
100
break
}
'Tagged' {
200
break
}
'Tagged All' {
300
break
}
default {
$_
}
}
}
}
process {
foreach ($InterfaceId in $Id) {
$CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
$URI = BuildNewURI -Segments $Segments
if ($Force -or $pscmdlet.ShouldProcess("Interface ID $($CurrentInterface.Id)", "Set")) {
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
}
}
}
end {
}
}