mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-15 18:55:46 +00:00
Correct for OTBS
This commit is contained in:
parent
008c4d41f5
commit
ea93390f8d
3 changed files with 21 additions and 42 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
function Add-NetboxDCIMInterface
|
function Add-NetboxDCIMInterface {
|
||||||
{
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
|
|
@ -38,30 +37,24 @@ function Add-NetboxDCIMInterface
|
||||||
[uint16[]]$Tagged_VLANs
|
[uint16[]]$Tagged_VLANs
|
||||||
)
|
)
|
||||||
|
|
||||||
if (-not [System.String]::IsNullOrWhiteSpace($Mode))
|
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
|
||||||
{
|
$PSBoundParameters.Mode = switch ($Mode) {
|
||||||
$PSBoundParameters.Mode = switch ($Mode)
|
'Access' {
|
||||||
{
|
|
||||||
'Access'
|
|
||||||
{
|
|
||||||
100
|
100
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
'Tagged'
|
'Tagged' {
|
||||||
{
|
|
||||||
200
|
200
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
'Tagged All'
|
'Tagged All' {
|
||||||
{
|
|
||||||
300
|
300
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default
|
default {
|
||||||
{
|
|
||||||
$_
|
$_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
function Get-NetboxDCIMInterface
|
function Get-NetboxDCIMInterface {
|
||||||
{
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
|
|
@ -36,8 +35,7 @@ function Get-NetboxDCIMInterface
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
process
|
process {
|
||||||
{
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
function Set-NetboxDCIMInterface
|
function Set-NetboxDCIMInterface {
|
||||||
{
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
|
|
@ -41,42 +40,33 @@ function Set-NetboxDCIMInterface
|
||||||
[uint16[]]$Tagged_VLANs
|
[uint16[]]$Tagged_VLANs
|
||||||
)
|
)
|
||||||
|
|
||||||
begin
|
begin {
|
||||||
{
|
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
|
||||||
if (-not [System.String]::IsNullOrWhiteSpace($Mode))
|
$PSBoundParameters.Mode = switch ($Mode) {
|
||||||
{
|
'Access' {
|
||||||
$PSBoundParameters.Mode = switch ($Mode)
|
|
||||||
{
|
|
||||||
'Access'
|
|
||||||
{
|
|
||||||
100
|
100
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
'Tagged'
|
'Tagged' {
|
||||||
{
|
|
||||||
200
|
200
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
'Tagged All'
|
'Tagged All' {
|
||||||
{
|
|
||||||
300
|
300
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default
|
default {
|
||||||
{
|
|
||||||
$_
|
$_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
process
|
process {
|
||||||
{
|
foreach ($InterfaceId in $Id) {
|
||||||
foreach ($InterfaceId in $Id)
|
|
||||||
{
|
|
||||||
$CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
|
$CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
|
||||||
|
|
@ -85,15 +75,13 @@ function Set-NetboxDCIMInterface
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $Segments
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("Interface ID $($CurrentInterface.Id)", "Set"))
|
if ($Force -or $pscmdlet.ShouldProcess("Interface ID $($CurrentInterface.Id)", "Set")) {
|
||||||
{
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue