Get Identity Access Items Snapshot API - Pagination/Sorting

I have been messing around with the list-identity-snapshot-access-items API endpoint and it appears that it only returns 250 results at a time.

The documentation in the API specs does not mention this, but it will accept your limit and offset query parameters allowing pagination. It does not appear to accept a sorters query parameter to ensure that you aren’t paginating through duplicate results.

Any thoughts on if this data is already sorted and we’d be fine to paginate through it?

Note that because the API specs don’t include offset/limit query parameters, you can’t use the Invoke-Paginate Powershell cmdlet in the SDK

invoke-paginate -function "get-betaidentitysnapshotaccessitems" -increment 250 -limit 10000 -initialoffset 0 -parameters @{"id" = "2c9180878043083b0180479fb9761ac0";"date" = "2024-02-24T03:06:17.845Z"; "type" = "entitlement"} | select displayName,sourcename
A parameter cannot be found that matches parameter name 'Limit'.
ConvertFrom-Json: C:\Users\mcheek\OneDrive - Chesapeake Energy\Documents\PowerShell\Modules\PSSailPoint\1.4.3\Pagination.ps1:58
Line |
  58 |  … when calling {1}: {0}" -f ($_.ErrorDetails | ConvertFrom-Json), $Func …
     |                                                 ~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'InputObject' because it is null.

If you want, you can modify the BetaIdentityHistory.ps1 file to make it accept limit and offset parameters so that you can use invoke-paginate. This is my modified version

function Get-BetaIdentitySnapshotAccessItems {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [String]
        ${Id},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [String]
        ${Date},
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [String]
        ${Type},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [System.Nullable[Int32]]
        ${Limit},
        [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [System.Nullable[Int32]]
        ${Offset},
        [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
        [System.Nullable[Boolean]]
        ${Count},
        [Switch]
        $WithHttpInfo
    )

    Process {
        'Calling method: Get-BetaIdentitySnapshotAccessItems' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $LocalVarAccepts = @()
        $LocalVarContentTypes = @()
        $LocalVarQueryParameters = @{}
        $LocalVarHeaderParameters = @{}
        $LocalVarFormParameters = @{}
        $LocalVarPathParameters = @{}
        $LocalVarCookieParameters = @{}
        $LocalVarBodyParameter = $null

        # HTTP header 'Accept' (if needed)
        $LocalVarAccepts = @('application/json')

        $LocalVarUri = '/historical-identities/{id}/snapshots/{date}/access-items'
        if (!$Id) {
            throw "Error! The required parameter `Id` missing when calling listIdentitySnapshotAccessItems."
        }
        $LocalVarUri = $LocalVarUri.replace('{id}', [System.Web.HTTPUtility]::UrlEncode($Id))
        if (!$Date) {
            throw "Error! The required parameter `Date` missing when calling listIdentitySnapshotAccessItems."
        }
        $LocalVarUri = $LocalVarUri.replace('{date}', [System.Web.HTTPUtility]::UrlEncode($Date))

        if ($Type) {
            $LocalVarQueryParameters['type'] = $Type
        }
        if ($Limit) {
            $LocalVarQueryParameters['limit'] = $Limit
        }

        if ($Offset) {
            $LocalVarQueryParameters['offset'] = $Offset
        }



        $LocalVarResult = Invoke-BetaApiClient -Method 'GET' `
                                -Uri $LocalVarUri `
                                -Accepts $LocalVarAccepts `
                                -ContentTypes $LocalVarContentTypes `
                                -Body $LocalVarBodyParameter `
                                -HeaderParameters $LocalVarHeaderParameters `
                                -QueryParameters $LocalVarQueryParameters `
                                -FormParameters $LocalVarFormParameters `
                                -CookieParameters $LocalVarCookieParameters `
                                -ReturnType "ListIdentityAccessItems200ResponseInner[]" `
                                -IsBodyNullable $false

        if ($WithHttpInfo.IsPresent) {
            return $LocalVarResult
        } else {
            return $LocalVarResult["Response"]
        }
    }
}

i have tested this with a smaller sample of count ~20 and then limiting it to 5 per page and looks like it comes sorted by id.

I would get the count first and loop over till last.