mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-15 02:35:46 +00:00
✨feature: adding Manufactures (GET/NEW)
This commit is contained in:
parent
c2a3dc285b
commit
dccfde55ba
2 changed files with 83 additions and 0 deletions
50
Functions/DCIM/Manufacture/Get-NetboxDCIMDManufacture.ps1
Normal file
50
Functions/DCIM/Manufacture/Get-NetboxDCIMDManufacture.ps1
Normal 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
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
33
Functions/DCIM/Manufacture/New-NetboxDCIMManufacture.ps1
Normal file
33
Functions/DCIM/Manufacture/New-NetboxDCIMManufacture.ps1
Normal 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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue