slackapi / python-slack-sdk

Slack Developer Kit for Python
https://tools.slack.dev/python-slack-sdk/
MIT License
3.86k stars 834 forks source link

More convenient pagination support in SCIM / Audit Logs API clients #1121

Open ruberVulpes opened 3 years ago

ruberVulpes commented 3 years ago

If it's possible I'd love for the SCIMClient's searches to be able to be paginated like the WebClient does with the SlackResponse. It looks like it could be done with the body returned.

Category (place an x in each of the [ ])

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

seratch commented 3 years ago

Hi @ruberVulpes, thanks for writing in! Indeed, that should be more convenient in some situations.

One challenge around the feature addition is that, if we enhance the response class as with the WebClient, the internals of the response/client classes can be a bit complex. The reason is that we have to properly support both the default and asyncio-based clients.

Thus, I am thinking that providing a kind of wrapper class (in other words, decorator in GoF design pattern) may be easier and cleaner. Here is pseudo code illustrating how it can work:

client = SCIMClient(token=os.environ["SLACK_ORG_ADMIN_USER_TOKEN"])
paginator = SCIMClientPaginator(client)

for page in paginator.search_users(filter="""filter=userName Eq "Carly""""):
    print(page.users) # list

Also, if we add this feature to the SCIM clients, we can do the same for the Audit Logs clients too.