feature: adding Manufactures (GET/NEW)

This commit is contained in:
Chris Lawson 2023-03-22 16:46:06 +08:00
parent c2a3dc285b
commit dccfde55ba
2 changed files with 83 additions and 0 deletions

View file

@ -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
}
}
}

View file

@ -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
}
}