mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-13 18:02:29 +00:00
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
This commit is contained in:
parent
b4803a5697
commit
cc52fdc844
1 changed files with 28 additions and 19 deletions
|
|
@ -23,7 +23,7 @@ function Set-NetboxIPAMAddress {
|
|||
|
||||
[string]$Address,
|
||||
|
||||
[object]$Status,
|
||||
[string]$Status,
|
||||
|
||||
[uint16]$Tenant,
|
||||
|
||||
|
|
@ -35,7 +35,10 @@ function Set-NetboxIPAMAddress {
|
|||
|
||||
[hashtable]$Custom_Fields,
|
||||
|
||||
[uint16]$Interface,
|
||||
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
||||
[string]$Assigned_Object_Type,
|
||||
|
||||
[uint16]$Assigned_Object_Id,
|
||||
|
||||
[string]$Description,
|
||||
|
||||
|
|
@ -43,28 +46,34 @@ function Set-NetboxIPAMAddress {
|
|||
)
|
||||
|
||||
begin {
|
||||
# Write-Verbose "Validating enum properties"
|
||||
# $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', 0))
|
||||
# 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"
|
||||
#
|
||||
# # 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 ($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"
|
||||
}
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IPId))
|
||||
|
||||
Write-Verbose "Obtaining IP from ID $IPId"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue