8000 Updates to Group Documentation and user pagination options by cmtoomey · Pull Request #142 · tableau/server-client-python · GitHub
[go: up one dir, main page]

Skip to content

Updates to Group Documentation and user pagination options #142

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

Closed
wants to merge 4 commits into from
Closed

Updates to Group Documentation and user pagination options #142

wants to merge 4 commits into from

Conversation

cmtoomey
Copy link
Contributor

Per #141, adding a pagination object to groups.populate_users solved the problem. There is still no way to know how many users are in a group, without actually running populate_users and pulling total_available.

I also added documentation so others will be able to walk through group interaction.

Copy link
Collaborator
@t8y8 t8y8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chris!

Glad to see you contributing!

You'll need to sign the CLA as well, is that in progress?

if not group_item.id:
error = "Group item missing ID. Group must be retrieved from server first."
raise MissingRequiredFieldError(error)
url = "{0}/{1}/users".format(self.baseurl, group_item.id)
url = "{0}/{1}/users?pageSize={2}".format(self.baseurl, group_item.id,page_size)
server_response = self.get_request(url, req_options)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will, sadly, still fail for cases where groups have more than the max page size, which is 1000.

I haven't reviewed this part of the design recently, but we need a way to either:

  1. Make Pager work with populating group calls or
  2. Make this user Pager under the covers.

/cc @RussTheAerialist

I'll have some time later this week to think about it in detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will fail - but so will the standard API call. Moving to Pager would be very helpful.

```
groups = server.groups.get()
```
Returns two objects - the groups and the pagination item. To access info about groups
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The preferred way to show this would be:
groups, _ = server.groups.get()

Instead of indexing the 2-tuple

The group object contains the same information as the standard XML from REST API. For Sites with more than one group, you can access each individual group like this.

```
#To see the attributes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically true, but not really scl related, I would this out

#To see the attributes
dir(group_list[i])

#use these attributes (domain_name, id, name, users)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this isn't doc'd yet (which I'm sure it isn't?) can you list out the group class and it's attributes with a brief one-liner.

OR, if you'd like, submit a docstring for those classes first, and then update the docs?

@cmtoomey
Copy link
Contributor Author

CLA Request submitted - @t8y8 updates pushed per your comments in the meantime.

@t8y8
Copy link
Collaborator
t8y8 commented Feb 14, 2017

@cmtoomey I think I came up with a way to make this use Pager.

But it's got 4 parts to it:

  1. Refactor Pager to accept any 'getter' endpoint
  2. Refactor the logic so there's a _get_users_for_group getter
  3. Refactor _set_users to take a list of user objects instead of an xml response
  4. Call it all from populate_users.
  5. Do this for Connections, Views, and everything else :(

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

Successfully merging this pull request may close these issues.

3 participants
0