Rename ValidateIPAMChoices and ValidateVirtualizationChoices to singluar Choice

This commit is contained in:
Ben Claussen 2018-05-23 11:09:51 -04:00
parent b50375722e
commit b8bfcf33e3
3 changed files with 18 additions and 19 deletions

View file

@ -23,7 +23,7 @@ function Get-NetboxIPAMChoices {
InvokeNetboxRequest -URI $uri
}
function VerifyIPAMChoices {
function ValidateIPAMChoice {
<#
.SYNOPSIS
Internal function to verify provided values for static choices
@ -60,10 +60,10 @@ function VerifyIPAMChoices {
Verify against service protocol values
.EXAMPLE
PS C:\> VerifyIPAMChoices -ProvidedValue 'loopback' -IPAddressRole
PS C:\> ValidateIPAMChoice -ProvidedValue 'loopback' -IPAddressRole
.EXAMPLE
PS C:\> VerifyIPAMChoices -ProvidedValue 'Loopback' -IPAddressFamily
PS C:\> ValidateIPAMChoice -ProvidedValue 'Loopback' -IPAddressFamily
>> Invalid value Loopback for ip-address:family. Must be one of: 4, 6, IPv4, IPv6
.OUTPUTS
@ -122,7 +122,6 @@ function VerifyIPAMChoices {
function Get-NetboxIPAMAggregate {
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
param
(
[uint16]$Limit,
@ -145,7 +144,7 @@ function Get-NetboxIPAMAggregate {
)
if ($null -ne $Family) {
$PSBoundParameters.Family = VerifyIPAMChoices -ProvidedValue $Family -AggregateFamily
$PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -AggregateFamily
}
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates'))
@ -201,15 +200,15 @@ function Get-NetboxIPAMAddress {
)
if ($null -ne $Family) {
$PSBoundParameters.Family = VerifyIPAMChoices -ProvidedValue $Family -IPAddressFamily
$PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -IPAddressFamily
}
if ($null -ne $Status) {
$PSBoundParameters.Status = VerifyIPAMChoices -ProvidedValue $Status -IPAddressStatus
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
}
if ($null -ne $Role) {
$PSBoundParameters.Role = VerifyIPAMChoices -ProvidedValue $Role -IPAddressRole
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
}
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
@ -398,11 +397,11 @@ function Get-NetboxIPAMPrefix {
)
if ($null -ne $Family) {
$PSBoundParameters.Family = VerifyIPAMChoices -ProvidedValue $Family -PrefixFamily
$PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -PrefixFamily
}
if ($null -ne $Status) {
$PSBoundParameters.Status = VerifyIPAMChoices -ProvidedValue $Status -PrefixStatus
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
}
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
@ -485,10 +484,10 @@ function New-NetboxIPAMAddress {
[switch]$Raw
)
$PSBoundParameters.Status = VerifyIPAMChoices -ProvidedValue $Status -IPAddressStatus
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
if ($null -ne $Role) {
$PSBoundParameters.Role = VerifyIPAMChoices -ProvidedValue $Role -IPAddressRole
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
}
$segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
@ -580,11 +579,11 @@ function Set-NetboxIPAMAddress {
)
if ($Status) {
$PSBoundParameters.Status = VerifyIPAMChoices -ProvidedValue $Status -IPAddressStatus
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
}
if ($Role) {
$PSBoundParameters.Role = VerifyIPAMChoices -ProvidedValue $Role -IPAddressRole
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
}
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $Id))

View file

@ -11,7 +11,7 @@
Virtualization object functions
#>
function ValidateVirtualizationChoices {
function ValidateVirtualizationChoice {
<#
.SYNOPSIS
Internal function to verify provided values for static choices
@ -219,7 +219,7 @@ function Get-NetboxVirtualMachine {
)
if ($null -ne $Status) {
$PSBoundParameters.Status = ValidateVirtualizationChoices -ProvidedValue $Status -VirtualMachineStatus
$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
}
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
@ -491,7 +491,7 @@ function New-NetboxVirtualMachine {
[string]$Comments
)
$PSBoundParameters.Status = ValidateVirtualizationChoices -ProvidedValue $Status -VirtualMachineStatus
$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
@ -578,7 +578,7 @@ function Set-NetboxVirtualMachine {
)
if ($null -ne $Status) {
$PSBoundParameters.Status = ValidateVirtualizationChoices -ProvidedValue $Status -VirtualMachineStatus
$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
}
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $Id))

View file

@ -49,7 +49,7 @@ Describe -Name "IPAM tests" -Tag 'Ipam' -Fixture {
InModuleScope -ModuleName 'NetboxPS' -ScriptBlock {
$script:NetboxConfig.Choices.IPAM = (Get-Content "$PSScriptRoot\IPAMChoices.json" -ErrorAction Stop | ConvertFrom-Json)
Context -Name "VerifyIPAMChoices" -Fixture {
Context -Name "ValidateIPAMChoice" -Fixture {
#It "Should return a valid integer"
}