feature: add functions for NEW Device Role/Types

This commit is contained in:
Chris Lawson 2023-03-22 16:53:26 +08:00
parent 5afd24f531
commit 471a942309
2 changed files with 84 additions and 0 deletions

View file

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

View file

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