Skip to content

Commit ec5f9e8

Browse files
benclaussen1SheffSixbenclaussen
authored
v1.8.0 (#45)
* Fixing Interface Type parameter (#42) * Fixing #41 * Update `deploy.ps1` to remove trailing whitespaces from psd1 * Increase version to 1.7.3 * Fix location of whitespace cleanup in `deploy.ps1` * Device port support (#44) * Fixing #41 * Correct for OTBS * Start work on Front and Rear ports * Revert "Start work on Front and Rear ports" This reverts commit 257709fe2af5af5fbe4496b2d5b68481d80bf101. * Fixing #41 * Add-NetboxDCIMRearPort function * Revert "Revert "Start work on Front and Rear ports"" This reverts commit 4f6625a. * Fix incorrect parameter variable types * Parameter type adjustments * Create function to get tag information * Added Mark_Connected parameter * Add Set-NetboxDCIMRearPort function * Added Remove-NetboxDCIMRearPort function * Added validate pattern for Color parameter * Added Add-NetboxDCIMFrontPort function * Fixed param list missing Force parameter * Added Set-NetboxDCIMFrontPort function * Added Remove-NetboxDCIMFrontPort function * Init. functions for cables and cable terminations * Reformatting using OTBS Also working on defining tags by slug as an extra parameter, which appears only in Add-NetboxDCIMRearPort currently * Remove Tags_Slug parameter In hindsight implementing would create extra work that could be hard to maintain. Can be easily achieved outside of the function. * Update psproj * Fix braces * Update Postman for Netbox v3.4.5 * Update vscode settings * Update version 1.8.0 --------- Co-authored-by: SheffSix <jbeck1867@gmail.com> Co-authored-by: Ben Claussen <benclaussen@gmail.com> Co-authored-by: James Beck <jim@beck81.co.uk>
1 parent 29dd7ac commit ec5f9e8

20 files changed

+65435
-976
lines changed

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
"files.trimTrailingWhitespace": true,
55
"powershell.scriptAnalysis.settingsPath": ".vscode/PSScriptAnalyzerSettings.psd1",
66
"powershell.codeFormatting.newLineAfterCloseBrace": false,
7+
"powershell.codeFormatting.useCorrectCasing": true,
8+
"powershell.codeFormatting.preset": "OTBS",
9+
"powershell.codeFormatting.addWhitespaceAroundPipe": true,
10+
"powershell.codeFormatting.autoCorrectAliases": true,
11+
"powershell.codeFormatting.newLineAfterCloseBrace": true,
12+
"powershell.codeFormatting.newLineAfterOpenBrace": true,
13+
"powershell.codeFormatting.openBraceOnSameLine": true,
14+
"powershell.codeFormatting.whitespaceAfterSeparator": true,
15+
"powershell.codeFormatting.whitespaceAroundOperator": true,
16+
"powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
17+
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
18+
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
719
"[markdown]": {
820
"files.trimTrailingWhitespace": false,
921
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
function Get-NetboxDCIMCableTermination {
2+
[CmdletBinding()]
3+
#region Parameters
4+
param
5+
(
6+
[uint16]$Limit,
7+
8+
[uint16]$Offset,
9+
10+
[Parameter(ValueFromPipelineByPropertyName = $true)]
11+
[uint16[]]$Id,
12+
13+
[uint16]$Cable,
14+
15+
[string]$Cable_End,
16+
17+
[string]$Termination_Type,
18+
19+
[uint16]$Termination_ID,
20+
21+
[switch]$Raw
22+
)
23+
24+
#endregion Parameters
25+
26+
process {
27+
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'cable-terminations'))
28+
29+
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
30+
31+
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
32+
33+
InvokeNetboxRequest -URI $URI -Raw:$Raw
34+
}
35+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
function Get-NetboxDCIMCable {
2+
[CmdletBinding()]
3+
#region Parameters
4+
param
5+
(
6+
[uint16]$Limit,
7+
8+
[uint16]$Offset,
9+
10+
[Parameter(ValueFromPipelineByPropertyName = $true)]
11+
[uint16[]]$Id,
12+
13+
[string]$Label,
14+
15+
[string]$Termination_A_Type,
16+
17+
[uint16]$Termination_A_ID,
18+
19+
[string]$Termination_B_Type,
20+
21+
[UInt16]$Termination_B_ID,
22+
23+
[string]$Type,
24+
25+
[string]$Status,
26+
27+
[string]$Color,
28+
29+
[UInt16]$Device_ID,
30+
31+
[string]$Device,
32+
33+
[uint16]$Rack_Id,
34+
35+
[string]$Rack,
36+
37+
[uint16]$Location_ID,
38+
39+
[string]$Location,
40+
41+
[switch]$Raw
42+
)
43+
44+
#endregion Parameters
45+
46+
process {
47+
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'cables'))
48+
49+
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
50+
51+
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
52+
53+
InvokeNetboxRequest -URI $URI -Raw:$Raw
54+
}
55+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
function Add-NetboxDCIMFrontPort {
2+
[CmdletBinding()]
3+
[OutputType([pscustomobject])]
4+
param
5+
(
6+
[Parameter(Mandatory = $true)]
7+
[uint16]$Device,
8+
9+
[uint16]$Module,
10+
11+
[Parameter(Mandatory = $true)]
12+
[string]$Name,
13+
14+
[string]$Label,
15+
16+
[Parameter(Mandatory = $true)]
17+
[string]$Type,
18+
19+
[ValidatePattern('^[0-9a-f]{6}$')]
20+
[string]$Color,
21+
22+
[Parameter(Mandatory = $true)]
23+
[uint16]$Rear_Port,
24+
25+
[uint16]$Rear_Port_Position,
26+
27+
[string]$Description,
28+
29+
[bool]$Mark_Connected,
30+
31+
[uint16[]]$Tags
32+
33+
)
34+
35+
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'front-ports'))
36+
37+
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
38+
39+
$URI = BuildNewURI -Segments $URIComponents.Segments
40+
41+
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
42+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
function Get-NetboxDCIMFrontPort {
2+
[CmdletBinding()]
3+
[OutputType([pscustomobject])]
4+
param
5+
(
6+
[uint16]$Limit,
7+
8+
[uint16]$Offset,
9+
10+
[Parameter(ValueFromPipelineByPropertyName = $true)]
11+
[uint16]$Id,
12+
13+
[string]$Name,
14+
15+
[string]$Device,
16+
17+
[uint16]$Device_Id,
18+
19+
[string]$Type,
20+
21+
[switch]$Raw
22+
)
23+
24+
process {
25+
26+
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'front-ports'))
27+
28+
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
29+
30+
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
31+
32+
InvokeNetboxRequest -URI $URI -Raw:$Raw
33+
}
34+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
function Remove-NetboxDCIMFrontPort {
2+
3+
[CmdletBinding(ConfirmImpact = 'High',
4+
SupportsShouldProcess = $true)]
5+
param
6+
(
7+
[Parameter(Mandatory = $true,
8+
ValueFromPipelineByPropertyName = $true)]
9+
[uint16[]]$Id,
10+
11+
[switch]$Force
12+
)
13+
14+
begin {
15+
16+
}
17+
18+
process {
19+
foreach ($FrontPortID in $Id) {
20+
$CurrentPort = Get-NetboxDCIMFrontPort -Id $FrontPortID -ErrorAction Stop
21+
22+
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentPort.Name) | ID: $($CurrentPort.Id)", "Remove")) {
23+
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'front-ports', $CurrentPort.Id))
24+
25+
$URI = BuildNewURI -Segments $Segments
26+
27+
InvokeNetboxRequest -URI $URI -Method DELETE
28+
}
29+
}
30+
}
31+
32+
end {
33+
34+
}
35+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
function Set-NetboxDCIMFrontPort {
2+
[CmdletBinding(ConfirmImpact = 'Medium',
3+
SupportsShouldProcess = $true)]
4+
[OutputType([pscustomobject])]
5+
param
6+
(
7+
[Parameter(Mandatory = $true,
8+
ValueFromPipelineByPropertyName = $true)]
9+
[uint16[]]$Id,
10+
11+
[uint16]$Device,
12+
13+
[uint16]$Module,
14+
15+
[string]$Name,
16+
17+
[string]$Label,
18+
19+
[string]$Type,
20+
21+
[ValidatePattern('^[0-9a-f]{6}$')]
22+
[string]$Color,
23+
24+
[uint16]$Rear_Port,
25+
26+
[uint16]$Rear_Port_Position,
27+
28+
[string]$Description,
29+
30+
[bool]$Mark_Connected,
31+
32+
[uint16[]]$Tags,
33+
34+
[switch]$Force
35+
)
36+
37+
begin {
38+
39+
}
40+
41+
process {
42+
foreach ($FrontPortID in $Id) {
43+
$CurrentPort = Get-NetboxDCIMFrontPort -Id $FrontPortID -ErrorAction Stop
44+
45+
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'front-ports', $CurrentPort.Id))
46+
47+
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
48+
49+
$URI = BuildNewURI -Segments $Segments
50+
51+
if ($Force -or $pscmdlet.ShouldProcess("Front Port ID $($CurrentPort.Id)", "Set")) {
52+
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
53+
}
54+
}
55+
}
56+
57+
end {
58+
59+
}
60+
}

Functions/DCIM/Interfaces/Get-NetboxDCIMInterface.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
function Get-NetboxDCIMInterface {
1+
function Get-NetboxDCIMInterface {
32
[CmdletBinding()]
43
[OutputType([pscustomobject])]
54
param

Functions/DCIM/Interfaces/Remove-NetboxDCIMInterface.ps1

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
2-
function Remove-NetboxDCIMInterface {
3-
<#
1+
function Remove-NetboxDCIMInterface {
2+
<#
43
.SYNOPSIS
54
Removes an interface
65
@@ -21,11 +20,11 @@ function Remove-NetboxDCIMInterface {
2120
#>
2221

2322
[CmdletBinding(ConfirmImpact = 'High',
24-
SupportsShouldProcess = $true)]
23+
SupportsShouldProcess = $true)]
2524
param
2625
(
2726
[Parameter(Mandatory = $true,
28-
ValueFromPipelineByPropertyName = $true)]
27+
ValueFromPipelineByPropertyName = $true)]
2928
[uint16[]]$Id,
3029

3130
[switch]$Force

Functions/DCIM/Interfaces/Set-NetboxDCIMInterface.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
function Set-NetboxDCIMInterface {
1+
function Set-NetboxDCIMInterface {
32
[CmdletBinding(ConfirmImpact = 'Medium',
43
SupportsShouldProcess = $true)]
54
[OutputType([pscustomobject])]
@@ -37,7 +36,9 @@ function Set-NetboxDCIMInterface {
3736
[uint16]$Untagged_VLAN,
3837

3938
[ValidateRange(1, 4094)]
40-
[uint16[]]$Tagged_VLANs
39+
[uint16[]]$Tagged_VLANs,
40+
41+
[switch]$Force
4142
)
4243

4344
begin {

0 commit comments

Comments
 (0)