NetboxPS/Functions/IPAM/Role/Get-NetboxIPAMRole.ps1

96 lines
2.3 KiB
PowerShell
Raw Normal View History

2020-03-23 12:18:01 -04:00

function Get-NetboxIPAMRole {
<#
.SYNOPSIS
Get IPAM Prefix/VLAN roles
2020-03-23 12:18:01 -04:00
.DESCRIPTION
A role indicates the function of a prefix or VLAN. For example, you might define Data, Voice, and Security roles. Generally, a prefix will be assigned the same functional role as the VLAN to which it is assigned (if any).
2020-03-23 12:18:01 -04:00
.PARAMETER Id
Unique ID
2020-03-23 12:18:01 -04:00
.PARAMETER Query
Search query
2020-03-23 12:18:01 -04:00
.PARAMETER Name
Role name
2020-03-23 12:18:01 -04:00
.PARAMETER Slug
Role URL slug
2020-03-23 12:18:01 -04:00
.PARAMETER Brief
Brief format
2020-03-23 12:18:01 -04:00
.PARAMETER Limit
Result limit
2020-03-23 12:18:01 -04:00
.PARAMETER Offset
Result offset
2020-03-23 12:18:01 -04:00
.PARAMETER Raw
A description of the Raw parameter.
2020-03-23 12:18:01 -04:00
.EXAMPLE
PS C:\> Get-NetboxIPAMRole
2020-03-23 12:18:01 -04:00
.NOTES
Additional information about the function.
#>
2020-03-23 12:18:01 -04:00
[CmdletBinding()]
param
(
[Parameter(ParameterSetName = 'Query',
Position = 0)]
[string]$Name,
[Parameter(ParameterSetName = 'Query')]
2020-03-23 12:18:01 -04:00
[string]$Query,
[Parameter(ParameterSetName = 'ByID')]
[uint32[]]$Id,
[Parameter(ParameterSetName = 'Query')]
2020-03-23 12:18:01 -04:00
[string]$Slug,
[Parameter(ParameterSetName = 'Query')]
2020-03-23 12:18:01 -04:00
[switch]$Brief,
[Parameter(ParameterSetName = 'Query')]
2020-03-23 12:18:01 -04:00
[uint16]$Limit,
[Parameter(ParameterSetName = 'Query')]
2020-03-23 12:18:01 -04:00
[uint16]$Offset,
2020-03-23 12:18:01 -04:00
[switch]$Raw
)
switch ($PSCmdlet.ParameterSetName) {
'ById' {
foreach ($Role_ID in $Id) {
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'roles', $Role_ID))
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
break
}
default {
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'roles'))
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $uri -Raw:$Raw
break
}
}
2020-03-23 12:18:01 -04:00
}