NetboxPS/Functions/DCIM/Devices/New-NetboxDCIMDevice.ps1

80 lines
1.8 KiB
PowerShell
Raw Normal View History

2022-12-06 13:34:52 -05:00

2020-03-23 12:18:01 -04:00
function New-NetboxDCIMDevice {
[CmdletBinding(ConfirmImpact = 'low',
SupportsShouldProcess = $true)]
2020-03-23 12:18:01 -04:00
[OutputType([pscustomobject])]
#region Parameters
param
(
[Parameter(Mandatory = $true)]
[string]$Name,
2020-03-23 12:18:01 -04:00
[Parameter(Mandatory = $true)]
[object]$Device_Role,
2020-03-23 12:18:01 -04:00
[Parameter(Mandatory = $true)]
[object]$Device_Type,
2020-03-23 12:18:01 -04:00
[Parameter(Mandatory = $true)]
[uint16]$Site,
2020-03-23 12:18:01 -04:00
[object]$Status = 'Active',
2020-03-23 12:18:01 -04:00
[uint16]$Platform,
2020-03-23 12:18:01 -04:00
[uint16]$Tenant,
2020-03-23 12:18:01 -04:00
[uint16]$Cluster,
2020-03-23 12:18:01 -04:00
[uint16]$Rack,
2020-03-23 12:18:01 -04:00
[uint16]$Position,
2020-03-23 12:18:01 -04:00
[object]$Face,
2020-03-23 12:18:01 -04:00
[string]$Serial,
2020-03-23 12:18:01 -04:00
[string]$Asset_Tag,
2020-03-23 12:18:01 -04:00
[uint16]$Virtual_Chassis,
2020-03-23 12:18:01 -04:00
[uint16]$VC_Priority,
2020-03-23 12:18:01 -04:00
[uint16]$VC_Position,
2020-03-23 12:18:01 -04:00
[uint16]$Primary_IP4,
2020-03-23 12:18:01 -04:00
[uint16]$Primary_IP6,
2020-03-23 12:18:01 -04:00
[string]$Comments,
2020-03-23 12:18:01 -04:00
[hashtable]$Custom_Fields
)
#endregion Parameters
# if ($null -ne $Device_Role) {
# # Validate device role?
# }
# if ($null -ne $Device_Type) {
# # Validate device type?
# }
# if ($null -ne $Status) {
# $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
# }
# if ($null -ne $Face) {
# $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
# }
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
2020-03-23 12:18:01 -04:00
$URI = BuildNewURI -Segments $URIComponents.Segments
if ($PSCmdlet.ShouldProcess($Name, 'Create new Device')) {
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
}
2020-03-23 12:18:01 -04:00
}