okta / okta-powershell-cli

Powershell CLI for communicating with the Okta API
Other
15 stars 4 forks source link

Add convenience for pagination. #19

Closed laura-rodriguez closed 9 months ago

laura-rodriguez commented 9 months ago

Feature

Add convenience for paginated results

Description

Developers will be able to use pagination in the following way:

$GroupsPageResponse = Invoke-ListGroups -limit 10 -withHttpInfo

The -withHttpInfo flag indicates that in addition to the response, you expect additional information. The response for the above call will look like this:

$GroupsPageResponse

Headers                        {[Date, System.String[]], [Transfer-Encoding, System.String[]], [Connection, S… 
Response                       @{id=00g9erhe4rJGXhdYs5d7; created=5/5/23 1:44:39 PM; lastUpdated=5/5/23 1:44:… 
StatusCode                     200
NextPageUri                    https://dev-79816133.okta.com/api/v1/groups?after=00g9erhe4rJGXhdYs5d7&limit=10

For convenience, a property called NextPageUri is added, but you can also access all the response headers via the Headers property.

To paginate results, a developer can use the Uri param, which allows passing full URIs:

While ($GroupsPageResponse.NextPageUri)
{
    $GroupsPageResponse = Invoke-ListGroups -Uri 
$GroupsPageResponse.NextPageUri  -withHttpInfo

     $Response =  $GroupsPageResponse.Response
}

What changed?