mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-13 18:02:29 +00:00
Push compiled module
This commit is contained in:
parent
32b7db1eb7
commit
8194acb5eb
1 changed files with 497 additions and 325 deletions
822
dist/NetboxPS.psm1
vendored
822
dist/NetboxPS.psm1
vendored
|
|
@ -1,8 +1,8 @@
|
|||
<#
|
||||
.NOTES
|
||||
--------------------------------------------------------------------------------
|
||||
Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.152
|
||||
Generated on: 5/29/2018 10:42 AM
|
||||
Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.154
|
||||
Generated on: 10/18/2018 3:45 PM
|
||||
Generated by: Ben Claussen
|
||||
Organization: NEOnet
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
@ -173,21 +173,41 @@
|
|||
continue
|
||||
}
|
||||
|
||||
if ($CmdletParameterName -eq 'Id') {
|
||||
# Check if there is one or more values for Id and build a URI or query as appropriate
|
||||
if (@($ParametersDictionary[$CmdletParameterName]).Count -gt 1) {
|
||||
Write-Verbose " Joining IDs for parameter"
|
||||
$URIParameters['id__in'] = $ParametersDictionary[$CmdletParameterName] -join ','
|
||||
} else {
|
||||
Write-Verbose " Adding ID to segments"
|
||||
[void]$uriSegments.Add($ParametersDictionary[$CmdletParameterName])
|
||||
switch ($CmdletParameterName) {
|
||||
"id" {
|
||||
# Check if there is one or more values for Id and build a URI or query as appropriate
|
||||
if (@($ParametersDictionary[$CmdletParameterName]).Count -gt 1) {
|
||||
Write-Verbose " Joining IDs for parameter"
|
||||
$URIParameters['id__in'] = $ParametersDictionary[$CmdletParameterName] -join ','
|
||||
} else {
|
||||
Write-Verbose " Adding ID to segments"
|
||||
[void]$uriSegments.Add($ParametersDictionary[$CmdletParameterName])
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
'Query' {
|
||||
Write-Verbose " Adding query parameter"
|
||||
$URIParameters['q'] = $ParametersDictionary[$CmdletParameterName]
|
||||
break
|
||||
}
|
||||
|
||||
'CustomFields' {
|
||||
Write-Verbose " Adding custom field query parameters"
|
||||
foreach ($field in $ParametersDictionary[$CmdletParameterName].GetEnumerator()) {
|
||||
Write-Verbose " Adding parameter 'cf_$($field.Key) = $($field.Value)"
|
||||
$URIParameters["cf_$($field.Key.ToLower())"] = $field.Value
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
default {
|
||||
Write-Verbose " Adding $($CmdletParameterName.ToLower()) parameter"
|
||||
$URIParameters[$CmdletParameterName.ToLower()] = $ParametersDictionary[$CmdletParameterName]
|
||||
break
|
||||
}
|
||||
} elseif ($CmdletParameterName -eq 'Query') {
|
||||
Write-Verbose " Adding query parameter"
|
||||
$URIParameters['q'] = $ParametersDictionary[$CmdletParameterName]
|
||||
} else {
|
||||
Write-Verbose " Adding $($CmdletParameterName.ToLower()) parameter"
|
||||
$URIParameters[$CmdletParameterName.ToLower()] = $ParametersDictionary[$CmdletParameterName]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -454,29 +474,6 @@ public enum $EnumName
|
|||
to a Netbox API
|
||||
#>
|
||||
|
||||
function SetupNetboxConfigVariable {
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[switch]$Overwrite
|
||||
)
|
||||
|
||||
Write-Verbose "Checking for NetboxConfig hashtable"
|
||||
if ((-not ($script:NetboxConfig)) -or $Overwrite) {
|
||||
Write-Verbose "Creating NetboxConfig hashtable"
|
||||
$script:NetboxConfig = @{
|
||||
'Connected' = $false
|
||||
'Choices' = @{}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Verbose "NetboxConfig hashtable already exists"
|
||||
}
|
||||
|
||||
function GetNetboxConfigVariable {
|
||||
return $script:NetboxConfig
|
||||
}
|
||||
|
||||
function Set-NetboxHostName {
|
||||
[CmdletBinding(ConfirmImpact = 'Low',
|
||||
SupportsShouldProcess = $true)]
|
||||
|
|
@ -550,17 +547,6 @@ public enum $EnumName
|
|||
$script:NetboxConfig.Credential
|
||||
}
|
||||
|
||||
function VerifyAPIConnectivity {
|
||||
[CmdletBinding()]
|
||||
param ()
|
||||
|
||||
$uriSegments = [System.Collections.ArrayList]::new(@('extras', '_choices'))
|
||||
|
||||
$uri = BuildNewURI -Segments $uriSegments -SkipConnectedCheck
|
||||
|
||||
InvokeNetboxRequest -URI $uri
|
||||
}
|
||||
|
||||
function Connect-NetboxAPI {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
|
@ -629,7 +615,7 @@ public enum $EnumName
|
|||
$script:NetboxConfig.Choices.Extras = Get-NetboxExtrasChoices
|
||||
$script:NetboxConfig.Choices.IPAM = Get-NetboxIPAMChoices
|
||||
#$script:NetboxConfig.Choices.Secrets = Get-NetboxSecretsChoices # Not completed yet
|
||||
#$script:NetboxConfig.Choices.Tenancy = Get-NetboxTenancyChoices # Not completed yet
|
||||
#$script:NetboxConfig.Choices.Tenancy = Get-NetboxTenancyChoices
|
||||
$script:NetboxConfig.Choices.Virtualization = Get-NetboxVirtualizationChoices
|
||||
|
||||
Write-Verbose "Connection process completed"
|
||||
|
|
@ -796,70 +782,6 @@ public enum $EnumName
|
|||
Virtualization object functions
|
||||
#>
|
||||
|
||||
function ValidateVirtualizationChoice {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Internal function to verify provided values for static choices
|
||||
|
||||
.DESCRIPTION
|
||||
When users connect to the API, choices for each major object are cached to the config variable.
|
||||
These values are then utilized to verify if the provided value from a user is valid.
|
||||
|
||||
.PARAMETER ProvidedValue
|
||||
The value to validate against static choices
|
||||
|
||||
.PARAMETER AggregateFamily
|
||||
Verify against aggregate family values
|
||||
|
||||
.PARAMETER PrefixFamily
|
||||
Verify against prefix family values
|
||||
|
||||
.PARAMETER PrefixStatus
|
||||
Verify against prefix status values
|
||||
|
||||
.PARAMETER IPAddressFamily
|
||||
Verify against ip-address family values
|
||||
|
||||
.PARAMETER IPAddressStatus
|
||||
Verify against ip-address status values
|
||||
|
||||
.PARAMETER IPAddressRole
|
||||
Verify against ip-address role values
|
||||
|
||||
.PARAMETER VLANStatus
|
||||
Verify against VLAN status values
|
||||
|
||||
.PARAMETER ServiceProtocol
|
||||
Verify against service protocol values
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> VerifyIPAMChoices -ProvidedValue 'loopback' -IPAddressRole
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> VerifyIPAMChoices -ProvidedValue 'Loopback' -IPAddressFamily
|
||||
>> Invalid value Loopback for ip-address:family. Must be one of: 4, 6, IPv4, IPv6
|
||||
|
||||
.FUNCTIONALITY
|
||||
This cmdlet is intended to be used internally and not exposed to the user
|
||||
|
||||
.OUTPUT
|
||||
This function returns nothing if the value is valid. Otherwise, it will throw an error.
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object]$ProvidedValue,
|
||||
|
||||
[Parameter(ParameterSetName = 'virtual-machine:status',
|
||||
Mandatory = $true)]
|
||||
[switch]$VirtualMachineStatus
|
||||
)
|
||||
|
||||
ValidateChoice -MajorObject 'Virtualization' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
|
||||
}
|
||||
|
||||
#region GET commands
|
||||
|
||||
function Get-NetboxVirtualizationChoices {
|
||||
|
|
@ -1271,6 +1193,10 @@ public enum $EnumName
|
|||
|
||||
[uint16]$Disk,
|
||||
|
||||
[uint16]$Primary_IP4,
|
||||
|
||||
[uint16]$Primary_IP6,
|
||||
|
||||
[hashtable]$Custom_Fields,
|
||||
|
||||
[string]$Comments
|
||||
|
|
@ -1325,7 +1251,7 @@ public enum $EnumName
|
|||
#region SET commands
|
||||
|
||||
function Set-NetboxVirtualMachine {
|
||||
[CmdletBinding(ConfirmImpact = 'High',
|
||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||
SupportsShouldProcess = $true)]
|
||||
param
|
||||
(
|
||||
|
|
@ -1343,9 +1269,9 @@ public enum $EnumName
|
|||
|
||||
[uint16]$Platform,
|
||||
|
||||
[uint16]$Primary_IPv4,
|
||||
[uint16]$Primary_IP4,
|
||||
|
||||
[uint16]$Primary_IPv6,
|
||||
[uint16]$Primary_IP6,
|
||||
|
||||
[byte]$VCPUs,
|
||||
|
||||
|
|
@ -1548,102 +1474,7 @@ public enum $EnumName
|
|||
InvokeNetboxRequest -URI $uri
|
||||
}
|
||||
|
||||
function ValidateIPAMChoice {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Internal function to verify provided values for static choices
|
||||
|
||||
.DESCRIPTION
|
||||
When users connect to the API, choices for each major object are cached to the config variable.
|
||||
These values are then utilized to verify if the provided value from a user is valid.
|
||||
|
||||
.PARAMETER ProvidedValue
|
||||
The value to validate against static choices
|
||||
|
||||
.PARAMETER AggregateFamily
|
||||
Verify against aggregate family values
|
||||
|
||||
.PARAMETER PrefixFamily
|
||||
Verify against prefix family values
|
||||
|
||||
.PARAMETER PrefixStatus
|
||||
Verify against prefix status values
|
||||
|
||||
.PARAMETER IPAddressFamily
|
||||
Verify against ip-address family values
|
||||
|
||||
.PARAMETER IPAddressStatus
|
||||
Verify against ip-address status values
|
||||
|
||||
.PARAMETER IPAddressRole
|
||||
Verify against ip-address role values
|
||||
|
||||
.PARAMETER VLANStatus
|
||||
Verify against VLAN status values
|
||||
|
||||
.PARAMETER ServiceProtocol
|
||||
Verify against service protocol values
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> ValidateIPAMChoice -ProvidedValue 'loopback' -IPAddressRole
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> ValidateIPAMChoice -ProvidedValue 'Loopback' -IPAddressFamily
|
||||
>> Invalid value Loopback for ip-address:family. Must be one of: 4, 6, IPv4, IPv6
|
||||
|
||||
.OUTPUTS
|
||||
This function returns the integer value if valid. Otherwise, it will throw an error.
|
||||
|
||||
.NOTES
|
||||
Additional information about the function.
|
||||
|
||||
.FUNCTIONALITY
|
||||
This cmdlet is intended to be used internally and not exposed to the user
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName = 'service:protocol')]
|
||||
[OutputType([uint16])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object]$ProvidedValue,
|
||||
|
||||
[Parameter(ParameterSetName = 'aggregate:family',
|
||||
Mandatory = $true)]
|
||||
[switch]$AggregateFamily,
|
||||
|
||||
[Parameter(ParameterSetName = 'prefix:family',
|
||||
Mandatory = $true)]
|
||||
[switch]$PrefixFamily,
|
||||
|
||||
[Parameter(ParameterSetName = 'prefix:status',
|
||||
Mandatory = $true)]
|
||||
[switch]$PrefixStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'ip-address:family',
|
||||
Mandatory = $true)]
|
||||
[switch]$IPAddressFamily,
|
||||
|
||||
[Parameter(ParameterSetName = 'ip-address:status',
|
||||
Mandatory = $true)]
|
||||
[switch]$IPAddressStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'ip-address:role',
|
||||
Mandatory = $true)]
|
||||
[switch]$IPAddressRole,
|
||||
|
||||
[Parameter(ParameterSetName = 'vlan:status',
|
||||
Mandatory = $true)]
|
||||
[switch]$VLANStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'service:protocol',
|
||||
Mandatory = $true)]
|
||||
[switch]$ServiceProtocol
|
||||
)
|
||||
|
||||
ValidateChoice -MajorObject 'IPAM' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
|
||||
}
|
||||
|
||||
#region GET commands
|
||||
|
||||
function Get-NetboxIPAMAggregate {
|
||||
[CmdletBinding()]
|
||||
|
|
@ -1943,6 +1774,11 @@ public enum $EnumName
|
|||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||
}
|
||||
|
||||
#endregion GET commands
|
||||
|
||||
|
||||
#region NEW commands
|
||||
|
||||
function New-NetboxIPAMAddress {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
|
@ -2029,6 +1865,58 @@ public enum $EnumName
|
|||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
||||
}
|
||||
|
||||
function New-NetboxIPAMPrefix {
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Prefix,
|
||||
|
||||
[object]$Status = 'Active',
|
||||
|
||||
[uint16]$Tenant,
|
||||
|
||||
[object]$Role,
|
||||
|
||||
[bool]$IsPool,
|
||||
|
||||
[string]$Description,
|
||||
|
||||
[uint16]$Site,
|
||||
|
||||
[uint16]$VRF,
|
||||
|
||||
[uint16]$VLAN,
|
||||
|
||||
[hashtable]$Custom_Fields,
|
||||
|
||||
[switch]$Raw
|
||||
)
|
||||
|
||||
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
||||
|
||||
<#
|
||||
# As of 2018/10/18, this does not appear to be a validated IPAM choice
|
||||
if ($null -ne $Role) {
|
||||
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -PrefixRole
|
||||
}
|
||||
#>
|
||||
|
||||
$segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
||||
}
|
||||
|
||||
|
||||
#endregion ADD commands
|
||||
|
||||
|
||||
#region REMOVE commands
|
||||
|
||||
function Remove-NetboxIPAMAddress {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
|
@ -2082,6 +1970,11 @@ public enum $EnumName
|
|||
}
|
||||
}
|
||||
|
||||
#endregion REMOVE commands
|
||||
|
||||
|
||||
#region SET commands
|
||||
|
||||
function Set-NetboxIPAMAddress {
|
||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||
SupportsShouldProcess = $true)]
|
||||
|
|
@ -2143,6 +2036,7 @@ public enum $EnumName
|
|||
}
|
||||
}
|
||||
|
||||
#endregion SET commands
|
||||
|
||||
|
||||
|
||||
|
|
@ -2180,109 +2074,6 @@ public enum $EnumName
|
|||
InvokeNetboxRequest -URI $uri
|
||||
}
|
||||
|
||||
function ValidateDCIMChoice {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Internal function to validate provided values for static choices
|
||||
|
||||
.DESCRIPTION
|
||||
When users connect to the API, choices for each major object are cached to the config variable.
|
||||
These values are then utilized to validate if the provided value from a user is valid.
|
||||
|
||||
.PARAMETER ProvidedValue
|
||||
The value to validate against static choices
|
||||
|
||||
.PARAMETER PowerConnectionStatus
|
||||
Validate against power connection status values
|
||||
|
||||
.PARAMETER InterfaceTemplateFormFactor
|
||||
Validate against interface template form factor values
|
||||
|
||||
.PARAMETER InterfaceConnectionStatus
|
||||
Validate against interface connection status values
|
||||
|
||||
.PARAMETER InterfaceFormFactor
|
||||
Validate against interface form factor values
|
||||
|
||||
.PARAMETER ConsolePortConnectionStatus
|
||||
Validate against console port connection status values
|
||||
|
||||
.PARAMETER DeviceStatus
|
||||
Validate against device status values
|
||||
|
||||
.PARAMETER DeviceFace
|
||||
Validate against device face values
|
||||
|
||||
.PARAMETER RackType
|
||||
Validate against rack type values
|
||||
|
||||
.PARAMETER RackWidth
|
||||
Validate against rack width values.
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> ValidateDCIMChoice -ProvidedValue 'rear' -DeviceFace
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> ValidateDCIMChoice -ProvidedValue 'middle' -DeviceFace
|
||||
>> Invalid value middle for device:face. Must be one of: 0, 1, Front, Rear
|
||||
|
||||
.OUTPUTS
|
||||
This function returns the integer value if valid. Otherwise, it will throw an error.
|
||||
|
||||
.NOTES
|
||||
Additional information about the function.
|
||||
|
||||
.FUNCTIONALITY
|
||||
This cmdlet is intended to be used internally and not exposed to the user
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
[OutputType([uint16])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object]$ProvidedValue,
|
||||
|
||||
[Parameter(ParameterSetName = 'power-port:connection_status',
|
||||
Mandatory = $true)]
|
||||
[switch]$PowerConnectionStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'interface-template:form_factor',
|
||||
Mandatory = $true)]
|
||||
[switch]$InterfaceTemplateFormFactor,
|
||||
|
||||
[Parameter(ParameterSetName = 'interface-connection:connection_status',
|
||||
Mandatory = $true)]
|
||||
[switch]$InterfaceConnectionStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'interface:form_factor',
|
||||
Mandatory = $true)]
|
||||
[switch]$InterfaceFormFactor,
|
||||
|
||||
[Parameter(ParameterSetName = 'console-port:connection_status',
|
||||
Mandatory = $true)]
|
||||
[switch]$ConsolePortConnectionStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'device:status',
|
||||
Mandatory = $true)]
|
||||
[switch]$DeviceStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'device:face',
|
||||
Mandatory = $true)]
|
||||
[switch]$DeviceFace,
|
||||
|
||||
[Parameter(ParameterSetName = 'rack:type',
|
||||
Mandatory = $true)]
|
||||
[switch]$RackType,
|
||||
|
||||
[Parameter(ParameterSetName = 'rack:width',
|
||||
Mandatory = $true)]
|
||||
[switch]$RackWidth
|
||||
)
|
||||
|
||||
ValidateChoice -MajorObject 'DCIM' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
|
||||
}
|
||||
|
||||
|
||||
#region GET commands
|
||||
|
||||
|
|
@ -3294,13 +3085,394 @@ public enum $EnumName
|
|||
|
||||
#endregion
|
||||
|
||||
# Build a list of common paramters so we can omit them to build URI parameters
|
||||
$script:CommonParameterNames = New-Object System.Collections.ArrayList
|
||||
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::CommonParameters))
|
||||
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::OptionalCommonParameters))
|
||||
[void]$script:CommonParameterNames.Add('Raw')
|
||||
#region Invoke-Tenancy_ps1
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.152
|
||||
Created on: 5/29/2018 1:45 PM
|
||||
Created by: Ben Claussen
|
||||
Organization: NEOnet
|
||||
Filename: Tenancy.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
function Get-NetboxTenancyChoices {
|
||||
[CmdletBinding()]
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
|
||||
param ()
|
||||
|
||||
$uriSegments = [System.Collections.ArrayList]::new(@('tenancy', '_choices'))
|
||||
|
||||
$uri = BuildNewURI -Segments $uriSegments
|
||||
|
||||
InvokeNetboxRequest -URI $uri
|
||||
}
|
||||
|
||||
|
||||
#region GET commands
|
||||
|
||||
function Get-NetboxTenant {
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[uint16]$Limit,
|
||||
|
||||
[uint16]$Offset,
|
||||
|
||||
[string]$Name,
|
||||
|
||||
[uint16[]]$Id,
|
||||
|
||||
[string]$Query,
|
||||
|
||||
[string]$Group,
|
||||
|
||||
[uint16]$GroupID,
|
||||
|
||||
[hashtable]$CustomFields,
|
||||
|
||||
[switch]$Raw
|
||||
)
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||
}
|
||||
|
||||
#endregion GET commands
|
||||
|
||||
|
||||
#region SET commands
|
||||
|
||||
#endregion SET commands
|
||||
|
||||
|
||||
#region ADD/NEW commands
|
||||
|
||||
#endregion ADD/NEW commands
|
||||
|
||||
|
||||
#region REMOVE commands
|
||||
|
||||
#endregion REMOVE commands#endregion
|
||||
|
||||
SetupNetboxConfigVariable
|
||||
#region Invoke-DCIM_Support_ps1
|
||||
function ValidateDCIMChoice {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Internal function to validate provided values for static choices
|
||||
|
||||
.DESCRIPTION
|
||||
When users connect to the API, choices for each major object are cached to the config variable.
|
||||
These values are then utilized to validate if the provided value from a user is valid.
|
||||
|
||||
.PARAMETER ProvidedValue
|
||||
The value to validate against static choices
|
||||
|
||||
.PARAMETER PowerConnectionStatus
|
||||
Validate against power connection status values
|
||||
|
||||
.PARAMETER InterfaceTemplateFormFactor
|
||||
Validate against interface template form factor values
|
||||
|
||||
.PARAMETER InterfaceConnectionStatus
|
||||
Validate against interface connection status values
|
||||
|
||||
.PARAMETER InterfaceFormFactor
|
||||
Validate against interface form factor values
|
||||
|
||||
.PARAMETER ConsolePortConnectionStatus
|
||||
Validate against console port connection status values
|
||||
|
||||
.PARAMETER DeviceStatus
|
||||
Validate against device status values
|
||||
|
||||
.PARAMETER DeviceFace
|
||||
Validate against device face values
|
||||
|
||||
.PARAMETER RackType
|
||||
Validate against rack type values
|
||||
|
||||
.PARAMETER RackWidth
|
||||
Validate against rack width values.
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> ValidateDCIMChoice -ProvidedValue 'rear' -DeviceFace
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> ValidateDCIMChoice -ProvidedValue 'middle' -DeviceFace
|
||||
>> Invalid value middle for device:face. Must be one of: 0, 1, Front, Rear
|
||||
|
||||
.OUTPUTS
|
||||
This function returns the integer value if valid. Otherwise, it will throw an error.
|
||||
|
||||
.NOTES
|
||||
Additional information about the function.
|
||||
|
||||
.FUNCTIONALITY
|
||||
This cmdlet is intended to be used internally and not exposed to the user
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
[OutputType([uint16])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object]$ProvidedValue,
|
||||
|
||||
[Parameter(ParameterSetName = 'power-port:connection_status',
|
||||
Mandatory = $true)]
|
||||
[switch]$PowerConnectionStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'interface-template:form_factor',
|
||||
Mandatory = $true)]
|
||||
[switch]$InterfaceTemplateFormFactor,
|
||||
|
||||
[Parameter(ParameterSetName = 'interface-connection:connection_status',
|
||||
Mandatory = $true)]
|
||||
[switch]$InterfaceConnectionStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'interface:form_factor',
|
||||
Mandatory = $true)]
|
||||
[switch]$InterfaceFormFactor,
|
||||
|
||||
[Parameter(ParameterSetName = 'console-port:connection_status',
|
||||
Mandatory = $true)]
|
||||
[switch]$ConsolePortConnectionStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'device:status',
|
||||
Mandatory = $true)]
|
||||
[switch]$DeviceStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'device:face',
|
||||
Mandatory = $true)]
|
||||
[switch]$DeviceFace,
|
||||
|
||||
[Parameter(ParameterSetName = 'rack:type',
|
||||
Mandatory = $true)]
|
||||
[switch]$RackType,
|
||||
|
||||
[Parameter(ParameterSetName = 'rack:width',
|
||||
Mandatory = $true)]
|
||||
[switch]$RackWidth
|
||||
)
|
||||
|
||||
ValidateChoice -MajorObject 'DCIM' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
|
||||
}#endregion
|
||||
|
||||
#Export-ModuleMember -Function *
|
||||
Export-ModuleMember -Function *-*
|
||||
#region Invoke-IPAM_Support_ps1
|
||||
function ValidateIPAMChoice {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Internal function to verify provided values for static choices
|
||||
|
||||
.DESCRIPTION
|
||||
When users connect to the API, choices for each major object are cached to the config variable.
|
||||
These values are then utilized to verify if the provided value from a user is valid.
|
||||
|
||||
.PARAMETER ProvidedValue
|
||||
The value to validate against static choices
|
||||
|
||||
.PARAMETER AggregateFamily
|
||||
Verify against aggregate family values
|
||||
|
||||
.PARAMETER PrefixFamily
|
||||
Verify against prefix family values
|
||||
|
||||
.PARAMETER PrefixStatus
|
||||
Verify against prefix status values
|
||||
|
||||
.PARAMETER IPAddressFamily
|
||||
Verify against ip-address family values
|
||||
|
||||
.PARAMETER IPAddressStatus
|
||||
Verify against ip-address status values
|
||||
|
||||
.PARAMETER IPAddressRole
|
||||
Verify against ip-address role values
|
||||
|
||||
.PARAMETER VLANStatus
|
||||
Verify against VLAN status values
|
||||
|
||||
.PARAMETER ServiceProtocol
|
||||
Verify against service protocol values
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> ValidateIPAMChoice -ProvidedValue 'loopback' -IPAddressRole
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> ValidateIPAMChoice -ProvidedValue 'Loopback' -IPAddressFamily
|
||||
>> Invalid value Loopback for ip-address:family. Must be one of: 4, 6, IPv4, IPv6
|
||||
|
||||
.OUTPUTS
|
||||
This function returns the integer value if valid. Otherwise, it will throw an error.
|
||||
|
||||
.NOTES
|
||||
Additional information about the function.
|
||||
|
||||
.FUNCTIONALITY
|
||||
This cmdlet is intended to be used internally and not exposed to the user
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName = 'service:protocol')]
|
||||
[OutputType([uint16])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object]$ProvidedValue,
|
||||
|
||||
[Parameter(ParameterSetName = 'aggregate:family',
|
||||
Mandatory = $true)]
|
||||
[switch]$AggregateFamily,
|
||||
|
||||
[Parameter(ParameterSetName = 'prefix:family',
|
||||
Mandatory = $true)]
|
||||
[switch]$PrefixFamily,
|
||||
|
||||
[Parameter(ParameterSetName = 'prefix:status',
|
||||
Mandatory = $true)]
|
||||
[switch]$PrefixStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'ip-address:family',
|
||||
Mandatory = $true)]
|
||||
[switch]$IPAddressFamily,
|
||||
|
||||
[Parameter(ParameterSetName = 'ip-address:status',
|
||||
Mandatory = $true)]
|
||||
[switch]$IPAddressStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'ip-address:role',
|
||||
Mandatory = $true)]
|
||||
[switch]$IPAddressRole,
|
||||
|
||||
[Parameter(ParameterSetName = 'vlan:status',
|
||||
Mandatory = $true)]
|
||||
[switch]$VLANStatus,
|
||||
|
||||
[Parameter(ParameterSetName = 'service:protocol',
|
||||
Mandatory = $true)]
|
||||
[switch]$ServiceProtocol
|
||||
)
|
||||
|
||||
ValidateChoice -MajorObject 'IPAM' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Invoke-Virtualization_Support_ps1
|
||||
function ValidateVirtualizationChoice {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Internal function to verify provided values for static choices
|
||||
|
||||
.DESCRIPTION
|
||||
When users connect to the API, choices for each major object are cached to the config variable.
|
||||
These values are then utilized to verify if the provided value from a user is valid.
|
||||
|
||||
.PARAMETER ProvidedValue
|
||||
The value to validate against static choices
|
||||
|
||||
.PARAMETER AggregateFamily
|
||||
Verify against aggregate family values
|
||||
|
||||
.PARAMETER PrefixFamily
|
||||
Verify against prefix family values
|
||||
|
||||
.PARAMETER PrefixStatus
|
||||
Verify against prefix status values
|
||||
|
||||
.PARAMETER IPAddressFamily
|
||||
Verify against ip-address family values
|
||||
|
||||
.PARAMETER IPAddressStatus
|
||||
Verify against ip-address status values
|
||||
|
||||
.PARAMETER IPAddressRole
|
||||
Verify against ip-address role values
|
||||
|
||||
.PARAMETER VLANStatus
|
||||
Verify against VLAN status values
|
||||
|
||||
.PARAMETER ServiceProtocol
|
||||
Verify against service protocol values
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> VerifyIPAMChoices -ProvidedValue 'loopback' -IPAddressRole
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> VerifyIPAMChoices -ProvidedValue 'Loopback' -IPAddressFamily
|
||||
>> Invalid value Loopback for ip-address:family. Must be one of: 4, 6, IPv4, IPv6
|
||||
|
||||
.FUNCTIONALITY
|
||||
This cmdlet is intended to be used internally and not exposed to the user
|
||||
|
||||
.OUTPUT
|
||||
This function returns nothing if the value is valid. Otherwise, it will throw an error.
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object]$ProvidedValue,
|
||||
|
||||
[Parameter(ParameterSetName = 'virtual-machine:status',
|
||||
Mandatory = $true)]
|
||||
[switch]$VirtualMachineStatus
|
||||
)
|
||||
|
||||
ValidateChoice -MajorObject 'Virtualization' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
|
||||
}#endregion
|
||||
|
||||
#region Invoke-Setup_Support_ps1
|
||||
function VerifyAPIConnectivity {
|
||||
[CmdletBinding()]
|
||||
param ()
|
||||
|
||||
$uriSegments = [System.Collections.ArrayList]::new(@('extras', '_choices'))
|
||||
|
||||
$uri = BuildNewURI -Segments $uriSegments -SkipConnectedCheck
|
||||
|
||||
InvokeNetboxRequest -URI $uri
|
||||
}
|
||||
|
||||
function SetupNetboxConfigVariable {
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[switch]$Overwrite
|
||||
)
|
||||
|
||||
Write-Verbose "Checking for NetboxConfig hashtable"
|
||||
if ((-not ($script:NetboxConfig)) -or $Overwrite) {
|
||||
Write-Verbose "Creating NetboxConfig hashtable"
|
||||
$script:NetboxConfig = @{
|
||||
'Connected' = $false
|
||||
'Choices' = @{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Verbose "NetboxConfig hashtable already exists"
|
||||
}
|
||||
|
||||
function GetNetboxConfigVariable {
|
||||
return $script:NetboxConfig
|
||||
}#endregion
|
||||
|
||||
# Build a list of common paramters so we can omit them to build URI parameters
|
||||
$script:CommonParameterNames = New-Object System.Collections.ArrayList
|
||||
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::CommonParameters))
|
||||
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::OptionalCommonParameters))
|
||||
[void]$script:CommonParameterNames.Add('Raw')
|
||||
|
||||
SetupNetboxConfigVariable
|
||||
|
||||
Export-ModuleMember -Function *
|
||||
#Export-ModuleMember -Function *-*
|
||||
Loading…
Add table
Reference in a new issue