diff --git a/Functions/Circuits/Circuits/Get-NetboxCircuit.ps1 b/Functions/Circuits/Circuits/Get-NetboxCircuit.ps1
new file mode 100644
index 0000000..319ee48
--- /dev/null
+++ b/Functions/Circuits/Circuits/Get-NetboxCircuit.ps1
@@ -0,0 +1,131 @@
+<#
+ .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 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 [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 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')]
+ [uint16[]]$Id,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$CID,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [datetime]$InstallDate,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$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
+ )
+
+ 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
+ }
+ }
+}
\ No newline at end of file
diff --git a/Functions/Circuits/Circuits/New-NetboxCircuit.ps1 b/Functions/Circuits/Circuits/New-NetboxCircuit.ps1
new file mode 100644
index 0000000..aac3447
--- /dev/null
+++ b/Functions/Circuits/Circuits/New-NetboxCircuit.ps1
@@ -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
+ }
+}
\ No newline at end of file
diff --git a/Functions/Circuits/Get-NetboxCircuit.ps1 b/Functions/Circuits/Get-NetboxCircuit.ps1
deleted file mode 100644
index 54c6b21..0000000
--- a/Functions/Circuits/Get-NetboxCircuit.ps1
+++ /dev/null
@@ -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
-}
\ No newline at end of file
diff --git a/Functions/Circuits/Get-NetboxCircuitsChoices.ps1 b/Functions/Circuits/Get-NetboxCircuitsChoices.ps1
deleted file mode 100644
index 67fbbdf..0000000
--- a/Functions/Circuits/Get-NetboxCircuitsChoices.ps1
+++ /dev/null
@@ -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
-}
diff --git a/Functions/Circuits/Providers/Get-NetboxCircuitProvider.ps1 b/Functions/Circuits/Providers/Get-NetboxCircuitProvider.ps1
new file mode 100644
index 0000000..07ad3ca
--- /dev/null
+++ b/Functions/Circuits/Providers/Get-NetboxCircuitProvider.ps1
@@ -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
+ }
+ }
+}
\ No newline at end of file
diff --git a/Functions/Circuits/Terminations/Get-NetboxCircuitTermination.ps1 b/Functions/Circuits/Terminations/Get-NetboxCircuitTermination.ps1
new file mode 100644
index 0000000..6e055fd
--- /dev/null
+++ b/Functions/Circuits/Terminations/Get-NetboxCircuitTermination.ps1
@@ -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
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Functions/Circuits/Types/Get-NetboxCircuitType.ps1 b/Functions/Circuits/Types/Get-NetboxCircuitType.ps1
new file mode 100644
index 0000000..bce6ad5
--- /dev/null
+++ b/Functions/Circuits/Types/Get-NetboxCircuitType.ps1
@@ -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
+ }
+ }
+}
\ No newline at end of file
diff --git a/Functions/DCIM/Devices/New-NetboxDCIMDevice.ps1 b/Functions/DCIM/Devices/New-NetboxDCIMDevice.ps1
index f209a93..3a6751d 100644
--- a/Functions/DCIM/Devices/New-NetboxDCIMDevice.ps1
+++ b/Functions/DCIM/Devices/New-NetboxDCIMDevice.ps1
@@ -64,21 +64,21 @@ function New-NetboxDCIMDevice {
)
#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
- }
+# 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'))
diff --git a/Functions/DCIM/Devices/Set-NetboxDCIMDevice.ps1 b/Functions/DCIM/Devices/Set-NetboxDCIMDevice.ps1
index e15ce9f..00b50fc 100644
--- a/Functions/DCIM/Devices/Set-NetboxDCIMDevice.ps1
+++ b/Functions/DCIM/Devices/Set-NetboxDCIMDevice.ps1
@@ -64,13 +64,13 @@ function Set-NetboxDCIMDevice {
)
begin {
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
- }
-
- if ($null -ne $Face) {
- $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
- }
+# if ($null -ne $Status) {
+# $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
+# }
+#
+# if ($null -ne $Face) {
+# $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
+# }
}
process {
diff --git a/Functions/DCIM/Get-NetboxDCIMChoices.ps1 b/Functions/DCIM/Get-NetboxDCIMChoices.ps1
deleted file mode 100644
index 55104dd..0000000
--- a/Functions/DCIM/Get-NetboxDCIMChoices.ps1
+++ /dev/null
@@ -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
-}
\ No newline at end of file
diff --git a/Functions/DCIM/Interfaces/Add-NetboxDCIMInterface.ps1 b/Functions/DCIM/Interfaces/Add-NetboxDCIMInterface.ps1
index a19da07..c792d35 100644
--- a/Functions/DCIM/Interfaces/Add-NetboxDCIMInterface.ps1
+++ b/Functions/DCIM/Interfaces/Add-NetboxDCIMInterface.ps1
@@ -47,9 +47,9 @@ function Add-NetboxDCIMInterface {
[uint16[]]$Tagged_VLANs
)
- if ($null -ne $Form_Factor) {
- $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
- }
+# if ($null -ne $Form_Factor) {
+# $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
+# }
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
$PSBoundParameters.Mode = switch ($Mode) {
diff --git a/Functions/DCIM/Interfaces/Set-NetboxDCIMInterface.ps1 b/Functions/DCIM/Interfaces/Set-NetboxDCIMInterface.ps1
index fbfb552..431065a 100644
--- a/Functions/DCIM/Interfaces/Set-NetboxDCIMInterface.ps1
+++ b/Functions/DCIM/Interfaces/Set-NetboxDCIMInterface.ps1
@@ -50,9 +50,9 @@ function Set-NetboxDCIMInterface {
)
begin {
- if ($null -ne $Form_Factor) {
- $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
- }
+# if ($null -ne $Form_Factor) {
+# $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
+# }
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
$PSBoundParameters.Mode = switch ($Mode) {
diff --git a/Functions/DCIM/Interfaces/Set-NetboxDCIMInterfaceConnection.ps1 b/Functions/DCIM/Interfaces/Set-NetboxDCIMInterfaceConnection.ps1
index 2e2496f..0836bfc 100644
--- a/Functions/DCIM/Interfaces/Set-NetboxDCIMInterfaceConnection.ps1
+++ b/Functions/DCIM/Interfaces/Set-NetboxDCIMInterfaceConnection.ps1
@@ -60,9 +60,9 @@ function Set-NetboxDCIMInterfaceConnection {
)
begin {
- if ($null -ne $Connection_Status) {
- $PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
- }
+# if ($null -ne $Connection_Status) {
+# $PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
+# }
if ((@($ID).Count -gt 1) -and ($Interface_A -or $Interface_B)) {
throw "Cannot set multiple connections to the same interface"
diff --git a/Functions/DCIM/Sites/Get-NetboxDCIMSite.ps1 b/Functions/DCIM/Sites/Get-NetboxDCIMSite.ps1
new file mode 100644
index 0000000..b7e13a4
--- /dev/null
+++ b/Functions/DCIM/Sites/Get-NetboxDCIMSite.ps1
@@ -0,0 +1,108 @@
+<#
+ .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: Get-NetboxDCIMSite.ps1
+ ===========================================================================
+ .DESCRIPTION
+ A description of the file.
+#>
+
+
+
+function Get-NetboxDCIMSite {
+ [CmdletBinding()]
+ [OutputType([pscustomobject])]
+ param
+ (
+ [Parameter(ParameterSetName = 'ByID', ValueFromPipelineByPropertyName = $true)]
+ [uint32]$Id,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Name,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Query,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Slug,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Facility,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$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')]
+ [uint32]$Tenant_Group_ID,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Tenant_Group,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Tenant_ID,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Tenant,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Status,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Region_ID,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Region,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Limit,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Offset,
+
+ [switch]$Raw
+ )
+
+ 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
+ }
+ }
+}
+
diff --git a/Functions/DCIM/ValidateDCIMChoice.ps1 b/Functions/DCIM/ValidateDCIMChoice.ps1
deleted file mode 100644
index 25b3130..0000000
--- a/Functions/DCIM/ValidateDCIMChoice.ps1
+++ /dev/null
@@ -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
-}
\ No newline at end of file
diff --git a/Functions/Extras/Get-NetboxExtrasChoices.ps1 b/Functions/Extras/Get-NetboxExtrasChoices.ps1
deleted file mode 100644
index 78118e0..0000000
--- a/Functions/Extras/Get-NetboxExtrasChoices.ps1
+++ /dev/null
@@ -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
-}
diff --git a/Functions/Helpers/Get-ModelDefinition.ps1 b/Functions/Helpers/Get-ModelDefinition.ps1
new file mode 100644
index 0000000..bf389fa
--- /dev/null
+++ b/Functions/Helpers/Get-ModelDefinition.ps1
@@ -0,0 +1,64 @@
+<#
+ .NOTES
+ ===========================================================================
+ Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
+ Created on: 2020-11-04 14:23
+ Created by: Claussen
+ Organization: NEOnet
+ Filename: Get-ModelDefinition.ps1
+ ===========================================================================
+ .DESCRIPTION
+ A description of the file.
+#>
+
+
+
+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
+ }
+ }
+
+}
diff --git a/Functions/Helpers/GetChoiceValidValues.ps1 b/Functions/Helpers/GetChoiceValidValues.ps1
deleted file mode 100644
index 7579416..0000000
--- a/Functions/Helpers/GetChoiceValidValues.ps1
+++ /dev/null
@@ -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
-}
\ No newline at end of file
diff --git a/Functions/Helpers/InvokeNetboxRequest.ps1 b/Functions/Helpers/InvokeNetboxRequest.ps1
index 0f2d7fb..ef5d31e 100644
--- a/Functions/Helpers/InvokeNetboxRequest.ps1
+++ b/Functions/Helpers/InvokeNetboxRequest.ps1
@@ -27,7 +27,7 @@ function InvokeNetboxRequest {
[ValidateRange(0, 60)]
[uint16]$Timeout = 5,
- [ValidateSet('GET', 'PATCH', 'PUT', 'POST', 'DELETE', IgnoreCase = $true)]
+ [ValidateSet('GET', 'PATCH', 'PUT', 'POST', 'DELETE', 'OPTIONS', IgnoreCase = $true)]
[string]$Method = 'GET',
[switch]$Raw
diff --git a/Functions/Helpers/ValidateChoice.ps1 b/Functions/Helpers/ValidateChoice.ps1
deleted file mode 100644
index bb99844..0000000
--- a/Functions/Helpers/ValidateChoice.ps1
+++ /dev/null
@@ -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
- }
- }
-}
\ No newline at end of file
diff --git a/Functions/IPAM/Address/Get-NetboxIPAMAddress.ps1 b/Functions/IPAM/Address/Get-NetboxIPAMAddress.ps1
index 5a57726..d1a433c 100644
--- a/Functions/IPAM/Address/Get-NetboxIPAMAddress.ps1
+++ b/Functions/IPAM/Address/Get-NetboxIPAMAddress.ps1
@@ -1,65 +1,93 @@
function Get-NetboxIPAMAddress {
- [CmdletBinding()]
+ [CmdletBinding(DefaultParameterSetName = 'Query')]
param
(
+ [Parameter(ParameterSetName = 'Query',
+ Position = 0)]
[string]$Address,
- [uint16[]]$Id,
+ [Parameter(ParameterSetName = 'ByID')]
+ [uint32[]]$Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Query,
+ [Parameter(ParameterSetName = 'Query')]
[object]$Family,
- [uint16]$Parent,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Parent,
+ [Parameter(ParameterSetName = 'Query')]
[byte]$Mask_Length,
+ [Parameter(ParameterSetName = 'Query')]
[string]$VRF,
- [uint16]$VRF_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$VRF_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Tenant,
- [uint16]$Tenant_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Tenant_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Device,
- [uint16]$Device_ID,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Device_ID,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Virtual_Machine,
- [uint16]$Virtual_Machine_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Virtual_Machine_Id,
- [uint16]$Interface_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Interface_Id,
+ [Parameter(ParameterSetName = 'Query')]
[object]$Status,
+ [Parameter(ParameterSetName = 'Query')]
[object]$Role,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$Limit,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$Offset,
[switch]$Raw
)
- if ($null -ne $Family) {
- $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -IPAddressFamily
+ switch ($PSCmdlet.ParameterSetName) {
+ '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
+ }
+
+ break
+ }
+
+ default {
+ $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
+
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $uri -Raw:$Raw
+
+ break
+ }
}
-
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
- }
-
- if ($null -ne $Role) {
- $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 -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $uri -Raw:$Raw
}
\ No newline at end of file
diff --git a/Functions/IPAM/Address/New-NetboxIPAMAddress.ps1 b/Functions/IPAM/Address/New-NetboxIPAMAddress.ps1
index 0ee365a..c5d191b 100644
--- a/Functions/IPAM/Address/New-NetboxIPAMAddress.ps1
+++ b/Functions/IPAM/Address/New-NetboxIPAMAddress.ps1
@@ -47,6 +47,9 @@ function New-NetboxIPAMAddress {
.PARAMETER Description
Description of IP address
+ .PARAMETER Force
+ Do not prompt for confirmation to create IP.
+
.PARAMETER Raw
Return raw results from API service
@@ -57,11 +60,13 @@ function New-NetboxIPAMAddress {
Additional information about the function.
#>
- [CmdletBinding()]
+ [CmdletBinding(ConfirmImpact = 'Low',
+ SupportsShouldProcess = $true)]
[OutputType([pscustomobject])]
param
(
- [Parameter(Mandatory = $true)]
+ [Parameter(Mandatory = $true,
+ ValueFromPipelineByPropertyName = $true)]
[string]$Address,
[object]$Status = 'Active',
@@ -80,20 +85,35 @@ function New-NetboxIPAMAddress {
[string]$Description,
+ [switch]$Force,
+
[switch]$Raw
)
- $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
+ $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
+ $Method = 'POST'
- if ($null -ne $Role) {
- $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
- }
-
- $segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
-
- $URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
+ # # 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
+ # }
+ # }
+ #
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
$URI = BuildNewURI -Segments $URIComponents.Segments
- InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
-}
\ No newline at end of file
+ if ($Force -or $PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
+ InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
+ }
+}
+
+
+
+
+
diff --git a/Functions/IPAM/Address/Remove-NetboxIPAMAddress.ps1 b/Functions/IPAM/Address/Remove-NetboxIPAMAddress.ps1
index da80014..48871db 100644
--- a/Functions/IPAM/Address/Remove-NetboxIPAMAddress.ps1
+++ b/Functions/IPAM/Address/Remove-NetboxIPAMAddress.ps1
@@ -43,9 +43,6 @@ function Remove-NetboxIPAMAddress {
[switch]$Force
)
- begin {
- }
-
process {
foreach ($IPId in $Id) {
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
@@ -59,7 +56,4 @@ function Remove-NetboxIPAMAddress {
}
}
}
-
- end {
- }
}
\ No newline at end of file
diff --git a/Functions/IPAM/Address/Set-NetboxIPAMAddress.ps1 b/Functions/IPAM/Address/Set-NetboxIPAMAddress.ps1
index de2d07e..01c0731 100644
--- a/Functions/IPAM/Address/Set-NetboxIPAMAddress.ps1
+++ b/Functions/IPAM/Address/Set-NetboxIPAMAddress.ps1
@@ -23,7 +23,7 @@ function Set-NetboxIPAMAddress {
[string]$Address,
- [object]$Status,
+ [string]$Status,
[uint16]$Tenant,
@@ -35,7 +35,10 @@ function Set-NetboxIPAMAddress {
[hashtable]$Custom_Fields,
- [uint16]$Interface,
+ [ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
+ [string]$Assigned_Object_Type,
+
+ [uint16]$Assigned_Object_Id,
[string]$Description,
@@ -43,20 +46,39 @@ function Set-NetboxIPAMAddress {
)
begin {
- if ($Status) {
- $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
- }
-
- if ($Role) {
- $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
- }
+ # 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 ($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))
- Write-Verbose "Obtaining IPs from ID $IPId"
+ Write-Verbose "Obtaining IP from ID $IPId"
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
if ($Force -or $PSCmdlet.ShouldProcess($CurrentIP.Address, 'Set')) {
@@ -64,11 +86,8 @@ function Set-NetboxIPAMAddress {
$URI = BuildNewURI -Segments $URIComponents.Segments
- InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
+ InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method
}
}
}
-
- end {
- }
}
\ No newline at end of file
diff --git a/Functions/IPAM/Aggregate/Get-NetboxIPAMAggregate.ps1 b/Functions/IPAM/Aggregate/Get-NetboxIPAMAggregate.ps1
index 03e5255..a696bc6 100644
--- a/Functions/IPAM/Aggregate/Get-NetboxIPAMAggregate.ps1
+++ b/Functions/IPAM/Aggregate/Get-NetboxIPAMAggregate.ps1
@@ -13,37 +13,67 @@
function Get-NetboxIPAMAggregate {
- [CmdletBinding()]
+ [CmdletBinding(DefaultParameterSetName = 'Query')]
param
(
- [uint16]$Limit,
-
- [uint16]$Offset,
-
- [object]$Family,
-
- [datetime]$Date_Added,
-
- [uint16[]]$Id,
-
+ [Parameter(ParameterSetName = 'Query')]
[string]$Query,
+ [Parameter(ParameterSetName = 'ByID')]
+ [uint16[]]$Id,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Prefix,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [object]$Family,
+
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$RIR_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$RIR,
+ [Parameter(ParameterSetName = 'Query')]
+ [datetime]$Date_Added,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Limit,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Offset,
+
[switch]$Raw
)
- if ($null -ne $Family) {
- $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -AggregateFamily
+# if ($null -ne $Family) {
+# $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -AggregateFamily
+ # }
+
+ switch ($PSCmdlet.ParameterSetName) {
+ 'ById' {
+ foreach ($IP_ID in $Id) {
+ $Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates', $IP_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', 'aggregates'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
+
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $uri -Raw:$Raw
+
+ break
+ }
}
-
- $Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
-
- $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $uri -Raw:$Raw
}
\ No newline at end of file
diff --git a/Functions/IPAM/Get-NetboxIPAMChoices.ps1 b/Functions/IPAM/Get-NetboxIPAMChoices.ps1
deleted file mode 100644
index 13d1c99..0000000
--- a/Functions/IPAM/Get-NetboxIPAMChoices.ps1
+++ /dev/null
@@ -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
-}
\ No newline at end of file
diff --git a/Functions/IPAM/Prefix/Get-NetboxIPAMPrefix.ps1 b/Functions/IPAM/Prefix/Get-NetboxIPAMPrefix.ps1
index 1236046..a554fb6 100644
--- a/Functions/IPAM/Prefix/Get-NetboxIPAMPrefix.ps1
+++ b/Functions/IPAM/Prefix/Get-NetboxIPAMPrefix.ps1
@@ -93,70 +93,113 @@ function Get-NetboxIPAMPrefix {
Additional information about the function.
#>
- [CmdletBinding()]
+ [CmdletBinding(DefaultParameterSetName = 'Query')]
param
(
+ [Parameter(ParameterSetName = 'Query',
+ Position = 0)]
[string]$Prefix,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Query,
- [uint16[]]$Id,
+ [Parameter(ParameterSetName = 'ByID')]
+ [uint32[]]$Id,
+ [Parameter(ParameterSetName = 'Query')]
[object]$Family,
+ [Parameter(ParameterSetName = 'Query')]
[boolean]$Is_Pool,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Within,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Within_Include,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Contains,
+ [Parameter(ParameterSetName = 'Query')]
[ValidateRange(0, 127)]
[byte]$Mask_Length,
+ [Parameter(ParameterSetName = 'Query')]
[string]$VRF,
- [uint16]$VRF_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$VRF_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Tenant,
- [uint16]$Tenant_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Tenant_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Site,
- [uint16]$Site_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Site_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Vlan_VId,
- [uint16]$Vlan_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Vlan_Id,
+ [Parameter(ParameterSetName = 'Query')]
[object]$Status,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Role,
- [uint16]$Role_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Role_Id,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$Limit,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$Offset,
[switch]$Raw
)
- if ($null -ne $Family) {
- $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -PrefixFamily
+ # if ($null -ne $Family) {
+ # $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
+ }
+
+ break
+ }
+
+ default {
+ $Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
+
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $uri -Raw:$Raw
+
+ break
+ }
}
-
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
- }
-
- $Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
-
- $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $uri -Raw:$Raw
}
\ No newline at end of file
diff --git a/Functions/IPAM/Prefix/New-NetboxIPAMPrefix.ps1 b/Functions/IPAM/Prefix/New-NetboxIPAMPrefix.ps1
index a085eab..c9c7577 100644
--- a/Functions/IPAM/Prefix/New-NetboxIPAMPrefix.ps1
+++ b/Functions/IPAM/Prefix/New-NetboxIPAMPrefix.ps1
@@ -40,7 +40,7 @@ function New-NetboxIPAMPrefix {
[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
diff --git a/Functions/IPAM/Prefix/Set-NetboxIPAMPrefix.ps1 b/Functions/IPAM/Prefix/Set-NetboxIPAMPrefix.ps1
new file mode 100644
index 0000000..0670ad7
--- /dev/null
+++ b/Functions/IPAM/Prefix/Set-NetboxIPAMPrefix.ps1
@@ -0,0 +1,92 @@
+<#
+ .NOTES
+ ===========================================================================
+ Created with: SAPIEN Technologies, Inc., PowerShell Studio 2021 v5.8.186
+ Created on: 2021-03-23 13:54
+ Created by: Claussen
+ Organization: NEOnet
+ Filename: Set-NetboxIPAMPrefix.ps1
+ ===========================================================================
+ .DESCRIPTION
+ A description of the file.
+#>
+
+
+function Set-NetboxIPAMPrefix {
+ [CmdletBinding(ConfirmImpact = 'Medium',
+ SupportsShouldProcess = $true)]
+ param
+ (
+ [Parameter(Mandatory = $true,
+ ValueFromPipelineByPropertyName = $true)]
+ [uint16[]]$Id,
+
+ [string]$Prefix,
+
+ [string]$Status,
+
+ [uint16]$Tenant,
+
+ [uint16]$Site,
+
+ [uint16]$VRF,
+
+ [uint16]$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
+ }
+ }
+ }
+}
+
+
+
+
+
+
+
+
diff --git a/Functions/IPAM/Role/Get-NetboxIPAMRole.ps1 b/Functions/IPAM/Role/Get-NetboxIPAMRole.ps1
index 03cbb64..e7066c0 100644
--- a/Functions/IPAM/Role/Get-NetboxIPAMRole.ps1
+++ b/Functions/IPAM/Role/Get-NetboxIPAMRole.ps1
@@ -41,28 +41,56 @@ function Get-NetboxIPAMRole {
[CmdletBinding()]
param
(
- [uint16[]]$Id,
-
- [string]$Query,
-
+ [Parameter(ParameterSetName = 'Query',
+ Position = 0)]
[string]$Name,
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Query,
+
+ [Parameter(ParameterSetName = 'ByID')]
+ [uint32[]]$Id,
+
+ [Parameter(ParameterSetName = 'Query')]
[string]$Slug,
+ [Parameter(ParameterSetName = 'Query')]
[switch]$Brief,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$Limit,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$Offset,
[switch]$Raw
)
- $Segments = [System.Collections.ArrayList]::new(@('ipam', 'roles'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
-
- $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $uri -Raw:$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'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
+
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $uri -Raw:$Raw
+
+ break
+ }
+ }
}
\ No newline at end of file
diff --git a/Functions/IPAM/VLAN/Get-NetboxIPAMVLAN.ps1 b/Functions/IPAM/VLAN/Get-NetboxIPAMVLAN.ps1
index 025c028..050d5bc 100644
--- a/Functions/IPAM/VLAN/Get-NetboxIPAMVLAN.ps1
+++ b/Functions/IPAM/VLAN/Get-NetboxIPAMVLAN.ps1
@@ -16,56 +16,96 @@ function Get-NetboxIPAMVLAN {
[CmdletBinding()]
param
(
- [uint16]$Limit,
-
- [uint16]$Offset,
-
+ [Parameter(ParameterSetName = 'Query',
+ Position = 0)]
+ [ValidateRange(1, 4096)]
[uint16]$VID,
- [uint16[]]$Id,
+ [Parameter(ParameterSetName = 'ByID')]
+ [uint32[]]$Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Query,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Name,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Tenant,
- [uint16]$Tenant_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Tenant_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$TenantGroup,
- [uint16]$TenantGroup_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$TenantGroup_Id,
+ [Parameter(ParameterSetName = 'Query')]
[object]$Status,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Region,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Site,
- [uint16]$Site_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Site_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Group,
- [uint16]$Group_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Group_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Role,
- [uint16]$Role_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Role_Id,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Limit,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Offset,
[switch]$Raw
)
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
+ # if ($null -ne $Status) {
+ # $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
+ # }
+
+ switch ($PSCmdlet.ParameterSetName) {
+ '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'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
+
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $uri -Raw:$Raw
+
+ break
+ }
}
-
- $Segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
-
- $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $uri -Raw:$Raw
}
diff --git a/Functions/IPAM/VLAN/New-NetboxIPAMVLAN.ps1 b/Functions/IPAM/VLAN/New-NetboxIPAMVLAN.ps1
index bc55aed..c846296 100644
--- a/Functions/IPAM/VLAN/New-NetboxIPAMVLAN.ps1
+++ b/Functions/IPAM/VLAN/New-NetboxIPAMVLAN.ps1
@@ -63,11 +63,11 @@
[switch]$Raw
)
- $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
-
- if ($null -ne $Role) {
- $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
- }
+# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
+#
+# if ($null -ne $Role) {
+# $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
+# }
$segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
diff --git a/Functions/IPAM/ValidateIPAMChoice.ps1 b/Functions/IPAM/ValidateIPAMChoice.ps1
deleted file mode 100644
index 6b46427..0000000
--- a/Functions/IPAM/ValidateIPAMChoice.ps1
+++ /dev/null
@@ -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
-}
\ No newline at end of file
diff --git a/Functions/Setup/Connect-NetboxAPI.ps1 b/Functions/Setup/Connect-NetboxAPI.ps1
index c4e9809..9c372b2 100644
--- a/Functions/Setup/Connect-NetboxAPI.ps1
+++ b/Functions/Setup/Connect-NetboxAPI.ps1
@@ -48,8 +48,6 @@
try {
Write-Verbose "Verifying API connectivity..."
$null = VerifyAPIConnectivity
- $script:NetboxConfig.Connected = $true
- Write-Verbose "Successfully connected!"
} catch {
Write-Verbose "Failed to connect. Generating error"
Write-Verbose $_.Exception.Message
@@ -60,14 +58,25 @@
}
}
- Write-Verbose "Caching static choices"
- $script:NetboxConfig.Choices.Circuits = Get-NetboxCircuitsChoices
- $script:NetboxConfig.Choices.DCIM = Get-NetboxDCIMChoices # Not completed yet
- $script:NetboxConfig.Choices.Extras = Get-NetboxExtrasChoices
- $script:NetboxConfig.Choices.IPAM = Get-NetboxIPAMChoices
- #$script:NetboxConfig.Choices.Secrets = Get-NetboxSecretsChoices # Not completed yet
- #$script:NetboxConfig.Choices.Tenancy = Get-NetboxTenancyChoices
- $script:NetboxConfig.Choices.Virtualization = Get-NetboxVirtualizationChoices
+ Write-Verbose "Caching API definition"
+ $script:NetboxConfig.APIDefinition = Get-NetboxAPIDefinition
+
+ if ([version]$script:NetboxConfig.APIDefinition.info.version -lt 2.8) {
+ $Script:NetboxConfig.Connected = $false
+ throw "Netbox version is incompatible with this PS module. Requires >=2.8.*, found version $($script:NetboxConfig.APIDefinition.info.version)"
+ }
+
+ $script:NetboxConfig.Connected = $true
+ Write-Verbose "Successfully connected!"
+
+ #Write-Verbose "Caching static choices"
+ #$script:NetboxConfig.Choices.Circuits = Get-NetboxCircuitsChoices
+ #$script:NetboxConfig.Choices.DCIM = Get-NetboxDCIMChoices # Not completed yet
+ #$script:NetboxConfig.Choices.Extras = Get-NetboxExtrasChoices
+ #$script:NetboxConfig.Choices.IPAM = Get-NetboxIPAMChoices
+ ##$script:NetboxConfig.Choices.Secrets = Get-NetboxSecretsChoices # Not completed yet
+ ##$script:NetboxConfig.Choices.Tenancy = Get-NetboxTenancyChoices
+ #$script:NetboxConfig.Choices.Virtualization = Get-NetboxVirtualizationChoices
Write-Verbose "Connection process completed"
}
\ No newline at end of file
diff --git a/Functions/Setup/Support/Get-NetboxAPIDefinition.ps1 b/Functions/Setup/Support/Get-NetboxAPIDefinition.ps1
new file mode 100644
index 0000000..3fb0215
--- /dev/null
+++ b/Functions/Setup/Support/Get-NetboxAPIDefinition.ps1
@@ -0,0 +1,29 @@
+<#
+ .NOTES
+ ===========================================================================
+ Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.174
+ Created on: 4/28/2020 11:57
+ Created by: Claussen
+ Organization: NEOnet
+ Filename: Get-NetboxAPIDefinition.ps1
+ ===========================================================================
+ .DESCRIPTION
+ A description of the file.
+#>
+
+
+
+function Get-NetboxAPIDefinition {
+ [CmdletBinding()]
+ param ()
+
+ #$URI = "https://netbox.neonet.org/api/docs/?format=openapi"
+
+ $Segments = [System.Collections.ArrayList]::new(@('docs'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary @{'format' = 'openapi'}
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters -SkipConnectedCheck
+
+ InvokeNetboxRequest -URI $URI -Timeout 10
+}
diff --git a/Functions/Setup/Support/SetupNetboxConfigVariable.ps1 b/Functions/Setup/Support/SetupNetboxConfigVariable.ps1
index 8c28e27..20d84a8 100644
--- a/Functions/Setup/Support/SetupNetboxConfigVariable.ps1
+++ b/Functions/Setup/Support/SetupNetboxConfigVariable.ps1
@@ -12,6 +12,7 @@
'Connected' = $false
'Choices' = @{
}
+ 'APIDefinition' = $null
}
}
diff --git a/Functions/Setup/Support/VerifyAPIConnectivity.ps1 b/Functions/Setup/Support/VerifyAPIConnectivity.ps1
index dc461d0..b53760e 100644
--- a/Functions/Setup/Support/VerifyAPIConnectivity.ps1
+++ b/Functions/Setup/Support/VerifyAPIConnectivity.ps1
@@ -2,9 +2,9 @@
[CmdletBinding()]
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
}
\ No newline at end of file
diff --git a/Functions/Tenancy/Get-NetboxTenancyChoices.ps1 b/Functions/Tenancy/Get-NetboxTenancyChoices.ps1
deleted file mode 100644
index 1017a91..0000000
--- a/Functions/Tenancy/Get-NetboxTenancyChoices.ps1
+++ /dev/null
@@ -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
-}
\ No newline at end of file
diff --git a/Functions/Tenancy/Get-NetboxTenant.ps1 b/Functions/Tenancy/Get-NetboxTenant.ps1
index 4686223..85d110c 100644
--- a/Functions/Tenancy/Get-NetboxTenant.ps1
+++ b/Functions/Tenancy/Get-NetboxTenant.ps1
@@ -13,33 +13,109 @@
function Get-NetboxTenant {
- [CmdletBinding()]
+<#
+ .SYNOPSIS
+ Get a tenent from Netbox
+
+ .DESCRIPTION
+ A detailed description of the Get-NetboxTenant function.
+
+ .PARAMETER Name
+ The specific name of the tenant. Must match exactly as is defined in Netbox
+
+ .PARAMETER Id
+ The database ID of the tenant
+
+ .PARAMETER Query
+ A standard search query that will match one or more tenants.
+
+ .PARAMETER Slug
+ The specific slug of the tenant. Must match exactly as is defined in Netbox
+
+ .PARAMETER Group
+ The specific group as defined in Netbox.
+
+ .PARAMETER GroupID
+ The database ID of the group in Netbox
+
+ .PARAMETER CustomFields
+ Hashtable in the format @{"field_name" = "value"} to search
+
+ .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-NetboxTenant
+
+ .NOTES
+ Additional information about the function.
+#>
+
+ [CmdletBinding(DefaultParameterSetName = 'Query')]
param
(
- [uint16]$Limit,
-
- [uint16]$Offset,
-
+ [Parameter(ParameterSetName = 'Query',
+ Position = 0)]
[string]$Name,
- [uint16[]]$Id,
+ [Parameter(ParameterSetName = 'ByID')]
+ [uint32[]]$Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Query,
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Slug,
+
+ [Parameter(ParameterSetName = 'Query')]
[string]$Group,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$GroupID,
+ [Parameter(ParameterSetName = 'Query')]
[hashtable]$CustomFields,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Limit,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Offset,
+
[switch]$Raw
)
- $Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
-
- $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $uri -Raw:$Raw
+ switch ($PSCmdlet.ParameterSetName) {
+ 'ById' {
+ foreach ($Tenant_ID in $Id) {
+ $Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants', $Tenant_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', 'tenants'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
+
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $uri -Raw:$Raw
+
+ break
+ }
+ }
}
\ No newline at end of file
diff --git a/Functions/Virtualization/Get-NetboxVirtualizationChoices.ps1 b/Functions/Virtualization/Get-NetboxVirtualizationChoices.ps1
deleted file mode 100644
index 1e12a9d..0000000
--- a/Functions/Virtualization/Get-NetboxVirtualizationChoices.ps1
+++ /dev/null
@@ -1,25 +0,0 @@
-<#
- .NOTES
- ===========================================================================
- Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
- Created on: 3/19/2020 14:10
- Created by: Claussen
- Organization: NEOnet
- Filename: Get-NetboxVirtualizationChoices.ps1
- ===========================================================================
- .DESCRIPTION
- A description of the file.
-#>
-
-
-function Get-NetboxVirtualizationChoices {
- [CmdletBinding()]
- [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
- param ()
-
- $uriSegments = [System.Collections.ArrayList]::new(@('virtualization', '_choices'))
-
- $uri = BuildNewURI -Segments $uriSegments
-
- InvokeNetboxRequest -URI $uri
-}
\ No newline at end of file
diff --git a/Functions/Virtualization/ValidateVirtualizationChoice.ps1 b/Functions/Virtualization/ValidateVirtualizationChoice.ps1
deleted file mode 100644
index 76ccf6b..0000000
--- a/Functions/Virtualization/ValidateVirtualizationChoice.ps1
+++ /dev/null
@@ -1,76 +0,0 @@
-<#
- .NOTES
- ===========================================================================
- Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
- Created on: 3/19/2020 14:12
- Created by: Claussen
- Organization: NEOnet
- Filename: ValidateVirtualizationChoice.ps1
- ===========================================================================
- .DESCRIPTION
- A description of the file.
-#>
-
-function ValidateVirtualizationChoice {
-<#
- .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:\> VerifyIPAMChoices -ProvidedValue 'loopback' -IPAddressRole
-
- .EXAMPLE
- PS C:\> VerifyIPAMChoices -ProvidedValue 'Loopback' -IPAddressFamily
- >> Invalid value Loopback for ip-address:family. Must be one of: 4, 6, IPv4, IPv6
-
- .FUNCTIONALITY
- This cmdlet is intended to be used internally and not exposed to the user
-
- .OUTPUT
- This function returns nothing if the value is valid. Otherwise, it will throw an error.
-#>
-
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory = $true)]
- [object]$ProvidedValue,
-
- [Parameter(ParameterSetName = 'virtual-machine:status',
- Mandatory = $true)]
- [switch]$VirtualMachineStatus
- )
-
- ValidateChoice -MajorObject 'Virtualization' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
-}
\ No newline at end of file
diff --git a/Functions/Virtualization/VirtualMachine/New-NetboxVirtualMachine.ps1 b/Functions/Virtualization/VirtualMachine/New-NetboxVirtualMachine.ps1
index 31bc926..6798c36 100644
--- a/Functions/Virtualization/VirtualMachine/New-NetboxVirtualMachine.ps1
+++ b/Functions/Virtualization/VirtualMachine/New-NetboxVirtualMachine.ps1
@@ -46,7 +46,14 @@ function New-NetboxVirtualMachine {
[string]$Comments
)
- $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
+# $ModelDefinition = $script:NetboxConfig.APIDefinition.definitions.WritableVirtualMachineWithConfigContext
+#
+# # Validate the status against the APIDefinition
+# if ($ModelDefinition.properties.status.enum -inotcontains $Status) {
+# throw ("Invalid value [] for Status. Must be one of []" -f $Status, ($ModelDefinition.properties.status.enum -join ', '))
+# }
+#
+ #$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
@@ -55,4 +62,8 @@ function New-NetboxVirtualMachine {
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters
-}
\ No newline at end of file
+}
+
+
+
+
diff --git a/Functions/Virtualization/VirtualMachine/Set-NetboxVirtualMachine.ps1 b/Functions/Virtualization/VirtualMachine/Set-NetboxVirtualMachine.ps1
index 3cb7aff..abfaac5 100644
--- a/Functions/Virtualization/VirtualMachine/Set-NetboxVirtualMachine.ps1
+++ b/Functions/Virtualization/VirtualMachine/Set-NetboxVirtualMachine.ps1
@@ -50,19 +50,19 @@ function Set-NetboxVirtualMachine {
[switch]$Force
)
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
- }
-
+# if ($null -ne $Status) {
+# $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
+# }
+#
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $Id))
Write-Verbose "Obtaining VM from ID $Id"
- $CurrentVM = Get-NetboxVirtualMachine -Id $Id -ErrorAction Stop
+ #$CurrentVM = Get-NetboxVirtualMachine -Id $Id -ErrorAction Stop
Write-Verbose "Finished obtaining VM"
- if ($Force -or $pscmdlet.ShouldProcess($CurrentVM.Name, "Set")) {
+ if ($Force -or $pscmdlet.ShouldProcess($ID, "Set properties on VM ID")) {
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
$URI = BuildNewURI -Segments $URIComponents.Segments
diff --git a/Functions/Virtualization/VirtualMachineInterface/Get-NetboxVirtualMachineInterface.ps1 b/Functions/Virtualization/VirtualMachineInterface/Get-NetboxVirtualMachineInterface.ps1
index e1438e4..0b0c3c4 100644
--- a/Functions/Virtualization/VirtualMachineInterface/Get-NetboxVirtualMachineInterface.ps1
+++ b/Functions/Virtualization/VirtualMachineInterface/Get-NetboxVirtualMachineInterface.ps1
@@ -60,15 +60,13 @@ function Get-NetboxVirtualMachineInterface {
[CmdletBinding()]
param
(
- [uint16]$Limit,
-
- [uint16]$Offset,
-
[Parameter(ValueFromPipeline = $true)]
[uint16]$Id,
[string]$Name,
+ [string]$Query,
+
[boolean]$Enabled,
[uint16]$MTU,
@@ -79,6 +77,10 @@ function Get-NetboxVirtualMachineInterface {
[string]$MAC_Address,
+ [uint16]$Limit,
+
+ [uint16]$Offset,
+
[switch]$Raw
)
diff --git a/Functions/Virtualization/VirtualizationCluster/Get-NetboxVirtualizationCluster.ps1 b/Functions/Virtualization/VirtualizationCluster/Get-NetboxVirtualizationCluster.ps1
index 327d948..bb373a6 100644
--- a/Functions/Virtualization/VirtualizationCluster/Get-NetboxVirtualizationCluster.ps1
+++ b/Functions/Virtualization/VirtualizationCluster/Get-NetboxVirtualizationCluster.ps1
@@ -66,16 +66,11 @@ function Get-NetboxVirtualizationCluster {
[CmdletBinding()]
param
(
- [uint16]$Limit,
-
- [uint16]$Offset,
+ [string]$Name,
[Alias('q')]
[string]$Query,
- [string]$Name,
-
- [Alias('id__in')]
[uint16[]]$Id,
[string]$Group,
@@ -90,36 +85,18 @@ function Get-NetboxVirtualizationCluster {
[uint16]$Site_Id,
+ [uint16]$Limit,
+
+ [uint16]$Offset,
+
[switch]$Raw
)
- $uriSegments = [System.Collections.ArrayList]::new(@('virtualization', 'clusters'))
+ $Segments = [System.Collections.ArrayList]::new(@('virtualization', 'clusters'))
- $URIParameters = @{
- }
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
- foreach ($CmdletParameterName in $PSBoundParameters.Keys) {
- if ($CmdletParameterName -in $CommonParameterNames) {
- # These are common parameters and should not be appended to the URI
- Write-Debug "Skipping parameter $CmdletParameterName"
- continue
- }
-
- if ($CmdletParameterName -eq 'Id') {
- # Check if there is one or more values for Id and build a URI or query as appropriate
- if (@($PSBoundParameters[$CmdletParameterName]).Count -gt 1) {
- $URIParameters['id__in'] = $Id -join ','
- } else {
- [void]$uriSegments.Add($PSBoundParameters[$CmdletParameterName])
- }
- } elseif ($CmdletParameterName -eq 'Query') {
- $URIParameters['q'] = $PSBoundParameters[$CmdletParameterName]
- } else {
- $URIParameters[$CmdletParameterName.ToLower()] = $PSBoundParameters[$CmdletParameterName]
- }
- }
-
- $uri = BuildNewURI -Segments $uriSegments -Parameters $URIParameters
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
\ No newline at end of file
diff --git a/Functions/Virtualization/VirtualizationCluster/Get-NetboxVirtualizationClusterGroup.ps1 b/Functions/Virtualization/VirtualizationCluster/Get-NetboxVirtualizationClusterGroup.ps1
index f558bd8..467e716 100644
--- a/Functions/Virtualization/VirtualizationCluster/Get-NetboxVirtualizationClusterGroup.ps1
+++ b/Functions/Virtualization/VirtualizationCluster/Get-NetboxVirtualizationClusterGroup.ps1
@@ -16,33 +16,28 @@ function Get-NetboxVirtualizationClusterGroup {
[CmdletBinding()]
param
(
- [uint16]$Limit,
-
- [uint16]$Offset,
-
[string]$Name,
[string]$Slug,
+ [string]$Description,
+
+ [string]$Query,
+
+ [uint32[]]$Id,
+
+ [uint16]$Limit,
+
+ [uint16]$Offset,
+
[switch]$Raw
)
- $uriSegments = [System.Collections.ArrayList]::new(@('virtualization', 'cluster-groups'))
+ $Segments = [System.Collections.ArrayList]::new(@('virtualization', 'cluster-groups'))
- $URIParameters = @{
- }
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
- foreach ($CmdletParameterName in $PSBoundParameters.Keys) {
- if ($CmdletParameterName -in $CommonParameterNames) {
- # These are common parameters and should not be appended to the URI
- Write-Debug "Skipping parameter $CmdletParameterName"
- continue
- }
-
- $URIParameters[$CmdletParameterName.ToLower()] = $PSBoundParameters[$CmdletParameterName]
- }
-
- $uri = BuildNewURI -Segments $uriSegments -Parameters $URIParameters
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
\ No newline at end of file
diff --git a/NetboxPS.psd1 b/NetboxPS.psd1
index d927485..1a2fe44 100644
--- a/NetboxPS.psd1
+++ b/NetboxPS.psd1
@@ -1,127 +1,132 @@
-<#
- ===========================================================================
- Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.148
- Created on: 2/28/2018 11:04 AM
- Created by: Ben Claussen
- Organization: NEOnet
- Filename: NetboxPS.psd1
- -------------------------------------------------------------------------
- Module Manifest
- -------------------------------------------------------------------------
- Module Name: NetboxPS
- ===========================================================================
-#>
-
+#
+# Module manifest for module 'NetboxPS'
+#
+# Generated by: Ben Claussen
+#
+# Generated on: 2021-03-25
+#
@{
-
- # Script module or binary module file associated with this manifest
- RootModule = 'NetboxPS.psm1'
-
- # Version number of this module.
- ModuleVersion = '1.0.4'
-
- # ID used to uniquely identify this module
- GUID = 'bba9b06c-49c8-47cf-8358-aca7c4e78896'
-
- # Author of this module
- Author = 'Ben Claussen'
-
- # Company or vendor of this module
- CompanyName = 'NEOnet'
-
- # Copyright statement for this module
- Copyright = '(c) 2018. All rights reserved.'
-
- # Description of the functionality provided by this module
- Description = 'A Powershell wrapper for Netbox API'
-
- # Minimum version of the Windows PowerShell engine required by this module
- PowerShellVersion = '5.0'
-
- # Name of the Windows PowerShell host required by this module
- PowerShellHostName = ''
-
- # Minimum version of the Windows PowerShell host required by this module
- PowerShellHostVersion = ''
-
- # Minimum version of the .NET Framework required by this module
- DotNetFrameworkVersion = '2.0'
-
- # Minimum version of the common language runtime (CLR) required by this module
- CLRVersion = '2.0.50727'
-
- # Processor architecture (None, X86, Amd64, IA64) required by this module
- ProcessorArchitecture = 'None'
-
- # Modules that must be imported into the global environment prior to importing
- # this module
- RequiredModules = @()
-
- # Assemblies that must be loaded prior to importing this module
- RequiredAssemblies = @('System.Web')
-
- # Script files (.ps1) that are run in the caller's environment prior to
- # importing this module
- ScriptsToProcess = @()
-
- # Type files (.ps1xml) to be loaded when importing this module
- TypesToProcess = @()
-
- # Format files (.ps1xml) to be loaded when importing this module
- FormatsToProcess = @()
-
- # Modules to import as nested modules of the module specified in
- # ModuleToProcess
- NestedModules = @()
-
- # Functions to export from this module
- FunctionsToExport = @('*') #For performanace, list functions explicity
-
- # Cmdlets to export from this module
- CmdletsToExport = '*'
-
- # Variables to export from this module
- VariablesToExport = '*'
-
- # Aliases to export from this module
- AliasesToExport = '*' #For performanace, list alias explicity
-
- # List of all modules packaged with this module
- ModuleList = @()
-
- # List of all files packaged with this module
- FileList = @()
-
- # Private data to pass to the module specified in ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
- PrivateData = @{
-
- #Support for PowerShellGet galleries.
- PSData = @{
-
- # Tags applied to this module. These help with module discovery in online galleries.
- Tags = @('Netbox', 'API', 'DCIM', 'IPAM')
-
- # A URL to the license for this module.
- # LicenseUri = ''
-
- # A URL to the main website for this project.
- ProjectUri = 'https://github.com/benclaussen/NetboxPS'
-
- # A URL to an icon representing this module.
- # IconUri = ''
-
- # ReleaseNotes of this module
- # ReleaseNotes = ''
-
- } # End of PSData hashtable
-
- } # End of PrivateData hashtable
+
+# Script module or binary module file associated with this manifest.
+RootModule = 'NetboxPS.psm1'
+
+# Version number of this module.
+ModuleVersion = '1.3.0'
+
+# Supported PSEditions
+# CompatiblePSEditions = @()
+
+# ID used to uniquely identify this module
+GUID = 'bba9b06c-49c8-47cf-8358-aca7c4e78896'
+
+# Author of this module
+Author = 'Ben Claussen'
+
+# Company or vendor of this module
+CompanyName = 'NEOnet'
+
+# Copyright statement for this module
+Copyright = '(c) 2018. All rights reserved.'
+
+# Description of the functionality provided by this module
+Description = 'A Powershell wrapper for Netbox API'
+
+# Minimum version of the Windows PowerShell engine required by this module
+PowerShellVersion = '5.0'
+
+# Name of the Windows PowerShell host required by this module
+# PowerShellHostName = ''
+
+# Minimum version of the Windows PowerShell host required by this module
+# PowerShellHostVersion = ''
+
+# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+DotNetFrameworkVersion = '2.0'
+
+# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+CLRVersion = '2.0.50727'
+
+# Processor architecture (None, X86, Amd64) required by this module
+# ProcessorArchitecture = ''
+
+# Modules that must be imported into the global environment prior to importing this module
+# RequiredModules = @()
+
+# Assemblies that must be loaded prior to importing this module
+RequiredAssemblies = 'System.Web'
+
+# Script files (.ps1) that are run in the caller's environment prior to importing this module.
+# ScriptsToProcess = @()
+
+# Type files (.ps1xml) to be loaded when importing this module
+# TypesToProcess = @()
+
+# Format files (.ps1xml) to be loaded when importing this module
+# FormatsToProcess = @()
+
+# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
+NestedModules = @()
+
+# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
+FunctionsToExport = '*'
+
+# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
+CmdletsToExport = '*'
+
+# Variables to export from this module
+VariablesToExport = '*'
+
+# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
+AliasesToExport = '*'
+
+# DSC resources to export from this module
+# DscResourcesToExport = @()
+
+# List of all modules packaged with this module
+# ModuleList = @()
+
+# List of all files packaged with this module
+# FileList = @()
+
+# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
+PrivateData = @{
+
+ PSData = @{
+
+ # Tags applied to this module. These help with module discovery in online galleries.
+ Tags = 'Netbox','API','DCIM','IPAM'
+
+ # A URL to the license for this module.
+ # LicenseUri = ''
+
+ # A URL to the main website for this project.
+ ProjectUri = 'https://github.com/benclaussen/NetboxPS'
+
+ # A URL to an icon representing this module.
+ # IconUri = ''
+
+ # ReleaseNotes of this module
+ # ReleaseNotes = ''
+
+ # Prerelease string of this module
+ # Prerelease = ''
+
+ # Flag to indicate whether the module requires explicit user acceptance for install/update/save
+ # RequireLicenseAcceptance = $false
+
+ # External dependent modules of this module
+ # ExternalModuleDependencies = @()
+
+ } # End of PSData hashtable
+
+ } # End of PrivateData hashtable
+
+# HelpInfo URI of this module
+# HelpInfoURI = ''
+
+# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
+# DefaultCommandPrefix = ''
+
}
-
-
-
-
-
-
diff --git a/NetboxPS.psm1 b/NetboxPS.psm1
index f2a3679..cc051fc 100644
--- a/NetboxPS.psm1
+++ b/NetboxPS.psm1
@@ -18,5 +18,5 @@ $script:CommonParameterNames = New-Object System.Collections.ArrayList
SetupNetboxConfigVariable
-#Export-ModuleMember -Function *
-Export-ModuleMember -Function *-*
\ No newline at end of file
+Export-ModuleMember -Function *
+#Export-ModuleMember -Function *-*
\ No newline at end of file
diff --git a/NetboxPS.psproj b/NetboxPS.psproj
index a9c7f7a..7fc51c9 100644
--- a/NetboxPS.psproj
+++ b/NetboxPS.psproj
@@ -5,7 +5,6 @@
Functions
Functions\DCIM
- Functions\Extras
Functions\Circuits
Functions\Virtualization
Functions\IPAM
@@ -24,6 +23,11 @@
Functions\Setup
Functions\Setup\Support
Tests
+ Functions\DCIM\Sites
+ Functions\Circuits\Circuits
+ Functions\Circuits\Providers
+ Functions\Circuits\Types
+ Functions\Circuits\Terminations
NetboxPS.psd1
@@ -42,8 +46,6 @@
Functions\Helpers\CheckNetboxIsConnected.ps1
Functions\Helpers\BuildNewURI.ps1
Functions\Helpers\BuildURIComponents.ps1
- Functions\Helpers\GetChoiceValidValues.ps1
- Functions\Helpers\ValidateChoice.ps1
Functions\Helpers\GetNetboxAPIErrorBody.ps1
Functions\Helpers\InvokeNetboxRequest.ps1
Functions\Helpers\ThrowNetboxRESTError.ps1
@@ -56,8 +58,6 @@
Functions\Setup\Set-NetboxCredential.ps1
Functions\Setup\Get-NetboxCredential.ps1
Functions\Setup\Connect-NetboxAPI.ps1
- Functions\Extras\Get-NetboxExtrasChoices.ps1
- Functions\DCIM\ValidateDCIMChoice.ps1
Functions\IPAM\VLAN\Get-NetboxIPAMVLAN.ps1
Functions\IPAM\VLAN\New-NetboxIPAMVLAN.ps1
Functions\IPAM\Role\Get-NetboxIPAMRole.ps1
@@ -69,10 +69,7 @@
Functions\IPAM\Prefix\New-NetboxIPAMPrefix.ps1
Functions\IPAM\Address\Remove-NetboxIPAMAddress.ps1
Functions\IPAM\Address\Set-NetboxIPAMAddress.ps1
- Functions\IPAM\ValidateIPAMChoice.ps1
- Functions\IPAM\Get-NetboxIPAMChoices.ps1
Functions\Tenancy\Get-NetboxTenant.ps1
- Functions\Tenancy\Get-NetboxTenancyChoices.ps1
Functions\Virtualization\VirtualMachine\Get-NetboxVirtualMachine.ps1
Functions\Virtualization\VirtualMachine\New-NetboxVirtualMachine.ps1
Functions\Virtualization\VirtualMachine\Set-NetboxVirtualMachine.ps1
@@ -80,10 +77,8 @@
Functions\Virtualization\VirtualMachineInterface\Add-NetboxVirtualMachineInterface.ps1
Functions\Virtualization\VirtualMachineInterface\Get-NetboxVirtualMachineInterface.ps1
Functions\Virtualization\VirtualMachineInterface\Set-NetboxVirtualMachineInterface.ps1
- Functions\Virtualization\Get-NetboxVirtualizationChoices.ps1
Functions\Virtualization\VirtualizationCluster\Get-NetboxVirtualizationCluster.ps1
Functions\Virtualization\VirtualizationCluster\Get-NetboxVirtualizationClusterGroup.ps1
- Functions\Virtualization\ValidateVirtualizationChoice.ps1
Functions\DCIM\Devices\Get-NetboxDCIMDevice.ps1
Functions\DCIM\Devices\Get-NetboxDCIMDeviceType.ps1
Functions\DCIM\Devices\Get-NetboxDCIMDeviceRole.ps1
@@ -99,10 +94,16 @@
Functions\DCIM\Interfaces\Remove-NetboxDCIMInterface.ps1
Functions\DCIM\Interfaces\Remove-NetboxDCIMInterfaceConnection.ps1
Functions\DCIM\Get-NetboxDCIMPlatform.ps1
- Functions\DCIM\Get-NetboxDCIMChoices.ps1
- Functions\Circuits\Get-NetboxCircuitsChoices.ps1
- Functions\Circuits\Get-NetboxCircuit.ps1
+ Functions\Circuits\Circuits\Get-NetboxCircuit.ps1
deploy.ps1
+ Functions\Setup\Support\Get-NetboxAPIDefinition.ps1
+ Functions\DCIM\Sites\Get-NetboxDCIMSite.ps1
+ Functions\Circuits\Terminations\Get-NetboxCircuitTermination.ps1
+ Functions\Circuits\Circuits\New-NetboxCircuit.ps1
+ Functions\Circuits\Providers\Get-NetboxCircuitProvider.ps1
+ Functions\Circuits\Types\Get-NetboxCircuitType.ps1
+ Functions\Helpers\Get-ModelDefinition.ps1
+ Functions\IPAM\Prefix\Set-NetboxIPAMPrefix.ps1
R:\Netbox\NetboxPS\Test-Module.ps1
\ No newline at end of file
diff --git a/NetboxPS/NetboxPS.psd1 b/NetboxPS/NetboxPS.psd1
new file mode 100644
index 0000000..1a2fe44
--- /dev/null
+++ b/NetboxPS/NetboxPS.psd1
@@ -0,0 +1,132 @@
+#
+# Module manifest for module 'NetboxPS'
+#
+# Generated by: Ben Claussen
+#
+# Generated on: 2021-03-25
+#
+
+@{
+
+# Script module or binary module file associated with this manifest.
+RootModule = 'NetboxPS.psm1'
+
+# Version number of this module.
+ModuleVersion = '1.3.0'
+
+# Supported PSEditions
+# CompatiblePSEditions = @()
+
+# ID used to uniquely identify this module
+GUID = 'bba9b06c-49c8-47cf-8358-aca7c4e78896'
+
+# Author of this module
+Author = 'Ben Claussen'
+
+# Company or vendor of this module
+CompanyName = 'NEOnet'
+
+# Copyright statement for this module
+Copyright = '(c) 2018. All rights reserved.'
+
+# Description of the functionality provided by this module
+Description = 'A Powershell wrapper for Netbox API'
+
+# Minimum version of the Windows PowerShell engine required by this module
+PowerShellVersion = '5.0'
+
+# Name of the Windows PowerShell host required by this module
+# PowerShellHostName = ''
+
+# Minimum version of the Windows PowerShell host required by this module
+# PowerShellHostVersion = ''
+
+# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+DotNetFrameworkVersion = '2.0'
+
+# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+CLRVersion = '2.0.50727'
+
+# Processor architecture (None, X86, Amd64) required by this module
+# ProcessorArchitecture = ''
+
+# Modules that must be imported into the global environment prior to importing this module
+# RequiredModules = @()
+
+# Assemblies that must be loaded prior to importing this module
+RequiredAssemblies = 'System.Web'
+
+# Script files (.ps1) that are run in the caller's environment prior to importing this module.
+# ScriptsToProcess = @()
+
+# Type files (.ps1xml) to be loaded when importing this module
+# TypesToProcess = @()
+
+# Format files (.ps1xml) to be loaded when importing this module
+# FormatsToProcess = @()
+
+# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
+NestedModules = @()
+
+# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
+FunctionsToExport = '*'
+
+# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
+CmdletsToExport = '*'
+
+# Variables to export from this module
+VariablesToExport = '*'
+
+# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
+AliasesToExport = '*'
+
+# DSC resources to export from this module
+# DscResourcesToExport = @()
+
+# List of all modules packaged with this module
+# ModuleList = @()
+
+# List of all files packaged with this module
+# FileList = @()
+
+# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
+PrivateData = @{
+
+ PSData = @{
+
+ # Tags applied to this module. These help with module discovery in online galleries.
+ Tags = 'Netbox','API','DCIM','IPAM'
+
+ # A URL to the license for this module.
+ # LicenseUri = ''
+
+ # A URL to the main website for this project.
+ ProjectUri = 'https://github.com/benclaussen/NetboxPS'
+
+ # A URL to an icon representing this module.
+ # IconUri = ''
+
+ # ReleaseNotes of this module
+ # ReleaseNotes = ''
+
+ # Prerelease string of this module
+ # Prerelease = ''
+
+ # Flag to indicate whether the module requires explicit user acceptance for install/update/save
+ # RequireLicenseAcceptance = $false
+
+ # External dependent modules of this module
+ # ExternalModuleDependencies = @()
+
+ } # End of PSData hashtable
+
+ } # End of PrivateData hashtable
+
+# HelpInfo URI of this module
+# HelpInfoURI = ''
+
+# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
+# DefaultCommandPrefix = ''
+
+}
+
diff --git a/dist/NetboxPS.psm1 b/NetboxPS/NetboxPS.psm1
similarity index 70%
rename from dist/NetboxPS.psm1
rename to NetboxPS/NetboxPS.psm1
index de2e468..1583b40 100644
--- a/dist/NetboxPS.psm1
+++ b/NetboxPS/NetboxPS.psm1
@@ -51,9 +51,9 @@ function Add-NetboxDCIMInterface {
[uint16[]]$Tagged_VLANs
)
- if ($null -ne $Form_Factor) {
- $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
- }
+# if ($null -ne $Form_Factor) {
+# $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
+# }
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
$PSBoundParameters.Mode = switch ($Mode) {
@@ -530,8 +530,6 @@ function Connect-NetboxAPI {
try {
Write-Verbose "Verifying API connectivity..."
$null = VerifyAPIConnectivity
- $script:NetboxConfig.Connected = $true
- Write-Verbose "Successfully connected!"
} catch {
Write-Verbose "Failed to connect. Generating error"
Write-Verbose $_.Exception.Message
@@ -542,14 +540,25 @@ function Connect-NetboxAPI {
}
}
- Write-Verbose "Caching static choices"
- $script:NetboxConfig.Choices.Circuits = Get-NetboxCircuitsChoices
- $script:NetboxConfig.Choices.DCIM = Get-NetboxDCIMChoices # Not completed yet
- $script:NetboxConfig.Choices.Extras = Get-NetboxExtrasChoices
- $script:NetboxConfig.Choices.IPAM = Get-NetboxIPAMChoices
- #$script:NetboxConfig.Choices.Secrets = Get-NetboxSecretsChoices # Not completed yet
- #$script:NetboxConfig.Choices.Tenancy = Get-NetboxTenancyChoices
- $script:NetboxConfig.Choices.Virtualization = Get-NetboxVirtualizationChoices
+ Write-Verbose "Caching API definition"
+ $script:NetboxConfig.APIDefinition = Get-NetboxAPIDefinition
+
+ if ([version]$script:NetboxConfig.APIDefinition.info.version -lt 2.8) {
+ $Script:NetboxConfig.Connected = $false
+ throw "Netbox version is incompatible with this PS module. Requires >=2.8.*, found version $($script:NetboxConfig.APIDefinition.info.version)"
+ }
+
+ $script:NetboxConfig.Connected = $true
+ Write-Verbose "Successfully connected!"
+
+ #Write-Verbose "Caching static choices"
+ #$script:NetboxConfig.Choices.Circuits = Get-NetboxCircuitsChoices
+ #$script:NetboxConfig.Choices.DCIM = Get-NetboxDCIMChoices # Not completed yet
+ #$script:NetboxConfig.Choices.Extras = Get-NetboxExtrasChoices
+ #$script:NetboxConfig.Choices.IPAM = Get-NetboxIPAMChoices
+ ##$script:NetboxConfig.Choices.Secrets = Get-NetboxSecretsChoices # Not completed yet
+ ##$script:NetboxConfig.Choices.Tenancy = Get-NetboxTenancyChoices
+ #$script:NetboxConfig.Choices.Virtualization = Get-NetboxVirtualizationChoices
Write-Verbose "Connection process completed"
}
@@ -602,48 +611,105 @@ public enum $EnumName
#endregion
-#region File GetChoiceValidValues.ps1
+#region File Get-ModelDefinition.ps1
<#
.NOTES
===========================================================================
- Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
- Created on: 3/26/2020 14:23
+ Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
+ Created on: 2020-11-04 14:23
Created by: Claussen
Organization: NEOnet
- Filename: GetChoiceValidValues.ps1
+ Filename: Get-ModelDefinition.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
-function GetChoiceValidValues {
- [CmdletBinding()]
- [OutputType([System.Collections.ArrayList])]
+
+function Get-ModelDefinition {
+ [CmdletBinding(DefaultParameterSetName = 'ByName')]
param
(
- [Parameter(Mandatory = $true)]
- [string]$MajorObject,
+ [Parameter(ParameterSetName = 'ByName',
+ Mandatory = $true)]
+ [string]$ModelName,
- [Parameter(Mandatory = $true)]
- [object]$Choice
+ [Parameter(ParameterSetName = 'ByPath',
+ Mandatory = $true)]
+ [string]$URIPath,
+
+ [Parameter(ParameterSetName = 'ByPath')]
+ [string]$Method = "post"
)
- $ValidValues = New-Object System.Collections.ArrayList
-
- if (-not $script:NetboxConfig.Choices.$MajorObject.$Choice) {
- throw "Missing choices for $Choice"
+ 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
+ }
}
- [void]$ValidValues.AddRange($script:NetboxConfig.Choices.$MajorObject.$Choice.value)
- [void]$ValidValues.AddRange($script:NetboxConfig.Choices.$MajorObject.$Choice.label)
+}
+
+#endregion
+
+#region File Get-NetboxAPIDefinition.ps1
+
+<#
+ .NOTES
+ ===========================================================================
+ Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.174
+ Created on: 4/28/2020 11:57
+ Created by: Claussen
+ Organization: NEOnet
+ Filename: Get-NetboxAPIDefinition.ps1
+ ===========================================================================
+ .DESCRIPTION
+ A description of the file.
+#>
+
+
+
+function Get-NetboxAPIDefinition {
+ [CmdletBinding()]
+ param ()
- if ($ValidValues.Count -eq 0) {
- throw "Missing valid values for $MajorObject.$Choice"
- }
+ #$URI = "https://netbox.neonet.org/api/docs/?format=openapi"
- return [System.Collections.ArrayList]$ValidValues
+ $Segments = [System.Collections.ArrayList]::new(@('docs'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary @{'format' = 'openapi'}
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters -SkipConnectedCheck
+
+ InvokeNetboxRequest -URI $URI -Timeout 10
}
#endregion
@@ -700,115 +766,350 @@ function GetNetboxAPIErrorBody {
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.
+ .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 [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 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()]
+ [CmdletBinding(DefaultParameterSetName = 'Query')]
param
(
+ [Parameter(ParameterSetName = 'ById')]
+ [uint16[]]$Id,
+
+ [Parameter(ParameterSetName = 'Query')]
[string]$CID,
+ [Parameter(ParameterSetName = 'Query')]
[datetime]$InstallDate,
+ [Parameter(ParameterSetName = 'Query')]
[uint32]$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,
- [uint16[]]$Id
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Limit,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Offset,
+
+ [switch]$Raw
)
- #TODO: Place script here
+ 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
+ }
+ }
}
#endregion
-#region File Get-NetboxCircuitsChoices.ps1
+#region File Get-NetboxCircuitProvider.ps1
<#
.NOTES
===========================================================================
- Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
- Created on: 3/23/2020 12:15
+ 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-NetboxCircuitsChoices.ps1
+ Filename: Get-NetboxCircuitProvider.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
-
+
+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
+ }
+ }
+}
+
+#endregion
+
+#region File Get-NetboxCircuitTermination.ps1
+
+<#
.NOTES
- Additional information about the function.
+ ===========================================================================
+ 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
+ )
- [CmdletBinding()]
- [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
- param ()
+ 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
+ }
+ }
+ }
+}
+
+#endregion
+
+#region File Get-NetboxCircuitType.ps1
+
+<#
+ .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
+ )
- $uriSegments = [System.Collections.ArrayList]::new(@('circuits', '_choices'))
- $uri = BuildNewURI -Segments $uriSegments
-
- InvokeNetboxRequest -URI $uri
+ 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
+ }
+ }
}
#endregion
@@ -837,36 +1138,6 @@ function Get-NetboxCredential {
#endregion
-#region File Get-NetboxDCIMChoices.ps1
-
-<#
- .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
-}
-
-#endregion
-
#region File Get-NetboxDCIMDevice.ps1
<#
@@ -1289,20 +1560,117 @@ function Get-NetboxDCIMPlatform {
#endregion
-#region File Get-NetboxExtrasChoices.ps1
+#region File Get-NetboxDCIMSite.ps1
-function Get-NetboxExtrasChoices {
+<#
+ .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: Get-NetboxDCIMSite.ps1
+ ===========================================================================
+ .DESCRIPTION
+ A description of the file.
+#>
+
+
+
+function Get-NetboxDCIMSite {
[CmdletBinding()]
- [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
- param ()
+ [OutputType([pscustomobject])]
+ param
+ (
+ [Parameter(ParameterSetName = 'ByID', ValueFromPipelineByPropertyName = $true)]
+ [uint32]$Id,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Name,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Query,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Slug,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Facility,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$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')]
+ [uint32]$Tenant_Group_ID,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Tenant_Group,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Tenant_ID,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Tenant,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Status,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Region_ID,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Region,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Limit,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Offset,
+
+ [switch]$Raw
+ )
- $uriSegments = [System.Collections.ArrayList]::new(@('extras', '_choices'))
-
- $uri = BuildNewURI -Segments $uriSegments
-
- InvokeNetboxRequest -URI $uri
+ 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
+ }
+ }
}
+
#endregion
#region File Get-NetboxHostname.ps1
@@ -1324,69 +1692,97 @@ function Get-NetboxHostname {
#region File Get-NetboxIPAMAddress.ps1
function Get-NetboxIPAMAddress {
- [CmdletBinding()]
+ [CmdletBinding(DefaultParameterSetName = 'Query')]
param
(
+ [Parameter(ParameterSetName = 'Query',
+ Position = 0)]
[string]$Address,
- [uint16[]]$Id,
+ [Parameter(ParameterSetName = 'ByID')]
+ [uint32[]]$Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Query,
+ [Parameter(ParameterSetName = 'Query')]
[object]$Family,
- [uint16]$Parent,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Parent,
+ [Parameter(ParameterSetName = 'Query')]
[byte]$Mask_Length,
+ [Parameter(ParameterSetName = 'Query')]
[string]$VRF,
- [uint16]$VRF_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$VRF_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Tenant,
- [uint16]$Tenant_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Tenant_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Device,
- [uint16]$Device_ID,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Device_ID,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Virtual_Machine,
- [uint16]$Virtual_Machine_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Virtual_Machine_Id,
- [uint16]$Interface_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Interface_Id,
+ [Parameter(ParameterSetName = 'Query')]
[object]$Status,
+ [Parameter(ParameterSetName = 'Query')]
[object]$Role,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$Limit,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$Offset,
[switch]$Raw
)
- if ($null -ne $Family) {
- $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -IPAddressFamily
+ switch ($PSCmdlet.ParameterSetName) {
+ '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
+ }
+
+ break
+ }
+
+ default {
+ $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
+
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $uri -Raw:$Raw
+
+ break
+ }
}
-
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
- }
-
- if ($null -ne $Role) {
- $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 -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $uri -Raw:$Raw
}
#endregion
@@ -1408,39 +1804,69 @@ function Get-NetboxIPAMAddress {
function Get-NetboxIPAMAggregate {
- [CmdletBinding()]
+ [CmdletBinding(DefaultParameterSetName = 'Query')]
param
(
- [uint16]$Limit,
-
- [uint16]$Offset,
-
- [object]$Family,
-
- [datetime]$Date_Added,
-
- [uint16[]]$Id,
-
+ [Parameter(ParameterSetName = 'Query')]
[string]$Query,
+ [Parameter(ParameterSetName = 'ByID')]
+ [uint16[]]$Id,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Prefix,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [object]$Family,
+
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$RIR_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$RIR,
+ [Parameter(ParameterSetName = 'Query')]
+ [datetime]$Date_Added,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Limit,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Offset,
+
[switch]$Raw
)
- if ($null -ne $Family) {
- $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -AggregateFamily
+# if ($null -ne $Family) {
+# $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -AggregateFamily
+ # }
+
+ switch ($PSCmdlet.ParameterSetName) {
+ 'ById' {
+ foreach ($IP_ID in $Id) {
+ $Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates', $IP_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', 'aggregates'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
+
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $uri -Raw:$Raw
+
+ break
+ }
}
-
- $Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
-
- $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $uri -Raw:$Raw
}
#endregion
@@ -1514,36 +1940,6 @@ function Get-NetboxIPAMAvailableIP {
#endregion
-#region File Get-NetboxIPAMChoices.ps1
-
-<#
- .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
-}
-
-#endregion
-
#region File Get-NetboxIPAMPrefix.ps1
<#
@@ -1641,72 +2037,115 @@ function Get-NetboxIPAMPrefix {
Additional information about the function.
#>
- [CmdletBinding()]
+ [CmdletBinding(DefaultParameterSetName = 'Query')]
param
(
+ [Parameter(ParameterSetName = 'Query',
+ Position = 0)]
[string]$Prefix,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Query,
- [uint16[]]$Id,
+ [Parameter(ParameterSetName = 'ByID')]
+ [uint32[]]$Id,
+ [Parameter(ParameterSetName = 'Query')]
[object]$Family,
+ [Parameter(ParameterSetName = 'Query')]
[boolean]$Is_Pool,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Within,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Within_Include,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Contains,
+ [Parameter(ParameterSetName = 'Query')]
[ValidateRange(0, 127)]
[byte]$Mask_Length,
+ [Parameter(ParameterSetName = 'Query')]
[string]$VRF,
- [uint16]$VRF_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$VRF_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Tenant,
- [uint16]$Tenant_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Tenant_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Site,
- [uint16]$Site_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Site_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Vlan_VId,
- [uint16]$Vlan_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Vlan_Id,
+ [Parameter(ParameterSetName = 'Query')]
[object]$Status,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Role,
- [uint16]$Role_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Role_Id,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$Limit,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$Offset,
[switch]$Raw
)
- if ($null -ne $Family) {
- $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -PrefixFamily
+ # if ($null -ne $Family) {
+ # $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
+ }
+
+ break
+ }
+
+ default {
+ $Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
+
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $uri -Raw:$Raw
+
+ break
+ }
}
-
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
- }
-
- $Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
-
- $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $uri -Raw:$Raw
}
#endregion
@@ -1756,30 +2195,58 @@ function Get-NetboxIPAMRole {
[CmdletBinding()]
param
(
- [uint16[]]$Id,
-
- [string]$Query,
-
+ [Parameter(ParameterSetName = 'Query',
+ Position = 0)]
[string]$Name,
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Query,
+
+ [Parameter(ParameterSetName = 'ByID')]
+ [uint32[]]$Id,
+
+ [Parameter(ParameterSetName = 'Query')]
[string]$Slug,
+ [Parameter(ParameterSetName = 'Query')]
[switch]$Brief,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$Limit,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$Offset,
[switch]$Raw
)
- $Segments = [System.Collections.ArrayList]::new(@('ipam', 'roles'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
-
- $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $uri -Raw:$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'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
+
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $uri -Raw:$Raw
+
+ break
+ }
+ }
}
#endregion
@@ -1804,92 +2271,102 @@ function Get-NetboxIPAMVLAN {
[CmdletBinding()]
param
(
- [uint16]$Limit,
-
- [uint16]$Offset,
-
+ [Parameter(ParameterSetName = 'Query',
+ Position = 0)]
+ [ValidateRange(1, 4096)]
[uint16]$VID,
- [uint16[]]$Id,
+ [Parameter(ParameterSetName = 'ByID')]
+ [uint32[]]$Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Query,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Name,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Tenant,
- [uint16]$Tenant_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Tenant_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$TenantGroup,
- [uint16]$TenantGroup_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$TenantGroup_Id,
+ [Parameter(ParameterSetName = 'Query')]
[object]$Status,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Region,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Site,
- [uint16]$Site_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Site_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Group,
- [uint16]$Group_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Group_Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Role,
- [uint16]$Role_Id,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint32]$Role_Id,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Limit,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Offset,
[switch]$Raw
)
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
+ # if ($null -ne $Status) {
+ # $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
+ # }
+
+ switch ($PSCmdlet.ParameterSetName) {
+ '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'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
+
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $uri -Raw:$Raw
+
+ break
+ }
}
-
- $Segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
-
- $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $uri -Raw:$Raw
}
-#endregion
-
-#region File Get-NetboxTenancyChoices.ps1
-
-<#
- .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
-}
-
#endregion
#region File Get-NetboxTenant.ps1
@@ -1909,65 +2386,111 @@ function Get-NetboxTenancyChoices {
function Get-NetboxTenant {
- [CmdletBinding()]
+<#
+ .SYNOPSIS
+ Get a tenent from Netbox
+
+ .DESCRIPTION
+ A detailed description of the Get-NetboxTenant function.
+
+ .PARAMETER Name
+ The specific name of the tenant. Must match exactly as is defined in Netbox
+
+ .PARAMETER Id
+ The database ID of the tenant
+
+ .PARAMETER Query
+ A standard search query that will match one or more tenants.
+
+ .PARAMETER Slug
+ The specific slug of the tenant. Must match exactly as is defined in Netbox
+
+ .PARAMETER Group
+ The specific group as defined in Netbox.
+
+ .PARAMETER GroupID
+ The database ID of the group in Netbox
+
+ .PARAMETER CustomFields
+ Hashtable in the format @{"field_name" = "value"} to search
+
+ .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-NetboxTenant
+
+ .NOTES
+ Additional information about the function.
+#>
+
+ [CmdletBinding(DefaultParameterSetName = 'Query')]
param
(
- [uint16]$Limit,
-
- [uint16]$Offset,
-
+ [Parameter(ParameterSetName = 'Query',
+ Position = 0)]
[string]$Name,
- [uint16[]]$Id,
+ [Parameter(ParameterSetName = 'ByID')]
+ [uint32[]]$Id,
+ [Parameter(ParameterSetName = 'Query')]
[string]$Query,
+ [Parameter(ParameterSetName = 'Query')]
+ [string]$Slug,
+
+ [Parameter(ParameterSetName = 'Query')]
[string]$Group,
+ [Parameter(ParameterSetName = 'Query')]
[uint16]$GroupID,
+ [Parameter(ParameterSetName = 'Query')]
[hashtable]$CustomFields,
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Limit,
+
+ [Parameter(ParameterSetName = 'Query')]
+ [uint16]$Offset,
+
[switch]$Raw
)
- $Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
-
- $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $uri -Raw:$Raw
-}
-
-#endregion
-
-#region File Get-NetboxVirtualizationChoices.ps1
-
-<#
- .NOTES
- ===========================================================================
- Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
- Created on: 3/19/2020 14:10
- Created by: Claussen
- Organization: NEOnet
- Filename: Get-NetboxVirtualizationChoices.ps1
- ===========================================================================
- .DESCRIPTION
- A description of the file.
-#>
-
-
-function Get-NetboxVirtualizationChoices {
- [CmdletBinding()]
- [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
- param ()
-
- $uriSegments = [System.Collections.ArrayList]::new(@('virtualization', '_choices'))
-
- $uri = BuildNewURI -Segments $uriSegments
-
- InvokeNetboxRequest -URI $uri
+ switch ($PSCmdlet.ParameterSetName) {
+ 'ById' {
+ foreach ($Tenant_ID in $Id) {
+ $Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants', $Tenant_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', 'tenants'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
+
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $uri -Raw:$Raw
+
+ break
+ }
+ }
}
#endregion
@@ -2042,16 +2565,11 @@ function Get-NetboxVirtualizationCluster {
[CmdletBinding()]
param
(
- [uint16]$Limit,
-
- [uint16]$Offset,
+ [string]$Name,
[Alias('q')]
[string]$Query,
- [string]$Name,
-
- [Alias('id__in')]
[uint16[]]$Id,
[string]$Group,
@@ -2066,36 +2584,18 @@ function Get-NetboxVirtualizationCluster {
[uint16]$Site_Id,
+ [uint16]$Limit,
+
+ [uint16]$Offset,
+
[switch]$Raw
)
- $uriSegments = [System.Collections.ArrayList]::new(@('virtualization', 'clusters'))
+ $Segments = [System.Collections.ArrayList]::new(@('virtualization', 'clusters'))
- $URIParameters = @{
- }
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
- foreach ($CmdletParameterName in $PSBoundParameters.Keys) {
- if ($CmdletParameterName -in $CommonParameterNames) {
- # These are common parameters and should not be appended to the URI
- Write-Debug "Skipping parameter $CmdletParameterName"
- continue
- }
-
- if ($CmdletParameterName -eq 'Id') {
- # Check if there is one or more values for Id and build a URI or query as appropriate
- if (@($PSBoundParameters[$CmdletParameterName]).Count -gt 1) {
- $URIParameters['id__in'] = $Id -join ','
- } else {
- [void]$uriSegments.Add($PSBoundParameters[$CmdletParameterName])
- }
- } elseif ($CmdletParameterName -eq 'Query') {
- $URIParameters['q'] = $PSBoundParameters[$CmdletParameterName]
- } else {
- $URIParameters[$CmdletParameterName.ToLower()] = $PSBoundParameters[$CmdletParameterName]
- }
- }
-
- $uri = BuildNewURI -Segments $uriSegments -Parameters $URIParameters
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
@@ -2122,33 +2622,28 @@ function Get-NetboxVirtualizationClusterGroup {
[CmdletBinding()]
param
(
- [uint16]$Limit,
-
- [uint16]$Offset,
-
[string]$Name,
[string]$Slug,
+ [string]$Description,
+
+ [string]$Query,
+
+ [uint32[]]$Id,
+
+ [uint16]$Limit,
+
+ [uint16]$Offset,
+
[switch]$Raw
)
- $uriSegments = [System.Collections.ArrayList]::new(@('virtualization', 'cluster-groups'))
+ $Segments = [System.Collections.ArrayList]::new(@('virtualization', 'cluster-groups'))
- $URIParameters = @{
- }
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
- foreach ($CmdletParameterName in $PSBoundParameters.Keys) {
- if ($CmdletParameterName -in $CommonParameterNames) {
- # These are common parameters and should not be appended to the URI
- Write-Debug "Skipping parameter $CmdletParameterName"
- continue
- }
-
- $URIParameters[$CmdletParameterName.ToLower()] = $PSBoundParameters[$CmdletParameterName]
- }
-
- $uri = BuildNewURI -Segments $uriSegments -Parameters $URIParameters
+ $uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
@@ -2379,15 +2874,13 @@ function Get-NetboxVirtualMachineInterface {
[CmdletBinding()]
param
(
- [uint16]$Limit,
-
- [uint16]$Offset,
-
[Parameter(ValueFromPipeline = $true)]
[uint16]$Id,
[string]$Name,
+ [string]$Query,
+
[boolean]$Enabled,
[uint16]$MTU,
@@ -2398,6 +2891,10 @@ function Get-NetboxVirtualMachineInterface {
[string]$MAC_Address,
+ [uint16]$Limit,
+
+ [uint16]$Offset,
+
[switch]$Raw
)
@@ -2443,7 +2940,7 @@ function InvokeNetboxRequest {
[ValidateRange(0, 60)]
[uint16]$Timeout = 5,
- [ValidateSet('GET', 'PATCH', 'PUT', 'POST', 'DELETE', IgnoreCase = $true)]
+ [ValidateSet('GET', 'PATCH', 'PUT', 'POST', 'DELETE', 'OPTIONS', IgnoreCase = $true)]
[string]$Method = 'GET',
[switch]$Raw
@@ -2522,6 +3019,78 @@ function InvokeNetboxRequest {
#endregion
+#region File New-NetboxCircuit.ps1
+
+<#
+ .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
+ }
+}
+
+#endregion
+
#region File New-NetboxDCIMDevice.ps1
<#
@@ -2590,21 +3159,21 @@ function New-NetboxDCIMDevice {
)
#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
- }
+# 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'))
@@ -2668,6 +3237,9 @@ function New-NetboxIPAMAddress {
.PARAMETER Description
Description of IP address
+ .PARAMETER Force
+ Do not prompt for confirmation to create IP.
+
.PARAMETER Raw
Return raw results from API service
@@ -2678,11 +3250,13 @@ function New-NetboxIPAMAddress {
Additional information about the function.
#>
- [CmdletBinding()]
+ [CmdletBinding(ConfirmImpact = 'Low',
+ SupportsShouldProcess = $true)]
[OutputType([pscustomobject])]
param
(
- [Parameter(Mandatory = $true)]
+ [Parameter(Mandatory = $true,
+ ValueFromPipelineByPropertyName = $true)]
[string]$Address,
[object]$Status = 'Active',
@@ -2701,24 +3275,39 @@ function New-NetboxIPAMAddress {
[string]$Description,
+ [switch]$Force,
+
[switch]$Raw
)
- $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
+ $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
+ $Method = 'POST'
- if ($null -ne $Role) {
- $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
- }
-
- $segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
-
- $URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
+ # # 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
+ # }
+ # }
+ #
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
$URI = BuildNewURI -Segments $URIComponents.Segments
- InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
+ if ($Force -or $PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
+ InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
+ }
}
+
+
+
+
+
#endregion
#region File New-NetboxIPAMPrefix.ps1
@@ -2765,7 +3354,7 @@ function New-NetboxIPAMPrefix {
[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
@@ -2852,11 +3441,11 @@ function New-NetboxIPAMVLAN {
[switch]$Raw
)
- $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
-
- if ($null -ne $Role) {
- $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
- }
+# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
+#
+# if ($null -ne $Role) {
+# $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
+# }
$segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
@@ -2919,7 +3508,14 @@ function New-NetboxVirtualMachine {
[string]$Comments
)
- $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
+# $ModelDefinition = $script:NetboxConfig.APIDefinition.definitions.WritableVirtualMachineWithConfigContext
+#
+# # Validate the status against the APIDefinition
+# if ($ModelDefinition.properties.status.enum -inotcontains $Status) {
+# throw ("Invalid value [] for Status. Must be one of []" -f $Status, ($ModelDefinition.properties.status.enum -join ', '))
+# }
+#
+ #$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
@@ -2930,6 +3526,10 @@ function New-NetboxVirtualMachine {
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters
}
+
+
+
+
#endregion
#region File Remove-NetboxDCIMDevice.ps1
@@ -3181,9 +3781,6 @@ function Remove-NetboxIPAMAddress {
[switch]$Force
)
- begin {
- }
-
process {
foreach ($IPId in $Id) {
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
@@ -3197,9 +3794,6 @@ function Remove-NetboxIPAMAddress {
}
}
}
-
- end {
- }
}
#endregion
@@ -3382,13 +3976,13 @@ function Set-NetboxDCIMDevice {
)
begin {
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
- }
-
- if ($null -ne $Face) {
- $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
- }
+# if ($null -ne $Status) {
+# $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
+# }
+#
+# if ($null -ne $Face) {
+# $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
+# }
}
process {
@@ -3468,9 +4062,9 @@ function Set-NetboxDCIMInterface {
)
begin {
- if ($null -ne $Form_Factor) {
- $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
- }
+# if ($null -ne $Form_Factor) {
+# $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
+# }
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
$PSBoundParameters.Mode = switch ($Mode) {
@@ -3581,9 +4175,9 @@ function Set-NetboxDCIMInterfaceConnection {
)
begin {
- if ($null -ne $Connection_Status) {
- $PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
- }
+# if ($null -ne $Connection_Status) {
+# $PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
+# }
if ((@($ID).Count -gt 1) -and ($Interface_A -or $Interface_B)) {
throw "Cannot set multiple connections to the same interface"
@@ -3661,7 +4255,7 @@ function Set-NetboxIPAMAddress {
[string]$Address,
- [object]$Status,
+ [string]$Status,
[uint16]$Tenant,
@@ -3673,7 +4267,10 @@ function Set-NetboxIPAMAddress {
[hashtable]$Custom_Fields,
- [uint16]$Interface,
+ [ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
+ [string]$Assigned_Object_Type,
+
+ [uint16]$Assigned_Object_Id,
[string]$Description,
@@ -3681,20 +4278,39 @@ function Set-NetboxIPAMAddress {
)
begin {
- if ($Status) {
- $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
- }
-
- if ($Role) {
- $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
- }
+ # 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 ($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))
- Write-Verbose "Obtaining IPs from ID $IPId"
+ Write-Verbose "Obtaining IP from ID $IPId"
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
if ($Force -or $PSCmdlet.ShouldProcess($CurrentIP.Address, 'Set')) {
@@ -3702,15 +4318,109 @@ function Set-NetboxIPAMAddress {
$URI = BuildNewURI -Segments $URIComponents.Segments
- InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
+ InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method
}
}
}
+}
+
+#endregion
+
+#region File Set-NetboxIPAMPrefix.ps1
+
+<#
+ .NOTES
+ ===========================================================================
+ Created with: SAPIEN Technologies, Inc., PowerShell Studio 2021 v5.8.186
+ Created on: 2021-03-23 13:54
+ Created by: Claussen
+ Organization: NEOnet
+ Filename: Set-NetboxIPAMPrefix.ps1
+ ===========================================================================
+ .DESCRIPTION
+ A description of the file.
+#>
+
+
+function Set-NetboxIPAMPrefix {
+ [CmdletBinding(ConfirmImpact = 'Medium',
+ SupportsShouldProcess = $true)]
+ param
+ (
+ [Parameter(Mandatory = $true,
+ ValueFromPipelineByPropertyName = $true)]
+ [uint16[]]$Id,
+
+ [string]$Prefix,
+
+ [string]$Status,
+
+ [uint16]$Tenant,
+
+ [uint16]$Site,
+
+ [uint16]$VRF,
+
+ [uint16]$VLAN,
+
+ [object]$Role,
+
+ [hashtable]$Custom_Fields,
+
+ [string]$Description,
+
+ [switch]$Is_Pool,
+
+ [switch]$Force
+ )
- end {
+ 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
+ }
+ }
}
}
+
+
+
+
+
+
+
+
#endregion
#region File Set-NetboxVirtualMachine.ps1
@@ -3767,19 +4477,19 @@ function Set-NetboxVirtualMachine {
[switch]$Force
)
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
- }
-
+# if ($null -ne $Status) {
+# $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
+# }
+#
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $Id))
Write-Verbose "Obtaining VM from ID $Id"
- $CurrentVM = Get-NetboxVirtualMachine -Id $Id -ErrorAction Stop
+ #$CurrentVM = Get-NetboxVirtualMachine -Id $Id -ErrorAction Stop
Write-Verbose "Finished obtaining VM"
- if ($Force -or $pscmdlet.ShouldProcess($CurrentVM.Name, "Set")) {
+ if ($Force -or $pscmdlet.ShouldProcess($ID, "Set properties on VM ID")) {
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
$URI = BuildNewURI -Segments $URIComponents.Segments
@@ -3876,6 +4586,7 @@ function SetupNetboxConfigVariable {
'Connected' = $false
'Choices' = @{
}
+ 'APIDefinition' = $null
}
}
@@ -3954,398 +4665,15 @@ function ThrowNetboxRESTError {
#endregion
-#region File ValidateChoice.ps1
-
-<#
- .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
- }
- }
-}
-
-#endregion
-
-#region File ValidateDCIMChoice.ps1
-
-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
-}
-
-#endregion
-
-#region File ValidateIPAMChoice.ps1
-
-<#
- .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
-}
-
-#endregion
-
-#region File ValidateVirtualizationChoice.ps1
-
-<#
- .NOTES
- ===========================================================================
- Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
- Created on: 3/19/2020 14:12
- Created by: Claussen
- Organization: NEOnet
- Filename: ValidateVirtualizationChoice.ps1
- ===========================================================================
- .DESCRIPTION
- A description of the file.
-#>
-
-function ValidateVirtualizationChoice {
-<#
- .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:\> VerifyIPAMChoices -ProvidedValue 'loopback' -IPAddressRole
-
- .EXAMPLE
- PS C:\> VerifyIPAMChoices -ProvidedValue 'Loopback' -IPAddressFamily
- >> Invalid value Loopback for ip-address:family. Must be one of: 4, 6, IPv4, IPv6
-
- .FUNCTIONALITY
- This cmdlet is intended to be used internally and not exposed to the user
-
- .OUTPUT
- This function returns nothing if the value is valid. Otherwise, it will throw an error.
-#>
-
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory = $true)]
- [object]$ProvidedValue,
-
- [Parameter(ParameterSetName = 'virtual-machine:status',
- Mandatory = $true)]
- [switch]$VirtualMachineStatus
- )
-
- ValidateChoice -MajorObject 'Virtualization' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
-}
-
-#endregion
-
#region File VerifyAPIConnectivity.ps1
function VerifyAPIConnectivity {
[CmdletBinding()]
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
}
@@ -4372,5 +4700,5 @@ $script:CommonParameterNames = New-Object System.Collections.ArrayList
SetupNetboxConfigVariable
-#Export-ModuleMember -Function *
-Export-ModuleMember -Function *-*
+Export-ModuleMember -Function *
+#Export-ModuleMember -Function *-*
diff --git a/Postman/Netbox.postman_collection.json b/Postman/Netbox.postman_collection.json
new file mode 100644
index 0000000..427c372
--- /dev/null
+++ b/Postman/Netbox.postman_collection.json
@@ -0,0 +1,1189 @@
+{
+ "info": {
+ "_postman_id": "eba3e2e2-fd8e-5304-be69-4aebe1237cfc",
+ "name": "Netbox",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
+ },
+ "item": [
+ {
+ "name": "IPAM",
+ "item": [
+ {
+ "name": "Role",
+ "item": [
+ {
+ "name": "Get-NetboxIPAMRole",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/ipam/roles?brief=0",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "ipam",
+ "roles"
+ ],
+ "query": [
+ {
+ "key": "brief",
+ "value": "0"
+ }
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "Prefix",
+ "item": [
+ {
+ "name": "Get Prefixes",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/ipam/prefixes/?prefix",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "ipam",
+ "prefixes",
+ ""
+ ],
+ "query": [
+ {
+ "key": "id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "prefix",
+ "value": null
+ },
+ {
+ "key": "q",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "is_pool",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant_group_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant_group",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "family",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "within",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "mask_length",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "region",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "region_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "status",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "limit",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "offset",
+ "value": null,
+ "disabled": true
+ }
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "IP Address",
+ "item": [
+ {
+ "name": "Create New IP Address",
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\r\n \"status\": 3,\r\n \"description\": \"TEST API CALL DELETE ME\",\r\n \"tenant\": \"2\",\r\n \"address\": \"1.2.3.4/5\"\r\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/ipam/ip-addresses/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "ipam",
+ "ip-addresses",
+ ""
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get Available IP",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/ipam/prefixes/PREFIX_DATABASE_ID/available-ips",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "ipam",
+ "prefixes",
+ "PREFIX_DATABASE_ID",
+ "available-ips"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get IP Addresses By Query",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/ipam/ip-addresses/?q=1.2.3.4",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "ipam",
+ "ip-addresses",
+ ""
+ ],
+ "query": [
+ {
+ "key": "q",
+ "value": "1.2.3.4"
+ },
+ {
+ "key": "id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "dns_name",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant_group_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant_group",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "family",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "parent",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "address",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "mask_length",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "virtual_machine",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "virtual_machine_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "status",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "limit",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "offset",
+ "value": null,
+ "disabled": true
+ }
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get IP Address By ID",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/ipam/ip-addresses/DATABASEID",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "ipam",
+ "ip-addresses",
+ "DATABASEID"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Remove IP",
+ "request": {
+ "method": "DELETE",
+ "header": [],
+ "body": {
+ "mode": "formdata",
+ "formdata": []
+ },
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/ipam/ip-addresses/4110/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "ipam",
+ "ip-addresses",
+ "4110",
+ ""
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "VLAN",
+ "item": [
+ {
+ "name": "New-VLAN",
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\r\n \"status\": 1,\r\n \"description\": \"\",\r\n \"tenant\": \"2\",\r\n \"address\": \"0.0.0.0/0\",\r\n \"custom_fields\": {\r\n \"requested_by\": null,\r\n \"dns_host_name\": \"\"\r\n }\r\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/ipam/vlans/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "ipam",
+ "vlans",
+ ""
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get VLANs",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/ipam/vlans?vid",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "ipam",
+ "vlans"
+ ],
+ "query": [
+ {
+ "key": "id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "vid",
+ "value": null
+ },
+ {
+ "key": "name",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "q",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant_group_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant_group",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant",
+ "value": "",
+ "disabled": true
+ },
+ {
+ "key": "site",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "site_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "group",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "role",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "role_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "status",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "limit",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "offset",
+ "value": null,
+ "disabled": true
+ }
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "Tenancy",
+ "item": [
+ {
+ "name": "Get Tenants",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/tenancy/tenants/?name",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "tenancy",
+ "tenants",
+ ""
+ ],
+ "query": [
+ {
+ "key": "id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "name",
+ "value": null
+ },
+ {
+ "key": "q",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "slug",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "group_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "group",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "limit",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "offset",
+ "value": null,
+ "disabled": true
+ }
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "Virtualization",
+ "item": [
+ {
+ "name": "Get Virtual machines",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/virtualization/virtual-machines",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "virtualization",
+ "virtual-machines"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Set Virtual Machine",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/virtualization/virtual-machines/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "virtualization",
+ "virtual-machines",
+ ""
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get Clusters",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/virtualization/clusters/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "virtualization",
+ "clusters",
+ ""
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "New Virtual machine",
+ "request": {
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n\t\"status\": 1,\n\t\"name\": \"my-vm-name\",\n\t\"platform\": 12,\n\t\"memory\": 4096,\n\t\"cluster\": 9,\n\t\"vcpus\": 2,\n\t\"role\": 10,\n\t\"disk\": 54,\n\t\"tenant\": 47\n}"
+ },
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/virtualization/virtual-machines/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "virtualization",
+ "virtual-machines",
+ ""
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get Virtual Machine Interfaces",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/virtualization/interfaces/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "virtualization",
+ "interfaces",
+ ""
+ ],
+ "query": [
+ {
+ "key": "virtual_machine",
+ "value": "neo-claussen-vm",
+ "disabled": true
+ },
+ {
+ "key": "name",
+ "value": "Ethernet1",
+ "disabled": true
+ }
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "New Virtual Machine Interface",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n\t\"virtual_machine\": 281,\n\t\"name\": \"Ethernet0\"\n}"
+ },
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/virtualization/interfaces/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "virtualization",
+ "interfaces",
+ ""
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get Virtual Machine Interfaces",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/virtualization/interfaces/?virtual_machine_id=198",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "virtualization",
+ "interfaces",
+ ""
+ ],
+ "query": [
+ {
+ "key": "virtual_machine",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "name",
+ "value": "Ethernet1",
+ "disabled": true
+ },
+ {
+ "key": "virtual_machine_id",
+ "value": "198"
+ }
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Set Virtual Machine",
+ "request": {
+ "method": "PATCH",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"primary_ip\": null,\n \"primary_ip4\": null\n}"
+ },
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/virtualization/virtual-machines/198/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "virtualization",
+ "virtual-machines",
+ "198",
+ ""
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get Virtual machines",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/virtualization/virtual-machines/?q=Barracuda+Load",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "virtualization",
+ "virtual-machines",
+ ""
+ ],
+ "query": [
+ {
+ "key": "q",
+ "value": "Barracuda+Load"
+ }
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "Platforms",
+ "item": [
+ {
+ "name": "Get Platforms",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/dcim/device-roles/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "dcim",
+ "device-roles",
+ ""
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "DCIM",
+ "item": [
+ {
+ "name": "Get Device Roles",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/dcim/device-roles/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "dcim",
+ "device-roles",
+ ""
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "New Device",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/dcim/devices/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "dcim",
+ "devices",
+ ""
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get Device",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/dcim/devices/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "dcim",
+ "devices",
+ ""
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get Device Interfaces",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/dcim/interfaces/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "dcim",
+ "interfaces",
+ ""
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Add Interface",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\r\n \"device\": 62,\r\n \"name\": \"TestINterface2\",\r\n \"mgmt_only\": true\r\n}"
+ },
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/dcim/interfaces/",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "dcim",
+ "interfaces",
+ ""
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "Circuits",
+ "item": [
+ {
+ "name": "Get Circuits",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/circuits/circuits/?cid",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "circuits",
+ "circuits",
+ ""
+ ],
+ "query": [
+ {
+ "key": "q",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "cid",
+ "value": null
+ },
+ {
+ "key": "commit_rate",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant_group_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant_group",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "tenant",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "provider_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "provider",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "type_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "type",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "status",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "site_id",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "site",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "id__in",
+ "value": "1",
+ "disabled": true
+ },
+ {
+ "key": "limit",
+ "value": null,
+ "disabled": true
+ },
+ {
+ "key": "offset",
+ "value": null,
+ "disabled": true
+ }
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "Get-NetboxAPIInformation",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "{{SCHEME}}://{{HOSTNAME}}:{{PORT}}/api/extras/_choices",
+ "protocol": "{{SCHEME}}",
+ "host": [
+ "{{HOSTNAME}}"
+ ],
+ "port": "{{PORT}}",
+ "path": [
+ "api",
+ "extras",
+ "_choices"
+ ]
+ }
+ },
+ "response": []
+ }
+ ],
+ "auth": {
+ "type": "apikey",
+ "apikey": [
+ {
+ "key": "value",
+ "value": "Token {{APIKey}}",
+ "type": "string"
+ },
+ {
+ "key": "key",
+ "value": "Authorization",
+ "type": "string"
+ }
+ ]
+ },
+ "event": [
+ {
+ "listen": "prerequest",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ "pm.request.headers.upsert(",
+ " {",
+ " key: 'content-type',",
+ " value: 'application/json'",
+ " }",
+ ");",
+ "",
+ ""
+ ]
+ }
+ },
+ {
+ "listen": "test",
+ "script": {
+ "type": "text/javascript",
+ "exec": [
+ ""
+ ]
+ }
+ }
+ ],
+ "variable": [
+ {
+ "key": "SCHEME",
+ "value": "https"
+ },
+ {
+ "key": "HOSTNAME",
+ "value": "my.host.name"
+ },
+ {
+ "key": "PORT",
+ "value": "443"
+ },
+ {
+ "key": "APIKey",
+ "value": "myapikey"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/deploy.ps1 b/deploy.ps1
index 8316249..644d0f7 100644
--- a/deploy.ps1
+++ b/deploy.ps1
@@ -1,45 +1,132 @@
-<#
- .NOTES
- ===========================================================================
- Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.174
- Created on: 4/9/2020 09:43
- Created by: Claussen
- Organization: NEOnet
- Filename: deploy.ps1
- ===========================================================================
- .DESCRIPTION
- A description of the file.
+<#
+ .SYNOPSIS
+ A brief description of the Invoke-deploy_ps1 file.
+
+ .DESCRIPTION
+ A description of the file.
+
+ .PARAMETER SkipVersion
+ A description of the SkipVersion parameter.
+
+ .PARAMETER VersionIncrease
+ A description of the VersionIncrease parameter.
+
+ .PARAMETER NewVersion
+ A description of the NewVersion parameter.
+
+ .NOTES
+ ===========================================================================
+ Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.174
+ Created on: 4/9/2020 09:43
+ Created by: Claussen
+ Organization: NEOnet
+ Filename: deploy.ps1
+ ===========================================================================
#>
+[CmdletBinding(DefaultParameterSetName = 'IncreaseVersion')]
+param
+(
+ [Parameter(ParameterSetName = 'SkipVersion')]
+ [switch]$SkipVersion,
+
+ [Parameter(ParameterSetName = 'IncreaseVersion')]
+ [version]$VersionIncrease = "0.0.1",
+
+ [Parameter(ParameterSetName = 'SetVersion')]
+ [version]$NewVersion
+)
-
+Import-Module "Microsoft.PowerShell.Utility" -ErrorAction Stop
Write-Host "Beginning deployment" -ForegroundColor Green
-$PS1Files = Get-ChildItem "$PSScriptRoot\Functions" -Filter "*.ps1" -Recurse | Sort-Object Name
+$ModuleName = 'NetboxPS'
+$ConcatenatedFilePath = "$PSScriptRoot\concatenated.ps1"
+$FunctionPath = "$PSScriptRoot\Functions"
+$OutputDirectory = "$PSScriptRoot\$ModuleName"
+$PSD1OutputPath = "$OutputDirectory\$ModuleName.psd1"
+$PSM1OutputPath = "$OutputDirectory\$ModuleName.psm1"
-"" | Out-File -FilePath .\concatenated.ps1 -Encoding utf8
+$PS1Files = Get-ChildItem $FunctionPath -Filter "*.ps1" -Recurse | Sort-Object Name
+
+"" | Out-File -FilePath $ConcatenatedFilePath -Encoding utf8
$Counter = 0
+Write-Host "Concatenating [$($PS1Files.Count)] PS1 files from $FunctionPath"
foreach ($File in $PS1Files) {
$Counter++
- Write-Host (" Adding file {0:D2}/{1:D2}: $($File.Name)" -f $Counter, $PS1Files.Count)
- "`r`n#region File $($File.Name)`r`n" | Out-File -FilePath .\concatenated.ps1 -Encoding utf8 -Append
-
- Get-Content $File.FullName -Encoding UTF8 | Out-File -FilePath .\concatenated.ps1 -Encoding utf8 -Append
-
- "`r`n#endregion" | Out-File -FilePath .\concatenated.ps1 -Encoding utf8 -Append
+ try {
+ Write-Host (" Adding file {0:D2}/{1:D2}: $($File.Name)" -f $Counter, $PS1Files.Count)
+
+ "`r`n#region File $($File.Name)`r`n" | Out-File -FilePath $ConcatenatedFilePath -Encoding utf8 -Append -ErrorAction Stop
+
+ Get-Content $File.FullName -Encoding UTF8 -ErrorAction Stop | Out-File -FilePath $ConcatenatedFilePath -Encoding utf8 -Append -ErrorAction Stop
+
+ "`r`n#endregion" | Out-File -FilePath $ConcatenatedFilePath -Encoding utf8 -Append -ErrorAction Stop
+ } catch {
+ Write-Host "FAILED TO WRITE CONCATENATED FILE: $($_.Exception.Message): $($_.TargetObject)" -ForegroundColor Red
+ return
+ }
}
-"" | Out-File -FilePath .\concatenated.ps1 -Encoding utf8 -Append
+"" | Out-File -FilePath $ConcatenatedFilePath -Encoding utf8 -Append
Write-Host " Adding psm1"
-Get-Content .\NetboxPS.psm1 | Out-File -FilePath .\concatenated.ps1 -Encoding UTF8 -Append
+Get-Content "$PSScriptRoot\$ModuleName.psm1" | Out-File -FilePath $ConcatenatedFilePath -Encoding UTF8 -Append
+
+$PSDManifest = Import-PowerShellDataFile -Path "$PSScriptRoot\$ModuleName.psd1"
+# Get the version from the PSD1
+#[version]$CurrentVersion = [regex]::matches($PSDContent, "\s*ModuleVersion\s=\s'(\d*.\d*.\d*)'\s*").groups[1].value
+[version]$CurrentVersion = $PSDManifest.ModuleVersion
+
+
+switch ($PSCmdlet.ParameterSetName) {
+ "SkipVersion" {
+ # Dont do anything with the PSD
+ Write-Host " Skipping version update, maintaining version [$CurrentVersion]"
+
+ break
+ }
+
+ "IncreaseVersion" {
+ # Calculate the new version
+ [version]$NewVersion = "{0}.{1}.{2}" -f ($CurrentVersion.Major + $VersionIncrease.Major), ($CurrentVersion.Minor + $VersionIncrease.Minor), ($CurrentVersion.Build + $VersionIncrease.Build)
+
+ Write-Host " Updating version in PSD1 from [$CurrentVersion] to [$NewVersion]"
+
+ # Replace the version number in the content
+ #$PSDContent -replace $CurrentVersion, $NewVersion | Out-File $PSScriptRoot\$ModuleName.psd1 -Encoding UTF8
+ Update-ModuleManifest -Path "$PSScriptRoot\$ModuleName.psd1" -ModuleVersion $NewVersion
+
+ break
+ }
+
+ "SetVersion" {
+ Write-Host " Updating version in PSD1 from [$CurrentVersion] to [$NewVersion]"
+
+ # Replace the version number in the content
+ #$PSDContent -replace $CurrentVersion, $NewVersion | Out-File $PSScriptRoot\$ModuleName.psd1 -Encoding UTF8
+ Update-ModuleManifest -Path "$PSScriptRoot\$ModuleName.psd1" -ModuleVersion $NewVersion
+
+ break
+ }
+}
+
+
+if (-not (Test-Path $OutputDirectory)) {
+ try {
+ Write-Warning "Creating path [$OutputDirectory]"
+ $null = New-Item -Path $OutputDirectory -ItemType Directory -Force
+ } catch {
+ throw "Failed to create directory [$OutputDirectory]: $($_.Exception.Message)"
+ }
+}
Write-Host " Copying psd1"
-Copy-Item -Path .\NetboxPS.psd1 -Destination .\dist\NetboxPS.psd1 -Force
+Copy-Item -Path "$PSScriptRoot\$ModuleName.psd1" -Destination $PSD1OutputPath -Force
Write-Host " Copying psm1"
-Copy-Item -Path .\concatenated.ps1 -Destination .\dist\NetboxPS.psm1 -Force
+Copy-Item -Path $ConcatenatedFilePath -Destination $PSM1OutputPath -Force
Write-Host "Deployment complete" -ForegroundColor Green
\ No newline at end of file
diff --git a/dist/NetboxPS.psd1 b/dist/NetboxPS.psd1
deleted file mode 100644
index d927485..0000000
--- a/dist/NetboxPS.psd1
+++ /dev/null
@@ -1,127 +0,0 @@
-<#
- ===========================================================================
- Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.148
- Created on: 2/28/2018 11:04 AM
- Created by: Ben Claussen
- Organization: NEOnet
- Filename: NetboxPS.psd1
- -------------------------------------------------------------------------
- Module Manifest
- -------------------------------------------------------------------------
- Module Name: NetboxPS
- ===========================================================================
-#>
-
-
-@{
-
- # Script module or binary module file associated with this manifest
- RootModule = 'NetboxPS.psm1'
-
- # Version number of this module.
- ModuleVersion = '1.0.4'
-
- # ID used to uniquely identify this module
- GUID = 'bba9b06c-49c8-47cf-8358-aca7c4e78896'
-
- # Author of this module
- Author = 'Ben Claussen'
-
- # Company or vendor of this module
- CompanyName = 'NEOnet'
-
- # Copyright statement for this module
- Copyright = '(c) 2018. All rights reserved.'
-
- # Description of the functionality provided by this module
- Description = 'A Powershell wrapper for Netbox API'
-
- # Minimum version of the Windows PowerShell engine required by this module
- PowerShellVersion = '5.0'
-
- # Name of the Windows PowerShell host required by this module
- PowerShellHostName = ''
-
- # Minimum version of the Windows PowerShell host required by this module
- PowerShellHostVersion = ''
-
- # Minimum version of the .NET Framework required by this module
- DotNetFrameworkVersion = '2.0'
-
- # Minimum version of the common language runtime (CLR) required by this module
- CLRVersion = '2.0.50727'
-
- # Processor architecture (None, X86, Amd64, IA64) required by this module
- ProcessorArchitecture = 'None'
-
- # Modules that must be imported into the global environment prior to importing
- # this module
- RequiredModules = @()
-
- # Assemblies that must be loaded prior to importing this module
- RequiredAssemblies = @('System.Web')
-
- # Script files (.ps1) that are run in the caller's environment prior to
- # importing this module
- ScriptsToProcess = @()
-
- # Type files (.ps1xml) to be loaded when importing this module
- TypesToProcess = @()
-
- # Format files (.ps1xml) to be loaded when importing this module
- FormatsToProcess = @()
-
- # Modules to import as nested modules of the module specified in
- # ModuleToProcess
- NestedModules = @()
-
- # Functions to export from this module
- FunctionsToExport = @('*') #For performanace, list functions explicity
-
- # Cmdlets to export from this module
- CmdletsToExport = '*'
-
- # Variables to export from this module
- VariablesToExport = '*'
-
- # Aliases to export from this module
- AliasesToExport = '*' #For performanace, list alias explicity
-
- # List of all modules packaged with this module
- ModuleList = @()
-
- # List of all files packaged with this module
- FileList = @()
-
- # Private data to pass to the module specified in ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
- PrivateData = @{
-
- #Support for PowerShellGet galleries.
- PSData = @{
-
- # Tags applied to this module. These help with module discovery in online galleries.
- Tags = @('Netbox', 'API', 'DCIM', 'IPAM')
-
- # A URL to the license for this module.
- # LicenseUri = ''
-
- # A URL to the main website for this project.
- ProjectUri = 'https://github.com/benclaussen/NetboxPS'
-
- # A URL to an icon representing this module.
- # IconUri = ''
-
- # ReleaseNotes of this module
- # ReleaseNotes = ''
-
- } # End of PSData hashtable
-
- } # End of PrivateData hashtable
-}
-
-
-
-
-
-
-