mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-15 02:35:46 +00:00
add NetboxDCIMPlatform
This commit is contained in:
parent
9453383f34
commit
2b4cbbab80
7 changed files with 306 additions and 28 deletions
34
Functions/DCIM/Platform/Add-NetboxDCIMPlatform.ps1
Normal file
34
Functions/DCIM/Platform/Add-NetboxDCIMPlatform.ps1
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
function Add-NetboxDCIMPlatform {
|
||||
[CmdletBinding()]
|
||||
[OutputType([pscustomobject])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Name,
|
||||
|
||||
[ValidateLength(1, 100)]
|
||||
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
|
||||
[string]$Slug,
|
||||
|
||||
[uint64]$Manufacturer,
|
||||
|
||||
[uint64]$Config_Template,
|
||||
|
||||
[string]$Description,
|
||||
|
||||
[uint16[]]$Tags
|
||||
|
||||
)
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms'))
|
||||
|
||||
if (-not $PSBoundParameters.ContainsKey('slug')) {
|
||||
$PSBoundParameters.Add('slug', $($name | Get-NetboxSlug))
|
||||
}
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
||||
}
|
||||
35
Functions/DCIM/Platform/Remove-NetboxDCIMPlatform.ps1
Normal file
35
Functions/DCIM/Platform/Remove-NetboxDCIMPlatform.ps1
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
function Remove-NetboxDCIMPlatform {
|
||||
|
||||
[CmdletBinding(ConfirmImpact = 'High',
|
||||
SupportsShouldProcess = $true)]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true,
|
||||
ValueFromPipelineByPropertyName = $true)]
|
||||
[uint64[]]$Id,
|
||||
|
||||
[switch]$Force
|
||||
)
|
||||
|
||||
begin {
|
||||
|
||||
}
|
||||
|
||||
process {
|
||||
foreach ($PlatformID in $Id) {
|
||||
$CurrentPlatform = Get-NetboxDCIMPlatform -Id $PlatformID -ErrorAction Stop
|
||||
|
||||
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentPlatform.Name) | ID: $($CurrentPlatform.Id)", "Remove")) {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms', $CurrentPlatform.Id))
|
||||
|
||||
$URI = BuildNewURI -Segments $Segments
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Method DELETE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
}
|
||||
}
|
||||
51
Functions/DCIM/Platform/Set-NetboxDCIMPlatform.ps1
Normal file
51
Functions/DCIM/Platform/Set-NetboxDCIMPlatform.ps1
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
function Set-NetboxDCIMPlatform {
|
||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscustomobject])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true,
|
||||
ValueFromPipelineByPropertyName = $true)]
|
||||
[uint64[]]$Id,
|
||||
|
||||
[string]$Name,
|
||||
|
||||
[ValidateLength(1, 100)]
|
||||
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
|
||||
[string]$Slug,
|
||||
|
||||
[uint64]$Manufacturer,
|
||||
|
||||
[uint64]$Config_Template,
|
||||
|
||||
[string]$Description,
|
||||
|
||||
[uint64[]]$Tags,
|
||||
|
||||
[switch]$Force
|
||||
)
|
||||
|
||||
begin {
|
||||
|
||||
}
|
||||
|
||||
process {
|
||||
foreach ($FrontPortID in $Id) {
|
||||
$CurrentPlatform = Get-NetboxDCIMPlatform -Id $FrontPortID -ErrorAction Stop
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms', $CurrentPlatform.Id))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||
|
||||
$URI = BuildNewURI -Segments $Segments
|
||||
|
||||
if ($Force -or $pscmdlet.ShouldProcess("Platform ID $($CurrentPlatform.Id)", "Set")) {
|
||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# Generated by: Ben Claussen
|
||||
#
|
||||
# Generated on: 01/09/2024
|
||||
# Generated on: 10/5/2024
|
||||
#
|
||||
|
||||
@{
|
||||
|
|
@ -70,9 +70,9 @@ CLRVersion = '2.0.50727'
|
|||
|
||||
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
|
||||
FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
|
||||
'Add-NetboxDCIMInterfaceConnection', 'Add-NetboxDCIMRearPort',
|
||||
'Add-NetboxVirtualMachineInterface', 'BuildNewURI',
|
||||
'BuildURIComponents', 'CheckNetboxIsConnected',
|
||||
'Add-NetboxDCIMInterfaceConnection', 'Add-NetboxDCIMPlatform',
|
||||
'Add-NetboxDCIMRearPort', 'Add-NetboxVirtualMachineInterface',
|
||||
'BuildNewURI', 'BuildURIComponents', 'CheckNetboxIsConnected',
|
||||
'Clear-NetboxCredential', 'Connect-NetboxAPI', 'CreateEnum',
|
||||
'Get-ModelDefinition', 'Get-NetboxAPIDefinition',
|
||||
'GetNetboxAPIErrorBody', 'Get-NetboxCircuit',
|
||||
|
|
@ -90,8 +90,8 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
|
|||
'Get-NetboxIPAMAddress', 'Get-NetboxIPAMAddressRange',
|
||||
'Get-NetboxIPAMAggregate', 'Get-NetboxIPAMAvailableIP',
|
||||
'Get-NetboxIPAMPrefix', 'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN',
|
||||
'Get-NetboxObjectType', 'Get-NetboxTag', 'Get-NetboxTenant',
|
||||
'Get-NetboxTimeout', 'Get-NetboxVersion',
|
||||
'Get-NetboxObjectType', 'Get-NetboxSlug', 'Get-NetboxTag',
|
||||
'Get-NetboxTenant', 'Get-NetboxTimeout', 'Get-NetboxVersion',
|
||||
'Get-NetboxVirtualizationCluster',
|
||||
'Get-NetboxVirtualizationClusterGroup', 'Get-NetboxVirtualMachine',
|
||||
'Get-NetboxVirtualMachineInterface', 'InvokeNetboxRequest',
|
||||
|
|
@ -102,14 +102,15 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
|
|||
'New-NetboxIPAMVLAN', 'New-NetboxTenant', 'New-NetboxVirtualMachine',
|
||||
'Remove-NetboxDCIMDevice', 'Remove-NetboxDCIMFrontPort',
|
||||
'Remove-NetboxDCIMInterface',
|
||||
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort',
|
||||
'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress',
|
||||
'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine',
|
||||
'Set-NetboxCipherSSL', 'Set-NetboxContact',
|
||||
'Set-NetboxContactAssignment', 'Set-NetboxContactRole',
|
||||
'Set-NetboxCredential', 'Set-NetboxDCIMDevice',
|
||||
'Set-NetboxDCIMFrontPort', 'Set-NetboxDCIMInterface',
|
||||
'Set-NetboxDCIMInterfaceConnection', 'Set-NetboxDCIMRearPort',
|
||||
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMPlatform',
|
||||
'Remove-NetboxDCIMRearPort', 'Remove-NetboxDCIMSite',
|
||||
'Remove-NetboxIPAMAddress', 'Remove-NetboxIPAMAddressRange',
|
||||
'Remove-NetboxVirtualMachine', 'Set-NetboxCipherSSL',
|
||||
'Set-NetboxContact', 'Set-NetboxContactAssignment',
|
||||
'Set-NetboxContactRole', 'Set-NetboxCredential',
|
||||
'Set-NetboxDCIMDevice', 'Set-NetboxDCIMFrontPort',
|
||||
'Set-NetboxDCIMInterface', 'Set-NetboxDCIMInterfaceConnection',
|
||||
'Set-NetboxDCIMPlatform', 'Set-NetboxDCIMRearPort',
|
||||
'Set-NetboxHostName', 'Set-NetboxHostPort', 'Set-NetboxHostScheme',
|
||||
'Set-NetboxInvokeParams', 'Set-NetboxIPAMAddress',
|
||||
'Set-NetboxIPAMAddressRange', 'Set-NetboxIPAMPrefix',
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# Generated by: Ben Claussen
|
||||
#
|
||||
# Generated on: 01/09/2024
|
||||
# Generated on: 10/5/2024
|
||||
#
|
||||
|
||||
@{
|
||||
|
|
@ -70,9 +70,9 @@ CLRVersion = '2.0.50727'
|
|||
|
||||
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
|
||||
FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
|
||||
'Add-NetboxDCIMInterfaceConnection', 'Add-NetboxDCIMRearPort',
|
||||
'Add-NetboxVirtualMachineInterface', 'BuildNewURI',
|
||||
'BuildURIComponents', 'CheckNetboxIsConnected',
|
||||
'Add-NetboxDCIMInterfaceConnection', 'Add-NetboxDCIMPlatform',
|
||||
'Add-NetboxDCIMRearPort', 'Add-NetboxVirtualMachineInterface',
|
||||
'BuildNewURI', 'BuildURIComponents', 'CheckNetboxIsConnected',
|
||||
'Clear-NetboxCredential', 'Connect-NetboxAPI', 'CreateEnum',
|
||||
'Get-ModelDefinition', 'Get-NetboxAPIDefinition',
|
||||
'GetNetboxAPIErrorBody', 'Get-NetboxCircuit',
|
||||
|
|
@ -90,8 +90,8 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
|
|||
'Get-NetboxIPAMAddress', 'Get-NetboxIPAMAddressRange',
|
||||
'Get-NetboxIPAMAggregate', 'Get-NetboxIPAMAvailableIP',
|
||||
'Get-NetboxIPAMPrefix', 'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN',
|
||||
'Get-NetboxObjectType', 'Get-NetboxTag', 'Get-NetboxTenant',
|
||||
'Get-NetboxTimeout', 'Get-NetboxVersion',
|
||||
'Get-NetboxObjectType', 'Get-NetboxSlug', 'Get-NetboxTag',
|
||||
'Get-NetboxTenant', 'Get-NetboxTimeout', 'Get-NetboxVersion',
|
||||
'Get-NetboxVirtualizationCluster',
|
||||
'Get-NetboxVirtualizationClusterGroup', 'Get-NetboxVirtualMachine',
|
||||
'Get-NetboxVirtualMachineInterface', 'InvokeNetboxRequest',
|
||||
|
|
@ -102,14 +102,15 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
|
|||
'New-NetboxIPAMVLAN', 'New-NetboxTenant', 'New-NetboxVirtualMachine',
|
||||
'Remove-NetboxDCIMDevice', 'Remove-NetboxDCIMFrontPort',
|
||||
'Remove-NetboxDCIMInterface',
|
||||
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort',
|
||||
'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress',
|
||||
'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine',
|
||||
'Set-NetboxCipherSSL', 'Set-NetboxContact',
|
||||
'Set-NetboxContactAssignment', 'Set-NetboxContactRole',
|
||||
'Set-NetboxCredential', 'Set-NetboxDCIMDevice',
|
||||
'Set-NetboxDCIMFrontPort', 'Set-NetboxDCIMInterface',
|
||||
'Set-NetboxDCIMInterfaceConnection', 'Set-NetboxDCIMRearPort',
|
||||
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMPlatform',
|
||||
'Remove-NetboxDCIMRearPort', 'Remove-NetboxDCIMSite',
|
||||
'Remove-NetboxIPAMAddress', 'Remove-NetboxIPAMAddressRange',
|
||||
'Remove-NetboxVirtualMachine', 'Set-NetboxCipherSSL',
|
||||
'Set-NetboxContact', 'Set-NetboxContactAssignment',
|
||||
'Set-NetboxContactRole', 'Set-NetboxCredential',
|
||||
'Set-NetboxDCIMDevice', 'Set-NetboxDCIMFrontPort',
|
||||
'Set-NetboxDCIMInterface', 'Set-NetboxDCIMInterfaceConnection',
|
||||
'Set-NetboxDCIMPlatform', 'Set-NetboxDCIMRearPort',
|
||||
'Set-NetboxHostName', 'Set-NetboxHostPort', 'Set-NetboxHostScheme',
|
||||
'Set-NetboxInvokeParams', 'Set-NetboxIPAMAddress',
|
||||
'Set-NetboxIPAMAddressRange', 'Set-NetboxIPAMPrefix',
|
||||
|
|
|
|||
|
|
@ -177,6 +177,45 @@ function Add-NetboxDCIMInterfaceConnection {
|
|||
|
||||
#endregion
|
||||
|
||||
#region File Add-NetboxDCIMPlatform.ps1
|
||||
|
||||
function Add-NetboxDCIMPlatform {
|
||||
[CmdletBinding()]
|
||||
[OutputType([pscustomobject])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Name,
|
||||
|
||||
[ValidateLength(1, 100)]
|
||||
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
|
||||
[string]$Slug,
|
||||
|
||||
[uint64]$Manufacturer,
|
||||
|
||||
[uint64]$Config_Template,
|
||||
|
||||
[string]$Description,
|
||||
|
||||
[uint16[]]$Tags
|
||||
|
||||
)
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms'))
|
||||
|
||||
if (-not $PSBoundParameters.ContainsKey('slug')) {
|
||||
$PSBoundParameters.Add('slug', $($name | Get-NetboxSlug))
|
||||
}
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region File Add-NetboxDCIMRearPort.ps1
|
||||
|
||||
function Add-NetboxDCIMRearPort {
|
||||
|
|
@ -2910,6 +2949,27 @@ function Get-NetboxObjectType {
|
|||
|
||||
#endregion
|
||||
|
||||
#region File Get-NetboxSlug.ps1
|
||||
|
||||
function Get-NetboxSlug {
|
||||
param (
|
||||
[Parameter(ValueFromPipeline)]
|
||||
[string]$slug,
|
||||
|
||||
[uint16]$chars = 100
|
||||
)
|
||||
|
||||
process {
|
||||
return $slug -replace '[^\-.\w\s]', '' `
|
||||
-replace '[^a-zA-Z0-9-_ ]', '' `
|
||||
-replace '^[\s.]+|[\s.]+$', '' `
|
||||
-replace '[-.\s]+', '-' `
|
||||
| ForEach-Object { $_.ToLower().Substring(0, [Math]::Min($_.Length, $chars)) }
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region File Get-NetboxTag.ps1
|
||||
|
||||
|
||||
|
|
@ -4762,6 +4822,46 @@ function Remove-NetboxDCIMInterfaceConnection {
|
|||
|
||||
#endregion
|
||||
|
||||
#region File Remove-NetboxDCIMPlatform.ps1
|
||||
|
||||
function Remove-NetboxDCIMPlatform {
|
||||
|
||||
[CmdletBinding(ConfirmImpact = 'High',
|
||||
SupportsShouldProcess = $true)]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true,
|
||||
ValueFromPipelineByPropertyName = $true)]
|
||||
[uint64[]]$Id,
|
||||
|
||||
[switch]$Force
|
||||
)
|
||||
|
||||
begin {
|
||||
|
||||
}
|
||||
|
||||
process {
|
||||
foreach ($PlatformID in $Id) {
|
||||
$CurrentPlatform = Get-NetboxDCIMPlatform -Id $PlatformID -ErrorAction Stop
|
||||
|
||||
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentPlatform.Name) | ID: $($CurrentPlatform.Id)", "Remove")) {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms', $CurrentPlatform.Id))
|
||||
|
||||
$URI = BuildNewURI -Segments $Segments
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Method DELETE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region File Remove-NetboxDCIMRearPort.ps1
|
||||
|
||||
function Remove-NetboxDCIMRearPort {
|
||||
|
|
@ -5703,6 +5803,62 @@ function Set-NetboxDCIMInterfaceConnection {
|
|||
|
||||
#endregion
|
||||
|
||||
#region File Set-NetboxDCIMPlatform.ps1
|
||||
|
||||
function Set-NetboxDCIMPlatform {
|
||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscustomobject])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true,
|
||||
ValueFromPipelineByPropertyName = $true)]
|
||||
[uint64[]]$Id,
|
||||
|
||||
[string]$Name,
|
||||
|
||||
[ValidateLength(1, 100)]
|
||||
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
|
||||
[string]$Slug,
|
||||
|
||||
[uint64]$Manufacturer,
|
||||
|
||||
[uint64]$Config_Template,
|
||||
|
||||
[string]$Description,
|
||||
|
||||
[uint64[]]$Tags,
|
||||
|
||||
[switch]$Force
|
||||
)
|
||||
|
||||
begin {
|
||||
|
||||
}
|
||||
|
||||
process {
|
||||
foreach ($FrontPortID in $Id) {
|
||||
$CurrentPlatform = Get-NetboxDCIMPlatform -Id $FrontPortID -ErrorAction Stop
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms', $CurrentPlatform.Id))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||
|
||||
$URI = BuildNewURI -Segments $Segments
|
||||
|
||||
if ($Force -or $pscmdlet.ShouldProcess("Platform ID $($CurrentPlatform.Id)", "Set")) {
|
||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region File Set-NetboxDCIMRearPort.ps1
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue