{"action":"created","issue":{"url":"https://api.github.com/repos/tableau/server-client-python/issues/90","repository_url":"https://api.github.com/repos/tableau/server-client-python","labels_url":"https://api.github.com/repos/tableau/server-client-python/issues/90/labels{/name}","comments_url":"https://api.github.com/repos/tableau/server-client-python/issues/90/comments","events_url":"https://api.github.com/repos/tableau/server-client-python/issues/90/events","html_url":"https://github.com/tableau/server-client-python/pull/90","id":186198083,"number":90,"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},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-31T03:54:34Z","updated_at":"2016-10-31T20:15:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/tableau/server-client-python/pulls/90","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"},"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 "},"comment":{"url":"https://api.github.com/repos/tableau/server-client-python/issues/comments/257407611","html_url":"https://github.com/tableau/server-client-python/pull/90#issuecomment-257407611","issue_url":"https://api.github.com/repos/tableau/server-client-python/issues/90","id":257407611,"user":{"login":"LGraber","id":7854459,"avatar_url":"https://avatars.githubusercontent.com/u/7854459?v=3","gravatar_id":"","url":"https://api.github.com/users/LGraber","html_url":"https://github.com/LGraber","followers_url":"https://api.github.com/users/LGraber/followers","following_url":"https://api.github.com/users/LGraber/following{/other_user}","gists_url":"https://api.github.com/users/LGraber/gists{/gist_id}","starred_url":"https://api.github.com/users/LGraber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LGraber/subscriptions","organizations_url":"https://api.github.com/users/LGraber/orgs","repos_url":"https://api.github.com/users/LGraber/repos","events_url":"https://api.github.com/users/LGraber/events{/privacy}","received_events_url":"https://api.github.com/users/LGraber/received_events","type":"User","site_admin":false},"created_at":"2016-10-31T20:15:27Z","updated_at":"2016-10-31T20:15:27Z","body":"I am confused because the tests don't represent how we expect the users to use this class (ie you keep casting to list and doing len) and you don't have a sample of how to use it. Can you please add a sample"}}
{"actor":{"display_login":"LGraber"}}