NetboxPS/Functions/DCIM/Interfaces/Set-NetboxDCIMInterfaceConnection.ps1

75 lines
1.9 KiB
PowerShell
Raw Normal View History

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

2020-03-23 12:18:01 -04:00
function Set-NetboxDCIMInterfaceConnection {
<#
.SYNOPSIS
Update an interface connection
2020-03-23 12:18:01 -04:00
.DESCRIPTION
Update an interface connection
2020-03-23 12:18:01 -04:00
.PARAMETER Id
A description of the Id parameter.
2020-03-23 12:18:01 -04:00
.PARAMETER Connection_Status
A description of the Connection_Status parameter.
2020-03-23 12:18:01 -04:00
.PARAMETER Interface_A
A description of the Interface_A parameter.
2020-03-23 12:18:01 -04:00
.PARAMETER Interface_B
A description of the Interface_B parameter.
2020-03-23 12:18:01 -04:00
.PARAMETER Force
A description of the Force parameter.
2020-03-23 12:18:01 -04:00
.EXAMPLE
PS C:\> Set-NetboxDCIMInterfaceConnection -Id $value1
2020-03-23 12:18:01 -04:00
.NOTES
Additional information about the function.
#>
2020-03-23 12:18:01 -04:00
[CmdletBinding(ConfirmImpact = 'Medium',
SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
2020-03-23 12:18:01 -04:00
[object]$Connection_Status,
[uint64]$Interface_A,
[uint64]$Interface_B,
2020-03-23 12:18:01 -04:00
[switch]$Force
)
2020-03-23 12:18:01 -04:00
begin {
if ((@($ID).Count -gt 1) -and ($Interface_A -or $Interface_B)) {
throw "Cannot set multiple connections to the same interface"
}
}
2020-03-23 12:18:01 -04:00
process {
foreach ($ConnectionID in $Id) {
$CurrentConnection = Get-NetboxDCIMInterfaceConnection -Id $ConnectionID -ErrorAction Stop
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections', $CurrentConnection.Id))
2020-03-23 12:18:01 -04:00
if ($Force -or $pscmdlet.ShouldProcess("Connection ID $($CurrentConnection.Id)", "Set")) {
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
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 PATCH
}
}
}
2020-03-23 12:18:01 -04:00
end {
2020-03-23 12:18:01 -04:00
}
}