diff --git a/Functions/DCIM/DCIM.Devices.ps1 b/Functions/DCIM/DCIM.Devices.ps1
new file mode 100644
index 0000000..a0155b2
--- /dev/null
+++ b/Functions/DCIM/DCIM.Devices.ps1
@@ -0,0 +1,428 @@
+<#
+ .NOTES
+ ===========================================================================
+ Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.152
+ Created on: 5/25/2018 2:52 PM
+ Created by: Ben Claussen
+ Organization: NEOnet
+ Filename: DCIM.Devices.ps1
+ ===========================================================================
+ .DESCRIPTION
+ A description of the file.
+#>
+
+#region GET commands
+
+function Get-NetboxDCIMDevice {
+ [CmdletBinding()]
+ #region Parameters
+ param
+ (
+ [uint16]$Limit,
+
+ [uint16]$Offset,
+
+ [Parameter(ValueFromPipelineByPropertyName = $true)]
+ [uint16[]]$Id,
+
+ [string]$Query,
+
+ [string]$Name,
+
+ [uint16]$Manufacturer_Id,
+
+ [string]$Manufacturer,
+
+ [uint16]$Device_Type_Id,
+
+ [uint16]$Role_Id,
+
+ [string]$Role,
+
+ [uint16]$Tenant_Id,
+
+ [string]$Tenant,
+
+ [uint16]$Platform_Id,
+
+ [string]$Platform,
+
+ [string]$Asset_Tag,
+
+ [uint16]$Site_Id,
+
+ [string]$Site,
+
+ [uint16]$Rack_Group_Id,
+
+ [uint16]$Rack_Id,
+
+ [uint16]$Cluster_Id,
+
+ [uint16]$Model,
+
+ [object]$Status,
+
+ [bool]$Is_Full_Depth,
+
+ [bool]$Is_Console_Server,
+
+ [bool]$Is_PDU,
+
+ [bool]$Is_Network_Device,
+
+ [string]$MAC_Address,
+
+ [bool]$Has_Primary_IP,
+
+ [uint16]$Virtual_Chassis_Id,
+
+ [uint16]$Position,
+
+ [string]$Serial,
+
+ [switch]$Raw
+ )
+
+ #endregion Parameters
+
+ if ($null -ne $Status) {
+ $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
+ }
+
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $URI -Raw:$Raw
+}
+
+function Get-NetboxDCIMDeviceType {
+ [CmdletBinding()]
+ #region Parameters
+ param
+ (
+ [uint16]$Offset,
+
+ [uint16]$Limit,
+
+ [uint16[]]$Id,
+
+ [string]$Query,
+
+ [string]$Slug,
+
+ [string]$Manufacturer,
+
+ [uint16]$Manufacturer_Id,
+
+ [string]$Model,
+
+ [string]$Part_Number,
+
+ [uint16]$U_Height,
+
+ [bool]$Is_Full_Depth,
+
+ [bool]$Is_Console_Server,
+
+ [bool]$Is_PDU,
+
+ [bool]$Is_Network_Device,
+
+ [uint16]$Subdevice_Role,
+
+ [switch]$Raw
+ )
+ #endregion Parameters
+
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-types'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $URI -Raw:$Raw
+}
+
+function Get-NetboxDCIMDeviceRole {
+ [CmdletBinding()]
+ param
+ (
+ [uint16]$Limit,
+
+ [uint16]$Offset,
+
+ [Parameter(ParameterSetName = 'ById')]
+ [uint16[]]$Id,
+
+ [string]$Name,
+
+ [string]$Slug,
+
+ [string]$Color,
+
+ [bool]$VM_Role,
+
+ [switch]$Raw
+ )
+
+ switch ($PSCmdlet.ParameterSetName) {
+ 'ById' {
+ foreach ($DRId in $Id) {
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-roles', $DRId))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Raw'
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $URI -Raw:$Raw
+ }
+
+ break
+ }
+
+ default {
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-roles'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $URI -Raw:$Raw
+ }
+ }
+}
+
+#endregion GET commands
+
+
+#region NEW commands
+
+function New-NetboxDCIMDevice {
+ [CmdletBinding()]
+ [OutputType([pscustomobject])]
+ #region Parameters
+ param
+ (
+ [Parameter(Mandatory = $true)]
+ [string]$Name,
+
+ [Parameter(Mandatory = $true)]
+ [object]$Device_Role,
+
+ [Parameter(Mandatory = $true)]
+ [object]$Device_Type,
+
+ [Parameter(Mandatory = $true)]
+ [uint16]$Site,
+
+ [object]$Status = 'Active',
+
+ [uint16]$Platform,
+
+ [uint16]$Tenant,
+
+ [uint16]$Cluster,
+
+ [uint16]$Rack,
+
+ [uint16]$Position,
+
+ [object]$Face,
+
+ [string]$Serial,
+
+ [string]$Asset_Tag,
+
+ [uint16]$Virtual_Chassis,
+
+ [uint16]$VC_Priority,
+
+ [uint16]$VC_Position,
+
+ [uint16]$Primary_IP4,
+
+ [uint16]$Primary_IP6,
+
+ [string]$Comments,
+
+ [hashtable]$Custom_Fields
+ )
+ #endregion Parameters
+
+ if ($null -ne $Device_Role) {
+ # Validate device role?
+ }
+
+ if ($null -ne $Device_Type) {
+ # Validate device type?
+ }
+
+ if ($null -ne $Status) {
+ $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
+ }
+
+ if ($null -ne $Face) {
+ $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
+ }
+
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments
+
+ InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
+}
+
+#endregion NEW commands
+
+
+#region SET commands
+
+function Set-NetboxDCIMDevice {
+ [CmdletBinding(SupportsShouldProcess = $true)]
+ param
+ (
+ [Parameter(Mandatory = $true,
+ ValueFromPipelineByPropertyName = $true)]
+ [uint16[]]$Id,
+
+ [string]$Name,
+
+ [object]$Device_Role,
+
+ [object]$Device_Type,
+
+ [uint16]$Site,
+
+ [object]$Status,
+
+ [uint16]$Platform,
+
+ [uint16]$Tenant,
+
+ [uint16]$Cluster,
+
+ [uint16]$Rack,
+
+ [uint16]$Position,
+
+ [object]$Face,
+
+ [string]$Serial,
+
+ [string]$Asset_Tag,
+
+ [uint16]$Virtual_Chassis,
+
+ [uint16]$VC_Priority,
+
+ [uint16]$VC_Position,
+
+ [uint16]$Primary_IP4,
+
+ [uint16]$Primary_IP6,
+
+ [string]$Comments,
+
+ [hashtable]$Custom_Fields,
+
+ [switch]$Force
+ )
+
+ begin {
+ if ($null -ne $Status) {
+ $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
+ }
+
+ if ($null -ne $Face) {
+ $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
+ }
+ }
+
+ process {
+ foreach ($DeviceID in $Id) {
+ $CurrentDevice = Get-NetboxDCIMDevice -Id $DeviceID -ErrorAction Stop
+
+ if ($Force -or $pscmdlet.ShouldProcess("$($CurrentDevice.Name)", "Set")) {
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices', $CurrentDevice.Id))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments
+
+ InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
+ }
+ }
+ }
+
+ end {
+
+ }
+}
+
+#endregion SET commands
+
+
+#region REMOVE commands
+
+function Remove-NetboxDCIMDevice {
+<#
+ .SYNOPSIS
+ Delete a device
+
+ .DESCRIPTION
+ Deletes a device from Netbox by ID
+
+ .PARAMETER Id
+ Database ID of the device
+
+ .PARAMETER Force
+ Force deletion without any prompts
+
+ .EXAMPLE
+ PS C:\> Remove-NetboxDCIMDevice -Id $value1
+
+ .NOTES
+ Additional information about the function.
+#>
+
+ [CmdletBinding(ConfirmImpact = 'High',
+ SupportsShouldProcess = $true)]
+ param
+ (
+ [Parameter(Mandatory = $true,
+ ValueFromPipelineByPropertyName = $true)]
+ [uint16[]]$Id,
+
+ [switch]$Force
+ )
+
+ begin {
+
+ }
+
+ process {
+ foreach ($DeviceID in $Id) {
+ $CurrentDevice = Get-NetboxDCIMDevice -Id $DeviceID -ErrorAction Stop
+
+ if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentDevice.Name) | ID: $($CurrentDevice.Id)", "Remove")) {
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices', $CurrentDevice.Id))
+
+ $URI = BuildNewURI -Segments $Segments
+
+ InvokeNetboxRequest -URI $URI -Method DELETE
+ }
+ }
+ }
+
+ end {
+
+ }
+}
+
+#endregion REMOVE commands
\ No newline at end of file
diff --git a/Functions/DCIM/DCIM.Interfaces.ps1 b/Functions/DCIM/DCIM.Interfaces.ps1
new file mode 100644
index 0000000..65bf7e6
--- /dev/null
+++ b/Functions/DCIM/DCIM.Interfaces.ps1
@@ -0,0 +1,495 @@
+<#
+ .NOTES
+ ===========================================================================
+ Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.152
+ Created on: 5/25/2018 2:57 PM
+ Created by: Ben Claussen
+ Organization: NEOnet
+ Filename: DCIM.Interfaces.ps1
+ ===========================================================================
+ .DESCRIPTION
+ A description of the file.
+#>
+
+#region GET Commands
+
+function Get-NetboxDCIMInterface {
+ [CmdletBinding()]
+ [OutputType([pscustomobject])]
+ param
+ (
+ [uint16]$Limit,
+
+ [uint16]$Offset,
+
+ [Parameter(ValueFromPipelineByPropertyName = $true)]
+ [uint16]$Id,
+
+ [uint16]$Name,
+
+ [object]$Form_Factor,
+
+ [bool]$Enabled,
+
+ [uint16]$MTU,
+
+ [bool]$MGMT_Only,
+
+ [string]$Device,
+
+ [uint16]$Device_Id,
+
+ [uint16]$Type,
+
+ [uint16]$LAG_Id,
+
+ [string]$MAC_Address,
+
+ [switch]$Raw
+ )
+
+ if ($null -ne $Form_Factor) {
+ $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
+ }
+
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $URI -Raw:$Raw
+}
+
+function Get-NetboxDCIMInterfaceConnection {
+ [CmdletBinding()]
+ [OutputType([pscustomobject])]
+ param
+ (
+ [uint16]$Limit,
+
+ [uint16]$Offset,
+
+ [uint16]$Id,
+
+ [object]$Connection_Status,
+
+ [uint16]$Site,
+
+ [uint16]$Device,
+
+ [switch]$Raw
+ )
+
+ if ($null -ne $Connection_Status) {
+ $PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
+ }
+
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
+
+ InvokeNetboxRequest -URI $URI -Raw:$Raw
+}
+
+#endregion GET Commands
+
+
+#region ADD/NEW commands
+
+function Add-NetboxDCIMInterface {
+ [CmdletBinding()]
+ [OutputType([pscustomobject])]
+ param
+ (
+ [Parameter(Mandatory = $true)]
+ [uint16]$Device,
+
+ [Parameter(Mandatory = $true)]
+ [string]$Name,
+
+ [bool]$Enabled,
+
+ [object]$Form_Factor,
+
+ [uint16]$MTU,
+
+ [string]$MAC_Address,
+
+ [bool]$MGMT_Only,
+
+ [uint16]$LAG,
+
+ [string]$Description,
+
+ [ValidateSet('Access', 'Tagged', 'Tagged All', '100', '200', '300', IgnoreCase = $true)]
+ [string]$Mode,
+
+ [ValidateRange(1, 4094)]
+ [uint16]$Untagged_VLAN,
+
+ [ValidateRange(1, 4094)]
+ [uint16[]]$Tagged_VLANs
+ )
+
+ if ($null -ne $Form_Factor) {
+ $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
+ }
+
+ if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
+ $PSBoundParameters.Mode = switch ($Mode) {
+ 'Access' {
+ 100
+ break
+ }
+
+ 'Tagged' {
+ 200
+ break
+ }
+
+ 'Tagged All' {
+ 300
+ break
+ }
+
+ default {
+ $_
+ }
+ }
+ }
+
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments
+
+ InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
+}
+
+function Add-NetboxDCIMInterfaceConnection {
+<#
+ .SYNOPSIS
+ Create a new connection between two interfaces
+
+ .DESCRIPTION
+ Create a new connection between two interfaces
+
+ .PARAMETER Connection_Status
+ Is it connected or planned?
+
+ .PARAMETER Interface_A
+ Database ID of interface A
+
+ .PARAMETER Interface_B
+ Database ID of interface B
+
+ .EXAMPLE
+ PS C:\> Add-NetboxDCIMInterfaceConnection -Interface_A $value1 -Interface_B $value2
+
+ .NOTES
+ Additional information about the function.
+#>
+
+ [CmdletBinding()]
+ [OutputType([pscustomobject])]
+ param
+ (
+ [object]$Connection_Status,
+
+ [Parameter(Mandatory = $true)]
+ [uint16]$Interface_A,
+
+ [Parameter(Mandatory = $true)]
+ [uint16]$Interface_B
+ )
+
+ if ($null -ne $Connection_Status) {
+ $PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
+ }
+
+ # Verify if both Interfaces exist
+ $I_A = Get-NetboxDCIMInterface -Id $Interface_A -ErrorAction Stop
+ $I_B = Get-NetboxDCIMInterface -Id $Interface_B -ErrorAction Stop
+
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments
+
+ InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
+}
+
+#endregion ADD/NEW commands
+
+
+#region SET Commands
+
+function Set-NetboxDCIMInterface {
+ [CmdletBinding()]
+ [OutputType([pscustomobject])]
+ param
+ (
+ [Parameter(Mandatory = $true,
+ ValueFromPipelineByPropertyName = $true)]
+ [uint16[]]$Id,
+
+ [uint16]$Device,
+
+ [string]$Name,
+
+ [bool]$Enabled,
+
+ [object]$Form_Factor,
+
+ [uint16]$MTU,
+
+ [string]$MAC_Address,
+
+ [bool]$MGMT_Only,
+
+ [uint16]$LAG,
+
+ [string]$Description,
+
+ [ValidateSet('Access', 'Tagged', 'Tagged All', '100', '200', '300', IgnoreCase = $true)]
+ [string]$Mode,
+
+ [ValidateRange(1, 4094)]
+ [uint16]$Untagged_VLAN,
+
+ [ValidateRange(1, 4094)]
+ [uint16[]]$Tagged_VLANs
+ )
+
+ begin {
+ if ($null -ne $Form_Factor) {
+ $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
+ }
+
+ if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
+ $PSBoundParameters.Mode = switch ($Mode) {
+ 'Access' {
+ 100
+ break
+ }
+
+ 'Tagged' {
+ 200
+ break
+ }
+
+ 'Tagged All' {
+ 300
+ break
+ }
+
+ default {
+ $_
+ }
+ }
+ }
+ }
+
+ process {
+ foreach ($InterfaceId in $Id) {
+ $CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
+
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
+
+ $URI = BuildNewURI -Segments $Segments
+
+ InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
+ }
+ }
+
+ end {
+
+ }
+}
+
+function Set-NetboxDCIMInterfaceConnection {
+<#
+ .SYNOPSIS
+ Update an interface connection
+
+ .DESCRIPTION
+ Update an interface connection
+
+ .PARAMETER Id
+ A description of the Id parameter.
+
+ .PARAMETER Connection_Status
+ A description of the Connection_Status parameter.
+
+ .PARAMETER Interface_A
+ A description of the Interface_A parameter.
+
+ .PARAMETER Interface_B
+ A description of the Interface_B parameter.
+
+ .PARAMETER Force
+ A description of the Force parameter.
+
+ .EXAMPLE
+ PS C:\> Set-NetboxDCIMInterfaceConnection -Id $value1
+
+ .NOTES
+ Additional information about the function.
+#>
+
+ [CmdletBinding(ConfirmImpact = 'Medium',
+ SupportsShouldProcess = $true)]
+ param
+ (
+ [Parameter(Mandatory = $true,
+ ValueFromPipelineByPropertyName = $true)]
+ [uint16[]]$Id,
+
+ [object]$Connection_Status,
+
+ [uint16]$Interface_A,
+
+ [uint16]$Interface_B,
+
+ [switch]$Force
+ )
+
+ begin {
+ if ($null -ne $Connection_Status) {
+ $PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
+ }
+
+ if ((@($ID).Count -gt 1) -and ($Interface_A -or $Interface_B)) {
+ throw "Cannot set multiple connections to the same interface"
+ }
+ }
+
+ process {
+ foreach ($ConnectionID in $Id) {
+ $CurrentConnection = Get-NetboxDCIMInterfaceConnection -Id $ConnectionID -ErrorAction Stop
+
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections', $CurrentConnection.Id))
+
+ if ($Force -or $pscmdlet.ShouldProcess("Connection ID $($CurrentConnection.Id)", "Set")) {
+
+ $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments
+
+ InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
+ }
+ }
+ }
+
+ end {
+
+ }
+}
+
+#endregion SET Commands
+
+
+#region REMOVE commands
+
+function Remove-NetboxDCIMInterface {
+<#
+ .SYNOPSIS
+ Removes an interface
+
+ .DESCRIPTION
+ Removes an interface by ID from a device
+
+ .PARAMETER Id
+ A description of the Id parameter.
+
+ .PARAMETER Force
+ A description of the Force parameter.
+
+ .EXAMPLE
+ PS C:\> Remove-NetboxDCIMInterface -Id $value1
+
+ .NOTES
+ Additional information about the function.
+#>
+
+ [CmdletBinding(ConfirmImpact = 'High',
+ SupportsShouldProcess = $true)]
+ param
+ (
+ [Parameter(Mandatory = $true,
+ ValueFromPipelineByPropertyName = $true)]
+ [uint16[]]$Id,
+
+ [switch]$Force
+ )
+
+ begin {
+
+ }
+
+ process {
+ foreach ($InterfaceId in $Id) {
+ $CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
+
+ if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentInterface.Name) | ID: $($CurrentInterface.Id)", "Remove")) {
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
+
+ $URI = BuildNewURI -Segments $Segments
+
+ InvokeNetboxRequest -URI $URI -Method DELETE
+ }
+ }
+ }
+
+ end {
+
+ }
+}
+
+function Remove-NetboxDCIMInterfaceConnection {
+ [CmdletBinding(ConfirmImpact = 'High',
+ SupportsShouldProcess = $true)]
+ [OutputType([void])]
+ param
+ (
+ [Parameter(Mandatory = $true,
+ ValueFromPipelineByPropertyName = $true)]
+ [uint16[]]$Id,
+
+ [switch]$Force
+ )
+
+ begin {
+
+ }
+
+ process {
+ foreach ($ConnectionID in $Id) {
+ $CurrentConnection = Get-NetboxDCIMInterfaceConnection -Id $ConnectionID -ErrorAction Stop
+
+ if ($Force -or $pscmdlet.ShouldProcess("Connection ID $($ConnectionID.Id)", "REMOVE")) {
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections', $CurrentConnection.Id))
+
+ $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
+
+ $URI = BuildNewURI -Segments $URIComponents.Segments
+
+ InvokeNetboxRequest -URI $URI -Method DELETE
+ }
+ }
+ }
+
+ end {
+
+ }
+}
+
+#endregion REMOVE commands
+
diff --git a/Functions/DCIM/DCIM.ps1 b/Functions/DCIM/DCIM.ps1
index 159382d..6db5e73 100644
--- a/Functions/DCIM/DCIM.ps1
+++ b/Functions/DCIM/DCIM.ps1
@@ -126,142 +126,12 @@ function ValidateDCIMChoice {
ValidateChoice -MajorObject 'DCIM' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
}
-#region GET Commands
-function Get-NetboxDCIMDevice {
- [CmdletBinding()]
- param
- (
- [uint16]$Limit,
-
- [uint16]$Offset,
-
- [Parameter(ValueFromPipelineByPropertyName = $true)]
- [uint16[]]$Id,
-
- [string]$Query,
-
- [string]$Name,
-
- [uint16]$Manufacturer_Id,
-
- [string]$Manufacturer,
-
- [uint16]$Device_Type_Id,
-
- [uint16]$Role_Id,
-
- [string]$Role,
-
- [uint16]$Tenant_Id,
-
- [string]$Tenant,
-
- [uint16]$Platform_Id,
-
- [string]$Platform,
-
- [string]$Asset_Tag,
-
- [uint16]$Site_Id,
-
- [string]$Site,
-
- [uint16]$Rack_Group_Id,
-
- [uint16]$Rack_Id,
-
- [uint16]$Cluster_Id,
-
- [uint16]$Model,
-
- [object]$Status,
-
- [bool]$Is_Full_Depth,
-
- [bool]$Is_Console_Server,
-
- [bool]$Is_PDU,
-
- [bool]$Is_Network_Device,
-
- [string]$MAC_Address,
-
- [bool]$Has_Primary_IP,
-
- [uint16]$Virtual_Chassis_Id,
-
- [uint16]$Position,
-
- [string]$Serial,
-
- [switch]$Raw
- )
-
- #endregion Parameters
-
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
- }
-
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
-
- $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $URI -Raw:$Raw
-}
-function Get-NetboxDCIMDeviceType {
- [CmdletBinding()]
- #region Parameters
- param
- (
- [uint16]$Offset,
-
- [uint16]$Limit,
-
- [uint16[]]$Id,
-
- [string]$Query,
-
- [string]$Slug,
-
- [string]$Manufacturer,
-
- [uint16]$Manufacturer_Id,
-
- [string]$Model,
-
- [string]$Part_Number,
-
- [uint16]$U_Height,
-
- [bool]$Is_Full_Depth,
-
- [bool]$Is_Console_Server,
-
- [bool]$Is_PDU,
-
- [bool]$Is_Network_Device,
-
- [uint16]$Subdevice_Role,
-
- [switch]$Raw
- )
- #endregion Parameters
-
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-types'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
-
- $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $URI -Raw:$Raw
-}
+#region GET commands
-function Get-NetboxDCIMDeviceRole {
+function Get-NetboxDCIMPlatform {
[CmdletBinding()]
+ [OutputType([pscustomobject])]
param
(
[uint16]$Limit,
@@ -275,17 +145,17 @@ function Get-NetboxDCIMDeviceRole {
[string]$Slug,
- [string]$Color,
+ [uint16]$Manufacturer_Id,
- [bool]$VM_Role,
+ [string]$Manufacturer,
[switch]$Raw
)
switch ($PSCmdlet.ParameterSetName) {
'ById' {
- foreach ($DRId in $Id) {
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-roles', $DRId))
+ foreach ($PlatformID in $Id) {
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms', $PlatformID))
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Raw'
@@ -298,7 +168,7 @@ function Get-NetboxDCIMDeviceRole {
}
default {
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-roles'))
+ $Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms'))
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
@@ -309,697 +179,23 @@ function Get-NetboxDCIMDeviceRole {
}
}
-function Get-NetboxDCIMInterface {
- [CmdletBinding()]
- [OutputType([pscustomobject])]
- param
- (
- [uint16]$Limit,
-
- [uint16]$Offset,
-
- [Parameter(ValueFromPipelineByPropertyName = $true)]
- [uint16]$Id,
-
- [uint16]$Name,
-
- [object]$Form_Factor,
-
- [bool]$Enabled,
-
- [uint16]$MTU,
-
- [bool]$MGMT_Only,
-
- [string]$Device,
-
- [uint16]$Device_Id,
-
- [uint16]$Type,
-
- [uint16]$LAG_Id,
-
- [string]$MAC_Address,
-
- [switch]$Raw
- )
-
- if ($null -ne $Form_Factor) {
- $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
- }
-
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
-
- $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $URI -Raw:$Raw
-}
-
-function Get-NetboxDCIMInterfaceConnection {
- [CmdletBinding()]
- [OutputType([pscustomobject])]
- param
- (
- [uint16]$Limit,
-
- [uint16]$Offset,
-
- [uint16]$Id,
-
- [object]$Connection_Status,
-
- [uint16]$Site,
-
- [uint16]$Device,
-
- [switch]$Raw
- )
-
- if ($null -ne $Connection_Status) {
- $PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
- }
-
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
-
- $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
-
- InvokeNetboxRequest -URI $URI -Raw:$Raw
-}
-
-#endregion GET Commands
+#endregion GET commands
-#region ADD/NEW commands
-function New-NetboxDCIMDevice {
- [CmdletBinding()]
- [OutputType([pscustomobject])]
- #region Parameters
- param
- (
- [Parameter(Mandatory = $true)]
- [string]$Name,
-
- [Parameter(Mandatory = $true)]
- [object]$Device_Role,
-
- [Parameter(Mandatory = $true)]
- [object]$Device_Type,
-
- [Parameter(Mandatory = $true)]
- [uint16]$Site,
-
- [object]$Status = 'Active',
-
- [uint16]$Platform,
-
- [uint16]$Tenant,
-
- [uint16]$Cluster,
-
- [uint16]$Rack,
-
- [uint16]$Position,
-
- [object]$Face,
-
- [string]$Serial,
-
- [string]$Asset_Tag,
-
- [uint16]$Virtual_Chassis,
-
- [uint16]$VC_Priority,
-
- [uint16]$VC_Position,
-
- [uint16]$Primary_IP4,
-
- [uint16]$Primary_IP6,
-
- [string]$Comments,
-
- [hashtable]$Custom_Fields
- )
- #endregion Parameters
-
- if ($null -ne $Device_Role) {
- # Validate device role?
- }
-
- if ($null -ne $Device_Type) {
- # Validate device type?
- }
-
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
- }
-
- if ($null -ne $Face) {
- $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
- }
-
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
-
- $URI = BuildNewURI -Segments $URIComponents.Segments
-
- InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
-}
-function Add-NetboxDCIMInterface {
- [CmdletBinding()]
- [OutputType([pscustomobject])]
- param
- (
- [Parameter(Mandatory = $true)]
- [uint16]$Device,
-
- [Parameter(Mandatory = $true)]
- [string]$Name,
-
- [bool]$Enabled,
-
- [object]$Form_Factor,
-
- [uint16]$MTU,
-
- [string]$MAC_Address,
-
- [bool]$MGMT_Only,
-
- [uint16]$LAG,
-
- [string]$Description,
-
- [ValidateSet('Access', 'Tagged', 'Tagged All', '100', '200', '300', IgnoreCase = $true)]
- [string]$Mode,
-
- [ValidateRange(1, 4094)]
- [uint16]$Untagged_VLAN,
-
- [ValidateRange(1, 4094)]
- [uint16[]]$Tagged_VLANs
- )
-
- if ($null -ne $Form_Factor) {
- $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
- }
-
- if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
- $PSBoundParameters.Mode = switch ($Mode) {
- 'Access' {
- 100
- break
- }
-
- 'Tagged' {
- 200
- break
- }
-
- 'Tagged All' {
- 300
- break
- }
-
- default {
- $_
- }
- }
- }
-
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
-
- $URI = BuildNewURI -Segments $URIComponents.Segments
-
- InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
-}
+#region NEW/ADD commands
-function Add-NetboxDCIMInterfaceConnection {
-<#
- .SYNOPSIS
- Create a new connection between two interfaces
-
- .DESCRIPTION
- Create a new connection between two interfaces
-
- .PARAMETER Connection_Status
- Is it connected or planned?
-
- .PARAMETER Interface_A
- Database ID of interface A
-
- .PARAMETER Interface_B
- Database ID of interface B
-
- .EXAMPLE
- PS C:\> Add-NetboxDCIMInterfaceConnection -Interface_A $value1 -Interface_B $value2
-
- .NOTES
- Additional information about the function.
-#>
-
- [CmdletBinding()]
- [OutputType([pscustomobject])]
- param
- (
- [object]$Connection_Status,
-
- [Parameter(Mandatory = $true)]
- [uint16]$Interface_A,
-
- [Parameter(Mandatory = $true)]
- [uint16]$Interface_B
- )
-
- if ($null -ne $Connection_Status) {
- $PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
- }
-
- # Verify if both Interfaces exist
- $I_A = Get-NetboxDCIMInterface -Id $Interface_A -ErrorAction Stop
- $I_B = Get-NetboxDCIMInterface -Id $Interface_B -ErrorAction Stop
-
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
-
- $URI = BuildNewURI -Segments $URIComponents.Segments
-
- InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
-}
+#endregion NEW/ADD commands
-#endregion ADD/NEW commands
+#region SET commands
-#region SET Commands
-function Set-NetboxDCIMDevice {
- [CmdletBinding(SupportsShouldProcess = $true)]
- param
- (
- [Parameter(Mandatory = $true,
- ValueFromPipelineByPropertyName = $true)]
- [uint16[]]$Id,
-
- [string]$Name,
-
- [object]$Device_Role,
-
- [object]$Device_Type,
-
- [uint16]$Site,
-
- [object]$Status,
-
- [uint16]$Platform,
-
- [uint16]$Tenant,
-
- [uint16]$Cluster,
-
- [uint16]$Rack,
-
- [uint16]$Position,
-
- [object]$Face,
-
- [string]$Serial,
-
- [string]$Asset_Tag,
-
- [uint16]$Virtual_Chassis,
-
- [uint16]$VC_Priority,
-
- [uint16]$VC_Position,
-
- [uint16]$Primary_IP4,
-
- [uint16]$Primary_IP6,
-
- [string]$Comments,
-
- [hashtable]$Custom_Fields,
-
- [switch]$Force
- )
-
- begin {
- if ($null -ne $Status) {
- $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
- }
-
- if ($null -ne $Face) {
- $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
- }
- }
-
- process {
- foreach ($DeviceID in $Id) {
- $CurrentDevice = Get-NetboxDCIMDevice -Id $DeviceID -ErrorAction Stop
-
- if ($Force -or $pscmdlet.ShouldProcess("$($CurrentDevice.Name)", "Set")) {
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices', $CurrentDevice.Id))
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
-
- $URI = BuildNewURI -Segments $URIComponents.Segments
-
- InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
- }
- }
- }
-
- end {
-
- }
-}
+#endregion SET commands
-function Set-NetboxDCIMInterface {
- [CmdletBinding()]
- [OutputType([pscustomobject])]
- param
- (
- [Parameter(Mandatory = $true,
- ValueFromPipelineByPropertyName = $true)]
- [uint16[]]$Id,
-
- [uint16]$Device,
-
- [string]$Name,
-
- [bool]$Enabled,
-
- [object]$Form_Factor,
-
- [uint16]$MTU,
-
- [string]$MAC_Address,
-
- [bool]$MGMT_Only,
-
- [uint16]$LAG,
-
- [string]$Description,
-
- [ValidateSet('Access', 'Tagged', 'Tagged All', '100', '200', '300', IgnoreCase = $true)]
- [string]$Mode,
-
- [ValidateRange(1, 4094)]
- [uint16]$Untagged_VLAN,
-
- [ValidateRange(1, 4094)]
- [uint16[]]$Tagged_VLANs
- )
-
- begin {
- if ($null -ne $Form_Factor) {
- $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
- }
-
- if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
- $PSBoundParameters.Mode = switch ($Mode) {
- 'Access' {
- 100
- break
- }
-
- 'Tagged' {
- 200
- break
- }
-
- 'Tagged All' {
- 300
- break
- }
-
- default {
- $_
- }
- }
- }
- }
-
- process {
- foreach ($InterfaceId in $Id) {
- $CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
-
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
-
- $URI = BuildNewURI -Segments $Segments
-
- InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
- }
- }
-
- end {
-
- }
-}
-
-function Set-NetboxDCIMInterfaceConnection {
-<#
- .SYNOPSIS
- Update an interface connection
-
- .DESCRIPTION
- Update an interface connection
-
- .PARAMETER Id
- A description of the Id parameter.
-
- .PARAMETER Connection_Status
- A description of the Connection_Status parameter.
-
- .PARAMETER Interface_A
- A description of the Interface_A parameter.
-
- .PARAMETER Interface_B
- A description of the Interface_B parameter.
-
- .PARAMETER Force
- A description of the Force parameter.
-
- .EXAMPLE
- PS C:\> Set-NetboxDCIMInterfaceConnection -Id $value1
-
- .NOTES
- Additional information about the function.
-#>
-
- [CmdletBinding(ConfirmImpact = 'Medium',
- SupportsShouldProcess = $true)]
- param
- (
- [Parameter(Mandatory = $true,
- ValueFromPipelineByPropertyName = $true)]
- [uint16[]]$Id,
-
- [object]$Connection_Status,
-
- [uint16]$Interface_A,
-
- [uint16]$Interface_B,
-
- [switch]$Force
- )
-
- begin {
- if ($null -ne $Connection_Status) {
- $PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
- }
-
- if ((@($ID).Count -gt 1) -and ($Interface_A -or $Interface_B)) {
- throw "Cannot set multiple connections to the same interface"
- }
- }
-
- process {
- foreach ($ConnectionID in $Id) {
- $CurrentConnection = Get-NetboxDCIMInterfaceConnection -Id $ConnectionID -ErrorAction Stop
-
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections', $CurrentConnection.Id))
-
- if ($Force -or $pscmdlet.ShouldProcess("Connection ID $($CurrentConnection.Id)", "Set")) {
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
-
- $URI = BuildNewURI -Segments $URIComponents.Segments
-
- InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
- }
- }
- }
-
- end {
-
- }
-}
-
-
-#endregion SET Commands
#region REMOVE commands
-function Remove-NetboxDCIMDevice {
-<#
- .SYNOPSIS
- Delete a device
-
- .DESCRIPTION
- Deletes a device from Netbox by ID
-
- .PARAMETER Id
- Database ID of the device
-
- .PARAMETER Force
- Force deletion without any prompts
-
- .EXAMPLE
- PS C:\> Remove-NetboxDCIMDevice -Id $value1
-
- .NOTES
- Additional information about the function.
-#>
-
- [CmdletBinding(ConfirmImpact = 'High',
- SupportsShouldProcess = $true)]
- param
- (
- [Parameter(Mandatory = $true,
- ValueFromPipelineByPropertyName = $true)]
- [uint16[]]$Id,
-
- [switch]$Force
- )
-
- begin {
-
- }
-
- process {
- foreach ($DeviceID in $Id) {
- $CurrentDevice = Get-NetboxDCIMDevice -Id $DeviceID -ErrorAction Stop
-
- if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentDevice.Name) | ID: $($CurrentDevice.Id)", "Remove")) {
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices', $CurrentDevice.Id))
-
- $URI = BuildNewURI -Segments $Segments
-
- InvokeNetboxRequest -URI $URI -Method DELETE
- }
- }
- }
-
- end {
-
- }
-}
-
-function Remove-NetboxDCIMInterface {
-<#
- .SYNOPSIS
- Removes an interface
-
- .DESCRIPTION
- Removes an interface by ID from a device
-
- .PARAMETER Id
- A description of the Id parameter.
-
- .PARAMETER Force
- A description of the Force parameter.
-
- .EXAMPLE
- PS C:\> Remove-NetboxDCIMInterface -Id $value1
-
- .NOTES
- Additional information about the function.
-#>
-
- [CmdletBinding(ConfirmImpact = 'High',
- SupportsShouldProcess = $true)]
- param
- (
- [Parameter(Mandatory = $true,
- ValueFromPipelineByPropertyName = $true)]
- [uint16[]]$Id,
-
- [switch]$Force
- )
-
- begin {
-
- }
-
- process {
- foreach ($InterfaceId in $Id) {
- $CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
-
- if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentInterface.Name) | ID: $($CurrentInterface.Id)", "Remove")) {
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
-
- $URI = BuildNewURI -Segments $Segments
-
- InvokeNetboxRequest -URI $URI -Method DELETE
- }
- }
- }
-
- end {
-
- }
-}
-
-function Remove-NetboxDCIMInterfaceConnection {
- [CmdletBinding(ConfirmImpact = 'High',
- SupportsShouldProcess = $true)]
- [OutputType([void])]
- param
- (
- [Parameter(Mandatory = $true,
- ValueFromPipelineByPropertyName = $true)]
- [uint16[]]$Id,
-
- [switch]$Force
- )
-
- begin {
-
- }
-
- process {
- foreach ($ConnectionID in $Id) {
- $CurrentConnection = Get-NetboxDCIMInterfaceConnection -Id $ConnectionID -ErrorAction Stop
-
- if ($Force -or $pscmdlet.ShouldProcess("Connection ID $($ConnectionID.Id)", "REMOVE")) {
- $Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections', $CurrentConnection.Id))
-
- $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
-
- $URI = BuildNewURI -Segments $URIComponents.Segments
-
- InvokeNetboxRequest -URI $URI -Method DELETE
- }
- }
- }
-
- end {
-
- }
-}
-
#endregion REMOVE commands
@@ -1011,9 +207,3 @@ function Remove-NetboxDCIMInterfaceConnection {
-
-
-
-
-
-
diff --git a/Functions/Helpers.ps1 b/Functions/Helpers.ps1
index dfa11e3..715c9ce 100644
--- a/Functions/Helpers.ps1
+++ b/Functions/Helpers.ps1
@@ -28,7 +28,7 @@ function BuildNewURI {
Create a new URI for Netbox
.DESCRIPTION
- A detailed description of the BuildNewURI function.
+ Internal function used to build a URIBuilder object.
.PARAMETER Hostname
Hostname of the Netbox API
@@ -148,14 +148,14 @@ function BuildURIComponents {
$URIParameters = @{}
foreach ($CmdletParameterName in $ParametersDictionary.Keys) {
- if ($CmdletParameterName -in $CommonParameterNames) {
+ if ($CmdletParameterName -in $script:CommonParameterNames) {
# These are common parameters and should not be appended to the URI
- Write-Debug "Skipping parameter $CmdletParameterName"
+ Write-Debug "Skipping common parameter $CmdletParameterName"
continue
}
if ($CmdletParameterName -in $SkipParameterByName) {
- Write-Debug "Skipping parameter $CmdletParameterName"
+ Write-Debug "Skipping parameter $CmdletParameterName by SkipParameterByName"
continue
}
diff --git a/NetboxPS.psproj b/NetboxPS.psproj
index a356252..6053d35 100644
--- a/NetboxPS.psproj
+++ b/NetboxPS.psproj
@@ -31,6 +31,9 @@
Functions\DCIM\DCIM.ps1
Tests\DCIM.Devices.Tests.ps1
Tests\DCIM.Interfaces.Tests.ps1
+ Tests\DCIM.Platforms.Tests.ps1
+ Functions\DCIM\DCIM.Devices.ps1
+ Functions\DCIM\DCIM.Interfaces.ps1
R:\Netbox\NetboxPS\Test-Module.ps1
\ No newline at end of file
diff --git a/Tests/DCIM.Platforms.Tests.ps1 b/Tests/DCIM.Platforms.Tests.ps1
new file mode 100644
index 0000000..a909bc6
--- /dev/null
+++ b/Tests/DCIM.Platforms.Tests.ps1
@@ -0,0 +1,121 @@
+<#
+ .NOTES
+ ===========================================================================
+ Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.152
+ Created on: 5/25/2018 1:03 PM
+ Created by: Ben Claussen
+ Organization: NEOnet
+ Filename: DCIM.Platforms.Tests.ps1
+ ===========================================================================
+ .DESCRIPTION
+ A description of the file.
+#>
+
+Import-Module Pester
+Remove-Module NetboxPS -Force -ErrorAction SilentlyContinue
+
+$ModulePath = "$PSScriptRoot\..\dist\NetboxPS.psd1"
+
+if (Test-Path $ModulePath) {
+ Import-Module $ModulePath -ErrorAction Stop
+}
+
+Describe -Name "DCIM Platforms Tests" -Tag 'DCIM', 'platforms' -Fixture {
+ Mock -CommandName 'CheckNetboxIsConnected' -Verifiable -ModuleName 'NetboxPS' -MockWith {
+ return $true
+ }
+
+ Mock -CommandName 'Invoke-RestMethod' -Verifiable -ModuleName 'NetboxPS' -MockWith {
+ # Return a hashtable of the items we would normally pass to Invoke-RestMethod
+ return [ordered]@{
+ 'Method' = $Method
+ 'Uri' = $Uri
+ 'Headers' = $Headers
+ 'Timeout' = $Timeout
+ 'ContentType' = $ContentType
+ 'Body' = $Body
+ }
+ }
+
+ Mock -CommandName 'Get-NetboxCredential' -Verifiable -ModuleName 'NetboxPS' -MockWith {
+ return [PSCredential]::new('notapplicable', (ConvertTo-SecureString -String "faketoken" -AsPlainText -Force))
+ }
+
+ Mock -CommandName 'Get-NetboxHostname' -Verifiable -ModuleName 'NetboxPS' -MockWith {
+ return 'netbox.domain.com'
+ }
+
+ InModuleScope -ModuleName 'NetboxPS' -ScriptBlock {
+ Context -Name "Get-NetboxDCIMPlatform" -Fixture {
+ It "Should request the default number of platforms" {
+ $Result = Get-NetboxDCIMPlatform
+
+ Assert-VerifiableMock
+ Assert-MockCalled -CommandName 'Invoke-RestMethod' -Times 1 -Scope 'It' -Exactly
+
+ $Result.Method | Should -Be 'GET'
+ $Result.Uri | Should -Be 'https://netbox.domain.com/api/dcim/platforms/'
+ $Result.Headers.Keys.Count | Should -BeExactly 1
+ }
+
+ It "Should request with a limit and offset" {
+ $Result = Get-NetboxDCIMPlatform -Limit 10 -Offset 100
+
+ Assert-VerifiableMock
+ Assert-MockCalled -CommandName 'Invoke-RestMethod' -Times 1 -Scope 'It' -Exactly
+
+ $Result.Method | Should -Be 'GET'
+ $Result.Uri | Should -Be 'https://netbox.domain.com/api/dcim/platforms/?offset=100&limit=10'
+ $Result.Headers.Keys.Count | Should -BeExactly 1
+ }
+
+ It "Should request with a platform name" {
+ $Result = Get-NetboxDCIMPlatform -Name "Windows Server 2016"
+
+ Assert-VerifiableMock
+ Assert-MockCalled -CommandName 'Invoke-RestMethod' -Times 1 -Scope 'It' -Exactly
+
+ $Result.Method | Should -Be 'GET'
+ $Result.Uri | Should -Be 'https://netbox.domain.com/api/dcim/platforms/?name=Windows+Server+2016'
+ $Result.Headers.Keys.Count | Should -BeExactly 1
+ }
+
+ It "Should request a platform by manufacturer" {
+ $Result = Get-NetboxDCIMPlatform -Manufacturer 'Cisco'
+
+ Assert-VerifiableMock
+ Assert-MockCalled -CommandName 'Invoke-RestMethod' -Times 1 -Scope 'It' -Exactly
+
+ $Result.Method | Should -Be 'GET'
+ $Result.Uri | Should -BeExactly 'https://netbox.domain.com/api/dcim/platforms/?manufacturer=Cisco'
+ $Result.Headers.Keys.Count | Should -BeExactly 1
+ }
+
+ It "Should request a platform by ID" {
+ $Result = Get-NetboxDCIMPlatform -Id 10
+
+ Assert-VerifiableMock
+ Assert-MockCalled -CommandName 'Invoke-RestMethod' -Times 1 -Scope 'It' -Exactly
+
+ $Result.Method | Should -Be 'GET'
+ $Result.Uri | Should -BeExactly 'https://netbox.domain.com/api/dcim/platforms/10/'
+ $Result.Headers.Keys.Count | Should -BeExactly 1
+ }
+
+ It "Should request multiple platforms by ID" {
+ $Result = Get-NetboxDCIMPlatform -Id 10, 20
+
+ Assert-VerifiableMock
+ Assert-MockCalled -CommandName 'Invoke-RestMethod' -Times 2 -Scope 'It' -Exactly
+
+ $Result.Method | Should -Be 'GET', 'GET'
+ $Result.Uri | Should -BeExactly 'https://netbox.domain.com/api/dcim/platforms/10/', 'https://netbox.domain.com/api/dcim/platforms/20/'
+ $Result.Headers.Keys.Count | Should -BeExactly 2
+ }
+ }
+ }
+}
+
+
+
+