2022-12-06 13:34:52 -05:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
function Get-NetboxIPAMPrefix {
|
|
|
|
|
|
<#
|
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
|
A brief description of the Get-NetboxIPAMPrefix function.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.DESCRIPTION
|
|
|
|
|
|
A detailed description of the Get-NetboxIPAMPrefix function.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-04-09 09:58:52 -04:00
|
|
|
|
.PARAMETER Query
|
|
|
|
|
|
A description of the Query parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-04-09 09:58:52 -04:00
|
|
|
|
.PARAMETER Id
|
|
|
|
|
|
A description of the Id parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Limit
|
|
|
|
|
|
A description of the Limit parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Offset
|
|
|
|
|
|
A description of the Offset parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Family
|
|
|
|
|
|
A description of the Family parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Is_Pool
|
|
|
|
|
|
A description of the Is_Pool parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Within
|
|
|
|
|
|
Should be a CIDR notation prefix such as '10.0.0.0/16'
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Within_Include
|
|
|
|
|
|
Should be a CIDR notation prefix such as '10.0.0.0/16'
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Contains
|
|
|
|
|
|
A description of the Contains parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Mask_Length
|
|
|
|
|
|
CIDR mask length value
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER VRF
|
|
|
|
|
|
A description of the VRF parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER VRF_Id
|
|
|
|
|
|
A description of the VRF_Id parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Tenant
|
|
|
|
|
|
A description of the Tenant parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Tenant_Id
|
|
|
|
|
|
A description of the Tenant_Id parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Site
|
|
|
|
|
|
A description of the Site parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Site_Id
|
|
|
|
|
|
A description of the Site_Id parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Vlan_VId
|
|
|
|
|
|
A description of the Vlan_VId parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Vlan_Id
|
|
|
|
|
|
A description of the Vlan_Id parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Status
|
|
|
|
|
|
A description of the Status parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Role
|
|
|
|
|
|
A description of the Role parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Role_Id
|
|
|
|
|
|
A description of the Role_Id parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Raw
|
|
|
|
|
|
A description of the Raw parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.EXAMPLE
|
2020-04-09 09:58:52 -04:00
|
|
|
|
PS C:\> Get-NetboxIPAMPrefix
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.NOTES
|
|
|
|
|
|
Additional information about the function.
|
|
|
|
|
|
#>
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
param
|
|
|
|
|
|
(
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query',
|
|
|
|
|
|
Position = 0)]
|
2020-04-09 09:58:52 -04:00
|
|
|
|
[string]$Prefix,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-04-09 09:58:52 -04:00
|
|
|
|
[string]$Query,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'ByID')]
|
2023-11-07 10:30:05 -05:00
|
|
|
|
[uint64[]]$Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[object]$Family,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[boolean]$Is_Pool,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Within,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Within_Include,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Contains,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[ValidateRange(0, 127)]
|
|
|
|
|
|
[byte]$Mask_Length,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$VRF,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2023-11-07 10:30:05 -05:00
|
|
|
|
[uint64]$VRF_Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Tenant,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2023-11-07 10:30:05 -05:00
|
|
|
|
[uint64]$Tenant_Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Site,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2023-11-07 10:30:05 -05:00
|
|
|
|
[uint64]$Site_Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Vlan_VId,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2023-11-07 10:30:05 -05:00
|
|
|
|
[uint64]$Vlan_Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[object]$Status,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Role,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2023-11-07 10:30:05 -05:00
|
|
|
|
[uint64]$Role_Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-04-09 09:58:52 -04:00
|
|
|
|
[uint16]$Limit,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
2020-04-09 09:58:52 -04:00
|
|
|
|
[uint16]$Offset,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[switch]$Raw
|
|
|
|
|
|
)
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
# if ($null -ne $Family) {
|
|
|
|
|
|
# $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -PrefixFamily
|
|
|
|
|
|
# }
|
2021-07-23 22:06:42 +02:00
|
|
|
|
#
|
2021-03-25 16:52:08 -04:00
|
|
|
|
# if ($null -ne $Status) {
|
|
|
|
|
|
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
|
|
|
|
|
# }
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
switch ($PSCmdlet.ParameterSetName) {
|
|
|
|
|
|
'ById' {
|
|
|
|
|
|
foreach ($Prefix_ID in $Id) {
|
|
|
|
|
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $Prefix_ID))
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
|
|
|
|
}
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
break
|
|
|
|
|
|
}
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
default {
|
|
|
|
|
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
break
|
|
|
|
|
|
}
|
2020-03-23 12:18:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|