diff --git a/actions/users_filter_by.py b/actions/users_filter_by.py index 095d049..b5d8bf7 100644 --- a/actions/users_filter_by.py +++ b/actions/users_filter_by.py @@ -24,16 +24,21 @@ def run(self, **kwargs): attrs = kwargs.pop('attributes') res = super(FilterBy, self).run(**kwargs) - for user in res['members']: - match = True - for key, val in attrs.items(): - if isinstance(val, six.string_types): - if not fnmatch(user.get(key, ''), val): + while res.get('response_metadata').get('next_cursor'): + for user in res['members']: + match = True + for key, val in attrs.items(): + if isinstance(val, six.string_types): + if not fnmatch(user.get(key, ''), val): + match = False + elif user.get(key) != val: match = False - elif user.get(key) != val: - match = False - if match: - users.append(user) + if match: + users.append(user) + + kwargs.update({'cursor': res.get('response_metadata').get('next_cursor')}) + self.logger.debug(f"Next cursor: {kwargs.get('cursor')}") + res = super(FilterBy, self).run(**kwargs) return users