Public/Get-Collection.ps1

<#
.SYNOPSIS
    Gets collections 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-Collection {
    [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") {
            Write-Verbose "Getting Collection with Id: $Id"
            Get-CollectionObject -CollectionType "collections" -Id $Id
        } else {
            Get-CollectionObject -CollectionType "collections"
        }
    }
}