From b8bfcf33e32e5dfcc1a7c6ae4a410d95685b9d60 Mon Sep 17 00:00:00 2001 From: Ben Claussen Date: Wed, 23 May 2018 11:09:51 -0400 Subject: [PATCH] Rename ValidateIPAMChoices and ValidateVirtualizationChoices to singluar Choice --- Functions/IPAM/IPAM.ps1 | 27 ++++++++++----------- Functions/Virtualization/Virtualization.ps1 | 8 +++--- Tests/IPAM.Tests.ps1 | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Functions/IPAM/IPAM.ps1 b/Functions/IPAM/IPAM.ps1 index b00ec08..2af915e 100644 --- a/Functions/IPAM/IPAM.ps1 +++ b/Functions/IPAM/IPAM.ps1 @@ -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)) diff --git a/Functions/Virtualization/Virtualization.ps1 b/Functions/Virtualization/Virtualization.ps1 index 5c3c845..ada1bb6 100644 --- a/Functions/Virtualization/Virtualization.ps1 +++ b/Functions/Virtualization/Virtualization.ps1 @@ -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)) diff --git a/Tests/IPAM.Tests.ps1 b/Tests/IPAM.Tests.ps1 index 438f342..47e8447 100644 --- a/Tests/IPAM.Tests.ps1 +++ b/Tests/IPAM.Tests.ps1 @@ -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" }