NetboxPS/Functions/Tenancy/ContactRoles/Get-NetboxContactRole.ps1

90 lines
2.4 KiB
PowerShell
Raw Normal View History

2023-02-24 15:14:04 -05:00

2023-02-15 15:40:59 -05:00
function Get-NetboxContactRole {
<#
.SYNOPSIS
Get a contact role from Netbox
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
.DESCRIPTION
A detailed description of the Get-NetboxContactRole function.
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
.PARAMETER Name
The specific name of the contact role. Must match exactly as is defined in Netbox
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
.PARAMETER Id
The database ID of the contact role
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
.PARAMETER Query
A standard search query that will match one or more contact roles.
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
.PARAMETER Limit
Limit the number of results to this number
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
.PARAMETER Offset
Start the search at this index in results
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
.PARAMETER Raw
Return the unparsed data from the HTTP request
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
.EXAMPLE
PS C:\> Get-NetboxContactRole
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
.NOTES
Additional information about the function.
#>
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
[CmdletBinding(DefaultParameterSetName = 'Query')]
param
(
[Parameter(ParameterSetName = 'Query',
Position = 0)]
[string]$Name,
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
[Parameter(ParameterSetName = 'ByID')]
2023-07-28 16:17:23 -04:00
[uint64[]]$Id,
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
[Parameter(ParameterSetName = 'Query')]
[string]$Query,
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
[Parameter(ParameterSetName = 'Query')]
[string]$Slug,
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
[Parameter(ParameterSetName = 'Query')]
[string]$Description,
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
[Parameter(ParameterSetName = 'Query')]
[uint16]$Limit,
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
[Parameter(ParameterSetName = 'Query')]
[uint16]$Offset,
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
[switch]$Raw
)
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
switch ($PSCmdlet.ParameterSetName) {
'ById' {
foreach ($ContactRole_ID in $Id) {
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-roles', $ContactRole_ID))
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
break
}
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
default {
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-roles'))
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
InvokeNetboxRequest -URI $uri -Raw:$Raw
2023-02-24 15:14:04 -05:00
2023-02-15 15:40:59 -05:00
break
}
}
}