{"action":"created","comment":{"url":"https://api.github.com/repos/tableau/server-client-python/pulls/comments/85741766","pull_request_review_id":6438861,"id":85741766,"diff_hunk":"@@ -1,8 +1,47 @@\n from .exceptions import NotSignedInError\n from .endpoint import Sites, Views, Users, Groups, Workbooks, Datasources, Projects, Auth, Schedules, ServerInfo\n+from . import RequestOptions\n+\n import requests\n \n \n+class Pager(object):\n+    \"\"\" This class returns a generator that will iterate over all of the results.\n+\n+    server is the server object that will be used when calling the callback.  It will be passed\n+    to the callback on each iteration\n+\n+    Callback is expected to take a server object and a request options and return two values, an array of results,\n+    and the pagination item from the current call.  This will be used to build subsequent requests.\n+    \"\"\"\n+\n+    def __init__(self, fetcher, opts=None):\n+        self._fetcher = fetcher.get\n+        self._options = opts\n+\n+    def __call__(self):","path":"tableauserverclient/server/server.py","position":22,"original_position":22,"commit_id":"d4fe1c3d39bd3381fae3a428f2868cfc93e91f37","original_commit_id":"d4fe1c3d39bd3381fae3a428f2868cfc93e91f37","user":{"login":"RussTheAerialist","id":94549,"avatar_url":"https://avatars.githubusercontent.com/u/94549?v=3","gravatar_id":"","url":"https://api.github.com/users/RussTheAerialist","html_url":"https://github.com/RussTheAerialist","followers_url":"https://api.github.com/users/RussTheAerialist/followers","following_url":"https://api.github.com/users/RussTheAerialist/following{/other_user}","gists_url":"https://api.github.com/users/RussTheAerialist/gists{/gist_id}","starred_url":"https://api.github.com/users/RussTheAerialist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RussTheAerialist/subscriptions","organizations_url":"https://api.github.com/users/RussTheAerialist/orgs","repos_url":"https://api.github.com/users/RussTheAerialist/repos","events_url":"https://api.github.com/users/RussTheAerialist/events{/privacy}","received_events_url":"https://api.github.com/users/RussTheAerialist/received_events","type":"User","site_admin":false},"body":"yeah this is not ideal.  It should probably just live in `__iter__` and we get rid of `__call__`","created_at":"2016-10-31T13:53:41Z","updated_at":"2016-10-31T13:57:29Z","html_url":"https://github.com/tableau/server-client-python/pull/90#discussion_r85741766","pull_request_url":"https://api.github.com/repos/tableau/server-client-python/pulls/90","_links":{"self":{"href":"https://api.github.com/repos/tableau/server-client-python/pulls/comments/85741766"},"html":{"href":"https://github.com/tableau/server-client-python/pull/90#discussion_r85741766"},"pull_request":{"href":"https://api.github.com/repos/tableau/server-client-python/pulls/90"}}},"pull_request":{"url":"https://api.github.com/repos/tableau/server-client-python/pulls/90","id":91553722,"html_url":"https://github.com/tableau/server-client-python/pull/90","diff_url":"https://github.com/tableau/server-client-python/pull/90.diff","patch_url":"https://github.com/tableau/server-client-python/pull/90.patch","issue_url":"https://api.github.com/repos/tableau/server-client-python/issues/90","number":90,"state":"open","locked":false,"title":"Implement Pager for auto-paging requests","user":{"login":"t8y8","id":4370533,"avatar_url":"https://avatars.githubusercontent.com/u/4370533?v=3","gravatar_id":"","url":"https://api.github.com/users/t8y8","html_url":"https://github.com/t8y8","followers_url":"https://api.github.com/users/t8y8/followers","following_url":"https://api.github.com/users/t8y8/following{/other_user}","gists_url":"https://api.github.com/users/t8y8/gists{/gist_id}","starred_url":"https://api.github.com/users/t8y8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/t8y8/subscriptions","organizations_url":"https://api.github.com/users/t8y8/orgs","repos_url":"https://api.github.com/users/t8y8/repos","events_url":"https://api.github.com/users/t8y8/events{/privacy}","received_events_url":"https://api.github.com/users/t8y8/received_events","type":"User","site_admin":false},"body":"Here's a first draft based on @RussTheAerialist's code in `pagination_sample.py`.\r\n\r\nCurrently it:\r\n- Takes an endpoint as its argument instead of a `get` function, this is because these calls only apply to `get` anyway, so let's keep it clean.\r\n- Takes an options object and seeds the filters/sorts with it, as well as the initial page size\r\n- Can be used as an iterator\r\n\r\nI would like it to:\r\n\r\n- Not do everything in the `__call__` method. I _think_ we can move that to a helper or to `__init__`\r\n    - We would make the first page call on instantiation, which populates some properties that could be useful (like `__len__`)\r\n- Since we know the `total_avaliable` we might be able to implement `__len__`. This gives users the ability to check the length to see if they really want to iterate over it or not.\r\n- I need to read more to see if I need to worry about `__next__` or not.\r\n- Add tests\r\n\r\nThis script works (tested manually):\r\n```python\r\nimport tableauserverclient as TSC\r\n\r\nauth_stuff = TSC.TableauAuth(username='USERNAME', password='PASSWORD')\r\n\r\nserver = TSC.Server(\"http://SERVER\")\r\nserver.auth.sign_in(auth_stuff)\r\n\r\noptions = TSC.RequestOptions()\r\noptions.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,\r\n                                         TSC.RequestOptions.Operator.Equals,\r\n                                         \"WORKBOOKNAME\"))\r\n\r\n# Call with a filter\r\nwbs = TSC.server.Pager(server.workbooks, options)\r\nprint(len([i for i in wbs[)) # prints 1\r\n\r\n# Get them all!\r\nwbs = TSC.server.Pager(server.workbooks)\r\nprint(len([i for i in wbs])) # prints 1086 on my test server, that's all of em!\r\nserver.auth.sign_out()\r\n```\r\n\r\nOpen Questions:\r\n\r\n1. Where should it live? I'm not sure Server is the right place\r\n2. Thoughts on implementing `__len__`?\r\n3. Thoughts on implementing the primary logic somewhere other than `__call__`? It might just be me who thinks it's weird.\r\n\r\n/cc @RussTheAerialist @LGraber ","created_at":"2016-10-31T03:54:34Z","updated_at":"2016-10-31T13:57:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ffe9b3005c086156b290e044762d176c3a3aebfe","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tableau/server-client-python/pulls/90/commits","review_comments_url":"https://api.github.com/repos/tableau/server-client-python/pulls/90/comments","review_comment_url":"https://api.github.com/repos/tableau/server-client-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tableau/server-client-python/issues/90/comments","statuses_url":"https://api.github.com/repos/tableau/server-client-python/statuses/d4fe1c3d39bd3381fae3a428f2868cfc93e91f37","head":{"label":"t8y8:85-feature-pager","ref":"85-feature-pager","sha":"d4fe1c3d39bd3381fae3a428f2868cfc93e91f37","user":{"login":"t8y8","id":4370533,"avatar_url":"https://avatars.githubusercontent.com/u/4370533?v=3","gravatar_id":"","url":"https://api.github.com/users/t8y8","html_url":"https://github.com/t8y8","followers_url":"https://api.github.com/users/t8y8/followers","following_url":"https://api.github.com/users/t8y8/following{/other_user}","gists_url":"https://api.github.com/users/t8y8/gists{/gist_id}","starred_url":"https://api.github.com/users/t8y8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/t8y8/subscriptions","organizations_url":"https://api.github.com/users/t8y8/orgs","repos_url":"https://api.github.com/users/t8y8/repos","events_url":"https://api.github.com/users/t8y8/events{/privacy}","received_events_url":"https://api.github.com/users/t8y8/received_events","type":"User","site_admin":false},"repo":{"id":67840314,"name":"server-client-python","full_name":"t8y8/server-client-python","owner":{"login":"t8y8","id":4370533,"avatar_url":"https://avatars.githubusercontent.com/u/4370533?v=3","gravatar_id":"","url":"https://api.github.com/users/t8y8","html_url":"https://github.com/t8y8","followers_url":"https://api.github.com/users/t8y8/followers","following_url":"https://api.github.com/users/t8y8/following{/other_user}","gists_url":"https://api.github.com/users/t8y8/gists{/gist_id}","starred_url":"https://api.github.com/users/t8y8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/t8y8/subscriptions","organizations_url":"https://api.github.com/users/t8y8/orgs","repos_url":"https://api.github.com/users/t8y8/repos","events_url":"https://api.github.com/users/t8y8/events{/privacy}","received_events_url":"https://api.github.com/users/t8y8/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/t8y8/server-client-python","description":"Python client library for Tableau Server","fork":true,"url":"https://api.github.com/repos/t8y8/server-client-python","forks_url":"https://api.github.com/repos/t8y8/server-client-python/forks","keys_url":"https://api.github.com/repos/t8y8/server-client-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/t8y8/server-client-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/t8y8/server-client-python/teams","hooks_url":"https://api.github.com/repos/t8y8/server-client-python/hooks","issue_events_url":"https://api.github.com/repos/t8y8/server-client-python/issues/events{/number}","events_url":"https://api.github.com/repos/t8y8/server-client-python/events","assignees_url":"https://api.github.com/repos/t8y8/server-client-python/assignees{/user}","branches_url":"https://api.github.com/repos/t8y8/server-client-python/branches{/branch}","tags_url":"https://api.github.com/repos/t8y8/server-client-python/tags","blobs_url":"https://api.github.com/repos/t8y8/server-client-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/t8y8/server-client-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/t8y8/server-client-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/t8y8/server-client-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/t8y8/server-client-python/statuses/{sha}","languages_url":"https://api.github.com/repos/t8y8/server-client-python/languages","stargazers_url":"https://api.github.com/repos/t8y8/server-client-python/stargazers","contributors_url":"https://api.github.com/repos/t8y8/server-client-python/contributors","subscribers_url":"https://api.github.com/repos/t8y8/server-client-python/subscribers","subscription_url":"https://api.github.com/repos/t8y8/server-client-python/subscription","commits_url":"https://api.github.com/repos/t8y8/server-client-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/t8y8/server-client-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/t8y8/server-client-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/t8y8/server-client-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/t8y8/server-client-python/contents/{+path}","compare_url":"https://api.github.com/repos/t8y8/server-client-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/t8y8/server-client-python/merges","archive_url":"https://api.github.com/repos/t8y8/server-client-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/t8y8/server-client-python/downloads","issues_url":"https://api.github.com/repos/t8y8/server-client-python/issues{/number}","pulls_url":"https://api.github.com/repos/t8y8/server-client-python/pulls{/number}","milestones_url":"https://api.github.com/repos/t8y8/server-client-python/milestones{/number}","notifications_url":"https://api.github.com/repos/t8y8/server-client-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/t8y8/server-client-python/labels{/name}","releases_url":"https://api.github.com/repos/t8y8/server-client-python/releases{/id}","deployments_url":"https://api.github.com/repos/t8y8/server-client-python/deployments","created_at":"2016-09-10T00:04:59Z","updated_at":"2016-09-10T00:06:02Z","pushed_at":"2016-10-31T03:45:53Z","git_url":"git://github.com/t8y8/server-client-python.git","ssh_url":"git@github.com:t8y8/server-client-python.git","clone_url":"https://github.com/t8y8/server-client-python.git","svn_url":"https://github.com/t8y8/server-client-python","homepage":null,"size":393,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tableau:development","ref":"development","sha":"101eedba15b45bd487204663f92424132920a706","user":{"login":"tableau","id":828667,"avatar_url":"https://avatars.githubusercontent.com/u/828667?v=3","gravatar_id":"","url":"https://api.github.com/users/tableau","html_url":"https://github.com/tableau","followers_url":"https://api.github.com/users/tableau/followers","following_url":"https://api.github.com/users/tableau/following{/other_user}","gists_url":"https://api.github.com/users/tableau/gists{/gist_id}","starred_url":"https://api.github.com/users/tableau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tableau/subscriptions","organizations_url":"https://api.github.com/users/tableau/orgs","repos_url":"https://api.github.com/users/tableau/repos","events_url":"https://api.github.com/users/tableau/events{/privacy}","received_events_url":"https://api.github.com/users/tableau/received_events","type":"Organization","site_admin":false},"repo":{"id":62177327,"name":"server-client-python","full_name":"tableau/server-client-python","owner":{"login":"tableau","id":828667,"avatar_url":"https://avatars.githubusercontent.com/u/828667?v=3","gravatar_id":"","url":"https://api.github.com/users/tableau","html_url":"https://github.com/tableau","followers_url":"https://api.github.com/users/tableau/followers","following_url":"https://api.github.com/users/tableau/following{/other_user}","gists_url":"https://api.github.com/users/tableau/gists{/gist_id}","starred_url":"https://api.github.com/users/tableau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tableau/subscriptions","organizations_url":"https://api.github.com/users/tableau/orgs","repos_url":"https://api.github.com/users/tableau/repos","events_url":"https://api.github.com/users/tableau/events{/privacy}","received_events_url":"https://api.github.com/users/tableau/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tableau/server-client-python","description":"Python client library for Tableau Server","fork":false,"url":"https://api.github.com/repos/tableau/server-client-python","forks_url":"https://api.github.com/repos/tableau/server-client-python/forks","keys_url":"https://api.github.com/repos/tableau/server-client-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tableau/server-client-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tableau/server-client-python/teams","hooks_url":"https://api.github.com/repos/tableau/server-client-python/hooks","issue_events_url":"https://api.github.com/repos/tableau/server-client-python/issues/events{/number}","events_url":"https://api.github.com/repos/tableau/server-client-python/events","assignees_url":"https://api.github.com/repos/tableau/server-client-python/assignees{/user}","branches_url":"https://api.github.com/repos/tableau/server-client-python/branches{/branch}","tags_url":"https://api.github.com/repos/tableau/server-client-python/tags","blobs_url":"https://api.github.com/repos/tableau/server-client-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tableau/server-client-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tableau/server-client-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/tableau/server-client-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tableau/server-client-python/statuses/{sha}","languages_url":"https://api.github.com/repos/tableau/server-client-python/languages","stargazers_url":"https://api.github.com/repos/tableau/server-client-python/stargazers","contributors_url":"https://api.github.com/repos/tableau/server-client-python/contributors","subscribers_url":"https://api.github.com/repos/tableau/server-client-python/subscribers","subscription_url":"https://api.github.com/repos/tableau/server-client-python/subscription","commits_url":"https://api.github.com/repos/tableau/server-client-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/tableau/server-client-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/tableau/server-client-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/tableau/server-client-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/tableau/server-client-python/contents/{+path}","compare_url":"https://api.github.com/repos/tableau/server-client-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tableau/server-client-python/merges","archive_url":"https://api.github.com/repos/tableau/server-client-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tableau/server-client-python/downloads","issues_url":"https://api.github.com/repos/tableau/server-client-python/issues{/number}","pulls_url":"https://api.github.com/repos/tableau/server-client-python/pulls{/number}","milestones_url":"https://api.github.com/repos/tableau/server-client-python/milestones{/number}","notifications_url":"https://api.github.com/repos/tableau/server-client-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tableau/server-client-python/labels{/name}","releases_url":"https://api.github.com/repos/tableau/server-client-python/releases{/id}","deployments_url":"https://api.github.com/repos/tableau/server-client-python/deployments","created_at":"2016-06-28T22:05:32Z","updated_at":"2016-10-25T16:28:05Z","pushed_at":"2016-10-31T03:54:34Z","git_url":"git://github.com/tableau/server-client-python.git","ssh_url":"git@github.com:tableau/server-client-python.git","clone_url":"https://github.com/tableau/server-client-python.git","svn_url":"https://github.com/tableau/server-client-python","homepage":null,"size":469,"stargazers_count":12,"watchers_count":12,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":22,"forks":6,"open_issues":22,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tableau/server-client-python/pulls/90"},"html":{"href":"https://github.com/tableau/server-client-python/pull/90"},"issue":{"href":"https://api.github.com/repos/tableau/server-client-python/issues/90"},"comments":{"href":"https://api.github.com/repos/tableau/server-client-python/issues/90/comments"},"review_comments":{"href":"https://api.github.com/repos/tableau/server-client-python/pulls/90/comments"},"review_comment":{"href":"https://api.github.com/repos/tableau/server-client-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tableau/server-client-python/pulls/90/commits"},"statuses":{"href":"https://api.github.com/repos/tableau/server-client-python/statuses/d4fe1c3d39bd3381fae3a428f2868cfc93e91f37"}}}}
{"actor":{"display_login":"RussTheAerialist"}}