From c736e0a1f70bd783422bb5967e5a0779ad09467c Mon Sep 17 00:00:00 2001 From: Chris Lawson Date: Wed, 22 Mar 2023 16:57:07 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=B5=20other:=20run=20of=20.\deploy=20-?= =?UTF-8?q?skipversion=20for=20testing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NetboxPS.psd1 | 66 ++++++------- NetboxPS/NetboxPS.psd1 | 66 ++++++------- NetboxPS/NetboxPS.psm1 | 208 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 276 insertions(+), 64 deletions(-) diff --git a/NetboxPS.psd1 b/NetboxPS.psd1 index b9c80d4..69a96c5 100644 --- a/NetboxPS.psd1 +++ b/NetboxPS.psd1 @@ -1,9 +1,9 @@ # -# Module manifest for module 'NetboxPS' +# Module manifest for module 'PSGet_NetboxPS' # # Generated by: Ben Claussen # -# Generated on: 2023-03-17 +# Generated on: 22/03/2023 # @{ @@ -66,35 +66,41 @@ CLRVersion = '2.0.50727' # FormatsToProcess = @() # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -NestedModules = @() +# NestedModules = @() # 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', 'Clear-NetboxCredential', - 'Connect-NetboxAPI', 'Get-ModelDefinition', 'Get-NetboxAPIDefinition', - 'Get-NetboxCircuit', 'Get-NetboxCircuitProvider', - 'Get-NetboxCircuitTermination', 'Get-NetboxCircuitType', + 'Add-NetboxVirtualMachineInterface', 'BuildNewURI', + 'BuildURIComponents', 'CheckNetboxIsConnected', + 'Clear-NetboxCredential', 'Connect-NetboxAPI', 'CreateEnum', + 'GenerateSlug', 'Get-ModelDefinition', 'Get-NetboxAPIDefinition', + 'GetNetboxAPIErrorBody', 'Get-NetboxCircuit', + 'Get-NetboxCircuitProvider', 'Get-NetboxCircuitTermination', + 'Get-NetboxCircuitType', 'GetNetboxConfigVariable', 'Get-NetboxContact', 'Get-NetboxContactAssignment', 'Get-NetboxContactRole', 'Get-NetboxContentType', 'Get-NetboxCredential', 'Get-NetboxDCIMCable', 'Get-NetboxDCIMCableTermination', 'Get-NetboxDCIMDevice', 'Get-NetboxDCIMDeviceRole', 'Get-NetboxDCIMDeviceType', - 'Get-NetboxDCIMFrontPort', 'Get-NetboxDCIMInterface', - 'Get-NetboxDCIMInterfaceConnection', 'Get-NetboxDCIMPlatform', - 'Get-NetboxDCIMRearPort', 'Get-NetboxDCIMSite', 'Get-NetboxHostname', - 'Get-NetboxHostPort', 'Get-NetboxHostScheme', - 'Get-NetboxInvokeParams', 'Get-NetboxIPAMAddress', - 'Get-NetboxIPAMAggregate', 'Get-NetboxIPAMAvailableIP', - 'Get-NetboxIPAMPrefix', 'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN', - 'Get-NetboxTag', 'Get-NetboxTenant', 'Get-NetboxTimeout', - 'Get-NetboxVersion', 'Get-NetboxVirtualizationCluster', + 'Get-NetboxDCIMDManufacture', 'Get-NetboxDCIMFrontPort', + 'Get-NetboxDCIMInterface', 'Get-NetboxDCIMInterfaceConnection', + 'Get-NetboxDCIMPlatform', 'Get-NetboxDCIMRearPort', + 'Get-NetboxDCIMSite', 'Get-NetboxHostname', 'Get-NetboxHostPort', + 'Get-NetboxHostScheme', 'Get-NetboxInvokeParams', + 'Get-NetboxIPAMAddress', 'Get-NetboxIPAMAggregate', + 'Get-NetboxIPAMAvailableIP', 'Get-NetboxIPAMPrefix', + 'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN', 'Get-NetboxTag', + 'Get-NetboxTenant', 'Get-NetboxTimeout', 'Get-NetboxVersion', + 'Get-NetboxVirtualizationCluster', 'Get-NetboxVirtualizationClusterGroup', 'Get-NetboxVirtualMachine', - 'Get-NetboxVirtualMachineInterface', 'New-NetboxCircuit', - 'New-NetboxContact', 'New-NetboxContactAssignment', - 'New-NetboxContactRole', 'New-NetboxDCIMDevice', 'New-NetboxDCIMSite', - 'New-NetboxIPAMAddress', 'New-NetboxIPAMPrefix', 'New-NetboxIPAMVLAN', - 'New-NetboxTenant', 'New-NetboxVirtualMachine', + 'Get-NetboxVirtualMachineInterface', 'InvokeNetboxRequest', + 'New-NetboxCircuit', 'New-NetboxContact', + 'New-NetboxContactAssignment', 'New-NetboxContactRole', + 'New-NetboxDCIMDevice', 'New-NetboxDCIMDeviceRole', + 'New-NetboxDCIMDeviceType', 'New-NetboxDCIMManufacture', + 'New-NetboxDCIMSite', 'New-NetboxIPAMAddress', 'New-NetboxIPAMPrefix', + 'New-NetboxIPAMVLAN', 'New-NetboxTenant', 'New-NetboxVirtualMachine', 'Remove-NetboxDCIMDevice', 'Remove-NetboxDCIMFrontPort', 'Remove-NetboxDCIMInterface', 'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort', @@ -107,16 +113,18 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface', 'Set-NetboxInvokeParams', 'Set-NetboxIPAMAddress', 'Set-NetboxIPAMPrefix', 'Set-NetboxTimeout', 'Set-NetboxUnstrustedSSL', 'Set-NetboxVirtualMachine', - 'Set-NetboxVirtualMachineInterface', 'Test-NetboxAPIConnected' + 'Set-NetboxVirtualMachineInterface', 'SetupNetboxConfigVariable', + 'Test-NetboxAPIConnected', 'ThrowNetboxRESTError', + 'VerifyAPIConnectivity' # Cmdlets 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 cmdlets to export. -CmdletsToExport = '*' +CmdletsToExport = @() # Variables to export from this module -VariablesToExport = '*' +# VariablesToExport = @() # Aliases 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 aliases to export. -AliasesToExport = '*' +AliasesToExport = @() # DSC resources to export from this module # DscResourcesToExport = @() @@ -147,14 +155,8 @@ PrivateData = @{ # ReleaseNotes of this module # ReleaseNotes = '' - # Prerelease string of this module - # Prerelease = '' - - # Flag to indicate whether the module requires explicit user acceptance for install/update/save - # RequireLicenseAcceptance = $false - # External dependent modules of this module - # ExternalModuleDependencies = @() + # ExternalModuleDependencies = '' } # End of PSData hashtable diff --git a/NetboxPS/NetboxPS.psd1 b/NetboxPS/NetboxPS.psd1 index b9c80d4..69a96c5 100644 --- a/NetboxPS/NetboxPS.psd1 +++ b/NetboxPS/NetboxPS.psd1 @@ -1,9 +1,9 @@ # -# Module manifest for module 'NetboxPS' +# Module manifest for module 'PSGet_NetboxPS' # # Generated by: Ben Claussen # -# Generated on: 2023-03-17 +# Generated on: 22/03/2023 # @{ @@ -66,35 +66,41 @@ CLRVersion = '2.0.50727' # FormatsToProcess = @() # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -NestedModules = @() +# NestedModules = @() # 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', 'Clear-NetboxCredential', - 'Connect-NetboxAPI', 'Get-ModelDefinition', 'Get-NetboxAPIDefinition', - 'Get-NetboxCircuit', 'Get-NetboxCircuitProvider', - 'Get-NetboxCircuitTermination', 'Get-NetboxCircuitType', + 'Add-NetboxVirtualMachineInterface', 'BuildNewURI', + 'BuildURIComponents', 'CheckNetboxIsConnected', + 'Clear-NetboxCredential', 'Connect-NetboxAPI', 'CreateEnum', + 'GenerateSlug', 'Get-ModelDefinition', 'Get-NetboxAPIDefinition', + 'GetNetboxAPIErrorBody', 'Get-NetboxCircuit', + 'Get-NetboxCircuitProvider', 'Get-NetboxCircuitTermination', + 'Get-NetboxCircuitType', 'GetNetboxConfigVariable', 'Get-NetboxContact', 'Get-NetboxContactAssignment', 'Get-NetboxContactRole', 'Get-NetboxContentType', 'Get-NetboxCredential', 'Get-NetboxDCIMCable', 'Get-NetboxDCIMCableTermination', 'Get-NetboxDCIMDevice', 'Get-NetboxDCIMDeviceRole', 'Get-NetboxDCIMDeviceType', - 'Get-NetboxDCIMFrontPort', 'Get-NetboxDCIMInterface', - 'Get-NetboxDCIMInterfaceConnection', 'Get-NetboxDCIMPlatform', - 'Get-NetboxDCIMRearPort', 'Get-NetboxDCIMSite', 'Get-NetboxHostname', - 'Get-NetboxHostPort', 'Get-NetboxHostScheme', - 'Get-NetboxInvokeParams', 'Get-NetboxIPAMAddress', - 'Get-NetboxIPAMAggregate', 'Get-NetboxIPAMAvailableIP', - 'Get-NetboxIPAMPrefix', 'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN', - 'Get-NetboxTag', 'Get-NetboxTenant', 'Get-NetboxTimeout', - 'Get-NetboxVersion', 'Get-NetboxVirtualizationCluster', + 'Get-NetboxDCIMDManufacture', 'Get-NetboxDCIMFrontPort', + 'Get-NetboxDCIMInterface', 'Get-NetboxDCIMInterfaceConnection', + 'Get-NetboxDCIMPlatform', 'Get-NetboxDCIMRearPort', + 'Get-NetboxDCIMSite', 'Get-NetboxHostname', 'Get-NetboxHostPort', + 'Get-NetboxHostScheme', 'Get-NetboxInvokeParams', + 'Get-NetboxIPAMAddress', 'Get-NetboxIPAMAggregate', + 'Get-NetboxIPAMAvailableIP', 'Get-NetboxIPAMPrefix', + 'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN', 'Get-NetboxTag', + 'Get-NetboxTenant', 'Get-NetboxTimeout', 'Get-NetboxVersion', + 'Get-NetboxVirtualizationCluster', 'Get-NetboxVirtualizationClusterGroup', 'Get-NetboxVirtualMachine', - 'Get-NetboxVirtualMachineInterface', 'New-NetboxCircuit', - 'New-NetboxContact', 'New-NetboxContactAssignment', - 'New-NetboxContactRole', 'New-NetboxDCIMDevice', 'New-NetboxDCIMSite', - 'New-NetboxIPAMAddress', 'New-NetboxIPAMPrefix', 'New-NetboxIPAMVLAN', - 'New-NetboxTenant', 'New-NetboxVirtualMachine', + 'Get-NetboxVirtualMachineInterface', 'InvokeNetboxRequest', + 'New-NetboxCircuit', 'New-NetboxContact', + 'New-NetboxContactAssignment', 'New-NetboxContactRole', + 'New-NetboxDCIMDevice', 'New-NetboxDCIMDeviceRole', + 'New-NetboxDCIMDeviceType', 'New-NetboxDCIMManufacture', + 'New-NetboxDCIMSite', 'New-NetboxIPAMAddress', 'New-NetboxIPAMPrefix', + 'New-NetboxIPAMVLAN', 'New-NetboxTenant', 'New-NetboxVirtualMachine', 'Remove-NetboxDCIMDevice', 'Remove-NetboxDCIMFrontPort', 'Remove-NetboxDCIMInterface', 'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort', @@ -107,16 +113,18 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface', 'Set-NetboxInvokeParams', 'Set-NetboxIPAMAddress', 'Set-NetboxIPAMPrefix', 'Set-NetboxTimeout', 'Set-NetboxUnstrustedSSL', 'Set-NetboxVirtualMachine', - 'Set-NetboxVirtualMachineInterface', 'Test-NetboxAPIConnected' + 'Set-NetboxVirtualMachineInterface', 'SetupNetboxConfigVariable', + 'Test-NetboxAPIConnected', 'ThrowNetboxRESTError', + 'VerifyAPIConnectivity' # Cmdlets 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 cmdlets to export. -CmdletsToExport = '*' +CmdletsToExport = @() # Variables to export from this module -VariablesToExport = '*' +# VariablesToExport = @() # Aliases 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 aliases to export. -AliasesToExport = '*' +AliasesToExport = @() # DSC resources to export from this module # DscResourcesToExport = @() @@ -147,14 +155,8 @@ PrivateData = @{ # ReleaseNotes of this module # ReleaseNotes = '' - # Prerelease string of this module - # Prerelease = '' - - # Flag to indicate whether the module requires explicit user acceptance for install/update/save - # RequireLicenseAcceptance = $false - # External dependent modules of this module - # ExternalModuleDependencies = @() + # ExternalModuleDependencies = '' } # End of PSData hashtable diff --git a/NetboxPS/NetboxPS.psm1 b/NetboxPS/NetboxPS.psm1 index 87e5c9f..4b45566 100644 --- a/NetboxPS/NetboxPS.psm1 +++ b/NetboxPS/NetboxPS.psm1 @@ -655,6 +655,27 @@ public enum $EnumName #endregion +#region File GenerateSlug.ps1 + +function GenerateSlug { + [CmdletBinding()] + [OutputType([string])] + param ( + [Parameter(Mandatory = $true)] + [string]$Slug + ) + + Write-Verbose "Generating slug" + + $Slug = $Slug.Replace("-", "").Replace(" ", "-").ToLower() + + Write-Verbose " Completed building URIBuilder" + # Return the entire UriBuilder object + $Slug +} + +#endregion + #region File Get-ModelDefinition.ps1 @@ -1811,6 +1832,61 @@ function Get-NetboxDCIMDeviceType { #endregion +#region File Get-NetboxDCIMDManufacture.ps1 + + +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 + + } + } + +} + +#endregion + #region File Get-NetboxDCIMFrontPort.ps1 function Get-NetboxDCIMFrontPort { @@ -3900,6 +3976,138 @@ function New-NetboxDCIMDevice { #endregion +#region File New-NetboxDCIMDeviceRole.ps1 + + +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 + } +} + +#endregion + +#region File New-NetboxDCIMDeviceType.ps1 + + +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 + } +} + +#endregion + +#region File New-NetboxDCIMManufacture.ps1 + + +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 + } +} + +#endregion + #region File New-NetboxDCIMSite.ps1 <#