Public/Get-CollectionGroupLink.ps1
|
<# .SYNOPSIS Gets collection group links from the Fortytwo Collections API. .DESCRIPTION This function retrieves collections from the Fortytwo Collections API. It supports pagination to handle large result sets. #> function Get-CollectionGroupLink { [CmdletBinding(DefaultParameterSetName = "Default")] param ( [Parameter(Mandatory = $true, ParameterSetName = "Single", ValueFromPipeline = $true)] [ValidatePattern("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", ErrorMessage = "Id must be a valid GUID.")] # Is a guid connector object id [string] $Id ) process { if (-not $Script:APIRoot -or -not $Script:AccessTokenProfile) { throw "Not connected to Fortytwo Collections. Please run Connect-Collections first." } if ($PSCmdlet.ParameterSetName -eq "Single") { $Uri = "$Script:APIRoot" -f "group-link", "/group-links/$Id" } else { $Uri = "$Script:APIRoot" -f "group-link", "/group-links" } Write-Verbose "Request URI: $Uri" Invoke-RestMethod -Uri $Uri -Headers (Get-CollectionHeader) | Select-Object -ExpandProperty data } } |