mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-13 18:02:29 +00:00
Add Assigned Object (Type and ID) to New IPAM Address (#19)
* IPAMAddress(New): Remove tab (use 4 spaces) * IPAMAddress(New): Remove not longer needed code about value validation * IPAMAddress(New): Add Assigned Object Type and ID Fix #17 * IPAMAddress(New): add Parameter example * IPAMAddress(New): Add Validate for Assigned Object Type Can be only dcim.interface or virtualization.vminterface * IPAMAddress(New): Fix Example (it is New and not Create Verb !) * IPAMAddress(New): Remove -Force parameter, use -Confirm if you want a confirmation it is the standard with ShouldProcess
This commit is contained in:
parent
11ae767a6c
commit
ddf1d22e18
1 changed files with 23 additions and 26 deletions
|
|
@ -50,14 +50,19 @@ function New-NetboxIPAMAddress {
|
|||
.PARAMETER Dns_name
|
||||
DNS Name of IP address (example : netbox.example.com)
|
||||
|
||||
.PARAMETER Force
|
||||
Do not prompt for confirmation to create IP.
|
||||
.PARAMETER Assigned_Object_Type
|
||||
Assigned Object Type dcim.interface or virtualization.vminterface
|
||||
|
||||
.PARAMETER Assigned_Object_Id
|
||||
Assigned Object ID
|
||||
|
||||
.PARAMETER Raw
|
||||
Return raw results from API service
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> Create-NetboxIPAMAddress
|
||||
New-NetboxIPAMAddress -Address 192.0.2.1/32
|
||||
|
||||
Add new IP Address 192.0.2.1/32 with status active
|
||||
|
||||
.NOTES
|
||||
Additional information about the function.
|
||||
|
|
@ -90,7 +95,10 @@ function New-NetboxIPAMAddress {
|
|||
|
||||
[string]$Dns_name,
|
||||
|
||||
[switch]$Force,
|
||||
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
||||
[string]$Assigned_Object_Type,
|
||||
|
||||
[int]$Assigned_Object_Id,
|
||||
|
||||
[switch]$Raw
|
||||
)
|
||||
|
|
@ -99,22 +107,11 @@ function New-NetboxIPAMAddress {
|
|||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
||||
$Method = 'POST'
|
||||
|
||||
# # 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
|
||||
# }
|
||||
# }
|
||||
#
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
if ($Force -or $PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
||||
if ($PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue