How to use the tableauserverclient.GroupItem function in tableauserverclient

To help you get started, we’ve selected a few tableauserverclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tableau / server-client-python / test / test_group.py View on Github external
def test_update(self):
        with open(UPDATE_XML, 'rb') as f:
            response_xml = f.read().decode('utf-8')
        with requests_mock.mock() as m:
            m.put(self.baseurl + '/ef8b19c0-43b6-11e6-af50-63f5805dbe3c', text=response_xml)
            group = TSC.GroupItem(name='Test Group')
            group._domain_name = 'local'
            group._id = 'ef8b19c0-43b6-11e6-af50-63f5805dbe3c'
            group = self.server.groups.update(group)

        self.assertEqual('ef8b19c0-43b6-11e6-af50-63f5805dbe3c', group.id)
        self.assertEqual('Group updated name', group.name)
github tableau / server-client-python / test / test_group.py View on Github external
def test_create_group(self):
        with open(CREATE_GROUP, 'rb') as f:
            response_xml = f.read().decode('utf-8')
        with requests_mock.mock() as m:
            m.post(self.baseurl, text=response_xml)
            group_to_create = TSC.GroupItem(u'試供品')
            group = self.server.groups.create(group_to_create)
            self.assertEqual(group.name, u'試供品')
            self.assertEqual(group.id, '3e4a9ea0-a07a-4fe6-b50f-c345c8c81034')
github tableau / server-client-python / test / test_group.py View on Github external
def test_add_user_missing_user_id(self):
        with open(POPULATE_USERS, 'rb') as f:
            response_xml = f.read().decode('utf-8')
        with requests_mock.mock() as m:
            m.get(self.baseurl + '/e7833b48-c6f7-47b5-a2a7-36e7dd232758/users', text=response_xml)
            single_group = TSC.GroupItem(name='Test Group')
            single_group._id = 'e7833b48-c6f7-47b5-a2a7-36e7dd232758'
            self.server.groups.populate_users(single_group)

        self.assertRaises(ValueError, self.server.groups.add_user, single_group, '')
github tableau / server-client-python / test / test_group.py View on Github external
def test_add_user(self):
        with open(ADD_USER, 'rb') as f:
            response_xml_add = f.read().decode('utf-8')
        with open(ADD_USER_POPULATE, 'rb') as f:
            response_xml_populate = f.read().decode('utf-8')
        with requests_mock.mock() as m:
            m.post(self.baseurl + '/e7833b48-c6f7-47b5-a2a7-36e7dd232758/users', text=response_xml_add)
            m.get(self.baseurl + '/e7833b48-c6f7-47b5-a2a7-36e7dd232758/users', text=response_xml_populate)
            single_group = TSC.GroupItem('test')
            single_group._id = 'e7833b48-c6f7-47b5-a2a7-36e7dd232758'

            self.server.groups.add_user(single_group, '5de011f8-5aa9-4d5b-b991-f462c8dd6bb7')
            self.server.groups.populate_users(single_group)
            self.assertEqual(1, len(list(single_group.users)))
            user = list(single_group.users).pop()
            self.assertEqual('5de011f8-5aa9-4d5b-b991-f462c8dd6bb7', user.id)
            self.assertEqual('testuser', user.name)
            self.assertEqual('ServerAdministrator', user.site_role)
github tableau / server-client-python / samples / filter_sort_groups.py View on Github external
def create_example_group(group_name='Example Group', server=None):
    new_group = TSC.GroupItem(group_name)
    try:
        new_group = server.groups.create(new_group)
        print('Created a new project called: \'%s\'' % group_name)
        print(new_group)
    except TSC.ServerResponseError:
        print('Group \'%s\' already existed' % group_name)
github tableau / server-client-python / samples / tabcmd.py View on Github external
def creategroup(self):
        parser = argparse.ArgumentParser(description='Create a local group')
        parser.add_argument('groupname', help='Name of the group to create')        # positional, required argument
        # now that we're inside a subcommand, ignore the first TWO argvs, ie the command (tabcmd) and the subcommand (creategroup)
        args = parser.parse_args(sys.argv[2:])
        # print('Running tabcmd {0}, groupname={1}'.format(sys._getframe().f_code.co_name, args.groupname))

        server = self.set_server_from_session_file()
        new_group = TSC.GroupItem(args.groupname)
        group = server.groups.create(new_group)