(WIP) Enhance IPAM Address (#4)

* Address(IPAM): Fix trailing whitespace (with Visual Code Formater)

* Address(IPAM): Fix PSSA about Command accepts pipeline input but not defined a process block

* Address(IPAM): Add dns_name parameter to Add and Set

* Address(IPAM): all integer are [int] (not uint16)
This commit is contained in:
Alexis La Goutte 2021-03-30 16:34:25 +02:00 committed by GitHub
parent cfb53cf933
commit 2595c58eaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 164 additions and 152 deletions

View file

@ -46,14 +46,15 @@ function Get-NetboxIPAMAvailableIP {
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[Alias('Id')]
[uint16]$Prefix_ID,
[int]$Prefix_ID,
[Alias('NumberOfIPs')]
[uint16]$Limit,
[int]$Limit,
[switch]$Raw
)
process {
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $Prefix_ID, 'available-ips'))
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'prefix_id'
@ -62,3 +63,4 @@ function Get-NetboxIPAMAvailableIP {
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
}

View file

@ -47,6 +47,9 @@ function New-NetboxIPAMAddress {
.PARAMETER Description
Description of IP address
.PARAMETER Dns_name
DNS Name of IP address (example : netbox.example.com)
.PARAMETER Force
Do not prompt for confirmation to create IP.
@ -71,25 +74,28 @@ function New-NetboxIPAMAddress {
[object]$Status = 'Active',
[uint16]$Tenant,
[int]$Tenant,
[uint16]$VRF,
[int]$VRF,
[object]$Role,
[uint16]$NAT_Inside,
[int]$NAT_Inside,
[hashtable]$Custom_Fields,
[uint16]$Interface,
[int]$Interface,
[string]$Description,
[string]$Dns_name,
[switch]$Force,
[switch]$Raw
)
process {
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
$Method = 'POST'
@ -112,6 +118,7 @@ function New-NetboxIPAMAddress {
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
}
}
}

View file

@ -38,7 +38,7 @@ function Remove-NetboxIPAMAddress {
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
[int[]]$Id,
[switch]$Force
)

View file

@ -19,19 +19,19 @@ function Set-NetboxIPAMAddress {
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
[int[]]$Id,
[string]$Address,
[string]$Status,
[uint16]$Tenant,
[int]$Tenant,
[uint16]$VRF,
[int]$VRF,
[object]$Role,
[uint16]$NAT_Inside,
[int]$NAT_Inside,
[hashtable]$Custom_Fields,
@ -42,6 +42,8 @@ function Set-NetboxIPAMAddress {
[string]$Description,
[string]$Dns_name,
[switch]$Force
)
@ -71,7 +73,8 @@ function Set-NetboxIPAMAddress {
if ($PSBoundParameters.ContainsKey('Assigned_Object_Type') -or $PSBoundParameters.ContainsKey('Assigned_Object_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)) {
}
elseif ((-not [string]::IsNullOrWhiteSpace($Assigned_Object_Type)) -and [string]::IsNullOrWhiteSpace($Assigned_Object_Id)) {
throw "Assigned_Object_Id is required when specifying Assigned_Object_Type"
}
}