Add Set-NetboxIPAMPrefix function

This commit is contained in:
Ben Claussen 2021-03-23 14:39:08 -04:00
parent e11dfe726b
commit ad4c80e4f6
2 changed files with 93 additions and 0 deletions

View file

@ -0,0 +1,92 @@
<#
.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
}
}
}
}

View file

@ -103,6 +103,7 @@
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxCircuitProvider_ps1" ExportFunctions="True">Functions\Circuits\Providers\Get-NetboxCircuitProvider.ps1</File>
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxCircuitType_ps1" ExportFunctions="True">Functions\Circuits\Types\Get-NetboxCircuitType.ps1</File>
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-ModelDefinition_ps1" ExportFunctions="True">Functions\Helpers\Get-ModelDefinition.ps1</File>
<File Build="2" Shared="True" ReferenceFunction="Invoke-Set-NetboxIPAMPrefix_ps1" ExportFunctions="False">Functions\IPAM\Prefix\Set-NetboxIPAMPrefix.ps1</File>
</Files>
<StartupScript>R:\Netbox\NetboxPS\Test-Module.ps1</StartupScript>
</Project>