2022-12-06 13:34:52 -05:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
function Get-NetboxTenant {
|
2021-03-25 16:52:08 -04:00
|
|
|
|
<#
|
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
|
Get a tenent from Netbox
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.DESCRIPTION
|
|
|
|
|
|
A detailed description of the Get-NetboxTenant function.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.PARAMETER Name
|
|
|
|
|
|
The specific name of the tenant. Must match exactly as is defined in Netbox
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.PARAMETER Id
|
|
|
|
|
|
The database ID of the tenant
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.PARAMETER Query
|
|
|
|
|
|
A standard search query that will match one or more tenants.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.PARAMETER Slug
|
|
|
|
|
|
The specific slug of the tenant. Must match exactly as is defined in Netbox
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.PARAMETER Group
|
|
|
|
|
|
The specific group as defined in Netbox.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.PARAMETER GroupID
|
|
|
|
|
|
The database ID of the group in Netbox
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.PARAMETER CustomFields
|
|
|
|
|
|
Hashtable in the format @{"field_name" = "value"} to search
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.PARAMETER Limit
|
|
|
|
|
|
Limit the number of results to this number
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.PARAMETER Offset
|
|
|
|
|
|
Start the search at this index in results
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.PARAMETER Raw
|
|
|
|
|
|
Return the unparsed data from the HTTP request
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.EXAMPLE
|
|
|
|
|
|
PS C:\> Get-NetboxTenant
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -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-03-23 12:18:01 -04:00
|
|
|
|
[string]$Name,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'ByID')]
|
|
|
|
|
|
[uint32[]]$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]$Query,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
|
|
|
|
|
[string]$Slug,
|
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]$Group,
|
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
|
|
|
|
[uint16]$GroupID,
|
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
|
|
|
|
[hashtable]$CustomFields,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
|
|
|
|
|
[uint16]$Limit,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(ParameterSetName = 'Query')]
|
|
|
|
|
|
[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
|
|
|
|
switch ($PSCmdlet.ParameterSetName) {
|
|
|
|
|
|
'ById' {
|
|
|
|
|
|
foreach ($Tenant_ID in $Id) {
|
|
|
|
|
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants', $Tenant_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(@('tenancy', 'tenants'))
|
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
|
|
|
|
}
|