mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-16 19:25:47 +00:00
Compare commits
163 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7129e7d3c7 | ||
|
|
bb43ac490c | ||
|
|
59a28faff5 | ||
|
|
b441e02e2b | ||
|
|
40c7aac059 | ||
|
|
e4eb42a7a3 | ||
|
|
bf01b354bd | ||
|
|
cceb8fe765 | ||
|
|
8326e3eb29 | ||
|
|
26cc2b3c0d | ||
|
|
44dcb252b8 | ||
|
|
88647882cc | ||
|
|
2233de974d | ||
|
|
9e00636fbe | ||
|
|
bb0dfc0aa4 | ||
|
|
4897d6b71f | ||
|
|
6c2d358171 | ||
|
|
383ca2b002 | ||
|
|
985f920900 | ||
|
|
a63478a8d6 | ||
|
|
080d655f8d | ||
|
|
914b245f24 | ||
|
|
58fbbeb0cd | ||
|
|
46068dcc04 | ||
|
|
5b0c2897e0 | ||
|
|
ec5f9e810f | ||
|
|
c2a3dc285b | ||
|
|
bea65f0b06 | ||
|
|
cf1bcb3691 | ||
|
|
0049ba4985 | ||
|
|
7c03023bb8 | ||
|
|
0fd989c82a | ||
|
|
d441a1ddac | ||
|
|
7caf1a1d93 | ||
|
|
29dd7ac038 | ||
|
|
eb4d0eeb3b | ||
|
|
6f4309aa04 | ||
|
|
5421febdd1 | ||
|
|
a4c1886a23 | ||
|
|
441b06eb04 | ||
|
|
5d6fb23e91 | ||
|
|
e2a5157790 | ||
|
|
27209d6917 | ||
|
|
6965f61e6e | ||
|
|
ddf0a081b4 | ||
|
|
d09e20baee | ||
|
|
7925db838f | ||
|
|
3e0d817267 | ||
|
|
010fb0410b | ||
|
|
44dc6c86a2 | ||
|
|
5b7f0c658b | ||
|
|
5333d10ce0 | ||
|
|
f289854ddf | ||
|
|
1fed2d27e6 | ||
|
|
c1a0675b02 | ||
|
|
6654f798b0 | ||
|
|
aa444871a4 | ||
|
|
1f3626f319 | ||
|
|
356bd71ac8 | ||
|
|
f5c94b206f | ||
|
|
35916a5ab7 | ||
|
|
c47d787447 | ||
|
|
1ec38d3da2 | ||
|
|
4a0bd1d2d0 | ||
|
|
8b8ca091b1 | ||
|
|
b720c03851 | ||
|
|
c0e18ec134 | ||
|
|
049745554e | ||
|
|
c91d5fd32c | ||
|
|
458a4ae7c2 | ||
|
|
6dd82ee688 | ||
|
|
d85f675469 | ||
|
|
d7c008871d | ||
|
|
ea75e796ef | ||
|
|
6b8caf0bd7 | ||
|
|
e7a67328bf | ||
|
|
ff0c0127cd | ||
|
|
c3621f237e | ||
|
|
cad361c1b4 | ||
|
|
cd0d6383e6 | ||
|
|
7aedcf8338 | ||
|
|
cb4e2f2f57 | ||
|
|
e29299022e | ||
|
|
9dd6bc2b0e | ||
|
|
3e03e1e3ad | ||
|
|
7edbae953f | ||
|
|
a608d6ebd7 | ||
|
|
e8a5fdf15d | ||
|
|
e162c05900 | ||
|
|
26c7ccfdd0 | ||
|
|
c8e0a96690 | ||
|
|
30ae377493 | ||
|
|
c11680a20e | ||
|
|
f9fc02756c | ||
|
|
48452ce686 | ||
|
|
42b00279cb | ||
|
|
8167b0dbf0 | ||
|
|
ddf1d22e18 | ||
|
|
11ae767a6c | ||
|
|
01335bd225 | ||
|
|
739f5e98e2 | ||
|
|
2b7c1b4be3 | ||
|
|
68161a78b0 | ||
|
|
17c4d9d779 | ||
|
|
ea9f6c41bc | ||
|
|
22607fde48 | ||
|
|
802ab317f6 | ||
|
|
218114d8fe | ||
|
|
c48bfe78ad | ||
|
|
06d758d7b3 | ||
|
|
989c5eaac2 | ||
|
|
6122fd2301 | ||
|
|
1f66348205 | ||
|
|
fcbb25c088 | ||
|
|
4800cc6564 | ||
|
|
1a2484db2c | ||
|
|
254a2798ac | ||
|
|
c8233ab572 | ||
|
|
c8c6d48ee4 | ||
|
|
2bf4ed6f6f | ||
|
|
4ad0562466 | ||
|
|
5b1ee45769 | ||
|
|
b164ffe0b4 | ||
|
|
1f89363cbd | ||
|
|
7436f53f54 | ||
|
|
5921bfee57 | ||
|
|
214d5615e7 | ||
|
|
cd6dad5937 | ||
|
|
ef03cc5467 | ||
|
|
13b00d4fc9 | ||
|
|
5a23e75512 | ||
|
|
5fc0a8e9fa | ||
|
|
83944e0a45 | ||
|
|
2595c58eaa | ||
|
|
cfb53cf933 | ||
|
|
6d00855644 | ||
|
|
ad4c80e4f6 | ||
|
|
e11dfe726b | ||
|
|
af5315d43a | ||
|
|
d087ff8eed | ||
|
|
3a4f8d9152 | ||
|
|
acbbb284d3 | ||
|
|
f29701ad2f | ||
|
|
7badb7cda8 | ||
|
|
55510e5f03 | ||
|
|
3b82f91fc0 | ||
|
|
ae9371e883 | ||
|
|
cc52fdc844 | ||
|
|
b4803a5697 | ||
|
|
c844322e48 | ||
|
|
6636fe74d8 | ||
|
|
de9b616093 | ||
|
|
43b628a736 | ||
|
|
a6b3d31d44 | ||
|
|
18852aa990 | ||
|
|
b72684709a | ||
|
|
9649237394 | ||
|
|
a905a8d598 | ||
|
|
ee7ba72450 | ||
|
|
b36632cb9a | ||
|
|
a98495e5f4 | ||
|
|
657a8405bc | ||
|
|
c9077abd51 |
141 changed files with 76869 additions and 8043 deletions
16
.github/workflows/pssa.yml
vendored
Normal file
16
.github/workflows/pssa.yml
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
name: CI
|
||||||
|
on: [pull_request]
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Run PSSA
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: lint
|
||||||
|
uses: docker://devblackops/github-action-psscriptanalyzer:2.3.0
|
||||||
|
with:
|
||||||
|
settingsPath: .vscode/PSScriptAnalyzerSettings.psd1
|
||||||
|
sendComment: false
|
||||||
|
failOnInfos: true
|
||||||
|
failOnErrors: true
|
||||||
|
failOnWarnings: true
|
||||||
16
.github/workflows/release.yml
vendored
Normal file
16
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Publish
|
||||||
|
run: |
|
||||||
|
pwsh -Command "Publish-Module -Path ./NetboxPS -NuGetApiKey ${{ secrets.PSGALLERY_API_KEY }}"
|
||||||
5
.vscode/PSScriptAnalyzerSettings.psd1
vendored
Normal file
5
.vscode/PSScriptAnalyzerSettings.psd1
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
@{
|
||||||
|
ExcludeRules = @(
|
||||||
|
'PSUseToExportFieldsInManifest'
|
||||||
|
)
|
||||||
|
}
|
||||||
22
.vscode/settings.json
vendored
Normal file
22
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Place your settings in this file to overwrite default and user settings.
|
||||||
|
{
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"files.trimTrailingWhitespace": true,
|
||||||
|
"powershell.scriptAnalysis.settingsPath": ".vscode/PSScriptAnalyzerSettings.psd1",
|
||||||
|
"powershell.codeFormatting.newLineAfterCloseBrace": false,
|
||||||
|
"powershell.codeFormatting.useCorrectCasing": true,
|
||||||
|
"powershell.codeFormatting.preset": "OTBS",
|
||||||
|
"powershell.codeFormatting.addWhitespaceAroundPipe": true,
|
||||||
|
"powershell.codeFormatting.autoCorrectAliases": true,
|
||||||
|
"powershell.codeFormatting.newLineAfterCloseBrace": true,
|
||||||
|
"powershell.codeFormatting.newLineAfterOpenBrace": true,
|
||||||
|
"powershell.codeFormatting.openBraceOnSameLine": true,
|
||||||
|
"powershell.codeFormatting.whitespaceAfterSeparator": true,
|
||||||
|
"powershell.codeFormatting.whitespaceAroundOperator": true,
|
||||||
|
"powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
|
||||||
|
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
|
||||||
|
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
|
||||||
|
"[markdown]": {
|
||||||
|
"files.trimTrailingWhitespace": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.148
|
|
||||||
Created on: 2/28/2018 4:06 PM
|
|
||||||
Created by: Ben Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Circuits.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
Circuit object functions
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
120
Functions/Circuits/Circuits/Get-NetboxCircuit.ps1
Normal file
120
Functions/Circuits/Circuits/Get-NetboxCircuit.ps1
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
|
||||||
|
function Get-NetboxCircuit {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets one or more circuits
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
A detailed description of the Get-NetboxCircuit function.
|
||||||
|
|
||||||
|
.PARAMETER Id
|
||||||
|
Database ID of circuit. This will query for exactly the IDs provided
|
||||||
|
|
||||||
|
.PARAMETER CID
|
||||||
|
Circuit ID
|
||||||
|
|
||||||
|
.PARAMETER InstallDate
|
||||||
|
Date of installation
|
||||||
|
|
||||||
|
.PARAMETER CommitRate
|
||||||
|
Committed rate in Kbps
|
||||||
|
|
||||||
|
.PARAMETER Query
|
||||||
|
A raw search query... As if you were searching the web site
|
||||||
|
|
||||||
|
.PARAMETER Provider
|
||||||
|
The name or ID of the provider. Provide either [string] or [uint64]. String will search provider names, integer will search database IDs
|
||||||
|
|
||||||
|
.PARAMETER Type
|
||||||
|
Type of circuit. Provide either [string] or [uint64]. String will search provider type names, integer will search database IDs
|
||||||
|
|
||||||
|
.PARAMETER Site
|
||||||
|
Location/site of circuit. Provide either [string] or [uint64]. String will search site names, integer will search database IDs
|
||||||
|
|
||||||
|
.PARAMETER Tenant
|
||||||
|
Tenant assigned to circuit. Provide either [string] or [uint64]. String will search tenant names, integer will search database IDs
|
||||||
|
|
||||||
|
.PARAMETER Limit
|
||||||
|
A description of the Limit parameter.
|
||||||
|
|
||||||
|
.PARAMETER Offset
|
||||||
|
A description of the Offset parameter.
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
A description of the Raw parameter.
|
||||||
|
|
||||||
|
.PARAMETER ID__IN
|
||||||
|
Multiple unique DB IDs to retrieve
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> Get-NetboxCircuit
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Additional information about the function.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'ById')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$CID,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[datetime]$InstallDate,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$CommitRate,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Query,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[object]$Provider,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[object]$Type,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Site,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Tenant,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($i in $ID) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits', $i))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
55
Functions/Circuits/Circuits/New-NetboxCircuit.ps1
Normal file
55
Functions/Circuits/Circuits/New-NetboxCircuit.ps1
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
|
||||||
|
function New-NetboxCircuit {
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[string]$CID,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[uint64]$Provider,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[uint64]$Type,
|
||||||
|
|
||||||
|
#[ValidateSet('Active', 'Planned', 'Provisioning', 'Offline', 'Deprovisioning', 'Decommissioned ')]
|
||||||
|
[uint16]$Status = 'Active',
|
||||||
|
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[uint64]$Tenant,
|
||||||
|
|
||||||
|
[string]$Termination_A,
|
||||||
|
|
||||||
|
[datetime]$Install_Date,
|
||||||
|
|
||||||
|
[string]$Termination_Z,
|
||||||
|
|
||||||
|
[ValidateRange(0, 2147483647)]
|
||||||
|
[uint64]$Commit_Rate,
|
||||||
|
|
||||||
|
[string]$Comments,
|
||||||
|
|
||||||
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
|
[switch]$Force,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits'))
|
||||||
|
$Method = 'POST'
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
if ($Force -or $PSCmdlet.ShouldProcess($CID, 'Create new circuit')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,83 +0,0 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:15
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxCircuit.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxCircuit {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Gets one or more circuits
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
A detailed description of the Get-NetboxCircuit function.
|
|
||||||
|
|
||||||
.PARAMETER CID
|
|
||||||
Circuit ID
|
|
||||||
|
|
||||||
.PARAMETER InstallDate
|
|
||||||
Date of installation
|
|
||||||
|
|
||||||
.PARAMETER CommitRate
|
|
||||||
Committed rate in Kbps
|
|
||||||
|
|
||||||
.PARAMETER Query
|
|
||||||
A raw search query... As if you were searching the web site
|
|
||||||
|
|
||||||
.PARAMETER Provider
|
|
||||||
The name or ID of the provider. Provide either [string] or [int]. String will search provider names, integer will search database IDs
|
|
||||||
|
|
||||||
.PARAMETER Type
|
|
||||||
Type of circuit. Provide either [string] or [int]. String will search provider type names, integer will search database IDs
|
|
||||||
|
|
||||||
.PARAMETER Site
|
|
||||||
Location/site of circuit. Provide either [string] or [int]. String will search site names, integer will search database IDs
|
|
||||||
|
|
||||||
.PARAMETER Tenant
|
|
||||||
Tenant assigned to circuit. Provide either [string] or [int]. String will search tenant names, integer will search database IDs
|
|
||||||
|
|
||||||
.PARAMETER Id
|
|
||||||
Database ID of circuit. This will query for exactly the IDs provided
|
|
||||||
|
|
||||||
.PARAMETER ID__IN
|
|
||||||
Multiple unique DB IDs to retrieve
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> Get-NetboxCircuit
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding()]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[string]$CID,
|
|
||||||
|
|
||||||
[datetime]$InstallDate,
|
|
||||||
|
|
||||||
[uint32]$CommitRate,
|
|
||||||
|
|
||||||
[string]$Query,
|
|
||||||
|
|
||||||
[object]$Provider,
|
|
||||||
|
|
||||||
[object]$Type,
|
|
||||||
|
|
||||||
[string]$Site,
|
|
||||||
|
|
||||||
[string]$Tenant,
|
|
||||||
|
|
||||||
[uint16[]]$Id
|
|
||||||
)
|
|
||||||
|
|
||||||
#TODO: Place script here
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:15
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxCircuitsChoices.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxCircuitsChoices {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Gets the choices associated with circuits
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
A detailed description of the Get-NetboxCircuitsChoices function.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> Get-NetboxCircuitsChoices
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding()]
|
|
||||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
|
|
||||||
param ()
|
|
||||||
|
|
||||||
$uriSegments = [System.Collections.ArrayList]::new(@('circuits', '_choices'))
|
|
||||||
$uri = BuildNewURI -Segments $uriSegments
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri
|
|
||||||
}
|
|
||||||
58
Functions/Circuits/Providers/Get-NetboxCircuitProvider.ps1
Normal file
58
Functions/Circuits/Providers/Get-NetboxCircuitProvider.ps1
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
|
||||||
|
function Get-NetboxCircuitProvider {
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'ById',
|
||||||
|
Mandatory = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query',
|
||||||
|
Mandatory = $false)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Query,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Slug,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$ASN,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Account,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($i in $ID) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'providers', $i))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'providers'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
|
||||||
|
function Get-NetboxCircuitTermination {
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'ById',
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Circuit_ID,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Term_Side,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Port_Speed,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Query,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Site_ID,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Site,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$XConnect_ID,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($i in $ID) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuit-terminations', $i))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuit-terminations'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
50
Functions/Circuits/Types/Get-NetboxCircuitType.ps1
Normal file
50
Functions/Circuits/Types/Get-NetboxCircuitType.ps1
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
|
||||||
|
function Get-NetboxCircuitType {
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'ById')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Slug,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Query,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($i in $ID) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuit_types', $i))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuit-types'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
function Get-NetboxDCIMCableTermination {
|
||||||
|
[CmdletBinding()]
|
||||||
|
#region Parameters
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[uint64]$Cable,
|
||||||
|
|
||||||
|
[string]$Cable_End,
|
||||||
|
|
||||||
|
[string]$Termination_Type,
|
||||||
|
|
||||||
|
[uint64]$Termination_ID,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
#endregion Parameters
|
||||||
|
|
||||||
|
process {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'cable-terminations'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
55
Functions/DCIM/Cables/Get-NetboxDCIMCable.ps1
Normal file
55
Functions/DCIM/Cables/Get-NetboxDCIMCable.ps1
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
function Get-NetboxDCIMCable {
|
||||||
|
[CmdletBinding()]
|
||||||
|
#region Parameters
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[string]$Label,
|
||||||
|
|
||||||
|
[string]$Termination_A_Type,
|
||||||
|
|
||||||
|
[uint64]$Termination_A_ID,
|
||||||
|
|
||||||
|
[string]$Termination_B_Type,
|
||||||
|
|
||||||
|
[uint64]$Termination_B_ID,
|
||||||
|
|
||||||
|
[string]$Type,
|
||||||
|
|
||||||
|
[string]$Status,
|
||||||
|
|
||||||
|
[string]$Color,
|
||||||
|
|
||||||
|
[uint64]$Device_ID,
|
||||||
|
|
||||||
|
[string]$Device,
|
||||||
|
|
||||||
|
[uint64]$Rack_Id,
|
||||||
|
|
||||||
|
[string]$Rack,
|
||||||
|
|
||||||
|
[uint64]$Location_ID,
|
||||||
|
|
||||||
|
[string]$Location,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
#endregion Parameters
|
||||||
|
|
||||||
|
process {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'cables'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:06
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxDCIMDevice.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMDevice {
|
function Get-NetboxDCIMDevice {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
#region Parameters
|
#region Parameters
|
||||||
|
|
@ -22,43 +9,43 @@ function Get-NetboxDCIMDevice {
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint16[]]$Id,
|
[uint64[]]$Id,
|
||||||
|
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[uint16]$Manufacturer_Id,
|
[uint64]$Manufacturer_Id,
|
||||||
|
|
||||||
[string]$Manufacturer,
|
[string]$Manufacturer,
|
||||||
|
|
||||||
[uint16]$Device_Type_Id,
|
[uint64]$Device_Type_Id,
|
||||||
|
|
||||||
[uint16]$Role_Id,
|
[uint64]$Role_Id,
|
||||||
|
|
||||||
[string]$Role,
|
[string]$Role,
|
||||||
|
|
||||||
[uint16]$Tenant_Id,
|
[uint64]$Tenant_Id,
|
||||||
|
|
||||||
[string]$Tenant,
|
[string]$Tenant,
|
||||||
|
|
||||||
[uint16]$Platform_Id,
|
[uint64]$Platform_Id,
|
||||||
|
|
||||||
[string]$Platform,
|
[string]$Platform,
|
||||||
|
|
||||||
[string]$Asset_Tag,
|
[string]$Asset_Tag,
|
||||||
|
|
||||||
[uint16]$Site_Id,
|
[uint64]$Site_Id,
|
||||||
|
|
||||||
[string]$Site,
|
[string]$Site,
|
||||||
|
|
||||||
[uint16]$Rack_Group_Id,
|
[uint64]$Rack_Group_Id,
|
||||||
|
|
||||||
[uint16]$Rack_Id,
|
[uint64]$Rack_Id,
|
||||||
|
|
||||||
[uint16]$Cluster_Id,
|
[uint64]$Cluster_Id,
|
||||||
|
|
||||||
[uint16]$Model,
|
[uint64]$Model,
|
||||||
|
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
||||||
|
|
@ -74,7 +61,7 @@ function Get-NetboxDCIMDevice {
|
||||||
|
|
||||||
[bool]$Has_Primary_IP,
|
[bool]$Has_Primary_IP,
|
||||||
|
|
||||||
[uint16]$Virtual_Chassis_Id,
|
[uint64]$Virtual_Chassis_Id,
|
||||||
|
|
||||||
[uint16]$Position,
|
[uint16]$Position,
|
||||||
|
|
||||||
|
|
@ -85,10 +72,7 @@ function Get-NetboxDCIMDevice {
|
||||||
|
|
||||||
#endregion Parameters
|
#endregion Parameters
|
||||||
|
|
||||||
if ($null -ne $Status) {
|
process {
|
||||||
$PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
|
||||||
}
|
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
||||||
|
|
@ -97,3 +81,4 @@ function Get-NetboxDCIMDevice {
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:07
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxDCIMDeviceRole.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMDeviceRole {
|
function Get-NetboxDCIMDeviceRole {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
|
|
@ -21,7 +8,7 @@ function Get-NetboxDCIMDeviceRole {
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ById')]
|
[Parameter(ParameterSetName = 'ById')]
|
||||||
[uint16[]]$Id,
|
[uint64[]]$Id,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:07
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxDCIMDeviceType.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMDeviceType {
|
function Get-NetboxDCIMDeviceType {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
#region Parameters
|
#region Parameters
|
||||||
|
|
@ -21,7 +8,7 @@ function Get-NetboxDCIMDeviceType {
|
||||||
|
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[uint16[]]$Id,
|
[uint64[]]$Id,
|
||||||
|
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
|
|
@ -29,7 +16,7 @@ function Get-NetboxDCIMDeviceType {
|
||||||
|
|
||||||
[string]$Manufacturer,
|
[string]$Manufacturer,
|
||||||
|
|
||||||
[uint16]$Manufacturer_Id,
|
[uint64]$Manufacturer_Id,
|
||||||
|
|
||||||
[string]$Model,
|
[string]$Model,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,7 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:08
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: New-NetboxDCIMDevice.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function New-NetboxDCIMDevice {
|
function New-NetboxDCIMDevice {
|
||||||
[CmdletBinding()]
|
[CmdletBinding(ConfirmImpact = 'low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
#region Parameters
|
#region Parameters
|
||||||
param
|
param
|
||||||
|
|
@ -28,17 +16,17 @@ function New-NetboxDCIMDevice {
|
||||||
[object]$Device_Type,
|
[object]$Device_Type,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint16]$Site,
|
[uint64]$Site,
|
||||||
|
|
||||||
[object]$Status = 'Active',
|
[object]$Status = 'Active',
|
||||||
|
|
||||||
[uint16]$Platform,
|
[uint64]$Platform,
|
||||||
|
|
||||||
[uint16]$Tenant,
|
[uint64]$Tenant,
|
||||||
|
|
||||||
[uint16]$Cluster,
|
[uint64]$Cluster,
|
||||||
|
|
||||||
[uint16]$Rack,
|
[uint64]$Rack,
|
||||||
|
|
||||||
[uint16]$Position,
|
[uint16]$Position,
|
||||||
|
|
||||||
|
|
@ -48,15 +36,15 @@ function New-NetboxDCIMDevice {
|
||||||
|
|
||||||
[string]$Asset_Tag,
|
[string]$Asset_Tag,
|
||||||
|
|
||||||
[uint16]$Virtual_Chassis,
|
[uint64]$Virtual_Chassis,
|
||||||
|
|
||||||
[uint16]$VC_Priority,
|
[uint64]$VC_Priority,
|
||||||
|
|
||||||
[uint16]$VC_Position,
|
[uint64]$VC_Position,
|
||||||
|
|
||||||
[uint16]$Primary_IP4,
|
[uint64]$Primary_IP4,
|
||||||
|
|
||||||
[uint16]$Primary_IP6,
|
[uint64]$Primary_IP6,
|
||||||
|
|
||||||
[string]$Comments,
|
[string]$Comments,
|
||||||
|
|
||||||
|
|
@ -64,27 +52,13 @@ function New-NetboxDCIMDevice {
|
||||||
)
|
)
|
||||||
#endregion Parameters
|
#endregion Parameters
|
||||||
|
|
||||||
if ($null -ne $Device_Role) {
|
|
||||||
# Validate device role?
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($null -ne $Device_Type) {
|
|
||||||
# Validate device type?
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($null -ne $Status) {
|
|
||||||
$PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($null -ne $Face) {
|
|
||||||
$PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
|
|
||||||
}
|
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess($Name, 'Create new Device')) {
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:08
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Remove-NetboxDCIMDevice.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Remove-NetboxDCIMDevice {
|
function Remove-NetboxDCIMDevice {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
@ -39,7 +26,7 @@ function Remove-NetboxDCIMDevice {
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint16[]]$Id,
|
[uint64[]]$Id,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,11 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:08
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Set-NetboxDCIMDevice.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Set-NetboxDCIMDevice {
|
function Set-NetboxDCIMDevice {
|
||||||
[CmdletBinding(SupportsShouldProcess = $true)]
|
[CmdletBinding(SupportsShouldProcess = $true)]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint16[]]$Id,
|
[uint64[]]$Id,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
|
|
@ -26,17 +13,17 @@ function Set-NetboxDCIMDevice {
|
||||||
|
|
||||||
[object]$Device_Type,
|
[object]$Device_Type,
|
||||||
|
|
||||||
[uint16]$Site,
|
[uint64]$Site,
|
||||||
|
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
||||||
[uint16]$Platform,
|
[uint64]$Platform,
|
||||||
|
|
||||||
[uint16]$Tenant,
|
[uint64]$Tenant,
|
||||||
|
|
||||||
[uint16]$Cluster,
|
[uint64]$Cluster,
|
||||||
|
|
||||||
[uint16]$Rack,
|
[uint64]$Rack,
|
||||||
|
|
||||||
[uint16]$Position,
|
[uint16]$Position,
|
||||||
|
|
||||||
|
|
@ -46,15 +33,15 @@ function Set-NetboxDCIMDevice {
|
||||||
|
|
||||||
[string]$Asset_Tag,
|
[string]$Asset_Tag,
|
||||||
|
|
||||||
[uint16]$Virtual_Chassis,
|
[uint64]$Virtual_Chassis,
|
||||||
|
|
||||||
[uint16]$VC_Priority,
|
[uint64]$VC_Priority,
|
||||||
|
|
||||||
[uint16]$VC_Position,
|
[uint64]$VC_Position,
|
||||||
|
|
||||||
[uint16]$Primary_IP4,
|
[uint64]$Primary_IP4,
|
||||||
|
|
||||||
[uint16]$Primary_IP6,
|
[uint64]$Primary_IP6,
|
||||||
|
|
||||||
[string]$Comments,
|
[string]$Comments,
|
||||||
|
|
||||||
|
|
@ -64,13 +51,7 @@ function Set-NetboxDCIMDevice {
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
if ($null -ne $Status) {
|
|
||||||
$PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($null -ne $Face) {
|
|
||||||
$PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
|
|
|
||||||
42
Functions/DCIM/FrontPorts/Add-NetboxDCIMFrontPort.ps1
Normal file
42
Functions/DCIM/FrontPorts/Add-NetboxDCIMFrontPort.ps1
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
function Add-NetboxDCIMFrontPort {
|
||||||
|
[CmdletBinding()]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[uint64]$Device,
|
||||||
|
|
||||||
|
[uint64]$Module,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[string]$Label,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Type,
|
||||||
|
|
||||||
|
[ValidatePattern('^[0-9a-f]{6}$')]
|
||||||
|
[string]$Color,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[uint64]$Rear_Port,
|
||||||
|
|
||||||
|
[uint64]$Rear_Port_Position,
|
||||||
|
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[bool]$Mark_Connected,
|
||||||
|
|
||||||
|
[uint16[]]$Tags
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'front-ports'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
||||||
|
}
|
||||||
34
Functions/DCIM/FrontPorts/Get-NetboxDCIMFrontPort.ps1
Normal file
34
Functions/DCIM/FrontPorts/Get-NetboxDCIMFrontPort.ps1
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
function Get-NetboxDCIMFrontPort {
|
||||||
|
[CmdletBinding()]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64]$Id,
|
||||||
|
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[string]$Device,
|
||||||
|
|
||||||
|
[uint64]$Device_Id,
|
||||||
|
|
||||||
|
[string]$Type,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'front-ports'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
35
Functions/DCIM/FrontPorts/Remove-NetboxDCIMFrontPort.ps1
Normal file
35
Functions/DCIM/FrontPorts/Remove-NetboxDCIMFrontPort.ps1
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
function Remove-NetboxDCIMFrontPort {
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'High',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[switch]$Force
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach ($FrontPortID in $Id) {
|
||||||
|
$CurrentPort = Get-NetboxDCIMFrontPort -Id $FrontPortID -ErrorAction Stop
|
||||||
|
|
||||||
|
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentPort.Name) | ID: $($CurrentPort.Id)", "Remove")) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'front-ports', $CurrentPort.Id))
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Method DELETE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
60
Functions/DCIM/FrontPorts/Set-NetboxDCIMFrontPort.ps1
Normal file
60
Functions/DCIM/FrontPorts/Set-NetboxDCIMFrontPort.ps1
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
function Set-NetboxDCIMFrontPort {
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[uint16]$Device,
|
||||||
|
|
||||||
|
[uint16]$Module,
|
||||||
|
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[string]$Label,
|
||||||
|
|
||||||
|
[string]$Type,
|
||||||
|
|
||||||
|
[ValidatePattern('^[0-9a-f]{6}$')]
|
||||||
|
[string]$Color,
|
||||||
|
|
||||||
|
[uint64]$Rear_Port,
|
||||||
|
|
||||||
|
[uint16]$Rear_Port_Position,
|
||||||
|
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[bool]$Mark_Connected,
|
||||||
|
|
||||||
|
[uint64[]]$Tags,
|
||||||
|
|
||||||
|
[switch]$Force
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach ($FrontPortID in $Id) {
|
||||||
|
$CurrentPort = Get-NetboxDCIMFrontPort -Id $FrontPortID -ErrorAction Stop
|
||||||
|
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'front-ports', $CurrentPort.Id))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
|
if ($Force -or $pscmdlet.ShouldProcess("Front Port ID $($CurrentPort.Id)", "Set")) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:13
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxDCIMChoices.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMChoices {
|
|
||||||
[CmdletBinding()]
|
|
||||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
|
|
||||||
param ()
|
|
||||||
|
|
||||||
$uriSegments = [System.Collections.ArrayList]::new(@('dcim', '_choices'))
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $uriSegments -Parameters $Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:13
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxDCIMPlatform.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMPlatform {
|
function Get-NetboxDCIMPlatform {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
|
|
@ -22,13 +9,13 @@ function Get-NetboxDCIMPlatform {
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ById')]
|
[Parameter(ParameterSetName = 'ById')]
|
||||||
[uint16[]]$Id,
|
[uint64[]]$Id,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[uint16]$Manufacturer_Id,
|
[uint64]$Manufacturer_Id,
|
||||||
|
|
||||||
[string]$Manufacturer,
|
[string]$Manufacturer,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,18 @@
|
||||||
<#
|
|
||||||
.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-NetboxDCIMInterface.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Add-NetboxDCIMInterface {
|
function Add-NetboxDCIMInterface {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint16]$Device,
|
[uint64]$Device,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
|
[ValidateSet('virtual', 'bridge', 'lag', '100base-tx', '1000base-t', '2.5gbase-t', '5gbase-t', '10gbase-t', '10gbase-cx4', '1000base-x-gbic', '1000base-x-sfp', '10gbase-x-sfpp', '10gbase-x-xfp', '10gbase-x-xenpak', '10gbase-x-x2', '25gbase-x-sfp28', '50gbase-x-sfp56', '40gbase-x-qsfpp', '50gbase-x-sfp28', '100gbase-x-cfp', '100gbase-x-cfp2', '200gbase-x-cfp2', '100gbase-x-cfp4', '100gbase-x-cpak', '100gbase-x-qsfp28', '200gbase-x-qsfp56', '400gbase-x-qsfpdd', '400gbase-x-osfp', '1000base-kx', '10gbase-kr', '10gbase-kx4', '25gbase-kr', '40gbase-kr4', '50gbase-kr', '100gbase-kp4', '100gbase-kr2', '100gbase-kr4', 'ieee802.11a', 'ieee802.11g', 'ieee802.11n', 'ieee802.11ac', 'ieee802.11ad', 'ieee802.11ax', 'ieee802.11ay', 'ieee802.15.1', 'other-wireless', 'gsm', 'cdma', 'lte', 'sonet-oc3', 'sonet-oc12', 'sonet-oc48', 'sonet-oc192', 'sonet-oc768', 'sonet-oc1920', 'sonet-oc3840', '1gfc-sfp', '2gfc-sfp', '4gfc-sfp', '8gfc-sfpp', '16gfc-sfpp', '32gfc-sfp28', '64gfc-qsfpp', '128gfc-qsfp28', 'infiniband-sdr', 'infiniband-ddr', 'infiniband-qdr', 'infiniband-fdr10', 'infiniband-fdr', 'infiniband-edr', 'infiniband-hdr', 'infiniband-ndr', 'infiniband-xdr', 't1', 'e1', 't3', 'e3', 'xdsl', 'docsis', 'gpon', 'xg-pon', 'xgs-pon', 'ng-pon2', 'epon', '10g-epon', 'cisco-stackwise', 'cisco-stackwise-plus', 'cisco-flexstack', 'cisco-flexstack-plus', 'cisco-stackwise-80', 'cisco-stackwise-160', 'cisco-stackwise-320', 'cisco-stackwise-480', 'juniper-vcp', 'extreme-summitstack', 'extreme-summitstack-128', 'extreme-summitstack-256', 'extreme-summitstack-512', 'other', IgnoreCase = $true)]
|
||||||
|
[string]$Type,
|
||||||
|
|
||||||
[bool]$Enabled,
|
[bool]$Enabled,
|
||||||
|
|
||||||
[object]$Form_Factor,
|
[object]$Form_Factor,
|
||||||
|
|
@ -33,7 +23,7 @@ function Add-NetboxDCIMInterface {
|
||||||
|
|
||||||
[bool]$MGMT_Only,
|
[bool]$MGMT_Only,
|
||||||
|
|
||||||
[uint16]$LAG,
|
[uint64]$LAG,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
|
|
@ -47,10 +37,6 @@ function Add-NetboxDCIMInterface {
|
||||||
[uint16[]]$Tagged_VLANs
|
[uint16[]]$Tagged_VLANs
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($null -ne $Form_Factor) {
|
|
||||||
$PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
|
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
|
||||||
$PSBoundParameters.Mode = switch ($Mode) {
|
$PSBoundParameters.Mode = switch ($Mode) {
|
||||||
'Access' {
|
'Access' {
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.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 {
|
function Add-NetboxDCIMInterfaceConnection {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
@ -43,19 +30,15 @@ function Add-NetboxDCIMInterfaceConnection {
|
||||||
[object]$Connection_Status,
|
[object]$Connection_Status,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint16]$Interface_A,
|
[uint64]$Interface_A,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint16]$Interface_B
|
[uint64]$Interface_B
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($null -ne $Connection_Status) {
|
|
||||||
$PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
|
|
||||||
}
|
|
||||||
|
|
||||||
# Verify if both Interfaces exist
|
# Verify if both Interfaces exist
|
||||||
$I_A = Get-NetboxDCIMInterface -Id $Interface_A -ErrorAction Stop
|
Get-NetboxDCIMInterface -Id $Interface_A -ErrorAction Stop | Out-null
|
||||||
$I_B = Get-NetboxDCIMInterface -Id $Interface_B -ErrorAction Stop
|
Get-NetboxDCIMInterface -Id $Interface_B -ErrorAction Stop | Out-null
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,4 @@
|
||||||
<#
|
function Get-NetboxDCIMInterface {
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:09
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxDCIMInterface.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMInterface {
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
|
|
@ -22,9 +8,9 @@ function Get-NetboxDCIMInterface {
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint16]$Id,
|
[uint64]$Id,
|
||||||
|
|
||||||
[uint16]$Name,
|
[uint64]$Name,
|
||||||
|
|
||||||
[object]$Form_Factor,
|
[object]$Form_Factor,
|
||||||
|
|
||||||
|
|
@ -36,21 +22,19 @@ function Get-NetboxDCIMInterface {
|
||||||
|
|
||||||
[string]$Device,
|
[string]$Device,
|
||||||
|
|
||||||
[uint16]$Device_Id,
|
[uint64]$Device_Id,
|
||||||
|
|
||||||
[uint16]$Type,
|
[ValidateSet('virtual', 'bridge', 'lag', '100base-tx', '1000base-t', '2.5gbase-t', '5gbase-t', '10gbase-t', '10gbase-cx4', '1000base-x-gbic', '1000base-x-sfp', '10gbase-x-sfpp', '10gbase-x-xfp', '10gbase-x-xenpak', '10gbase-x-x2', '25gbase-x-sfp28', '50gbase-x-sfp56', '40gbase-x-qsfpp', '50gbase-x-sfp28', '100gbase-x-cfp', '100gbase-x-cfp2', '200gbase-x-cfp2', '100gbase-x-cfp4', '100gbase-x-cpak', '100gbase-x-qsfp28', '200gbase-x-qsfp56', '400gbase-x-qsfpdd', '400gbase-x-osfp', '1000base-kx', '10gbase-kr', '10gbase-kx4', '25gbase-kr', '40gbase-kr4', '50gbase-kr', '100gbase-kp4', '100gbase-kr2', '100gbase-kr4', 'ieee802.11a', 'ieee802.11g', 'ieee802.11n', 'ieee802.11ac', 'ieee802.11ad', 'ieee802.11ax', 'ieee802.11ay', 'ieee802.15.1', 'other-wireless', 'gsm', 'cdma', 'lte', 'sonet-oc3', 'sonet-oc12', 'sonet-oc48', 'sonet-oc192', 'sonet-oc768', 'sonet-oc1920', 'sonet-oc3840', '1gfc-sfp', '2gfc-sfp', '4gfc-sfp', '8gfc-sfpp', '16gfc-sfpp', '32gfc-sfp28', '64gfc-qsfpp', '128gfc-qsfp28', 'infiniband-sdr', 'infiniband-ddr', 'infiniband-qdr', 'infiniband-fdr10', 'infiniband-fdr', 'infiniband-edr', 'infiniband-hdr', 'infiniband-ndr', 'infiniband-xdr', 't1', 'e1', 't3', 'e3', 'xdsl', 'docsis', 'gpon', 'xg-pon', 'xgs-pon', 'ng-pon2', 'epon', '10g-epon', 'cisco-stackwise', 'cisco-stackwise-plus', 'cisco-flexstack', 'cisco-flexstack-plus', 'cisco-stackwise-80', 'cisco-stackwise-160', 'cisco-stackwise-320', 'cisco-stackwise-480', 'juniper-vcp', 'extreme-summitstack', 'extreme-summitstack-128', 'extreme-summitstack-256', 'extreme-summitstack-512', 'other', IgnoreCase = $true)]
|
||||||
|
[string]$Type,
|
||||||
|
|
||||||
[uint16]$LAG_Id,
|
[uint64]$LAG_Id,
|
||||||
|
|
||||||
[string]$MAC_Address,
|
[string]$MAC_Address,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($null -ne $Form_Factor) {
|
process {
|
||||||
$PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
|
||||||
}
|
|
||||||
|
|
||||||
$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
|
||||||
|
|
@ -59,3 +43,4 @@ function Get-NetboxDCIMInterface {
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.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: Get-NetboxDCIMInterfaceConnection.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMInterfaceConnection {
|
function Get-NetboxDCIMInterfaceConnection {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
|
|
@ -21,21 +8,17 @@ function Get-NetboxDCIMInterfaceConnection {
|
||||||
|
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[uint16]$Id,
|
[uint64]$Id,
|
||||||
|
|
||||||
[object]$Connection_Status,
|
[object]$Connection_Status,
|
||||||
|
|
||||||
[uint16]$Site,
|
[uint64]$Site,
|
||||||
|
|
||||||
[uint16]$Device,
|
[uint64]$Device,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($null -ne $Connection_Status) {
|
|
||||||
$PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
|
|
||||||
}
|
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,4 @@
|
||||||
<#
|
function Remove-NetboxDCIMInterface {
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:11
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Remove-NetboxDCIMInterface.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Remove-NetboxDCIMInterface {
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Removes an interface
|
Removes an interface
|
||||||
|
|
@ -39,7 +25,7 @@ function Remove-NetboxDCIMInterface {
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint16[]]$Id,
|
[uint64[]]$Id,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:12
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Remove-NetboxDCIMInterfaceConnection.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Remove-NetboxDCIMInterfaceConnection {
|
function Remove-NetboxDCIMInterfaceConnection {
|
||||||
[CmdletBinding(ConfirmImpact = 'High',
|
[CmdletBinding(ConfirmImpact = 'High',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
|
|
@ -20,7 +7,7 @@ function Remove-NetboxDCIMInterfaceConnection {
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint16[]]$Id,
|
[uint64[]]$Id,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,14 @@
|
||||||
<#
|
function Set-NetboxDCIMInterface {
|
||||||
.NOTES
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
===========================================================================
|
SupportsShouldProcess = $true)]
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:11
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Set-NetboxDCIMInterface.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Set-NetboxDCIMInterface {
|
|
||||||
[CmdletBinding()]
|
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint16[]]$Id,
|
[uint64[]]$Id,
|
||||||
|
|
||||||
[uint16]$Device,
|
[uint64]$Device,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
|
|
@ -29,13 +16,16 @@ function Set-NetboxDCIMInterface {
|
||||||
|
|
||||||
[object]$Form_Factor,
|
[object]$Form_Factor,
|
||||||
|
|
||||||
|
[ValidateSet('virtual', 'bridge', 'lag', '100base-tx', '1000base-t', '2.5gbase-t', '5gbase-t', '10gbase-t', '10gbase-cx4', '1000base-x-gbic', '1000base-x-sfp', '10gbase-x-sfpp', '10gbase-x-xfp', '10gbase-x-xenpak', '10gbase-x-x2', '25gbase-x-sfp28', '50gbase-x-sfp56', '40gbase-x-qsfpp', '50gbase-x-sfp28', '100gbase-x-cfp', '100gbase-x-cfp2', '200gbase-x-cfp2', '100gbase-x-cfp4', '100gbase-x-cpak', '100gbase-x-qsfp28', '200gbase-x-qsfp56', '400gbase-x-qsfpdd', '400gbase-x-osfp', '1000base-kx', '10gbase-kr', '10gbase-kx4', '25gbase-kr', '40gbase-kr4', '50gbase-kr', '100gbase-kp4', '100gbase-kr2', '100gbase-kr4', 'ieee802.11a', 'ieee802.11g', 'ieee802.11n', 'ieee802.11ac', 'ieee802.11ad', 'ieee802.11ax', 'ieee802.11ay', 'ieee802.15.1', 'other-wireless', 'gsm', 'cdma', 'lte', 'sonet-oc3', 'sonet-oc12', 'sonet-oc48', 'sonet-oc192', 'sonet-oc768', 'sonet-oc1920', 'sonet-oc3840', '1gfc-sfp', '2gfc-sfp', '4gfc-sfp', '8gfc-sfpp', '16gfc-sfpp', '32gfc-sfp28', '64gfc-qsfpp', '128gfc-qsfp28', 'infiniband-sdr', 'infiniband-ddr', 'infiniband-qdr', 'infiniband-fdr10', 'infiniband-fdr', 'infiniband-edr', 'infiniband-hdr', 'infiniband-ndr', 'infiniband-xdr', 't1', 'e1', 't3', 'e3', 'xdsl', 'docsis', 'gpon', 'xg-pon', 'xgs-pon', 'ng-pon2', 'epon', '10g-epon', 'cisco-stackwise', 'cisco-stackwise-plus', 'cisco-flexstack', 'cisco-flexstack-plus', 'cisco-stackwise-80', 'cisco-stackwise-160', 'cisco-stackwise-320', 'cisco-stackwise-480', 'juniper-vcp', 'extreme-summitstack', 'extreme-summitstack-128', 'extreme-summitstack-256', 'extreme-summitstack-512', 'other', IgnoreCase = $true)]
|
||||||
|
[string]$Type,
|
||||||
|
|
||||||
[uint16]$MTU,
|
[uint16]$MTU,
|
||||||
|
|
||||||
[string]$MAC_Address,
|
[string]$MAC_Address,
|
||||||
|
|
||||||
[bool]$MGMT_Only,
|
[bool]$MGMT_Only,
|
||||||
|
|
||||||
[uint16]$LAG,
|
[uint64]$LAG,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
|
|
@ -46,14 +36,12 @@ function Set-NetboxDCIMInterface {
|
||||||
[uint16]$Untagged_VLAN,
|
[uint16]$Untagged_VLAN,
|
||||||
|
|
||||||
[ValidateRange(1, 4094)]
|
[ValidateRange(1, 4094)]
|
||||||
[uint16[]]$Tagged_VLANs
|
[uint16[]]$Tagged_VLANs,
|
||||||
|
|
||||||
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
if ($null -ne $Form_Factor) {
|
|
||||||
$PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
|
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
|
||||||
$PSBoundParameters.Mode = switch ($Mode) {
|
$PSBoundParameters.Mode = switch ($Mode) {
|
||||||
'Access' {
|
'Access' {
|
||||||
|
|
@ -88,9 +76,11 @@ function Set-NetboxDCIMInterface {
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $Segments
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
|
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 {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/23/2020 12:11
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Set-NetboxDCIMInterfaceConnection.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Set-NetboxDCIMInterfaceConnection {
|
function Set-NetboxDCIMInterfaceConnection {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
@ -48,22 +35,18 @@ function Set-NetboxDCIMInterfaceConnection {
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint16[]]$Id,
|
[uint64[]]$Id,
|
||||||
|
|
||||||
[object]$Connection_Status,
|
[object]$Connection_Status,
|
||||||
|
|
||||||
[uint16]$Interface_A,
|
[uint64]$Interface_A,
|
||||||
|
|
||||||
[uint16]$Interface_B,
|
[uint64]$Interface_B,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
if ($null -ne $Connection_Status) {
|
|
||||||
$PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((@($ID).Count -gt 1) -and ($Interface_A -or $Interface_B)) {
|
if ((@($ID).Count -gt 1) -and ($Interface_A -or $Interface_B)) {
|
||||||
throw "Cannot set multiple connections to the same interface"
|
throw "Cannot set multiple connections to the same interface"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
48
Functions/DCIM/RearPorts/Add-NetboxDCIMRearPort.ps1
Normal file
48
Functions/DCIM/RearPorts/Add-NetboxDCIMRearPort.ps1
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
function Add-NetboxDCIMRearPort {
|
||||||
|
[CmdletBinding()]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[uint64]$Device,
|
||||||
|
|
||||||
|
[uint64]$Module,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[string]$Label,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Type,
|
||||||
|
|
||||||
|
[ValidatePattern('^[0-9a-f]{6}$')]
|
||||||
|
[string]$Color,
|
||||||
|
|
||||||
|
[uint16]$Positions = 1,
|
||||||
|
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[bool]$Mark_Connected,
|
||||||
|
|
||||||
|
[uint16[]]$Tags
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'rear-ports'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
||||||
|
}
|
||||||
|
|
||||||
|
end {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
34
Functions/DCIM/RearPorts/Get-NetboxDCIMRearPort.ps1
Normal file
34
Functions/DCIM/RearPorts/Get-NetboxDCIMRearPort.ps1
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
function Get-NetboxDCIMRearPort {
|
||||||
|
[CmdletBinding()]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64]$Id,
|
||||||
|
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[string]$Device,
|
||||||
|
|
||||||
|
[uint64]$Device_Id,
|
||||||
|
|
||||||
|
[string]$Type,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'rear-ports'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
35
Functions/DCIM/RearPorts/Remove-NetboxDCIMRearPort.ps1
Normal file
35
Functions/DCIM/RearPorts/Remove-NetboxDCIMRearPort.ps1
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
function Remove-NetboxDCIMRearPort {
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'High',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[switch]$Force
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach ($RearPortID in $Id) {
|
||||||
|
$CurrentPort = Get-NetboxDCIMRearPort -Id $RearPortID -ErrorAction Stop
|
||||||
|
|
||||||
|
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentPort.Name) | ID: $($CurrentPort.Id)", "Remove")) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'rear-ports', $CurrentPort.Id))
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Method DELETE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
59
Functions/DCIM/RearPorts/Set-NetboxDCIMRearPort.ps1
Normal file
59
Functions/DCIM/RearPorts/Set-NetboxDCIMRearPort.ps1
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
|
||||||
|
function Set-NetboxDCIMRearPort {
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[uint64]$Device,
|
||||||
|
|
||||||
|
[uint64]$Module,
|
||||||
|
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[string]$Label,
|
||||||
|
|
||||||
|
[string]$Type,
|
||||||
|
|
||||||
|
[ValidatePattern('^[0-9a-f]{6}$')]
|
||||||
|
[string]$Color,
|
||||||
|
|
||||||
|
[uint16]$Positions,
|
||||||
|
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[bool]$Mark_Connected,
|
||||||
|
|
||||||
|
[uint16[]]$Tags,
|
||||||
|
|
||||||
|
[switch]$Force
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach ($RearPortID in $Id) {
|
||||||
|
$CurrentPort = Get-NetboxDCIMRearPort -Id $RearPortID -ErrorAction Stop
|
||||||
|
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'rear-ports', $CurrentPort.Id))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
|
if ($Force -or $pscmdlet.ShouldProcess("Rear Port ID $($CurrentPort.Id)", "Set")) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
95
Functions/DCIM/Sites/Get-NetboxDCIMSite.ps1
Normal file
95
Functions/DCIM/Sites/Get-NetboxDCIMSite.ps1
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
|
||||||
|
function Get-NetboxDCIMSite {
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'ByID', ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Query,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Slug,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Facility,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$ASN,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[decimal]$Latitude,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[decimal]$Longitude,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Contact_Name,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Contact_Phone,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Contact_Email,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Tenant_Group_ID,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Tenant_Group,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Tenant_ID,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Tenant,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Status,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Region_ID,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Region,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($Site_ID in $ID) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites', $Site_Id))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
86
Functions/DCIM/Sites/New-NetboxDCIMSite.ps1
Normal file
86
Functions/DCIM/Sites/New-NetboxDCIMSite.ps1
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
||||||
|
Created on: 2020-10-02 15:52
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: New-NetboxDCIMSite.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function New-NetboxDCIMSite {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Create a new Site to Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Create a new Site to Netbox
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
New-NetboxDCIMSite -name MySite
|
||||||
|
|
||||||
|
Add new Site MySite on Netbox
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[string]$Slug,
|
||||||
|
|
||||||
|
[string]$Facility,
|
||||||
|
|
||||||
|
[uint64]$ASN,
|
||||||
|
|
||||||
|
[decimal]$Latitude,
|
||||||
|
|
||||||
|
[decimal]$Longitude,
|
||||||
|
|
||||||
|
[string]$Contact_Name,
|
||||||
|
|
||||||
|
[string]$Contact_Phone,
|
||||||
|
|
||||||
|
[string]$Contact_Email,
|
||||||
|
|
||||||
|
[uint64]$Tenant_Group,
|
||||||
|
|
||||||
|
[uint64]$Tenant,
|
||||||
|
|
||||||
|
[string]$Status,
|
||||||
|
|
||||||
|
[uint64]$Region,
|
||||||
|
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[string]$Comments,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites'))
|
||||||
|
$Method = 'POST'
|
||||||
|
|
||||||
|
if (-not $PSBoundParameters.ContainsKey('slug')) {
|
||||||
|
$PSBoundParameters.Add('slug', $name)
|
||||||
|
}
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess($name, 'Create new Site')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
64
Functions/DCIM/Sites/Remove-NetboxDCIMSite.ps1
Normal file
64
Functions/DCIM/Sites/Remove-NetboxDCIMSite.ps1
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
||||||
|
Created on: 2020-10-02 15:52
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: New-NetboxDCIMSite.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
function Remove-NetboxDCIMSite {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Remove a Site
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Remove a DCIM Site from Netbox
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Remove-NetboxDCIMSite -Id 1
|
||||||
|
|
||||||
|
Remove DCM Site with id 1
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-NetboxDCIMSite -name My Site | Remove-NetboxDCIMSite -confirm:$false
|
||||||
|
|
||||||
|
Remove DCM Site with name My Site without confirmation
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'High',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint]$Id
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
$CurrentSite = Get-NetboxDCIMSite -Id $Id -ErrorAction Stop
|
||||||
|
|
||||||
|
if ($pscmdlet.ShouldProcess("$($CurrentSite.Name)/$($CurrentSite.Id)", "Remove Site")) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites', $CurrentSite.Id))
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Method DELETE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,102 +0,0 @@
|
||||||
function ValidateDCIMChoice {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Internal function to validate provided values for static choices
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
When users connect to the API, choices for each major object are cached to the config variable.
|
|
||||||
These values are then utilized to validate if the provided value from a user is valid.
|
|
||||||
|
|
||||||
.PARAMETER ProvidedValue
|
|
||||||
The value to validate against static choices
|
|
||||||
|
|
||||||
.PARAMETER PowerConnectionStatus
|
|
||||||
Validate against power connection status values
|
|
||||||
|
|
||||||
.PARAMETER InterfaceTemplateFormFactor
|
|
||||||
Validate against interface template form factor values
|
|
||||||
|
|
||||||
.PARAMETER InterfaceConnectionStatus
|
|
||||||
Validate against interface connection status values
|
|
||||||
|
|
||||||
.PARAMETER InterfaceFormFactor
|
|
||||||
Validate against interface form factor values
|
|
||||||
|
|
||||||
.PARAMETER ConsolePortConnectionStatus
|
|
||||||
Validate against console port connection status values
|
|
||||||
|
|
||||||
.PARAMETER DeviceStatus
|
|
||||||
Validate against device status values
|
|
||||||
|
|
||||||
.PARAMETER DeviceFace
|
|
||||||
Validate against device face values
|
|
||||||
|
|
||||||
.PARAMETER RackType
|
|
||||||
Validate against rack type values
|
|
||||||
|
|
||||||
.PARAMETER RackWidth
|
|
||||||
Validate against rack width values.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> ValidateDCIMChoice -ProvidedValue 'rear' -DeviceFace
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> ValidateDCIMChoice -ProvidedValue 'middle' -DeviceFace
|
|
||||||
>> Invalid value middle for device:face. Must be one of: 0, 1, Front, Rear
|
|
||||||
|
|
||||||
.OUTPUTS
|
|
||||||
This function returns the integer value if valid. Otherwise, it will throw an error.
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
|
|
||||||
.FUNCTIONALITY
|
|
||||||
This cmdlet is intended to be used internally and not exposed to the user
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding()]
|
|
||||||
[OutputType([uint16])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[object]$ProvidedValue,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'power-port:connection_status',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$PowerConnectionStatus,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'interface-template:form_factor',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$InterfaceTemplateFormFactor,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'interface-connection:connection_status',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$InterfaceConnectionStatus,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'interface:form_factor',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$InterfaceFormFactor,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'console-port:connection_status',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$ConsolePortConnectionStatus,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'device:status',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$DeviceStatus,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'device:face',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$DeviceFace,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'rack:type',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$RackType,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'rack:width',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$RackWidth
|
|
||||||
)
|
|
||||||
|
|
||||||
ValidateChoice -MajorObject 'DCIM' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
function Get-NetboxExtrasChoices {
|
|
||||||
[CmdletBinding()]
|
|
||||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
|
|
||||||
param ()
|
|
||||||
|
|
||||||
$uriSegments = [System.Collections.ArrayList]::new(@('extras', '_choices'))
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $uriSegments
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri
|
|
||||||
}
|
|
||||||
31
Functions/Extras/Tags/Get-NetboxTag.ps1
Normal file
31
Functions/Extras/Tags/Get-NetboxTag.ps1
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
function Get-NetboxTag {
|
||||||
|
[CmdletBinding()]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64]$Id,
|
||||||
|
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[string]$Slug,
|
||||||
|
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('extras', 'tags'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/26/2020 14:22
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: BuildNewURI.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function BuildNewURI {
|
function BuildNewURI {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
@ -49,21 +36,12 @@ function BuildNewURI {
|
||||||
[OutputType([System.UriBuilder])]
|
[OutputType([System.UriBuilder])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[string]$Hostname,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[string[]]$Segments,
|
[string[]]$Segments,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[hashtable]$Parameters,
|
[hashtable]$Parameters,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[boolean]$HTTPS = $true,
|
|
||||||
|
|
||||||
[ValidateRange(1, 65535)]
|
|
||||||
[uint16]$Port = 443,
|
|
||||||
|
|
||||||
[switch]$SkipConnectedCheck
|
[switch]$SkipConnectedCheck
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -74,28 +52,8 @@ function BuildNewURI {
|
||||||
$null = CheckNetboxIsConnected
|
$null = CheckNetboxIsConnected
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not $Hostname) {
|
|
||||||
$Hostname = Get-NetboxHostname
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($HTTPS) {
|
|
||||||
Write-Verbose " Setting scheme to HTTPS"
|
|
||||||
$Scheme = 'https'
|
|
||||||
} else {
|
|
||||||
Write-Warning " Connecting via non-secure HTTP is not-recommended"
|
|
||||||
|
|
||||||
Write-Verbose " Setting scheme to HTTP"
|
|
||||||
$Scheme = 'http'
|
|
||||||
|
|
||||||
if (-not $PSBoundParameters.ContainsKey('Port')) {
|
|
||||||
# Set the port to 80 if the user did not supply it
|
|
||||||
Write-Verbose " Setting port to 80 as default because it was not supplied by the user"
|
|
||||||
$Port = 80
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Begin a URI builder with HTTP/HTTPS and the provided hostname
|
# Begin a URI builder with HTTP/HTTPS and the provided hostname
|
||||||
$uriBuilder = [System.UriBuilder]::new($Scheme, $Hostname, $Port)
|
$uriBuilder = [System.UriBuilder]::new($script:NetboxConfig.HostScheme, $script:NetboxConfig.Hostname, $script:NetboxConfig.HostPort)
|
||||||
|
|
||||||
# Generate the path by trimming excess slashes and whitespace from the $segments[] and joining together
|
# Generate the path by trimming excess slashes and whitespace from the $segments[] and joining together
|
||||||
$uriBuilder.Path = "api/{0}/" -f ($Segments.ForEach({
|
$uriBuilder.Path = "api/{0}/" -f ($Segments.ForEach({
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/26/2020 14:23
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: BuildURIComponents.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function BuildURIComponents {
|
function BuildURIComponents {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([hashtable])]
|
[OutputType([hashtable])]
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/26/2020 14:22
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: CheckNetboxIsConnected.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function CheckNetboxIsConnected {
|
function CheckNetboxIsConnected {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param ()
|
param ()
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/26/2020 14:25
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: CreateEnum.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function CreateEnum {
|
function CreateEnum {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
|
|
|
||||||
50
Functions/Helpers/Get-ModelDefinition.ps1
Normal file
50
Functions/Helpers/Get-ModelDefinition.ps1
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
|
||||||
|
function Get-ModelDefinition {
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'ByName')]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'ByName',
|
||||||
|
Mandatory = $true)]
|
||||||
|
[string]$ModelName,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'ByPath',
|
||||||
|
Mandatory = $true)]
|
||||||
|
[string]$URIPath,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'ByPath')]
|
||||||
|
[string]$Method = "post"
|
||||||
|
)
|
||||||
|
|
||||||
|
switch ($PsCmdlet.ParameterSetName) {
|
||||||
|
'ByName' {
|
||||||
|
$script:NetboxConfig.APIDefinition.definitions.$ModelName
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
'ByPath' {
|
||||||
|
switch ($Method) {
|
||||||
|
"get" {
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
"post" {
|
||||||
|
if (-not $URIPath.StartsWith('/')) {
|
||||||
|
$URIPath = "/$URIPath"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $URIPath.EndsWith('/')) {
|
||||||
|
$URIPath = "$URIPath/"
|
||||||
|
}
|
||||||
|
|
||||||
|
$ModelName = $script:NetboxConfig.APIDefinition.paths.$URIPath.post.parameters.schema.'$ref'.split('/')[-1]
|
||||||
|
$script:NetboxConfig.APIDefinition.definitions.$ModelName
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/26/2020 14:23
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: GetChoiceValidValues.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function GetChoiceValidValues {
|
|
||||||
[CmdletBinding()]
|
|
||||||
[OutputType([System.Collections.ArrayList])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$MajorObject,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[object]$Choice
|
|
||||||
)
|
|
||||||
|
|
||||||
$ValidValues = New-Object System.Collections.ArrayList
|
|
||||||
|
|
||||||
if (-not $script:NetboxConfig.Choices.$MajorObject.$Choice) {
|
|
||||||
throw "Missing choices for $Choice"
|
|
||||||
}
|
|
||||||
|
|
||||||
[void]$ValidValues.AddRange($script:NetboxConfig.Choices.$MajorObject.$Choice.value)
|
|
||||||
[void]$ValidValues.AddRange($script:NetboxConfig.Choices.$MajorObject.$Choice.label)
|
|
||||||
|
|
||||||
if ($ValidValues.Count -eq 0) {
|
|
||||||
throw "Missing valid values for $MajorObject.$Choice"
|
|
||||||
}
|
|
||||||
|
|
||||||
return [System.Collections.ArrayList]$ValidValues
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/26/2020 14:23
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: GetNetboxAPIErrorBody.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function GetNetboxAPIErrorBody {
|
function GetNetboxAPIErrorBody {
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/26/2020 14:24
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: InvokeNetboxRequest.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function InvokeNetboxRequest {
|
function InvokeNetboxRequest {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
|
|
@ -24,10 +11,10 @@ function InvokeNetboxRequest {
|
||||||
|
|
||||||
[pscustomobject]$Body = $null,
|
[pscustomobject]$Body = $null,
|
||||||
|
|
||||||
[ValidateRange(0, 60)]
|
[ValidateRange(1, 65535)]
|
||||||
[uint16]$Timeout = 5,
|
[uint16]$Timeout = (Get-NetboxTimeout),
|
||||||
|
|
||||||
[ValidateSet('GET', 'PATCH', 'PUT', 'POST', 'DELETE', IgnoreCase = $true)]
|
[ValidateSet('GET', 'PATCH', 'PUT', 'POST', 'DELETE', 'OPTIONS', IgnoreCase = $true)]
|
||||||
[string]$Method = 'GET',
|
[string]$Method = 'GET',
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
|
|
@ -47,6 +34,8 @@ function InvokeNetboxRequest {
|
||||||
'Verbose' = $VerbosePreference
|
'Verbose' = $VerbosePreference
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$splat += Get-NetboxInvokeParams
|
||||||
|
|
||||||
if ($Body) {
|
if ($Body) {
|
||||||
Write-Verbose "BODY: $($Body | ConvertTo-Json -Compress)"
|
Write-Verbose "BODY: $($Body | ConvertTo-Json -Compress)"
|
||||||
$null = $splat.Add('Body', ($Body | ConvertTo-Json -Compress))
|
$null = $splat.Add('Body', ($Body | ConvertTo-Json -Compress))
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/26/2020 14:25
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: ThrowNetboxRESTError.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function ThrowNetboxRESTError {
|
function ThrowNetboxRESTError {
|
||||||
$uriSegments = [System.Collections.ArrayList]::new(@('fake', 'url'))
|
$uriSegments = [System.Collections.ArrayList]::new(@('fake', 'url'))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/26/2020 14:23
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: ValidateChoice.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function ValidateChoice {
|
|
||||||
[CmdletBinding()]
|
|
||||||
[OutputType([uint16], [string], [bool])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[ValidateSet('Circuits', 'DCIM', 'Extras', 'IPAM', 'Virtualization', IgnoreCase = $true)]
|
|
||||||
[string]$MajorObject,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$ChoiceName,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[object]$ProvidedValue
|
|
||||||
)
|
|
||||||
|
|
||||||
$ValidValues = GetChoiceValidValues -MajorObject $MajorObject -Choice $ChoiceName
|
|
||||||
|
|
||||||
Write-Verbose "Validating $ChoiceName"
|
|
||||||
Write-Verbose "Checking '$ProvidedValue' against [$($ValidValues -join ', ')]"
|
|
||||||
|
|
||||||
# Coercing everything to strings for matching...
|
|
||||||
# some values are integers, some are strings, some are booleans
|
|
||||||
# Join the valid values with a pipe as a delimeter, because some values have spaces
|
|
||||||
if (([string]($ValidValues -join '|') -split '\|') -inotcontains [string]$ProvidedValue) {
|
|
||||||
throw "Invalid value '$ProvidedValue' for '$ChoiceName'. Must be one of: $($ValidValues -join ', ')"
|
|
||||||
}
|
|
||||||
|
|
||||||
switch -wildcard ("$MajorObject/$ChoiceName") {
|
|
||||||
"Circuits" {
|
|
||||||
# This has things that are not integers
|
|
||||||
}
|
|
||||||
|
|
||||||
"DCIM/*connection_status" {
|
|
||||||
# This has true/false values instead of integers
|
|
||||||
try {
|
|
||||||
$val = [bool]::Parse($ProvidedValue)
|
|
||||||
} catch {
|
|
||||||
# It must not be a true/false value
|
|
||||||
$val = $script:NetboxConfig.Choices.$MajorObject.$ChoiceName.Where({
|
|
||||||
$_.Label -eq $ProvidedValue
|
|
||||||
}).Value
|
|
||||||
}
|
|
||||||
|
|
||||||
return $val
|
|
||||||
}
|
|
||||||
|
|
||||||
default {
|
|
||||||
# Convert the ProvidedValue to the integer value
|
|
||||||
try {
|
|
||||||
$intVal = [uint16]"$ProvidedValue"
|
|
||||||
} catch {
|
|
||||||
# It must not be a number, get the value from the label
|
|
||||||
$intVal = [uint16]$script:NetboxConfig.Choices.$MajorObject.$ChoiceName.Where({
|
|
||||||
$_.Label -eq $ProvidedValue
|
|
||||||
}).Value
|
|
||||||
}
|
|
||||||
|
|
||||||
return $intVal
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +1,84 @@
|
||||||
function Get-NetboxIPAMAddress {
|
function Get-NetboxIPAMAddress {
|
||||||
[CmdletBinding()]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
|
[Parameter(ParameterSetName = 'Query',
|
||||||
|
Position = 0)]
|
||||||
[string]$Address,
|
[string]$Address,
|
||||||
|
|
||||||
[uint16[]]$Id,
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Family,
|
[object]$Family,
|
||||||
|
|
||||||
[uint16]$Parent,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Parent,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[byte]$Mask_Length,
|
[byte]$Mask_Length,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$VRF,
|
[string]$VRF,
|
||||||
|
|
||||||
[uint16]$VRF_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$VRF_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Tenant,
|
[string]$Tenant,
|
||||||
|
|
||||||
[uint16]$Tenant_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Tenant_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Device,
|
[string]$Device,
|
||||||
|
|
||||||
[uint16]$Device_ID,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Device_ID,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Virtual_Machine,
|
[string]$Virtual_Machine,
|
||||||
|
|
||||||
[uint16]$Virtual_Machine_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Virtual_Machine_Id,
|
||||||
|
|
||||||
[uint16]$Interface_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Interface_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($null -ne $Family) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
$PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -IPAddressFamily
|
'ById' {
|
||||||
|
foreach ($IP_ID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IP_ID))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($null -ne $Status) {
|
break
|
||||||
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($null -ne $Role) {
|
|
||||||
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
@ -62,4 +86,8 @@
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/19/2020 11:50
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxIPAMAvailableIP.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxIPAMAvailableIP {
|
function Get-NetboxIPAMAvailableIP {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
@ -34,7 +21,14 @@ function Get-NetboxIPAMAvailableIP {
|
||||||
A description of the NumberOfIPs parameter.
|
A description of the NumberOfIPs parameter.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxIPAMAvaiableIP -Prefix_ID $value1
|
Get-NetboxIPAMAvailableIP -Prefix_ID (Get-NetboxIPAMPrefix -Prefix 192.0.2.0/24).id
|
||||||
|
|
||||||
|
Get (Next) Available IP on the Prefix 192.0.2.0/24
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-NetboxIPAMAvailableIP -Prefix_ID 2 -NumberOfIPs 3
|
||||||
|
|
||||||
|
Get 3 (Next) Available IP on the Prefix 192.0.2.0/24
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
|
|
@ -46,14 +40,15 @@ function Get-NetboxIPAMAvailableIP {
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[Alias('Id')]
|
[Alias('Id')]
|
||||||
[uint16]$Prefix_ID,
|
[uint64]$Prefix_ID,
|
||||||
|
|
||||||
[Alias('NumberOfIPs')]
|
[Alias('NumberOfIPs')]
|
||||||
[uint16]$Limit,
|
[uint64]$Limit,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $Prefix_ID, 'available-ips'))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $Prefix_ID, 'available-ips'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'prefix_id'
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'prefix_id'
|
||||||
|
|
@ -62,3 +57,4 @@ function Get-NetboxIPAMAvailableIP {
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/19/2020 11:51
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: New-NetboxIPAMAddress.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function New-NetboxIPAMAddress {
|
function New-NetboxIPAMAddress {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
@ -47,53 +34,77 @@ function New-NetboxIPAMAddress {
|
||||||
.PARAMETER Description
|
.PARAMETER Description
|
||||||
Description of IP address
|
Description of IP address
|
||||||
|
|
||||||
|
.PARAMETER Dns_name
|
||||||
|
DNS Name of IP address (example : netbox.example.com)
|
||||||
|
|
||||||
|
.PARAMETER Assigned_Object_Type
|
||||||
|
Assigned Object Type dcim.interface or virtualization.vminterface
|
||||||
|
|
||||||
|
.PARAMETER Assigned_Object_Id
|
||||||
|
Assigned Object ID
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return raw results from API service
|
Return raw results from API service
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Create-NetboxIPAMAddress
|
New-NetboxIPAMAddress -Address 192.0.2.1/32
|
||||||
|
|
||||||
|
Add new IP Address 192.0.2.1/32 with status active
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[string]$Address,
|
[string]$Address,
|
||||||
|
|
||||||
[object]$Status = 'Active',
|
[object]$Status = 'Active',
|
||||||
|
|
||||||
[uint16]$Tenant,
|
[uint64]$Tenant,
|
||||||
|
|
||||||
[uint16]$VRF,
|
[uint64]$VRF,
|
||||||
|
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
[uint16]$NAT_Inside,
|
[uint64]$NAT_Inside,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[uint16]$Interface,
|
[uint64]$Interface,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
|
[string]$Dns_name,
|
||||||
|
|
||||||
|
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
||||||
|
[string]$Assigned_Object_Type,
|
||||||
|
|
||||||
|
[uint64]$Assigned_Object_Id,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
|
process {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
||||||
|
$Method = 'POST'
|
||||||
|
|
||||||
if ($null -ne $Role) {
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
|
|
||||||
}
|
|
||||||
|
|
||||||
$segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
if ($PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/19/2020 11:52
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Remove-NetboxIPAMAddress.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
function Remove-NetboxIPAMAddress {
|
function Remove-NetboxIPAMAddress {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
@ -38,14 +26,11 @@ function Remove-NetboxIPAMAddress {
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint16[]]$Id,
|
[uint64[]]$Id,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($IPId in $Id) {
|
foreach ($IPId in $Id) {
|
||||||
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
|
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
|
||||||
|
|
@ -59,7 +44,4 @@ function Remove-NetboxIPAMAddress {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/19/2020 11:53
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Set-NetboxIPAMAddress.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Set-NetboxIPAMAddress {
|
function Set-NetboxIPAMAddress {
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
|
|
@ -19,44 +6,69 @@ function Set-NetboxIPAMAddress {
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint16[]]$Id,
|
[uint64[]]$Id,
|
||||||
|
|
||||||
[string]$Address,
|
[string]$Address,
|
||||||
|
|
||||||
[object]$Status,
|
[string]$Status,
|
||||||
|
|
||||||
[uint16]$Tenant,
|
[uint64]$Tenant,
|
||||||
|
|
||||||
[uint16]$VRF,
|
[uint64]$VRF,
|
||||||
|
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
[uint16]$NAT_Inside,
|
[uint64]$NAT_Inside,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[uint16]$Interface,
|
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
||||||
|
[string]$Assigned_Object_Type,
|
||||||
|
|
||||||
|
[uint64]$Assigned_Object_Id,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
|
[string]$Dns_name,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
if ($Status) {
|
# Write-Verbose "Validating enum properties"
|
||||||
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
|
# $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', 0))
|
||||||
}
|
$Method = 'PATCH'
|
||||||
|
#
|
||||||
if ($Role) {
|
# # Value validation
|
||||||
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
|
# $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method
|
||||||
}
|
# $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition
|
||||||
|
#
|
||||||
|
# foreach ($Property in $EnumProperties.Keys) {
|
||||||
|
# if ($PSBoundParameters.ContainsKey($Property)) {
|
||||||
|
# Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]"
|
||||||
|
# $PSBoundParameters.$Property = ValidateValue -ModelDefinition $ModelDefinition -Property $Property -ProvidedValue $PSBoundParameters.$Property
|
||||||
|
# } else {
|
||||||
|
# Write-Verbose "User did not provide a value for [$Property]"
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# Write-Verbose "Finished enum validation"
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($IPId in $Id) {
|
foreach ($IPId in $Id) {
|
||||||
|
if ($PSBoundParameters.ContainsKey('Assigned_Object_Type') -or $PSBoundParameters.ContainsKey('Assigned_Object_Id')) {
|
||||||
|
if ((-not [string]::IsNullOrWhiteSpace($Assigned_Object_Id)) -and [string]::IsNullOrWhiteSpace($Assigned_Object_Type)) {
|
||||||
|
throw "Assigned_Object_Type is required when specifying Assigned_Object_Id"
|
||||||
|
}
|
||||||
|
elseif ((-not [string]::IsNullOrWhiteSpace($Assigned_Object_Type)) -and [string]::IsNullOrWhiteSpace($Assigned_Object_Id)) {
|
||||||
|
throw "Assigned_Object_Id is required when specifying Assigned_Object_Type"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IPId))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IPId))
|
||||||
|
|
||||||
Write-Verbose "Obtaining IPs from ID $IPId"
|
Write-Verbose "Obtaining IP from ID $IPId"
|
||||||
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
|
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
|
||||||
|
|
||||||
if ($Force -or $PSCmdlet.ShouldProcess($CurrentIP.Address, 'Set')) {
|
if ($Force -or $PSCmdlet.ShouldProcess($CurrentIP.Address, 'Set')) {
|
||||||
|
|
@ -64,11 +76,8 @@ function Set-NetboxIPAMAddress {
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,49 +1,66 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/19/2020 11:49
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxIPAMAggregate.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxIPAMAggregate {
|
function Get-NetboxIPAMAggregate {
|
||||||
[CmdletBinding()]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[uint16]$Limit,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
|
||||||
[uint16]$Offset,
|
|
||||||
|
|
||||||
[object]$Family,
|
|
||||||
|
|
||||||
[datetime]$Date_Added,
|
|
||||||
|
|
||||||
[uint16[]]$Id,
|
|
||||||
|
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[uint16]$RIR_Id,
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Prefix,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[object]$Family,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$RIR_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$RIR,
|
[string]$RIR,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[datetime]$Date_Added,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($null -ne $Family) {
|
# if ($null -ne $Family) {
|
||||||
$PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -AggregateFamily
|
# $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -AggregateFamily
|
||||||
}
|
# }
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates'))
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($IP_ID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates', $IP_ID))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/19/2020 11:54
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxIPAMChoices.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxIPAMChoices {
|
|
||||||
[CmdletBinding()]
|
|
||||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
|
|
||||||
param ()
|
|
||||||
|
|
||||||
$uriSegments = [System.Collections.ArrayList]::new(@('ipam', '_choices'))
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $uriSegments -Parameters $Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/19/2020 11:51
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxIPAMPrefix.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxIPAMPrefix {
|
function Get-NetboxIPAMPrefix {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
@ -93,65 +80,104 @@ function Get-NetboxIPAMPrefix {
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
|
[Parameter(ParameterSetName = 'Query',
|
||||||
|
Position = 0)]
|
||||||
[string]$Prefix,
|
[string]$Prefix,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[uint16[]]$Id,
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Family,
|
[object]$Family,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[boolean]$Is_Pool,
|
[boolean]$Is_Pool,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Within,
|
[string]$Within,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Within_Include,
|
[string]$Within_Include,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Contains,
|
[string]$Contains,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[ValidateRange(0, 127)]
|
[ValidateRange(0, 127)]
|
||||||
[byte]$Mask_Length,
|
[byte]$Mask_Length,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$VRF,
|
[string]$VRF,
|
||||||
|
|
||||||
[uint16]$VRF_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$VRF_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Tenant,
|
[string]$Tenant,
|
||||||
|
|
||||||
[uint16]$Tenant_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Tenant_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Site,
|
[string]$Site,
|
||||||
|
|
||||||
[uint16]$Site_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Site_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Vlan_VId,
|
[string]$Vlan_VId,
|
||||||
|
|
||||||
[uint16]$Vlan_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Vlan_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Role,
|
[string]$Role,
|
||||||
|
|
||||||
[uint16]$Role_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Role_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($null -ne $Family) {
|
# if ($null -ne $Family) {
|
||||||
$PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -PrefixFamily
|
# $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -PrefixFamily
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# if ($null -ne $Status) {
|
||||||
|
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
||||||
|
# }
|
||||||
|
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($Prefix_ID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $Prefix_ID))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($null -ne $Status) {
|
break
|
||||||
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
@ -159,4 +185,8 @@ function Get-NetboxIPAMPrefix {
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,7 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/19/2020 11:52
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: New-NetboxIPAMPrefix.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function New-NetboxIPAMPrefix {
|
function New-NetboxIPAMPrefix {
|
||||||
|
[CmdletBinding(ConfirmImpact = 'low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
|
|
@ -21,7 +10,7 @@ function New-NetboxIPAMPrefix {
|
||||||
|
|
||||||
[object]$Status = 'Active',
|
[object]$Status = 'Active',
|
||||||
|
|
||||||
[uint16]$Tenant,
|
[uint64]$Tenant,
|
||||||
|
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
|
|
@ -29,18 +18,18 @@ function New-NetboxIPAMPrefix {
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[uint16]$Site,
|
[uint64]$Site,
|
||||||
|
|
||||||
[uint16]$VRF,
|
[uint64]$VRF,
|
||||||
|
|
||||||
[uint16]$VLAN,
|
[uint64]$VLAN,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
||||||
|
|
||||||
<#
|
<#
|
||||||
# As of 2018/10/18, this does not appear to be a validated IPAM choice
|
# As of 2018/10/18, this does not appear to be a validated IPAM choice
|
||||||
|
|
@ -55,5 +44,7 @@ function New-NetboxIPAMPrefix {
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess($Prefix, 'Create new Prefix')) {
|
||||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
}
|
||||||
79
Functions/IPAM/Prefix/Set-NetboxIPAMPrefix.ps1
Normal file
79
Functions/IPAM/Prefix/Set-NetboxIPAMPrefix.ps1
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
|
||||||
|
function Set-NetboxIPAMPrefix {
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[string]$Prefix,
|
||||||
|
|
||||||
|
[string]$Status,
|
||||||
|
|
||||||
|
[uint64]$Tenant,
|
||||||
|
|
||||||
|
[uint64]$Site,
|
||||||
|
|
||||||
|
[uint64]$VRF,
|
||||||
|
|
||||||
|
[uint64]$VLAN,
|
||||||
|
|
||||||
|
[object]$Role,
|
||||||
|
|
||||||
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[switch]$Is_Pool,
|
||||||
|
|
||||||
|
[switch]$Force
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
# Write-Verbose "Validating enum properties"
|
||||||
|
# $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', 0))
|
||||||
|
$Method = 'PATCH'
|
||||||
|
#
|
||||||
|
# # Value validation
|
||||||
|
# $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method
|
||||||
|
# $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition
|
||||||
|
#
|
||||||
|
# foreach ($Property in $EnumProperties.Keys) {
|
||||||
|
# if ($PSBoundParameters.ContainsKey($Property)) {
|
||||||
|
# Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]"
|
||||||
|
# $PSBoundParameters.$Property = ValidateValue -ModelDefinition $ModelDefinition -Property $Property -ProvidedValue $PSBoundParameters.$Property
|
||||||
|
# } else {
|
||||||
|
# Write-Verbose "User did not provide a value for [$Property]"
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# Write-Verbose "Finished enum validation"
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach ($PrefixId in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $PrefixId))
|
||||||
|
|
||||||
|
Write-Verbose "Obtaining Prefix from ID $PrefixId"
|
||||||
|
$CurrentPrefix = Get-NetboxIPAMPrefix -Id $PrefixId -ErrorAction Stop
|
||||||
|
|
||||||
|
if ($Force -or $PSCmdlet.ShouldProcess($CurrentPrefix.Prefix, 'Set')) {
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
73
Functions/IPAM/Range/Get-NetboxIPAMAddressRange.ps1
Normal file
73
Functions/IPAM/Range/Get-NetboxIPAMAddressRange.ps1
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
|
||||||
|
function Get-NetboxIPAMAddressRange {
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'Query',
|
||||||
|
Position = 0)]
|
||||||
|
[string]$Range,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Query,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[object]$Family,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$VRF,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint32]$VRF_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Tenant,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint32]$Tenant_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[object]$Status,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[object]$Role,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($Range_ID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-ranges', $Range_ID))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-ranges'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
106
Functions/IPAM/Range/New-NetboxIPAMAddressRange.ps1
Normal file
106
Functions/IPAM/Range/New-NetboxIPAMAddressRange.ps1
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
|
||||||
|
|
||||||
|
function New-NetboxIPAMAddressRange {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Create a new IP address range to Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Create a new IP address range to Netbox with a status of Active by default. The maximum supported
|
||||||
|
size of an IP range is 2^32 - 1.
|
||||||
|
|
||||||
|
.PARAMETER Start_Address
|
||||||
|
Starting IPv4 or IPv6 address (with mask). The maximum supported size of an IP range is 2^32 - 1.
|
||||||
|
|
||||||
|
.PARAMETER End_Address
|
||||||
|
Ending IPv4 or IPv6 address (with mask). The maximum supported size of an IP range is 2^32 - 1.
|
||||||
|
|
||||||
|
.PARAMETER Status
|
||||||
|
Operational status of this range. Defaults to Active
|
||||||
|
|
||||||
|
.PARAMETER Tenant
|
||||||
|
Tenant ID
|
||||||
|
|
||||||
|
.PARAMETER VRF
|
||||||
|
VRF ID
|
||||||
|
|
||||||
|
.PARAMETER Role
|
||||||
|
Role such as backup, customer, development, etc... Defaults to nothing
|
||||||
|
|
||||||
|
.PARAMETER Custom_Fields
|
||||||
|
Custom field hash table. Will be validated by the API service
|
||||||
|
|
||||||
|
.PARAMETER Description
|
||||||
|
Description of IP address range
|
||||||
|
|
||||||
|
.PARAMETER Comments
|
||||||
|
Extra comments (markdown supported).
|
||||||
|
|
||||||
|
.PARAMETER Tags
|
||||||
|
One or more tags.
|
||||||
|
|
||||||
|
.PARAMETER Mark_Utilized
|
||||||
|
Treat as 100% utilized
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
Return raw results from API service
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
New-NetboxIPAMAddressRange -Start_Address 192.0.2.20/24 -End_Address 192.0.2.20/24
|
||||||
|
|
||||||
|
Add new IP Address range from 192.0.2.20/24 to 192.0.2.20/24 with status active
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
https://netbox.neonet.org/static/docs/models/ipam/iprange/
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Start_Address,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$End_Address,
|
||||||
|
|
||||||
|
[object]$Status = 'Active',
|
||||||
|
|
||||||
|
[uint64]$Tenant,
|
||||||
|
|
||||||
|
[uint64]$VRF,
|
||||||
|
|
||||||
|
[object]$Role,
|
||||||
|
|
||||||
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[string]$Comments,
|
||||||
|
|
||||||
|
[object[]]$Tags,
|
||||||
|
|
||||||
|
[switch]$Mark_Utilized,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-ranges'))
|
||||||
|
$Method = 'POST'
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess($Start_Address, 'Create new IP address range')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
47
Functions/IPAM/Range/Remove-NetboxIPAMAddressRange.ps1
Normal file
47
Functions/IPAM/Range/Remove-NetboxIPAMAddressRange.ps1
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
|
||||||
|
function Remove-NetboxIPAMAddressRange {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Remove an IP address range from Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Removes/deletes an IP address range from Netbox by ID
|
||||||
|
|
||||||
|
.PARAMETER Id
|
||||||
|
Database ID of the IP address range object.
|
||||||
|
|
||||||
|
.PARAMETER Force
|
||||||
|
Do not confirm.
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> Remove-NetboxIPAMAddressRange -Id 1234
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Additional information about the function.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'High',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[switch]$Force
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach ($Range_Id in $Id) {
|
||||||
|
$CurrentRange = Get-NetboxIPAMAddressRange -Id $Range_Id -ErrorAction Stop
|
||||||
|
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-ranges', $Range_Id))
|
||||||
|
|
||||||
|
if ($Force -or $pscmdlet.ShouldProcess($CurrentRange.start_address, "Delete")) {
|
||||||
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Method DELETE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
58
Functions/IPAM/Range/Set-NetboxIPAMAddressRange.ps1
Normal file
58
Functions/IPAM/Range/Set-NetboxIPAMAddressRange.ps1
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
|
||||||
|
function Set-NetboxIPAMAddressRange {
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[string]$Start_Address,
|
||||||
|
|
||||||
|
[string]$End_Address,
|
||||||
|
|
||||||
|
[object]$Status,
|
||||||
|
|
||||||
|
[uint64]$Tenant,
|
||||||
|
|
||||||
|
[uint64]$VRF,
|
||||||
|
|
||||||
|
[object]$Role,
|
||||||
|
|
||||||
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[string]$Comments,
|
||||||
|
|
||||||
|
[object[]]$Tags,
|
||||||
|
|
||||||
|
[switch]$Mark_Utilized,
|
||||||
|
|
||||||
|
[switch]$Force,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
$Method = 'PATCH'
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach ($RangeID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-ranges', $RangeID))
|
||||||
|
|
||||||
|
Write-Verbose "Obtaining IP range from ID $RangeID"
|
||||||
|
$CurrentRange = Get-NetboxIPAMAddressRange -Id $RangeID -ErrorAction Stop
|
||||||
|
|
||||||
|
if ($Force -or $PSCmdlet.ShouldProcess("$($CurrentRange.Start_Address) - $($CurrentRange.End_Address)", 'Set')) {
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -41,23 +41,47 @@ function Get-NetboxIPAMRole {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[uint16[]]$Id,
|
[Parameter(ParameterSetName = 'Query',
|
||||||
|
Position = 0)]
|
||||||
[string]$Query,
|
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Query,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[switch]$Brief,
|
[switch]$Brief,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($Role_ID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'roles', $Role_ID))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'roles'))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'roles'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
@ -65,4 +89,8 @@ function Get-NetboxIPAMRole {
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,64 +1,83 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/16/2020 16:34
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxIPAMVLAN.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxIPAMVLAN {
|
function Get-NetboxIPAMVLAN {
|
||||||
[CmdletBinding()]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[uint16]$Limit,
|
[Parameter(ParameterSetName = 'Query',
|
||||||
|
Position = 0)]
|
||||||
[uint16]$Offset,
|
[ValidateRange(1, 4096)]
|
||||||
|
|
||||||
[uint16]$VID,
|
[uint16]$VID,
|
||||||
|
|
||||||
[uint16[]]$Id,
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Tenant,
|
[string]$Tenant,
|
||||||
|
|
||||||
[uint16]$Tenant_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Tenant_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$TenantGroup,
|
[string]$TenantGroup,
|
||||||
|
|
||||||
[uint16]$TenantGroup_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$TenantGroup_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Region,
|
[string]$Region,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Site,
|
[string]$Site,
|
||||||
|
|
||||||
[uint16]$Site_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Site_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Group,
|
[string]$Group,
|
||||||
|
|
||||||
[uint16]$Group_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Group_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Role,
|
[string]$Role,
|
||||||
|
|
||||||
[uint16]$Role_Id,
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Role_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($null -ne $Status) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
|
'ById' {
|
||||||
|
foreach ($VLAN_ID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans', $VLAN_ID))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
@ -66,6 +85,10 @@ function Get-NetboxIPAMVLAN {
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding(ConfirmImpact = 'low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
|
|
@ -52,7 +53,7 @@
|
||||||
|
|
||||||
[object]$Status = 'Active',
|
[object]$Status = 'Active',
|
||||||
|
|
||||||
[uint16]$Tenant,
|
[uint64]$Tenant,
|
||||||
|
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
|
|
@ -63,11 +64,11 @@
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
|
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
|
||||||
|
|
||||||
if ($null -ne $Role) {
|
# if ($null -ne $Role) {
|
||||||
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
|
# $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
|
||||||
}
|
# }
|
||||||
|
|
||||||
$segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
|
$segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
|
||||||
|
|
||||||
|
|
@ -75,5 +76,7 @@
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess($nae, 'Create new Vlan $($vid)')) {
|
||||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/19/2020 11:54
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: ValidateIPAMChoice.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function ValidateIPAMChoice {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Internal function to verify provided values for static choices
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
When users connect to the API, choices for each major object are cached to the config variable.
|
|
||||||
These values are then utilized to verify if the provided value from a user is valid.
|
|
||||||
|
|
||||||
.PARAMETER ProvidedValue
|
|
||||||
The value to validate against static choices
|
|
||||||
|
|
||||||
.PARAMETER AggregateFamily
|
|
||||||
Verify against aggregate family values
|
|
||||||
|
|
||||||
.PARAMETER PrefixFamily
|
|
||||||
Verify against prefix family values
|
|
||||||
|
|
||||||
.PARAMETER PrefixStatus
|
|
||||||
Verify against prefix status values
|
|
||||||
|
|
||||||
.PARAMETER IPAddressFamily
|
|
||||||
Verify against ip-address family values
|
|
||||||
|
|
||||||
.PARAMETER IPAddressStatus
|
|
||||||
Verify against ip-address status values
|
|
||||||
|
|
||||||
.PARAMETER IPAddressRole
|
|
||||||
Verify against ip-address role values
|
|
||||||
|
|
||||||
.PARAMETER VLANStatus
|
|
||||||
Verify against VLAN status values
|
|
||||||
|
|
||||||
.PARAMETER ServiceProtocol
|
|
||||||
Verify against service protocol values
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> ValidateIPAMChoice -ProvidedValue 'loopback' -IPAddressRole
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> ValidateIPAMChoice -ProvidedValue 'Loopback' -IPAddressFamily
|
|
||||||
>> Invalid value Loopback for ip-address:family. Must be one of: 4, 6, IPv4, IPv6
|
|
||||||
|
|
||||||
.OUTPUTS
|
|
||||||
This function returns the integer value if valid. Otherwise, it will throw an error.
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
|
|
||||||
.FUNCTIONALITY
|
|
||||||
This cmdlet is intended to be used internally and not exposed to the user
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'service:protocol')]
|
|
||||||
[OutputType([uint16])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[object]$ProvidedValue,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'aggregate:family',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$AggregateFamily,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'prefix:family',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$PrefixFamily,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'prefix:status',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$PrefixStatus,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ip-address:family',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$IPAddressFamily,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ip-address:status',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$IPAddressStatus,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ip-address:role',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$IPAddressRole,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'vlan:status',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$VLANStatus,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'service:protocol',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[switch]$ServiceProtocol
|
|
||||||
)
|
|
||||||
|
|
||||||
ValidateChoice -MajorObject 'IPAM' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
|
|
||||||
}
|
|
||||||
11
Functions/Setup/Clear-NetboxCredential.ps1
Normal file
11
Functions/Setup/Clear-NetboxCredential.ps1
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
function Clear-NetboxCredential {
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Medium', SupportsShouldProcess = $true)]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[switch]$Force
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($Force -or ($PSCmdlet.ShouldProcess('Netbox Credentials', 'Clear'))) {
|
||||||
|
$script:NetboxConfig.Credential = $null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,13 +4,28 @@
|
||||||
Connects to the Netbox API and ensures Credential work properly
|
Connects to the Netbox API and ensures Credential work properly
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
A detailed description of the Connect-NetboxAPI function.
|
Connects to the Netbox API and ensures Credential work properly
|
||||||
|
|
||||||
.PARAMETER Hostname
|
.PARAMETER Hostname
|
||||||
A description of the Hostname parameter.
|
The hostname for the resource such as netbox.domain.com
|
||||||
|
|
||||||
.PARAMETER Credential
|
.PARAMETER Credential
|
||||||
A description of the Credential parameter.
|
Credential object containing the API key in the password. Username is not applicable
|
||||||
|
|
||||||
|
.PARAMETER Scheme
|
||||||
|
Scheme for the URI such as HTTP or HTTPS. Defaults to HTTPS
|
||||||
|
|
||||||
|
.PARAMETER Port
|
||||||
|
Port for the resource. Value between 1-65535
|
||||||
|
|
||||||
|
.PARAMETER URI
|
||||||
|
The full URI for the resource such as "https://netbox.domain.com:8443"
|
||||||
|
|
||||||
|
.PARAMETER SkipCertificateCheck
|
||||||
|
A description of the SkipCertificateCheck parameter.
|
||||||
|
|
||||||
|
.PARAMETER TimeoutSeconds
|
||||||
|
The number of seconds before the HTTP call times out. Defaults to 30 seconds
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Connect-NetboxAPI -Hostname "netbox.domain.com"
|
PS C:\> Connect-NetboxAPI -Hostname "netbox.domain.com"
|
||||||
|
|
@ -21,14 +36,33 @@
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding(DefaultParameterSetName = 'Manual')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(ParameterSetName = 'Manual',
|
||||||
|
Mandatory = $true)]
|
||||||
[string]$Hostname,
|
[string]$Hostname,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[pscredential]$Credential
|
[pscredential]$Credential,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Manual')]
|
||||||
|
[ValidateSet('https', 'http', IgnoreCase = $true)]
|
||||||
|
[string]$Scheme = 'https',
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Manual')]
|
||||||
|
[uint16]$Port = 443,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'URI',
|
||||||
|
Mandatory = $true)]
|
||||||
|
[string]$URI,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[switch]$SkipCertificateCheck = $false,
|
||||||
|
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[ValidateRange(1, 65535)]
|
||||||
|
[uint16]$TimeoutSeconds = 30
|
||||||
)
|
)
|
||||||
|
|
||||||
if (-not $Credential) {
|
if (-not $Credential) {
|
||||||
|
|
@ -42,14 +76,48 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$null = Set-NetboxHostName -Hostname $Hostname
|
$invokeParams = @{ SkipCertificateCheck = $SkipCertificateCheck; }
|
||||||
|
|
||||||
|
if ("Desktop" -eq $PSVersionTable.PsEdition) {
|
||||||
|
#Remove -SkipCertificateCheck from Invoke Parameter (not supported <= PS 5)
|
||||||
|
$invokeParams.remove("SkipCertificateCheck")
|
||||||
|
}
|
||||||
|
|
||||||
|
#for PowerShell (<=) 5 (Desktop), Enable TLS 1.1, 1.2 and Disable SSL chain trust
|
||||||
|
if ("Desktop" -eq $PSVersionTable.PsEdition) {
|
||||||
|
#Add System.web (Need for ParseQueryString)
|
||||||
|
Add-Type -AssemblyName System.Web
|
||||||
|
#Enable TLS 1.1 and 1.2
|
||||||
|
Set-NetboxCipherSSL
|
||||||
|
if ($SkipCertificateCheck) {
|
||||||
|
#Disable SSL chain trust...
|
||||||
|
Set-NetboxuntrustedSSL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'Manual' {
|
||||||
|
$uriBuilder = [System.UriBuilder]::new($Scheme, $Hostname, $Port)
|
||||||
|
}
|
||||||
|
|
||||||
|
'URI' {
|
||||||
|
$uriBuilder = [System.UriBuilder]::new($URI)
|
||||||
|
if ([string]::IsNullOrWhiteSpace($uriBuilder.Host)) {
|
||||||
|
throw "URI appears to be invalid. Must be in format [host.name], [scheme://host.name], or [scheme://host.name:port]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$null = Set-NetboxHostName -Hostname $uriBuilder.Host
|
||||||
$null = Set-NetboxCredential -Credential $Credential
|
$null = Set-NetboxCredential -Credential $Credential
|
||||||
|
$null = Set-NetboxHostScheme -Scheme $uriBuilder.Scheme
|
||||||
|
$null = Set-NetboxHostPort -Port $uriBuilder.Port
|
||||||
|
$null = Set-NetboxInvokeParams -invokeParams $invokeParams
|
||||||
|
$null = Set-NetboxTimeout -TimeoutSeconds $TimeoutSeconds
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Write-Verbose "Verifying API connectivity..."
|
Write-Verbose "Verifying API connectivity..."
|
||||||
$null = VerifyAPIConnectivity
|
$null = VerifyAPIConnectivity
|
||||||
$script:NetboxConfig.Connected = $true
|
|
||||||
Write-Verbose "Successfully connected!"
|
|
||||||
} catch {
|
} catch {
|
||||||
Write-Verbose "Failed to connect. Generating error"
|
Write-Verbose "Failed to connect. Generating error"
|
||||||
Write-Verbose $_.Exception.Message
|
Write-Verbose $_.Exception.Message
|
||||||
|
|
@ -60,14 +128,27 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Verbose "Caching static choices"
|
# Write-Verbose "Caching API definition"
|
||||||
$script:NetboxConfig.Choices.Circuits = Get-NetboxCircuitsChoices
|
# $script:NetboxConfig.APIDefinition = Get-NetboxAPIDefinition
|
||||||
$script:NetboxConfig.Choices.DCIM = Get-NetboxDCIMChoices # Not completed yet
|
#
|
||||||
$script:NetboxConfig.Choices.Extras = Get-NetboxExtrasChoices
|
# if ([version]$script:NetboxConfig.APIDefinition.info.version -lt 2.8) {
|
||||||
$script:NetboxConfig.Choices.IPAM = Get-NetboxIPAMChoices
|
# $Script:NetboxConfig.Connected = $false
|
||||||
#$script:NetboxConfig.Choices.Secrets = Get-NetboxSecretsChoices # Not completed yet
|
# throw "Netbox version is incompatible with this PS module. Requires >=2.8.*, found version $($script:NetboxConfig.APIDefinition.info.version)"
|
||||||
#$script:NetboxConfig.Choices.Tenancy = Get-NetboxTenancyChoices
|
# }
|
||||||
$script:NetboxConfig.Choices.Virtualization = Get-NetboxVirtualizationChoices
|
|
||||||
|
Write-Verbose "Checking Netbox version compatibility"
|
||||||
|
$script:NetboxConfig.NetboxVersion = Get-NetboxVersion
|
||||||
|
if ([version]$script:NetboxConfig.NetboxVersion.'netbox-version' -lt 2.8) {
|
||||||
|
$Script:NetboxConfig.Connected = $false
|
||||||
|
throw "Netbox version is incompatible with this PS module. Requires >=2.8.*, found version $($script:NetboxConfig.NetboxVersion.'netbox-version')"
|
||||||
|
} else {
|
||||||
|
Write-Verbose "Found compatible version [$($script:NetboxConfig.NetboxVersion.'netbox-version')]!"
|
||||||
|
}
|
||||||
|
|
||||||
|
$script:NetboxConfig.Connected = $true
|
||||||
|
Write-Verbose "Successfully connected!"
|
||||||
|
|
||||||
|
$script:NetboxConfig.ContentTypes = Get-NetboxContentType -Limit 500
|
||||||
|
|
||||||
Write-Verbose "Connection process completed"
|
Write-Verbose "Connection process completed"
|
||||||
}
|
}
|
||||||
11
Functions/Setup/Get-NetboxHostPort.ps1
Normal file
11
Functions/Setup/Get-NetboxHostPort.ps1
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
function Get-NetboxHostPort {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param ()
|
||||||
|
|
||||||
|
Write-Verbose "Getting Netbox host port"
|
||||||
|
if ($null -eq $script:NetboxConfig.HostPort) {
|
||||||
|
throw "Netbox host port is not set! You may set it with Set-NetboxHostPort -Port 'https'"
|
||||||
|
}
|
||||||
|
|
||||||
|
$script:NetboxConfig.HostPort
|
||||||
|
}
|
||||||
11
Functions/Setup/Get-NetboxHostScheme.ps1
Normal file
11
Functions/Setup/Get-NetboxHostScheme.ps1
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
function Get-NetboxHostScheme {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param ()
|
||||||
|
|
||||||
|
Write-Verbose "Getting Netbox host scheme"
|
||||||
|
if ($null -eq $script:NetboxConfig.Hostscheme) {
|
||||||
|
throw "Netbox host sceme is not set! You may set it with Set-NetboxHostScheme -Scheme 'https'"
|
||||||
|
}
|
||||||
|
|
||||||
|
$script:NetboxConfig.HostScheme
|
||||||
|
}
|
||||||
11
Functions/Setup/Get-NetboxInvokeParams.ps1
Normal file
11
Functions/Setup/Get-NetboxInvokeParams.ps1
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
function Get-NetboxInvokeParams {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param ()
|
||||||
|
|
||||||
|
Write-Verbose "Getting Netbox InvokeParams"
|
||||||
|
if ($null -eq $script:NetboxConfig.InvokeParams) {
|
||||||
|
throw "Netbox Invoke Params is not set! You may set it with Set-NetboxInvokeParams -InvokeParams ..."
|
||||||
|
}
|
||||||
|
|
||||||
|
$script:NetboxConfig.InvokeParams
|
||||||
|
}
|
||||||
13
Functions/Setup/Get-NetboxTimeout.ps1
Normal file
13
Functions/Setup/Get-NetboxTimeout.ps1
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
function Get-NetboxTimeout {
|
||||||
|
[CmdletBinding()]
|
||||||
|
[OutputType([uint16])]
|
||||||
|
param ()
|
||||||
|
|
||||||
|
Write-Verbose "Getting Netbox Timeout"
|
||||||
|
if ($null -eq $script:NetboxConfig.Timeout) {
|
||||||
|
throw "Netbox Timeout is not set! You may set it with Set-NetboxTimeout -TimeoutSeconds [uint16]"
|
||||||
|
}
|
||||||
|
|
||||||
|
$script:NetboxConfig.Timeout
|
||||||
|
}
|
||||||
15
Functions/Setup/Get-NetboxVersion.ps1
Normal file
15
Functions/Setup/Get-NetboxVersion.ps1
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
function Get-NetboxVersion {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param ()
|
||||||
|
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('status'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary @{
|
||||||
|
'format' = 'json'
|
||||||
|
}
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters -SkipConnectedCheck
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI
|
||||||
|
}
|
||||||
8
Functions/Setup/Set-NetboxCipherSSL.ps1
Normal file
8
Functions/Setup/Set-NetboxCipherSSL.ps1
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
Function Set-NetboxCipherSSL {
|
||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessforStateChangingFunctions", "")]
|
||||||
|
Param( )
|
||||||
|
# Hack for allowing TLS 1.1 and TLS 1.2 (by default it is only SSL3 and TLS (1.0))
|
||||||
|
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
|
||||||
|
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
|
||||||
|
|
||||||
|
}
|
||||||
15
Functions/Setup/Set-NetboxHostPort.ps1
Normal file
15
Functions/Setup/Set-NetboxHostPort.ps1
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
function Set-NetboxHostPort {
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([string])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[uint16]$Port
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess('Netbox Port', 'Set')) {
|
||||||
|
$script:NetboxConfig.HostPort = $Port
|
||||||
|
$script:NetboxConfig.HostPort
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Functions/Setup/Set-NetboxHostScheme.ps1
Normal file
20
Functions/Setup/Set-NetboxHostScheme.ps1
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
function Set-NetboxHostScheme {
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([string])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateSet('https', 'http', IgnoreCase = $true)]
|
||||||
|
[string]$Scheme = 'https'
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess('Netbox Host Scheme', 'Set')) {
|
||||||
|
if ($Scheme -eq 'http') {
|
||||||
|
Write-Warning "Connecting via non-secure HTTP is not-recommended"
|
||||||
|
}
|
||||||
|
|
||||||
|
$script:NetboxConfig.HostScheme = $Scheme
|
||||||
|
$script:NetboxConfig.HostScheme
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Functions/Setup/Set-NetboxInvokeParams.ps1
Normal file
14
Functions/Setup/Set-NetboxInvokeParams.ps1
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
function Set-NetboxInvokeParams {
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([string])]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[array]$InvokeParams
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess('Netbox Invoke Params', 'Set')) {
|
||||||
|
$script:NetboxConfig.InvokeParams = $InvokeParams
|
||||||
|
$script:NetboxConfig.InvokeParams
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Functions/Setup/Set-NetboxTimeout.ps1
Normal file
17
Functions/Setup/Set-NetboxTimeout.ps1
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
function Set-NetboxTimeout {
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([uint16])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateRange(1, 65535)]
|
||||||
|
[uint16]$TimeoutSeconds = 30
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess('Netbox Timeout', 'Set')) {
|
||||||
|
$script:NetboxConfig.Timeout = $TimeoutSeconds
|
||||||
|
$script:NetboxConfig.Timeout
|
||||||
|
}
|
||||||
|
}
|
||||||
19
Functions/Setup/Set-NetboxUnstrustedSSL.ps1
Normal file
19
Functions/Setup/Set-NetboxUnstrustedSSL.ps1
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
Function Set-NetboxUntrustedSSL {
|
||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessforStateChangingFunctions", "")]
|
||||||
|
Param( )
|
||||||
|
# Hack for allowing untrusted SSL certs with https connections
|
||||||
|
Add-Type -TypeDefinition @"
|
||||||
|
using System.Net;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
public class TrustAllCertsPolicy : ICertificatePolicy {
|
||||||
|
public bool CheckValidationResult(
|
||||||
|
ServicePoint srvPoint, X509Certificate certificate,
|
||||||
|
WebRequest request, int certificateProblem) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"@
|
||||||
|
|
||||||
|
[System.Net.ServicePointManager]::CertificatePolicy = New-Object -TypeName TrustAllCertsPolicy
|
||||||
|
|
||||||
|
}
|
||||||
21
Functions/Setup/Support/Get-NetboxAPIDefinition.ps1
Normal file
21
Functions/Setup/Support/Get-NetboxAPIDefinition.ps1
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
function Get-NetboxAPIDefinition {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[ValidateSet('json', 'yaml', IgnoreCase = $true)]
|
||||||
|
[string]$Format = 'json'
|
||||||
|
)
|
||||||
|
|
||||||
|
#$URI = "https://netbox.neonet.org/api/schema/?format=json"
|
||||||
|
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('schema'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary @{
|
||||||
|
'format' = $Format.ToLower()
|
||||||
|
}
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters -SkipConnectedCheck
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI
|
||||||
|
}
|
||||||
89
Functions/Setup/Support/Get-NetboxContentType.ps1
Normal file
89
Functions/Setup/Support/Get-NetboxContentType.ps1
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
function Get-NetboxContentType {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Get a content type definition from Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
A detailed description of the Get-NetboxContentType function.
|
||||||
|
|
||||||
|
.PARAMETER Model
|
||||||
|
A description of the Model parameter.
|
||||||
|
|
||||||
|
.PARAMETER Id
|
||||||
|
The database ID of the contact role
|
||||||
|
|
||||||
|
.PARAMETER App_Label
|
||||||
|
A description of the App_Label parameter.
|
||||||
|
|
||||||
|
.PARAMETER Query
|
||||||
|
A standard search query that will match one or more contact roles.
|
||||||
|
|
||||||
|
.PARAMETER Limit
|
||||||
|
Limit the number of results to this number
|
||||||
|
|
||||||
|
.PARAMETER Offset
|
||||||
|
Start the search at this index in results
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> Get-NetboxContentType
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Additional information about the function.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'Query',
|
||||||
|
Position = 0)]
|
||||||
|
[string]$Model,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$App_Label,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Query,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($ContentType_ID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('extras', 'content-types', $ContentType_ID))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('extras', 'content-types'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,6 +12,8 @@
|
||||||
'Connected' = $false
|
'Connected' = $false
|
||||||
'Choices' = @{
|
'Choices' = @{
|
||||||
}
|
}
|
||||||
|
'APIDefinition' = $null
|
||||||
|
'ContentTypes' = $null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
7
Functions/Setup/Support/Test-NetboxAPIConnected.ps1
Normal file
7
Functions/Setup/Support/Test-NetboxAPIConnected.ps1
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
function Test-NetboxAPIConnected {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param ()
|
||||||
|
|
||||||
|
$script:NetboxConfig.Connected
|
||||||
|
}
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param ()
|
param ()
|
||||||
|
|
||||||
$uriSegments = [System.Collections.ArrayList]::new(@('extras', '_choices'))
|
$uriSegments = [System.Collections.ArrayList]::new(@('extras'))
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $uriSegments -SkipConnectedCheck
|
$uri = BuildNewURI -Segments $uriSegments -Parameters @{'format' = 'json' } -SkipConnectedCheck
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri
|
InvokeNetboxRequest -URI $uri
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
|
||||||
|
function Get-NetboxContactAssignment {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Get a contact Assignment from Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
A detailed description of the Get-NetboxContactAssignment function.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The specific name of the contact Assignment. Must match exactly as is defined in Netbox
|
||||||
|
|
||||||
|
.PARAMETER Id
|
||||||
|
The database ID of the contact Assignment
|
||||||
|
|
||||||
|
.PARAMETER Content_Type_Id
|
||||||
|
A description of the Content_Type_Id parameter.
|
||||||
|
|
||||||
|
.PARAMETER Content_Type
|
||||||
|
A description of the Content_Type parameter.
|
||||||
|
|
||||||
|
.PARAMETER Object_Id
|
||||||
|
A description of the Object_Id parameter.
|
||||||
|
|
||||||
|
.PARAMETER Contact_Id
|
||||||
|
A description of the Contact_Id parameter.
|
||||||
|
|
||||||
|
.PARAMETER Role_Id
|
||||||
|
A description of the Role_Id parameter.
|
||||||
|
|
||||||
|
.PARAMETER Limit
|
||||||
|
Limit the number of results to this number
|
||||||
|
|
||||||
|
.PARAMETER Offset
|
||||||
|
Start the search at this index in results
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> Get-NetboxContactAssignment
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Additional information about the function.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'Query',
|
||||||
|
Position = 0)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Content_Type_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Content_Type,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Object_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Contact_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Role_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($ContactAssignment_ID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignments', $ContactAssignment_ID))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignments'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
|
||||||
|
function New-NetboxContactAssignment {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Create a new contact role assignment in Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Creates a new contact role assignment in Netbox
|
||||||
|
|
||||||
|
.PARAMETER Content_Type
|
||||||
|
The content type for this assignment.
|
||||||
|
|
||||||
|
.PARAMETER Object_Id
|
||||||
|
ID of the object to assign.
|
||||||
|
|
||||||
|
.PARAMETER Contact
|
||||||
|
ID of the contact to assign.
|
||||||
|
|
||||||
|
.PARAMETER Role
|
||||||
|
ID of the contact role to assign.
|
||||||
|
|
||||||
|
.PARAMETER Priority
|
||||||
|
Piority of the contact assignment.
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> New-NetboxContactAssignment -Content_Type 'dcim.location' -Object_id 10 -Contact 15 -Role 10 -Priority 'Primary'
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Valid content types: https://docs.netbox.dev/en/stable/features/contacts/#contacts_1
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[ValidateSet('circuits.circuit', 'circuits.provider', 'circuits.provideraccount', 'dcim.device', 'dcim.location', 'dcim.manufacturer', 'dcim.powerpanel', 'dcim.rack', 'dcim.region', 'dcim.site', 'dcim.sitegroup', 'tenancy.tenant', 'virtualization.cluster', 'virtualization.clustergroup', 'virtualization.virtualmachine', IgnoreCase = $true)]
|
||||||
|
[string]$Content_Type,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[uint64]$Object_Id,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[uint64]$Contact,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[uint64]$Role,
|
||||||
|
|
||||||
|
[ValidateSet('primary', 'secondary', 'tertiary', 'inactive', IgnoreCase = $true)]
|
||||||
|
[string]$Priority,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
$Method = 'POST'
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignments'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess($Content_Type, 'Create new contact assignment')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
|
||||||
|
|
||||||
|
function Set-NetboxContactAssignment {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Update a contact role assignment in Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Updates a contact role assignment in Netbox
|
||||||
|
|
||||||
|
.PARAMETER Content_Type
|
||||||
|
The content type for this assignment.
|
||||||
|
|
||||||
|
.PARAMETER Object_Id
|
||||||
|
ID of the object to assign.
|
||||||
|
|
||||||
|
.PARAMETER Contact
|
||||||
|
ID of the contact to assign.
|
||||||
|
|
||||||
|
.PARAMETER Role
|
||||||
|
ID of the contact role to assign.
|
||||||
|
|
||||||
|
.PARAMETER Priority
|
||||||
|
Priority of the contact assignment.
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> Set-NetboxContactAssignment -Id 11 -Content_Type 'dcim.location' -Object_id 10 -Contact 15 -Role 10 -Priority 'Primary'
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Valid content types: https://docs.netbox.dev/en/stable/features/contacts/#contacts_1
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[ValidateSet('circuits.circuit', 'circuits.provider', 'circuits.provideraccount', 'dcim.device', 'dcim.location', 'dcim.manufacturer', 'dcim.powerpanel', 'dcim.rack', 'dcim.region', 'dcim.site', 'dcim.sitegroup', 'tenancy.tenant', 'virtualization.cluster', 'virtualization.clustergroup', 'virtualization.virtualmachine', IgnoreCase = $true)]
|
||||||
|
[string]$Content_Type,
|
||||||
|
|
||||||
|
[uint64]$Object_Id,
|
||||||
|
|
||||||
|
[uint64]$Contact,
|
||||||
|
|
||||||
|
[uint64]$Role,
|
||||||
|
|
||||||
|
[ValidateSet('primary', 'secondary', 'tertiary', 'inactive', IgnoreCase = $true)]
|
||||||
|
[string]$Priority,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
$Method = 'Patch'
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach ($ContactAssignmentId in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignments', $ContactAssignmentId))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
$CurrentContactAssignment = Get-NetboxContactAssignment -Id $ContactAssignmentId -ErrorAction Stop
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess($CurrentContactAssignment.Id, 'Update contact assignment')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
90
Functions/Tenancy/ContactRoles/Get-NetboxContactRole.ps1
Normal file
90
Functions/Tenancy/ContactRoles/Get-NetboxContactRole.ps1
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
|
||||||
|
function Get-NetboxContactRole {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Get a contact role from Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
A detailed description of the Get-NetboxContactRole function.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The specific name of the contact role. Must match exactly as is defined in Netbox
|
||||||
|
|
||||||
|
.PARAMETER Id
|
||||||
|
The database ID of the contact role
|
||||||
|
|
||||||
|
.PARAMETER Query
|
||||||
|
A standard search query that will match one or more contact roles.
|
||||||
|
|
||||||
|
.PARAMETER Limit
|
||||||
|
Limit the number of results to this number
|
||||||
|
|
||||||
|
.PARAMETER Offset
|
||||||
|
Start the search at this index in results
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> Get-NetboxContactRole
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Additional information about the function.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'Query',
|
||||||
|
Position = 0)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Query,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Slug,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($ContactRole_ID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-roles', $ContactRole_ID))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-roles'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
71
Functions/Tenancy/ContactRoles/New-NetboxContactRole.ps1
Normal file
71
Functions/Tenancy/ContactRoles/New-NetboxContactRole.ps1
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
|
||||||
|
function New-NetboxContactRole {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Create a new contact role in Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Creates a new contact role object in Netbox
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The contact role name, e.g "Network Support"
|
||||||
|
|
||||||
|
.PARAMETER Slug
|
||||||
|
The unique URL for the role. Can only contain hypens, A-Z, a-z, 0-9, and underscores
|
||||||
|
|
||||||
|
.PARAMETER Description
|
||||||
|
Short description of the contact role
|
||||||
|
|
||||||
|
.PARAMETER Custom_Fields
|
||||||
|
A description of the Custom_Fields parameter.
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> New-NetboxContact -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Additional information about the function.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[ValidateLength(1, 100)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[ValidateLength(1, 100)]
|
||||||
|
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
|
||||||
|
[string]$Slug,
|
||||||
|
|
||||||
|
[ValidateLength(0, 200)]
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts'))
|
||||||
|
$Method = 'POST'
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess($Name, 'Create new contact')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
80
Functions/Tenancy/ContactRoles/Set-NetboxContactRole.ps1
Normal file
80
Functions/Tenancy/ContactRoles/Set-NetboxContactRole.ps1
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
|
||||||
|
function Set-NetboxContactRole {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Update a contact role in Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Updates a contact role in Netbox
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The contact role name, e.g "Network Support"
|
||||||
|
|
||||||
|
.PARAMETER Slug
|
||||||
|
The unique URL for the role. Can only contain hypens, A-Z, a-z, 0-9, and underscores
|
||||||
|
|
||||||
|
.PARAMETER Description
|
||||||
|
Short description of the contact role
|
||||||
|
|
||||||
|
.PARAMETER Custom_Fields
|
||||||
|
A description of the Custom_Fields parameter.
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> New-NetboxContact -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Additional information about the function.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[ValidateLength(1, 100)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[ValidateLength(1, 100)]
|
||||||
|
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
|
||||||
|
[string]$Slug,
|
||||||
|
|
||||||
|
[ValidateLength(0, 200)]
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
$Method = 'PATCH'
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach ($ContactRoleId in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts', $ContactRoleId))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
$CurrentContactRole = Get-NetboxContactRole -Id $ContactRoleId -ErrorAction Stop
|
||||||
|
|
||||||
|
if ($Force -or $PSCmdlet.ShouldProcess($CurrentContactRole.Name, 'Update contact role')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
120
Functions/Tenancy/Contacts/Get-NetboxContact.ps1
Normal file
120
Functions/Tenancy/Contacts/Get-NetboxContact.ps1
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
|
||||||
|
function Get-NetboxContact {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Get a contact from Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Obtain a contact or contacts from Netbox by ID or query
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The specific name of the Contact. Must match exactly as is defined in Netbox
|
||||||
|
|
||||||
|
.PARAMETER Id
|
||||||
|
The database ID of the Contact
|
||||||
|
|
||||||
|
.PARAMETER Query
|
||||||
|
A standard search query that will match one or more Contacts.
|
||||||
|
|
||||||
|
.PARAMETER Email
|
||||||
|
Email address of the contact
|
||||||
|
|
||||||
|
.PARAMETER Title
|
||||||
|
Title of the contact
|
||||||
|
|
||||||
|
.PARAMETER Phone
|
||||||
|
Telephone number of the contact
|
||||||
|
|
||||||
|
.PARAMETER Address
|
||||||
|
Physical address of the contact
|
||||||
|
|
||||||
|
.PARAMETER Group
|
||||||
|
The specific group as defined in Netbox.
|
||||||
|
|
||||||
|
.PARAMETER GroupID
|
||||||
|
The database ID of the group in Netbox
|
||||||
|
|
||||||
|
.PARAMETER Limit
|
||||||
|
Limit the number of results to this number
|
||||||
|
|
||||||
|
.PARAMETER Offset
|
||||||
|
Start the search at this index in results
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> Get-NetboxContact
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Additional information about the function.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'Query',
|
||||||
|
Position = 0)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Query,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Email,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Title,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Phone,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Address,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Group,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$GroupID,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($Contact_ID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts', $Contact_ID))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
99
Functions/Tenancy/Contacts/New-NetboxContact.ps1
Normal file
99
Functions/Tenancy/Contacts/New-NetboxContact.ps1
Normal file
|
|
@ -0,0 +1,99 @@
|
||||||
|
|
||||||
|
function New-NetboxContact {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Create a new contact in Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Creates a new contact object in Netbox which can be linked to other objects
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The contacts full name, e.g "Leroy Jenkins"
|
||||||
|
|
||||||
|
.PARAMETER Email
|
||||||
|
Email address of the contact
|
||||||
|
|
||||||
|
.PARAMETER Title
|
||||||
|
Job title or other title related to the contact
|
||||||
|
|
||||||
|
.PARAMETER Phone
|
||||||
|
Telephone number
|
||||||
|
|
||||||
|
.PARAMETER Address
|
||||||
|
Physical address, usually mailing address
|
||||||
|
|
||||||
|
.PARAMETER Description
|
||||||
|
Short description of the contact
|
||||||
|
|
||||||
|
.PARAMETER Comments
|
||||||
|
Detailed comments. Markdown supported.
|
||||||
|
|
||||||
|
.PARAMETER Link
|
||||||
|
URI related to the contact
|
||||||
|
|
||||||
|
.PARAMETER Custom_Fields
|
||||||
|
A description of the Custom_Fields parameter.
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
A description of the Raw parameter.
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> New-NetboxContact -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Additional information about the function.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[ValidateLength(1, 100)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[ValidateLength(0, 254)]
|
||||||
|
[string]$Email,
|
||||||
|
|
||||||
|
[ValidateLength(0, 100)]
|
||||||
|
[string]$Title,
|
||||||
|
|
||||||
|
[ValidateLength(0, 50)]
|
||||||
|
[string]$Phone,
|
||||||
|
|
||||||
|
[ValidateLength(0, 200)]
|
||||||
|
[string]$Address,
|
||||||
|
|
||||||
|
[ValidateLength(0, 200)]
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[string]$Comments,
|
||||||
|
|
||||||
|
[ValidateLength(0, 200)]
|
||||||
|
[string]$Link,
|
||||||
|
|
||||||
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts'))
|
||||||
|
$Method = 'POST'
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess($Name, 'Create new contact')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
120
Functions/Tenancy/Contacts/Set-NetboxContact.ps1
Normal file
120
Functions/Tenancy/Contacts/Set-NetboxContact.ps1
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
|
||||||
|
function Set-NetboxContact {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Update a contact in Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Updates a contact object in Netbox which can be linked to other objects
|
||||||
|
|
||||||
|
.PARAMETER Id
|
||||||
|
A description of the Id parameter.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The contacts full name, e.g "Leroy Jenkins"
|
||||||
|
|
||||||
|
.PARAMETER Email
|
||||||
|
Email address of the contact
|
||||||
|
|
||||||
|
.PARAMETER Group
|
||||||
|
Database ID of assigned group
|
||||||
|
|
||||||
|
.PARAMETER Title
|
||||||
|
Job title or other title related to the contact
|
||||||
|
|
||||||
|
.PARAMETER Phone
|
||||||
|
Telephone number
|
||||||
|
|
||||||
|
.PARAMETER Address
|
||||||
|
Physical address, usually mailing address
|
||||||
|
|
||||||
|
.PARAMETER Description
|
||||||
|
Short description of the contact
|
||||||
|
|
||||||
|
.PARAMETER Comments
|
||||||
|
Detailed comments. Markdown supported.
|
||||||
|
|
||||||
|
.PARAMETER Link
|
||||||
|
URI related to the contact
|
||||||
|
|
||||||
|
.PARAMETER Custom_Fields
|
||||||
|
A description of the Custom_Fields parameter.
|
||||||
|
|
||||||
|
.PARAMETER Force
|
||||||
|
A description of the Force parameter.
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
A description of the Raw parameter.
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> Set-NetboxContact -Id 10 -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Additional information about the function.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[ValidateLength(1, 100)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[ValidateLength(0, 254)]
|
||||||
|
[string]$Email,
|
||||||
|
|
||||||
|
[uint64]$Group,
|
||||||
|
|
||||||
|
[ValidateLength(0, 100)]
|
||||||
|
[string]$Title,
|
||||||
|
|
||||||
|
[ValidateLength(0, 50)]
|
||||||
|
[string]$Phone,
|
||||||
|
|
||||||
|
[ValidateLength(0, 200)]
|
||||||
|
[string]$Address,
|
||||||
|
|
||||||
|
[ValidateLength(0, 200)]
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[string]$Comments,
|
||||||
|
|
||||||
|
[ValidateLength(0, 200)]
|
||||||
|
[string]$Link,
|
||||||
|
|
||||||
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
|
[switch]$Force,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
$Method = 'PATCH'
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach ($ContactId in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts', $ContactId))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
$CurrentContact = Get-NetboxContact -Id $ContactId -ErrorAction Stop
|
||||||
|
|
||||||
|
if ($Force -or $PSCmdlet.ShouldProcess($CurrentContact.Name, 'Update contact')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
||||||
Created on: 3/19/2020 11:56
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: Get-NetboxTenancyChoices.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxTenancyChoices {
|
|
||||||
[CmdletBinding()]
|
|
||||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
|
|
||||||
param ()
|
|
||||||
|
|
||||||
$uriSegments = [System.Collections.ArrayList]::new(@('tenancy', '_choices'))
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $uriSegments
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue