8000 Merge pull request #22 from tableau/rename-project · sotnich/server-client-python@0dab12e · GitHub
[go: up one dir, main page]

Skip to content

Commit 0dab12e

Browse files
authored
Merge pull request tableau#22 from tableau/rename-project
renamining from tableauserverapi to tableauserverclient
2 parents dbae807 + e7e6df6 commit 0dab12e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+140
-140
lines changed

README.md

Lines changed: 5 additions & 5 deletions

samples/explore_datasource.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
####
1111

1212

13-
import tableauserverapi as TSA
13+
import tableauserverclient as TSC
1414
import os.path
1515
import argparse
1616
import getpass
@@ -32,8 +32,8 @@
3232
logging.basicConfig(level=logging_level)
3333

3434
##### SIGN IN #####
35-
tableau_auth = TSA.TableauAuth(args.username, password)
36-
server = TSA.Server(args.server)
35+
tableau_auth = TSC.TableauAuth(args.username, password)
36+
server = TSC.Server(args.server)
3737
with server.auth.sign_in(tableau_auth):
3838

3939
# Query projects for use when demonstrating publishing and updating
@@ -43,7 +43,7 @@
4343
# Publish datasource if publish flag is set (-publish, -p)
4444
if args.publish:
4545
if default_project is not None:
46-
new_datasource = TSA.DatasourceItem(default_project.id)
46+
new_datasource = TSC.DatasourceItem(default_project.id)
4747
new_datasource = server.datasources.publish(new_datasource, args.publish, server.PublishMode.Overwrite)
4848
print("Datasource published. ID: {}".format(new_datasource.id))
4949
else:

samples/explore_workbook.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# on top of the general operations.
1010
####
1111

12-
import tableauserverapi as TSA
12+
import tableauserverclient as TSC
1313
import os.path
1414
import copy
1515
import argparse
@@ -33,8 +33,8 @@
3333
logging.basicConfig(level=logging_level)
3434

3535
##### SIGN IN #####
36-
tableau_auth = TSA.TableauAuth(args.username, password)
37-
server = TSA.Server(args.server)
36+
tableau_auth = TSC.TableauAuth(args.username, password)
37+
server = TSC.Server(args.server)
3838
with server.auth.sign_in(tableau_auth):
3939

4040
# Publish workbook if publish flag is set (-publish, -p)
@@ -43,7 +43,7 @@
4343
default_project = next((project for project in all_projects if project.is_default()), None)
4444

4545
if default_project is not None:
46-
new_workbook = TSA.WorkbookItem(default_project.id)
46+
new_workbook = TSC.WorkbookItem(default_project.id)
4747
new_workbook = server.workbooks.publish(new_workbook, args.publish, server.PublishMode.Overwrite)
4848
print("Workbook published. ID: {}".format(new_workbook.id))
4949
else:

samples/move_workbook_projects.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# To run the script, you must have installed Python 2.7.9 or later.
88
####
99

10-
import tableauserverapi as TSA
10+
import tableauserverclient as TSC
1111
import argparse
1212
import getpass
1313
import logging
@@ -28,13 +28,13 @@
2828
logging.basicConfig(level=logging_level)
2929

3030
# Step 1: Sign in to server
31-
tableau_auth = TSA.TableauAuth(args.username, password)
32-
server = TSA.Server(args.server)
31+
tableau_auth = TSC.TableauAuth(args.username, password)
32+
server = TSC.Server(args.server)
3333
with server.auth.sign_in(tableau_auth):
3434
# Step 2: Query workbook to move
35-
req_option = TSA.RequestOptions()
36-
req_option.filter.add(TSA.Filter(TSA.RequestOptions.Field.Name,
37-
TSA.RequestOptions.Operator.Equals, args.workbook_name))
35+
req_option = TSC.RequestOptions()
36+
req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,
37+
TSC.RequestOptions.Operator.Equals, args.workbook_name))
3838
pagination_info, all_workbooks = server.workbooks.get(req_option)
3939

4040
# Step 3: Find destination project

samples/move_workbook_sites.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# To run the script, you must have installed Python 2.7.9 or later.
88
####
99

10-
import tableauserverapi as TSA
10+
import tableauserverclient as TSC
1111
import shutil
1212
import argparse
1313
import tempfile
@@ -32,16 +32,16 @@
3232
logging.basicConfig(level=logging_level)
3333

3434
# Step 1: Sign in to both sites on server
35-
tableau_auth = TSA.TableauAuth(args.username, password)
35+
tableau_auth = TSC.TableauAuth(args.username, password)
3636

37-
source_server = TSA.Server(args.server)
38-
dest_server = TSA.Server(args.server)
37+
source_server = TSC.Server(args.server)
38+
dest_server = TSC.Server(args.server)
3939

4040
with source_server.auth.sign_in(tableau_auth):
4141
# Step 2: Query workbook to move
42-
req_option = TSA.RequestOptions()
43-
req_option.filter.add(TSA.Filter(TSA.RequestOptions.Field.Name,
44-
TSA.RequestOptions.Operator.Equals, args.workbook_name))
42+
req_option = TSC.RequestOptions()
43+
req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,
44+
TSC.RequestOptions.Operator.Equals, args.workbook_name))
4545
pagination_info, all_workbooks = source_server.workbooks.get(req_option)
4646

4747
# Step 3: Download workbook to a temp directory
@@ -72,7 +72,7 @@
7272

7373
# Step 6: If default project is found, form a new workbook item and publish.
7474
if target_project is not None:
75-
new_workbook = TSA.WorkbookItem(name=args.workbook_name, project_id=target_project.id)
75+
new_workbook = TSC.WorkbookItem(name=args.workbook_name, project_id=target_project.id)
7676
new_workbook = dest_server.workbooks.publish(new_workbook, workbook_path,
7777
mode=dest_server.PublishMode.Overwrite)
7878
print("Successfully moved {0} ({1})".format(new_workbook.name, new_workbook.id))

samples/publish_workbook.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# To run the script, you must have installed Python 2.7.9 or later.
1515
####
1616

17-
import tableauserverapi as TSA
17+
import tableauserverclient as TSC
1818
import argparse
1919
import getpass
2020
import logging
@@ -34,8 +34,8 @@
3434
logging.basicConfig(level=logging_level)
3535

3636
# Step 1: Sign in to server.
37-
tableau_auth = TSA.TableauAuth(args.username, password)
38-
server = TSA.Server(args.server)
37+
tableau_auth = TSC.TableauAuth(args.username, password)
38+
server = TSC.Server(args.server)
3939
with server.auth.sign_in(tableau_auth):
4040

4141
# Step 2: Get all the projects on server, then look for the default one.
@@ -44,7 +44,7 @@
4444

4545
# Step 3: If default project is found, form a new workbook item and publish.
4646
if default_project is not None:
47-
new_workbook = TSA.WorkbookItem(default_project.id)
47+
new_workbook = TSC.WorkbookItem(default_project.id)
4848
new_workbook = server.workbooks.publish(new_workbook, args.filepath, server.PublishMode.Overwrite)
4949
print("Workbook published. ID: {0}".format(new_workbook.id))
5050
else:

samples/set_http_options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# To run the script, you must have installed Python 2.7.9 or later.
99
####
1010

11-
import tableauserverapi as TSA
11+
import tableauserverclient as TSC
1212
import argparse
1313
import getpass
1414
import logging
@@ -27,8 +27,8 @@
2727
logging.basicConfig(level=logging_level)
2828

2929
# Step 1: Create required objects for sign in
30-
tableau_auth = TSA.TableauAuth(args.username, password)
31-
server = TSA.Server(args.server)
30+
tableau_auth = TSC.TableauAuth(args.username, password)
31+
server = TSC.Server(args.server)
3232

3333
# Step 2: Set http options to disable verifying SSL
3434
server.add_http_options({'verify': False})

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from distutils.core import setup
55

66
setup(
7-
name='tableauserverapi',
7+
name='tableauserverclient',
88
version='0.1',
99
author='Tableau Software',
1010
author_email='github@tableau.com',
11-
url='https://github.com/tableau/server-api-python',
12-
packages=['tableauserverapi', 'tableauserverapi.models', 'tableauserverapi.server',
13-
'tableauserverapi.server.endpoint'],
11+
url='https://github.com/tableau/server-client-python',
12+
packages=['tableauserverclient', 'tableauserverclient.models', 'tableauserverclient.server',
13+
'tableauserverclient.server.endpoint'],
1414
license='MIT',
1515
description='A Python module for working with the Tableau Server REST API.',
1616
test_suite='test',
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/test_auth.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22
import os.path
33
import requests_mock
4-
import tableauserverapi as TSA
4+
import tableauserverclient as TSC
55

66
TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), 'assets')
77

@@ -12,15 +12,15 @@
1212

1313
class AuthTests(unittest.TestCase):
1414
def setUp(self):
15-
self.server = TSA.Server('http://test')
15+
self.server = TSC.Server('http://test')
1616
self.baseurl = self.server.auth.baseurl
1717

1818
def test_sign_in(self):
1919
with open(SIGN_IN_XML, 'rb') as f:
2020
response_xml = f.read().decode('utf-8')
2121
with requests_mock.mock() as m:
2222
m.post(self.baseurl + '/signin', text=response_xml)
23-
tableau_auth = TSA.TableauAuth('testuser', 'password', site='Samples')
23+
tableau_auth = TSC.TableauAuth('testuser', 'password', site='Samples')
2424
self.server.auth.sign_in(tableau_auth)
2525

2626
self.assertEqual('eIX6mvFsqyansa4KqEI1UwOpS8ggRs2l', self.server.auth_token)
@@ -32,7 +32,7 @@ def test_sign_in_impersonate(self):
3232
response_xml = f.read().decode('utf-8')
3333
with requests_mock.mock() as m:
3434
m.post(self.baseurl + '/signin', text=response_xml)
35-
tableau_auth = TSA.TableauAuth('testuser', 'password',
35+
tableau_auth = TSC.TableauAuth('testuser', 'password',
3636
user_id_to_impersonate='dd2239f6-ddf1-4107-981a-4cf94e415794')
3737
self.server.auth.sign_in(tableau_auth)
3838

@@ -45,24 +45,24 @@ def test_sign_in_error(self):
4545
response_xml = f.read().decode('utf-8')
4646
with requests_mock.mock() as m:
4747
m.post(self.baseurl + '/signin', text=response_xml, status_code=401)
48-
tableau_auth = TSA.TableauAuth('testuser', 'wrongpassword')
49-
self.assertRaises(TSA.ServerResponseError, self.server.auth.sign_in, tableau_auth)
48+
tableau_auth = TSC.TableauAuth('testuser', 'wrongpassword')
49+
self.assertRaises(TSC.ServerResponseError, self.server.auth.sign_in, tableau_auth)
5050

5151
def test_sign_in_without_auth(self):
5252
with open(SIGN_IN_ERROR_XML, 'rb') as f:
5353
response_xml = f.read().decode('utf-8')
5454
with requests_mock.mock() as m:
5555
m.post(self.baseurl + '/signin', text=response_xml, status_code=401)
56-
tableau_auth = TSA.TableauAuth('', '')
57-
self.assertRaises(TSA.ServerResponseError, self.server.auth.sign_in, tableau_auth)
56+
tableau_auth = TSC.TableauAuth('', '')
57+
self.assertRaises(TSC.ServerResponseError, self.server.auth.sign_in, tableau_auth)
5858

5959
def test_sign_out(self):
6060
with open(SIGN_IN_XML, 'rb') as f:
6161
response_xml = f.read().decode('utf-8')
6262
with requests_mock.mock() as m:
6363
m.post(self.baseurl + '/signin', text=response_xml)
6464
m.post(self.baseurl + '/signout', text='')
65-
tableau_auth = TSA.TableauAuth('testuser', 'password')
65+
tableau_auth = TSC.TableauAuth('testuser', 'password')
6666
self.server.auth.sign_in(tableau_auth)
6767
self.server.auth.sign_out()
6868

test/test_datasource.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22
import os
33
import requests_mock
4-
import tableauserverapi as TSA
4+
import tableauserverclient as TSC
55

66
TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), 'assets')
77

@@ -14,7 +14,7 @@
1414

1515
class DatasourceTests(unittest.TestCase):
1616
def setUp(self):
17-
self.server = TSA.Server('http://test')
17+
self.server = TSC.Server('http://test')
1818

1919
# Fake signin
2020
self.server._site_id = 'dad65087-b08b-4603-af4e-2887b8aafc67'
@@ -53,7 +53,7 @@ def test_get(self):
5353

5454
def test_get_before_signin(self):
5555
self.server._auth_token = None
56-
self.assertRaises(TSA.NotSignedInError, self.server.datasources.get)
56+
self.assertRaises(TSC.NotSignedInError, self.server.datasources.get)
5757

5858
def test_get_empty(self):
5959
with open(GET_EMPTY_XML, 'rb') as f:
@@ -88,7 +88,7 @@ def test_update(self):
8888
response_xml = f.read().decode('utf-8')
8989
with requests_mock.mock() as m:
9090
m.put(self.baseurl + '/9dbd2263-16b5-46e1-9c43-a76bb8ab65fb', text=response_xml)
91-
single_datasource = TSA.DatasourceItem('test', '1d0304cd-3796-429f-b815-7258370b9b74')
91+
single_datasource = TSC.DatasourceItem('test', '1d0304cd-3796-429f-b815-7258370b9b74')
9292
single_datasource.owner_id = 'dd2239f6-ddf1-4107-981a-4cf94e415794'
9393
single_datasource._id = '9dbd2263-16b5-46e1-9c43-a76bb8ab65fb'
9494
single_datasource = self.server.datasources.update(single_datasource)
@@ -102,7 +102,7 @@ def test_update_copy_fields(self):
102102
response_xml = f.read().decode('utf-8')
103103
with requests_mock.mock() as m:
104104
m.put(self.baseurl + '/9dbd2263-16b5-46e1-9c43-a76bb8ab65fb', text=response_xml)
105-
single_datasource = TSA.DatasourceItem('test', '1d0304cd-3796-429f-b815-7258370b9b74')
105+
single_datasource = TSC.DatasourceItem('test', '1d0304cd-3796-429f-b815-7258370b9b74')
106106
single_datasource._id = '9dbd2263-16b5-46e1-9c43-a76bb8ab65fb'
107107
single_datasource._tags = ['a', 'b', 'c']
108108
single_datasource._project_name = 'Tester'
@@ -116,7 +116,7 @@ def test_publish(self):
116116
response_xml = f.read().decode('utf-8')
117117
with requests_mock.mock() as m:
118118
m.post(self.baseurl, text=response_xml)
119-
new_datasource = TSA.DatasourceItem('SampleDS', 'ee8c6e70-43b6-11e6-af4f-f7b0d8e20760')
119+
new_datasource = TSC.DatasourceItem('SampleDS', 'ee8c6e70-43b6-11e6-af4f-f7b0d8e20760')
120120
new_datasource = self.server.datasources.publish(new_datasource,
121121
os.path.join(TEST_ASSET_DIR, 'SampleDS.tds'),
122122
mode=self.server.PublishMode.CreateNew)
@@ -145,20 +145,20 @@ def test_download(self):
145145
os.remove(file_path)
146146

147147
def test_update_missing_id(self):
148-
single_datasource = TSA.DatasourceItem('test', 'ee8c6e70-43b6-11e6-af4f-f7b0d8e20760')
149-
self.assertRaises(TSA.MissingRequiredFieldError, self.server.datasources.update, single_datasource)
148+
single_datasource = TSC.DatasourceItem('test', 'ee8c6e70-43b6-11e6-af4f-f7b0d8e20760')
149+
self.assertRaises(TSC.MissingRequiredFieldError, self.server.datasources.update, single_datasource)
150150

151151
def test_publish_missing_path(self):
152-
new_datasource = TSA.DatasourceItem('test', 'ee8c6e70-43b6-11e6-af4f-f7b0d8e20760')
152+
new_datasource = TSC.DatasourceItem('test', 'ee8c6e70-43b6-11e6-af4f-f7b0d8e20760')
153153
self.assertRaises(IOError, self.server.datasources.publish, new_datasource,
154154
'', self.server.PublishMode.CreateNew)
155155

156156
def test_publish_missing_mode(self):
157-
new_datasource = TSA.DatasourceItem('test', 'ee8c6e70-43b6-11e6-af4f-f7b0d8e20760')
157+
new_datasource = TSC.DatasourceItem('test', 'ee8c6e70-43b6-11e6-af4f-f7b0d8e20760')
158158
self.assertRaises(ValueError, self.server.datasources.publish, new_datasource,
159159
os.path.join(TEST_ASSET_DIR, 'SampleDS.tds'), None)
160160

161161
def test_publish_invalid_file_type(self):
162-
new_datasource = TSA.DatasourceItem('test', 'ee8c6e70-43b6-11e6-af4f-f7b0d8e20760')
162+
new_datasource = TSC.DatasourceItem('test', 'ee8c6e70-43b6-11e6-af4f-f7b0d8e20760')
163163
self.assertRaises(ValueError, self.server.datasources.publish, new_datasource,
164164
os.path.join(TEST_ASSET_DIR, 'SampleWB.twbx'), self.server.PublishMode.Append)

0 commit comments

Comments
 (0)
0