Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on Pagination. #170

Closed
SriG86 opened this issue Feb 23, 2018 · 10 comments
Closed

Question on Pagination. #170

SriG86 opened this issue Feb 23, 2018 · 10 comments

Comments

@SriG86
Copy link

SriG86 commented Feb 23, 2018

@bdemers In the new version of the sdk the pagination is mentioned to be automatic.Please let me know if pagination can still be used like the previous okta sdk.

The previous version of okta sdk allowed client executing the sdk a greater flexibility to restart a batch execution from the failure point in case of network failures.

@bdemers
Copy link
Contributor

bdemers commented Mar 5, 2018

Not directly, but we do have automatic retry logic. Were you programmatically retrying after a failure?

Can you give me an example of how you were iterating over all of your users? How many users did you have?

I ask for two reasons, we could possibly suggest a different approach, and if we add this or similar feature.

All that said, you could use the DataStore client.getDatastore() directly to make any request.

@SriG86
Copy link
Author

SriG86 commented Mar 5, 2018

The use case is we have a batch which validates data across our systems.If we find discrepancies with data we make necessary changes.

Sometimes this batch might be running and enter our maintenance windows.If we see too many network call failures on our end due to our maintenance window.

we save the getUserPagedResultsWithUrl into file.When our systems are back up we use the saved pagination url to restart the process so that we do not have to reprocess the whole data.

With this new SDK I do not know if this is possible.

@bdemers
Copy link
Contributor

bdemers commented Mar 5, 2018

@SrihariGanadinni Great info!

You could still do this by using client.getDataStore().getResource("your-href", UserList.class)

You may also want to change your search filter to only return the results from the subset of users you are looking for.

Does this help?

@bdemers
Copy link
Contributor

bdemers commented Mar 5, 2018

@SrihariGanadinni I'll close this issue, if that doesn't help, please reopen!

@bdemers bdemers closed this as completed Mar 5, 2018
@SriG86
Copy link
Author

SriG86 commented Mar 6, 2018

I started to work on it ,seems like there is no difference ,unless I am missing something,can you provide me an example?

  1. UserList users = client.listUsers(null, "status eq "ACTIVE"", null, null, null);
  2. UserList users = client.getDataStore().getResource("Org url with filter",UserList.class)

Are you suggesting that I execute the first step and then pull the getnexturl from the userlist and then use the second step to getdatastore to get the userlistdata?

@bdemers
Copy link
Contributor

bdemers commented Mar 6, 2018

Sort of,
You could keep track of an index as you loop through and set the after query param if you are forced to retry.
https://developer.okta.com/docs/api/resources/users.html#request-parameters-2

@SriG86
Copy link
Author

SriG86 commented Mar 13, 2018

I am trying out the solution that was provided it keeps giving com.okta.sdk.resource.ResourceException: HTTP 400, Okta E0000031 (Invalid search criteria.),

Works:

DEFAULT_FILTER_CRITERIA = "status eq "ACTIVE"";
UserList users = client.listUsers(null, DEFAULT_FILTER_CRITERIA, null, null, null);

Erroring out:

DEFAULT_FILTER_CRITERIA = "status eq "ACTIVE"&limit=150";
UserList users = client.listUsers(null, DEFAULT_FILTER_CRITERIA, null, null, null);

But if I go to postman and execute the criteria like below it works,unless I am missing something.

Works on Postman:

?filter=status%20eq%20%22ACTIVE%22&limit=3&after={OktaaUserID}

@bdemers
Copy link
Contributor

bdemers commented Mar 13, 2018

You would need to call client.getDataStore().getResource() instead of client.listUsers for this work around. Similar to #170 (comment), you could build your query this way.

@SriG86
Copy link
Author

SriG86 commented Mar 13, 2018

Okay,now I understand the filter has been simplified to restrict to what is documented in docs page and anything additional is via getdatastore. Probably documentation in examples would help! :)

@bdemers
Copy link
Contributor

bdemers commented Mar 13, 2018

Agreed, this discussion is helpful to see some of the use cases that we should add some doc for

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants