From 6d00855644fdc978bbdae2738a78010899c16e1e Mon Sep 17 00:00:00 2001 From: Ben Claussen Date: Thu, 25 Mar 2021 16:45:40 -0400 Subject: [PATCH] Increment version to 1.3.0 --- NetboxPS.psd1 | 4 +- NetboxPS.psproj | 2 +- NetboxPS/NetboxPS.psd1 | 4 +- NetboxPS/NetboxPS.psm1 | 107 +++++++++++++++++++++++++++++++++++++++-- 4 files changed, 108 insertions(+), 9 deletions(-) diff --git a/NetboxPS.psd1 b/NetboxPS.psd1 index 787786b..1a2fe44 100644 --- a/NetboxPS.psd1 +++ b/NetboxPS.psd1 @@ -3,7 +3,7 @@ # # Generated by: Ben Claussen # -# Generated on: 2020-12-08 +# Generated on: 2021-03-25 # @{ @@ -12,7 +12,7 @@ RootModule = 'NetboxPS.psm1' # Version number of this module. -ModuleVersion = '1.2.2' +ModuleVersion = '1.3.0' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/NetboxPS.psproj b/NetboxPS.psproj index b1f5a6f..7fc51c9 100644 --- a/NetboxPS.psproj +++ b/NetboxPS.psproj @@ -103,7 +103,7 @@ Functions\Circuits\Providers\Get-NetboxCircuitProvider.ps1 Functions\Circuits\Types\Get-NetboxCircuitType.ps1 Functions\Helpers\Get-ModelDefinition.ps1 - Functions\IPAM\Prefix\Set-NetboxIPAMPrefix.ps1 + Functions\IPAM\Prefix\Set-NetboxIPAMPrefix.ps1 R:\Netbox\NetboxPS\Test-Module.ps1 \ No newline at end of file diff --git a/NetboxPS/NetboxPS.psd1 b/NetboxPS/NetboxPS.psd1 index 787786b..1a2fe44 100644 --- a/NetboxPS/NetboxPS.psd1 +++ b/NetboxPS/NetboxPS.psd1 @@ -3,7 +3,7 @@ # # Generated by: Ben Claussen # -# Generated on: 2020-12-08 +# Generated on: 2021-03-25 # @{ @@ -12,7 +12,7 @@ RootModule = 'NetboxPS.psm1' # Version number of this module. -ModuleVersion = '1.2.2' +ModuleVersion = '1.3.0' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/NetboxPS/NetboxPS.psm1 b/NetboxPS/NetboxPS.psm1 index 1ba04dd..1583b40 100644 --- a/NetboxPS/NetboxPS.psm1 +++ b/NetboxPS/NetboxPS.psm1 @@ -4300,10 +4300,12 @@ function Set-NetboxIPAMAddress { process { foreach ($IPId in $Id) { - if ((-not [string]::IsNullOrWhiteSpace($Assigned_Object_Id))-and [string]::IsNullOrWhiteSpace($Assigned_Object_Type)) { - throw "Assigned_Object_Type is required when specifying Assigned_Object_Id" - } elseif ((-not [string]::IsNullOrWhiteSpace($Assigned_Object_Type)) -and [string]::IsNullOrWhiteSpace($Assigned_Object_Id)) { - throw "Assigned_Object_Id is required when specifying Assigned_Object_Type" + if ($PSBoundParameters.ContainsKey('Assigned_Object_Type') -or $PSBoundParameters.ContainsKey('Assigned_Object_Id')) { + if ((-not [string]::IsNullOrWhiteSpace($Assigned_Object_Id)) -and [string]::IsNullOrWhiteSpace($Assigned_Object_Type)) { + throw "Assigned_Object_Type is required when specifying Assigned_Object_Id" + } elseif ((-not [string]::IsNullOrWhiteSpace($Assigned_Object_Type)) -and [string]::IsNullOrWhiteSpace($Assigned_Object_Id)) { + throw "Assigned_Object_Id is required when specifying Assigned_Object_Type" + } } $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IPId)) @@ -4322,6 +4324,103 @@ function Set-NetboxIPAMAddress { } } +#endregion + +#region File Set-NetboxIPAMPrefix.ps1 + +<# + .NOTES + =========================================================================== + Created with: SAPIEN Technologies, Inc., PowerShell Studio 2021 v5.8.186 + Created on: 2021-03-23 13:54 + Created by: Claussen + Organization: NEOnet + Filename: Set-NetboxIPAMPrefix.ps1 + =========================================================================== + .DESCRIPTION + A description of the file. +#> + + +function Set-NetboxIPAMPrefix { + [CmdletBinding(ConfirmImpact = 'Medium', + SupportsShouldProcess = $true)] + param + ( + [Parameter(Mandatory = $true, + ValueFromPipelineByPropertyName = $true)] + [uint16[]]$Id, + + [string]$Prefix, + + [string]$Status, + + [uint16]$Tenant, + + [uint16]$Site, + + [uint16]$VRF, + + [uint16]$VLAN, + + [object]$Role, + + [hashtable]$Custom_Fields, + + [string]$Description, + + [switch]$Is_Pool, + + [switch]$Force + ) + + begin { + # Write-Verbose "Validating enum properties" + # $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', 0)) + $Method = 'PATCH' + # + # # Value validation + # $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method + # $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition + # + # foreach ($Property in $EnumProperties.Keys) { + # if ($PSBoundParameters.ContainsKey($Property)) { + # Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]" + # $PSBoundParameters.$Property = ValidateValue -ModelDefinition $ModelDefinition -Property $Property -ProvidedValue $PSBoundParameters.$Property + # } else { + # Write-Verbose "User did not provide a value for [$Property]" + # } + # } + # + # Write-Verbose "Finished enum validation" + } + + process { + foreach ($PrefixId in $Id) { + $Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $PrefixId)) + + Write-Verbose "Obtaining Prefix from ID $PrefixId" + $CurrentPrefix = Get-NetboxIPAMPrefix -Id $PrefixId -ErrorAction Stop + + if ($Force -or $PSCmdlet.ShouldProcess($CurrentPrefix.Prefix, 'Set')) { + $URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force' + + $URI = BuildNewURI -Segments $URIComponents.Segments + + InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method + } + } + } +} + + + + + + + + + #endregion #region File Set-NetboxVirtualMachine.ps1