mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-13 18:02:29 +00:00
Add Circuit cmdlets
- New-NetboxCircuit - Get-NetboxCircuitProvider - Get-NetboxCircuitTermination - Get-NetboxCircuitType
This commit is contained in:
parent
6636fe74d8
commit
c844322e48
4 changed files with 282 additions and 0 deletions
67
Functions/Circuits/Circuits/New-NetboxCircuit.ps1
Normal file
67
Functions/Circuits/Circuits/New-NetboxCircuit.ps1
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
||||
Created on: 2020-11-04 11:48
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: New-NetboxCircuit.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
|
||||
function New-NetboxCircuit {
|
||||
[CmdletBinding(ConfirmImpact = 'Low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscustomobject])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true,
|
||||
ValueFromPipelineByPropertyName = $true)]
|
||||
[string]$CID,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[uint32]$Provider,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[uint32]$Type,
|
||||
|
||||
#[ValidateSet('Active', 'Planned', 'Provisioning', 'Offline', 'Deprovisioning', 'Decommissioned ')]
|
||||
[uint16]$Status = 'Active',
|
||||
|
||||
[string]$Description,
|
||||
|
||||
[uint32]$Tenant,
|
||||
|
||||
[string]$Termination_A,
|
||||
|
||||
[datetime]$Install_Date,
|
||||
|
||||
[string]$Termination_Z,
|
||||
|
||||
[ValidateRange(0, 2147483647)]
|
||||
[uint32]$Commit_Rate,
|
||||
|
||||
[string]$Comments,
|
||||
|
||||
[hashtable]$Custom_Fields,
|
||||
|
||||
[switch]$Force,
|
||||
|
||||
[switch]$Raw
|
||||
)
|
||||
|
||||
$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
|
||||
}
|
||||
}
|
||||
72
Functions/Circuits/Providers/Get-NetboxCircuitProvider.ps1
Normal file
72
Functions/Circuits/Providers/Get-NetboxCircuitProvider.ps1
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
||||
Created on: 2020-11-04 12:06
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: Get-NetboxCircuitProvider.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
|
||||
function Get-NetboxCircuitProvider {
|
||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||
param
|
||||
(
|
||||
[Parameter(ParameterSetName = 'ById',
|
||||
Mandatory = $true)]
|
||||
[uint16[]]$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,79 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
||||
Created on: 2020-11-04 10:22
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: Get-NetboxCircuitTermination.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
|
||||
function Get-NetboxCircuitTermination {
|
||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||
param
|
||||
(
|
||||
[Parameter(ParameterSetName = 'ById',
|
||||
ValueFromPipelineByPropertyName = $true)]
|
||||
[uint32[]]$Id,
|
||||
|
||||
[Parameter(ParameterSetName = 'Query')]
|
||||
[string]$Circuit_ID,
|
||||
|
||||
[Parameter(ParameterSetName = 'Query')]
|
||||
[string]$Term_Side,
|
||||
|
||||
[Parameter(ParameterSetName = 'Query')]
|
||||
[uint32]$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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
64
Functions/Circuits/Types/Get-NetboxCircuitType.ps1
Normal file
64
Functions/Circuits/Types/Get-NetboxCircuitType.ps1
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
||||
Created on: 2020-11-04 12:34
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: Get-NetboxCircuitType.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
|
||||
function Get-NetboxCircuitType {
|
||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||
param
|
||||
(
|
||||
[Parameter(ParameterSetName = 'ById')]
|
||||
[uint16[]]$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
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue