How to use the tableauserverclient.SiteItem 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_site.py View on Github external
def test_update_missing_id(self):
        single_site = TSC.SiteItem('test', 'test')
        self.assertRaises(TSC.MissingRequiredFieldError, self.server.sites.update, single_site)
github tableau / server-client-python / test / test_site_model.py View on Github external
def test_invalid_revision_history_enabled(self):
        site = TSC.SiteItem("site", "url")
        with self.assertRaises(ValueError):
            site.revision_history_enabled = "Hello"

        with self.assertRaises(ValueError):
            site.revision_history_enabled = None
github tableau / server-client-python / test / test_site.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 + '/6b7179ba-b82b-4f0f-91ed-812074ac5da6', text=response_xml)
            single_site = TSC.SiteItem(name='Tableau', content_url='tableau',
                                       admin_mode=TSC.SiteItem.AdminMode.ContentAndUsers,
                                       user_quota=15, storage_quota=1000,
                                       disable_subscriptions=True, revision_history_enabled=False,
                                       materialized_views_mode='disable')
            single_site._id = '6b7179ba-b82b-4f0f-91ed-812074ac5da6'
            single_site = self.server.sites.update(single_site)

        self.assertEqual('6b7179ba-b82b-4f0f-91ed-812074ac5da6', single_site.id)
        self.assertEqual('tableau', single_site.content_url)
        self.assertEqual('Suspended', single_site.state)
        self.assertEqual('Tableau', single_site.name)
        self.assertEqual('ContentAndUsers', single_site.admin_mode)
        self.assertEqual(True, single_site.revision_history_enabled)
        self.assertEqual(13, single_site.revision_limit)
        self.assertEqual(True, single_site.disable_subscriptions)
        self.assertEqual(15, single_site.user_quota)
github tableau / server-client-python / test / test_site_model.py View on Github external
def test_invalid_state(self):
        site = TSC.SiteItem("site", "url")
        with self.assertRaises(ValueError):
            site.state = "Hello"
github tableau / server-client-python / test / test_site_model.py View on Github external
def test_invalid_name(self):
        self.assertRaises(ValueError, TSC.SiteItem, None, "url")
        self.assertRaises(ValueError, TSC.SiteItem, "", "url")
        site = TSC.SiteItem("site", "url")
        with self.assertRaises(ValueError):
            site.name = None

        with self.assertRaises(ValueError):
            site.name = ""
github tableau / server-client-python / test / test_site_model.py View on Github external
def test_invalid_content_url(self):

        with self.assertRaises(ValueError):
            site = TSC.SiteItem(name="蚵仔煎", content_url="蚵仔煎")

        with self.assertRaises(ValueError):
            site = TSC.SiteItem(name="蚵仔煎", content_url=None)
github tableau / server-client-python / test / test_site.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 + '/6b7179ba-b82b-4f0f-91ed-812074ac5da6', text=response_xml)
            single_site = TSC.SiteItem(name='Tableau', content_url='tableau',
                                       admin_mode=TSC.SiteItem.AdminMode.ContentAndUsers,
                                       user_quota=15, storage_quota=1000,
                                       disable_subscriptions=True, revision_history_enabled=False,
                                       materialized_views_mode='disable')
            single_site._id = '6b7179ba-b82b-4f0f-91ed-812074ac5da6'
            single_site = self.server.sites.update(single_site)

        self.assertEqual('6b7179ba-b82b-4f0f-91ed-812074ac5da6', single_site.id)
        self.assertEqual('tableau', single_site.content_url)
        self.assertEqual('Suspended', single_site.state)
        self.assertEqual('Tableau', single_site.name)
        self.assertEqual('ContentAndUsers', single_site.admin_mode)
        self.assertEqual(True, single_site.revision_history_enabled)
        self.assertEqual(13, single_site.revision_limit)
        self.assertEqual(True, single_site.disable_subscriptions)
        self.assertEqual(15, single_site.user_quota)
        self.assertEqual('disable', single_site.materialized_views_mode)
github tableau / server-client-python / samples / tabcmd.py View on Github external
# parser.add_argument('--allow-mobile-snapshots', '-ams', required=False, default=True, action='store_true', help='Allow [or-deny] mobile snapshots. Default is to allow mobile snapshots')               # TODO NOTSUPPORTED this isn't currently supported in TSC
        # parser.add_argument('--allow-web-authoring', '-awa', required=False, default=True, action='store_true', help='Allow [or deny] web authoring for this site. Default is to allow web authoring')          # TODO NOTSUPPORTED this isn't currently supported in TSC
        # parser.add_argument('--subscription-email', '-e', required=False, help='Email used for subscriptions')               # TODO NOTSUPPORTED this isn't currently supported in TSC
        # parser.add_argument('--subcription-footer', '-f', required=False, help='Footer used for subscriptions')               # TODO NOTSUPPORTED this isn't currently supported in TSC
        # parser.add_argument('--guest-access-enabled', '-g', required=False, help='Guest access permission to see views for those that are not signed into a Tableau Server account')               # TODO NOTSUPPORTED this isn't currently supported in TSC
        # parser.add_argument('--metrics-level', '-m', required=False, help='0 for no collection, 100 for all collections')               # TODO NOTSUPPORTED this isn't currently supported in TSC
        
        # now that we're inside a subcommand, ignore the first TWO argvs, ie the command (tabcmd) and the subcommand (createsite)
        args = parser.parse_args(sys.argv[2:])
        print('Running tabcmd {0}, name={1}, allow-subscriptions={2}, site-mode={3}, url={4}, storage-quota={5}, user-quota={6}'.format(sys._getframe().f_code.co_name, args.name, args.allow_subscriptions, args.site_mode, args.url, args.storage_quota, args.user_quota))
        server = self.set_server_from_session_file()

        # Set-up our SiteItem's AdminMode
        am = TSC.SiteItem.AdminMode.ContentAndUsers
        if args.site_mode == False:
            am = TSC.SiteItem.AdminMode.ContentOnly

        print('about to call with disable_subcriptions={0}'.format(not args.allow_subscriptions))
        print('am is {0}'.format(am))
        new_site = TSC.SiteItem(name=args.name, content_url=args.url, admin_mode=am, user_quota=args.user_quota, storage_quota=args.storage_quota, disable_subscriptions= not args.allow_subscriptions)
        site = server.sites.create(new_site)
github tableau / server-client-python / samples / tabcmd.py View on Github external
# parser.add_argument('--guest-access-enabled', '-g', required=False, help='Guest access permission to see views for those that are not signed into a Tableau Server account')               # TODO NOTSUPPORTED this isn't currently supported in TSC
        # parser.add_argument('--metrics-level', '-m', required=False, help='0 for no collection, 100 for all collections')               # TODO NOTSUPPORTED this isn't currently supported in TSC
        
        # now that we're inside a subcommand, ignore the first TWO argvs, ie the command (tabcmd) and the subcommand (createsite)
        args = parser.parse_args(sys.argv[2:])
        print('Running tabcmd {0}, name={1}, allow-subscriptions={2}, site-mode={3}, url={4}, storage-quota={5}, user-quota={6}'.format(sys._getframe().f_code.co_name, args.name, args.allow_subscriptions, args.site_mode, args.url, args.storage_quota, args.user_quota))
        server = self.set_server_from_session_file()

        # Set-up our SiteItem's AdminMode
        am = TSC.SiteItem.AdminMode.ContentAndUsers
        if args.site_mode == False:
            am = TSC.SiteItem.AdminMode.ContentOnly

        print('about to call with disable_subcriptions={0}'.format(not args.allow_subscriptions))
        print('am is {0}'.format(am))
        new_site = TSC.SiteItem(name=args.name, content_url=args.url, admin_mode=am, user_quota=args.user_quota, storage_quota=args.storage_quota, disable_subscriptions= not args.allow_subscriptions)
        site = server.sites.create(new_site)
github tableau / server-client-python / samples / initialize_server.py View on Github external
with server.auth.sign_in(tableau_auth):

        ################################################################################
        # Step 2: Create the site we need only if it doesn't exist
        ################################################################################
        print("Checking to see if we need to create the site...")

        all_sites, _ = server.sites.get()
        existing_site = next((s for s in all_sites if s.name == args.site), None)

        # Create the site if it doesn't exist
        if existing_site is None:
            print("Site not found: {0} Creating it...").format(args.site)
            new_site = TSC.SiteItem(name=args.site, content_url=args.site.replace(" ", ""),
                                    admin_mode=TSC.SiteItem.AdminMode.ContentAndUsers)
            server.sites.create(new_site)
        else:
            print("Site {0} exists. Moving on...").format(args.site)

    ################################################################################
    # Step 3: Sign-in to our target site
    ################################################################################
    print("Starting our content upload...")
    server_upload = TSC.Server(args.server)
    tableau_auth.site = args.site

    with server_upload.auth.sign_in(tableau_auth):

        ################################################################################
        # Step 4: Create the project we need only if it doesn't exist
        ################################################################################