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
|
|
@ -1,14 +1,14 @@
|
||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
Created on: 3/19/2020 11:51
|
Created on: 3/19/2020 11:51
|
||||||
Created by: Claussen
|
Created by: Claussen
|
||||||
Organization: NEOnet
|
Organization: NEOnet
|
||||||
Filename: New-NetboxIPAMAddress.ps1
|
Filename: New-NetboxIPAMAddress.ps1
|
||||||
===========================================================================
|
===========================================================================
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
A description of the file.
|
A description of the file.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -50,14 +50,19 @@ function New-NetboxIPAMAddress {
|
||||||
.PARAMETER Dns_name
|
.PARAMETER Dns_name
|
||||||
DNS Name of IP address (example : netbox.example.com)
|
DNS Name of IP address (example : netbox.example.com)
|
||||||
|
|
||||||
.PARAMETER Force
|
.PARAMETER Assigned_Object_Type
|
||||||
Do not prompt for confirmation to create IP.
|
Assigned Object Type dcim.interface or virtualization.vminterface
|
||||||
|
|
||||||
|
.PARAMETER Assigned_Object_Id
|
||||||
|
Assigned Object ID
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return raw results from API service
|
Return raw results from API service
|
||||||
|
|
||||||
.EXAMPLE
|
.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
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
|
|
@ -90,7 +95,10 @@ function New-NetboxIPAMAddress {
|
||||||
|
|
||||||
[string]$Dns_name,
|
[string]$Dns_name,
|
||||||
|
|
||||||
[switch]$Force,
|
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
||||||
|
[string]$Assigned_Object_Type,
|
||||||
|
|
||||||
|
[int]$Assigned_Object_Id,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
@ -99,22 +107,11 @@ function New-NetboxIPAMAddress {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
||||||
$Method = 'POST'
|
$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
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$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
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue