Private/Get-SCAPagination.ps1
|
function Get-SCAPagination { <# .SYNOPSIS Detects whether a parsed response indicates more pages of results are available. .DESCRIPTION CyberArk's SaaS APIs use a handful of different continuation conventions across services (e.g. Cloud Discovery Service's NextPageDetails/PagingDetails schemas). psSCA does not yet auto-follow continuation tokens for every list endpoint; this helper lets a cmdlet detect a truncated result set so it can warn the caller instead of silently returning a partial list. See docs/API-COMPATIBILITY.md for which list cmdlets support -NoAutoPaging today. .PARAMETER Response The parsed response object to inspect. .OUTPUTS System.Object. The continuation token/object if one is present, otherwise $null. #> [CmdletBinding()] [OutputType([object])] param( [Parameter(Mandatory, Position = 0)] [AllowNull()] [psobject]$Response ) if ($null -eq $Response) { return $null } foreach ($propertyName in 'nextPageDetails', 'pagingDetails', 'nextPageToken', 'nextLink', 'continuationToken') { $property = $Response.PSObject.Properties[$propertyName] if ($null -ne $property -and $null -ne $property.Value -and $property.Value -ne '') { return $property.Value } } return $null } |