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

67 lines
1.9 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/23/2020 12:10
Created by: Claussen
Organization: NEOnet
Filename: Add-NetboxDCIMInterfaceConnection.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
function Add-NetboxDCIMInterfaceConnection {
<#
2020-03-23 12:18:01 -04:00
.SYNOPSIS
Create a new connection between two interfaces
2020-03-23 12:18:01 -04:00
.DESCRIPTION
Create a new connection between two interfaces
2020-03-23 12:18:01 -04:00
.PARAMETER Connection_Status
Is it connected or planned?
2020-03-23 12:18:01 -04:00
.PARAMETER Interface_A
Database ID of interface A
2020-03-23 12:18:01 -04:00
.PARAMETER Interface_B
Database ID of interface B
2020-03-23 12:18:01 -04:00
.EXAMPLE
PS C:\> Add-NetboxDCIMInterfaceConnection -Interface_A $value1 -Interface_B $value2
2020-03-23 12:18:01 -04:00
.NOTES
Additional information about the function.
#>
2020-03-23 12:18:01 -04:00
[CmdletBinding()]
[OutputType([pscustomobject])]
param
(
[object]$Connection_Status,
2020-03-23 12:18:01 -04:00
[Parameter(Mandatory = $true)]
[uint16]$Interface_A,
2020-03-23 12:18:01 -04:00
[Parameter(Mandatory = $true)]
[uint16]$Interface_B
)
2020-03-23 12:18:01 -04:00
if ($null -ne $Connection_Status) {
$PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
}
2020-03-23 12:18:01 -04:00
# Verify if both Interfaces exist
Get-NetboxDCIMInterface -Id $Interface_A -ErrorAction Stop | Out-null
Get-NetboxDCIMInterface -Id $Interface_B -ErrorAction Stop | Out-null
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
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
}