Resources/Domains.ps1
function Get-ITGlueDomains { [CmdletBinding(DefaultParameterSetName = 'index')] Param ( [Parameter(ParameterSetName = 'index')] [Nullable[Int64]]$organization_id = $null, [Parameter(ParameterSetName = 'index')] [Nullable[Int64]]$filter_id = '', [Parameter(ParameterSetName = 'index')] [Nullable[Int64]]$filter_organization_id = '', [Parameter(ParameterSetName = 'index')] [ValidateSet('created_at', 'updated_at')] [String]$sort = '', [Parameter(ParameterSetName = 'index')] [Nullable[Int64]]$page_number = $null, [Parameter(ParameterSetName = 'index')] [Nullable[int]]$page_size = $null, [Parameter(ParameterSetName = 'index')] [ValidateSet('passwords', 'attachments', 'user_resource_accesses', 'group_resource_accesses')] [String]$include = '' ) $resource_uri = '/domains' if ($organization_id) { $resource_uri = ('/organizations/{0}/relationships/domains' -f $organization_id) } $body = @{} if ($PSCmdlet.ParameterSetName -eq 'index') { if ($filter_id) { $body += @{'filter[id]' = $filter_id} } if ($filter_organization_id) { $body += @{'filter[organization_id]' = $filter_organization_id} } if ($sort) { $body += @{'sort' = $sort} } if ($page_number) { $body += @{'page[number]' = $page_number} } if ($page_size) { $body += @{'page[size]' = $page_size} } } if($include) { $body += @{'include' = $include} } try { $ITGlue_Headers.Add('x-api-key', (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'N/A', $ITGlue_API_Key).GetNetworkCredential().Password) $rest_output = Invoke-RestMethod -method 'GET' -uri ($ITGlue_Base_URI + $resource_uri) -headers $ITGlue_Headers -body $body } catch { Write-Error $_ } finally { [void] $ITGlue_Headers.Remove('x-api-key') # Quietly clean up scope so the API key doesn't persist } $data = @{} $data = $rest_output return $data } |