From ea93390f8dd20437bb915d1af3113710666f5f12 Mon Sep 17 00:00:00 2001 From: Ben Claussen Date: Mon, 13 Mar 2023 09:16:57 -0400 Subject: [PATCH] Correct for OTBS --- .../Interfaces/Add-NetboxDCIMInterface.ps1 | 21 ++++------- .../Interfaces/Get-NetboxDCIMInterface.ps1 | 6 ++-- .../Interfaces/Set-NetboxDCIMInterface.ps1 | 36 +++++++------------ 3 files changed, 21 insertions(+), 42 deletions(-) diff --git a/Functions/DCIM/Interfaces/Add-NetboxDCIMInterface.ps1 b/Functions/DCIM/Interfaces/Add-NetboxDCIMInterface.ps1 index 9fdfd55..4fa4f79 100644 --- a/Functions/DCIM/Interfaces/Add-NetboxDCIMInterface.ps1 +++ b/Functions/DCIM/Interfaces/Add-NetboxDCIMInterface.ps1 @@ -1,6 +1,5 @@  -function Add-NetboxDCIMInterface -{ +function Add-NetboxDCIMInterface { [CmdletBinding()] [OutputType([pscustomobject])] param @@ -38,30 +37,24 @@ function Add-NetboxDCIMInterface [uint16[]]$Tagged_VLANs ) - if (-not [System.String]::IsNullOrWhiteSpace($Mode)) - { - $PSBoundParameters.Mode = switch ($Mode) - { - 'Access' - { + if (-not [System.String]::IsNullOrWhiteSpace($Mode)) { + $PSBoundParameters.Mode = switch ($Mode) { + 'Access' { 100 break } - 'Tagged' - { + 'Tagged' { 200 break } - 'Tagged All' - { + 'Tagged All' { 300 break } - default - { + default { $_ } } diff --git a/Functions/DCIM/Interfaces/Get-NetboxDCIMInterface.ps1 b/Functions/DCIM/Interfaces/Get-NetboxDCIMInterface.ps1 index 0045afc..730e776 100644 --- a/Functions/DCIM/Interfaces/Get-NetboxDCIMInterface.ps1 +++ b/Functions/DCIM/Interfaces/Get-NetboxDCIMInterface.ps1 @@ -1,6 +1,5 @@  -function Get-NetboxDCIMInterface -{ +function Get-NetboxDCIMInterface { [CmdletBinding()] [OutputType([pscustomobject])] param @@ -36,8 +35,7 @@ function Get-NetboxDCIMInterface [switch]$Raw ) - process - { + process { $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces')) $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters diff --git a/Functions/DCIM/Interfaces/Set-NetboxDCIMInterface.ps1 b/Functions/DCIM/Interfaces/Set-NetboxDCIMInterface.ps1 index dd35b17..566c1a0 100644 --- a/Functions/DCIM/Interfaces/Set-NetboxDCIMInterface.ps1 +++ b/Functions/DCIM/Interfaces/Set-NetboxDCIMInterface.ps1 @@ -1,6 +1,5 @@  -function Set-NetboxDCIMInterface -{ +function Set-NetboxDCIMInterface { [CmdletBinding(ConfirmImpact = 'Medium', SupportsShouldProcess = $true)] [OutputType([pscustomobject])] @@ -41,42 +40,33 @@ function Set-NetboxDCIMInterface [uint16[]]$Tagged_VLANs ) - begin - { - if (-not [System.String]::IsNullOrWhiteSpace($Mode)) - { - $PSBoundParameters.Mode = switch ($Mode) - { - 'Access' - { + begin { + if (-not [System.String]::IsNullOrWhiteSpace($Mode)) { + $PSBoundParameters.Mode = switch ($Mode) { + 'Access' { 100 break } - 'Tagged' - { + 'Tagged' { 200 break } - 'Tagged All' - { + 'Tagged All' { 300 break } - default - { + default { $_ } } } } - process - { - foreach ($InterfaceId in $Id) - { + process { + foreach ($InterfaceId in $Id) { $CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id)) @@ -85,15 +75,13 @@ function Set-NetboxDCIMInterface $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 } } } - end - { + end { } } \ No newline at end of file