mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-13 01:42:28 +00:00
* Add `OPTIONS` method validation * Remove parameter validation as workaround for CHOICES API endpoint until further testing * Add help block for Get-NetboxTenant * SkipConnectedCheck for Get-NetboxAPIDefinition * Correct help block for New-NetboxIPAMAddress * Add parameter position 0 for 'Address' in Get-NetboxIPAMAddress * Allow pipeline input for Address parameter in New-NetboxIPAMAddress * Update parameter types * Add parameter sets and logic for ID/Query searches * Add Get-NetboxDCIMSite * Update psproj * Update deploy.ps1 * Move Get-NetboxCircuit * Add Circuit cmdlets - New-NetboxCircuit - Get-NetboxCircuitProvider - Get-NetboxCircuitTermination - Get-NetboxCircuitType * Update deploy script output path * Update Set-NetboxIPAMAddress - Replace Interface parameter with Assigned_Object_Type and Assigned_Object_Id - Add validation logic for Assigned_Object_ parameters - Change Status parameter to string * Add Get-ModelDefinition function * Update psproj * Update deploy.ps1 variables * Update exported files * Remove references to `_choices` API calls * Add Postman collection * Add Postman collection * Update deploy.ps1 * Add Set-NetboxIPAMPrefix function * Increment version to 1.3.0 Co-authored-by: Ben Claussen <claussen@neonet.org>
92 lines
2.9 KiB
PowerShell
92 lines
2.9 KiB
PowerShell
<#
|
|
.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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|