From dccfde55ba53cd9ff37a381cc1dd3036a4aea11b Mon Sep 17 00:00:00 2001 From: Chris Lawson Date: Wed, 22 Mar 2023 16:46:06 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8feature:=20adding=20Manufactures=20(GE?= =?UTF-8?q?T/NEW)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Get-NetboxDCIMDManufacture.ps1 | 50 +++++++++++++++++++ .../Manufacture/New-NetboxDCIMManufacture.ps1 | 33 ++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 Functions/DCIM/Manufacture/Get-NetboxDCIMDManufacture.ps1 create mode 100644 Functions/DCIM/Manufacture/New-NetboxDCIMManufacture.ps1 diff --git a/Functions/DCIM/Manufacture/Get-NetboxDCIMDManufacture.ps1 b/Functions/DCIM/Manufacture/Get-NetboxDCIMDManufacture.ps1 new file mode 100644 index 0000000..57384a3 --- /dev/null +++ b/Functions/DCIM/Manufacture/Get-NetboxDCIMDManufacture.ps1 @@ -0,0 +1,50 @@ + +function Get-NetboxDCIMManufacture { + [CmdletBinding()] + #region Parameters + param + ( + [uint16]$Offset, + + [uint16]$Limit, + + [Parameter(ParameterSetName = 'ById')] + [uint16[]]$Id, + + [string]$Name, + + [string]$Slug, + + [switch]$Raw + ) + #endregion Parameters + + switch ($PSCmdlet.ParameterSetName) { + 'ById' { + foreach ($ManuID in $Id) { + $Segments = [System.Collections.ArrayList]::new(@('dcim', 'manufacturers', $ManuID)) + + $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', 'manufacturers')) + + $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw' + + $URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters + + InvokeNetboxRequest -URI $URI -Raw:$Raw + + } + } + +} \ No newline at end of file diff --git a/Functions/DCIM/Manufacture/New-NetboxDCIMManufacture.ps1 b/Functions/DCIM/Manufacture/New-NetboxDCIMManufacture.ps1 new file mode 100644 index 0000000..e792ba4 --- /dev/null +++ b/Functions/DCIM/Manufacture/New-NetboxDCIMManufacture.ps1 @@ -0,0 +1,33 @@ + +function New-NetboxDCIMManufacture { + [CmdletBinding(ConfirmImpact = 'low', + SupportsShouldProcess = $true)] + [OutputType([pscustomobject])] + #region Parameters + param + ( + [Parameter(Mandatory = $true)] + [string]$Name, + + [string]$Description, + + [hashtable]$Custom_Fields + + ) + #endregion Parameters + + $Segments = [System.Collections.ArrayList]::new(@('dcim', 'manufacturers')) + $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 Manufacture')) { + InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters + } +} \ No newline at end of file