From 471a9423099e2b6926d51358bad5a84c7f8e5958 Mon Sep 17 00:00:00 2001 From: Chris Lawson Date: Wed, 22 Mar 2023 16:53:26 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8feature:=20add=20functions=20for=20NEW?= =?UTF-8?q?=20Device=20Role/Types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DCIM/Devices/New-NetboxDCIMDeviceRole.ps1 | 33 ++++++++++++ .../DCIM/Devices/New-NetboxDCIMDeviceType.ps1 | 51 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 Functions/DCIM/Devices/New-NetboxDCIMDeviceRole.ps1 create mode 100644 Functions/DCIM/Devices/New-NetboxDCIMDeviceType.ps1 diff --git a/Functions/DCIM/Devices/New-NetboxDCIMDeviceRole.ps1 b/Functions/DCIM/Devices/New-NetboxDCIMDeviceRole.ps1 new file mode 100644 index 0000000..d34d897 --- /dev/null +++ b/Functions/DCIM/Devices/New-NetboxDCIMDeviceRole.ps1 @@ -0,0 +1,33 @@ + +function New-NetboxDCIMDeviceRole { + [CmdletBinding(ConfirmImpact = 'low', + SupportsShouldProcess = $true)] + [OutputType([pscustomobject])] + param + ( + [string]$Name, + + [string]$Color, + + [bool]$VM_Role, + + [string]$Description, + + [hashtable]$Custom_Fields + ) + + $Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-roles')) + $Method = 'POST' + + if (-not $PSBoundParameters.ContainsKey('slug')) { + $PSBoundParameters.Add('slug', (GenerateSlug -Slug $Name)) + } + + $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters + + $URI = BuildNewURI -Segments $URIComponents.Segments + + if ($PSCmdlet.ShouldProcess($Name, 'Create new Device Role')) { + InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters + } +} \ No newline at end of file diff --git a/Functions/DCIM/Devices/New-NetboxDCIMDeviceType.ps1 b/Functions/DCIM/Devices/New-NetboxDCIMDeviceType.ps1 new file mode 100644 index 0000000..dc3ff09 --- /dev/null +++ b/Functions/DCIM/Devices/New-NetboxDCIMDeviceType.ps1 @@ -0,0 +1,51 @@ + +function New-NetboxDCIMDeviceType { + [CmdletBinding(ConfirmImpact = 'low', + SupportsShouldProcess = $true)] + [OutputType([pscustomobject])] + #region Parameters + param + ( + [Parameter(Mandatory = $true)] + [string]$Manufacturer, + + [Parameter(Mandatory = $true)] + [string]$Model, + + [string]$Part_Number, + + [uint16]$U_Height, + + [bool]$Is_Full_Depth, + + [string]$Subdevice_Role, + + [string]$Airflow, + + [uint16]$Weight, + + [string]$Weight_Unit, + + [string]$Description, + + [string]$Comments, + + [hashtable]$Custom_Fields + ) + #endregion Parameters + + $Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-types')) + $Method = 'POST' + + if (-not $PSBoundParameters.ContainsKey('slug')) { + $PSBoundParameters.Add('slug', (GenerateSlug -Slug $Model)) + } + + $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters + + $URI = BuildNewURI -Segments $URIComponents.Segments + + if ($PSCmdlet.ShouldProcess($Name, 'Create new Device Types')) { + InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters + } +} \ No newline at end of file