Skip to content
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

Can't add users to group #162

Closed
tagyoureit opened this issue Mar 28, 2017 · 4 comments
Closed

Can't add users to group #162

tagyoureit opened this issue Mar 28, 2017 · 4 comments
Labels

Comments

@tagyoureit
Copy link
Contributor

When trying to add users to a group, the following error is thrown:

Traceback (most recent call last):
  File "create_group.py", line 50, in <module>
    main()
  File "create_group.py", line 45, in main
    server.groups.add_user(group, new_user._id)
  File "/Library/Python/2.7/site-packages/tableauserverclient/server/endpoint/groups_endpoint.py", line 70, in add_user
    user_set.add(new_user)
AttributeError: 'list' object has no attribute 'add'

The following script demonstrates this error (this was modified from the create_group.py script):

####
# This script demonstrates how to create groups using the Tableau
# Server Client.
#
# To run the script, you must have installed Python 2.7.9 or later.
####


import argparse
import getpass
import logging

from datetime import time

import tableauserverclient as TSC


def main():

    parser = argparse.ArgumentParser(description='Creates groups and add a user to it.')
    parser.add_argument('--server', '-s', required=True, help='server address')
    parser.add_argument('--username', '-u', required=True, help='username to sign into server')
    parser.add_argument('--group', '-g', required=True, help='group to create')
    parser.add_argument('--user-to-add', '-ua', required=True, help='user to add')
    parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error',
                        help='desired logging level (set to error by default)')
    args = parser.parse_args()

    password = getpass.getpass("Password: ")

    # Set logging level based on user input, or error by default
    logging_level = getattr(logging, args.logging_level.upper())
    logging.basicConfig(level=logging_level)

    tableau_auth = TSC.TableauAuth(args.username, password)
    server = TSC.Server(args.server)
    with server.auth.sign_in(tableau_auth):
        group = TSC.GroupItem(args.group)
        group = server.groups.create(group)
        print("Created group {0} with ID: {1}".format(group.name, group._id))
        server.groups.populate_users(group)
        new_user = TSC.UserItem(name=args.user_to_add, site_role='Interactor')
        new_user = server.users.add(new_user)
        print("added {0} with ID: {1}".format(new_user.name, new_user._id))
        server.groups.add_user(group, new_user._id)
        print("added {0} to group {2}".format(new_user.name, group.name))

if __name__ == '__main__':
    main()
@t8y8
Copy link
Collaborator

t8y8 commented Mar 28, 2017

I swear I've fixed this before, but I see the bug in the code.

We stopped using sets before we even shipped v 0.1

@t8y8 t8y8 added the bug label Mar 28, 2017
@t8y8
Copy link
Collaborator

t8y8 commented Mar 28, 2017

Solution: Full source search for .add and remove them all (replace with append usually), except for tags.

@t8y8 t8y8 mentioned this issue Mar 28, 2017
@isajediknight
Copy link

I would like to request this feature as well. The ability to add users to a group - and then setting the permissions of those users.

@t8y8
Copy link
Collaborator

t8y8 commented Apr 10, 2017

@isajediknight this was a bug that has now been fixed and checked in.

The Permissions discussion is underway, consider your vote noted!

@t8y8 t8y8 closed this as completed Apr 10, 2017
@seanbird2
Copy link

Is there any functionality to add users to a specific project? Thanks!

bryceglarsen pushed a commit to bryceglarsen/server-client-python that referenced this issue Dec 28, 2023
 tableau#162 preserve the xmlns:user namespace when saving a file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants