8000 Merge pull request #223 from tableau/development · williamlang/server-client-python@ada7dbc · GitHub
[go: up one dir, main page]

Skip to content

Commit ada7dbc

Browse files
author
Russell Hay
authored
Merge pull request tableau#223 from tableau/development
Merge master into development in prep for release
2 parents 1a5efa2 + 71dab33 commit ada7dbc

Some content is hidden

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

69 files changed

+901
-289
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
__pycache__/
33
*.py[cod]
44
*$py.class
5+
test.junit.xml
56

67
# C extensions
78
*.so
@@ -145,4 +146,4 @@ $RECYCLE.BIN/
145146

146147
# Documentation
147148
docs/_site/
148-
docs/.jekyll-metadata
149+
docs/.jekyll-metadata

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 0.5 (11 Sept 2017)
2+
3+
* Added revision settings to update site (#187)
4+
* Added support for certified data sources (#189)
5+
* Added support for include/exclude extract (#203)
6+
* Added auto-paging for group users (#204)
7+
* Added ability to add workbooks to a schedule (#206)
8+
* Added the ability to create nested projects (#208)
9+
* Fixed sort order when using pager (#192)
10+
* Docs Updates and new samples (#196, #199, #200, #201)
11+
112
## 0.4.1 (18 April 2017)
213

314
* Fix #177 to remove left in debugging print

CONTRIBUTORS.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ The following people have contributed to this project to make it possible, and w
55
## Contributors
66

77
* [geordielad](https://github.com/geordielad)
8-
* [Hugo Stijns)(https://github.com/hugoboos)
8+
* [Hugo Stijns](https://github.com/hugoboos)
99
* [kovner](https://github.com/kovner)
1010
* [Talvalin](https://github.com/Talvalin)
1111
* [Chris Toomey](https://github.com/cmtoomey)
1212
* [Vathsala Achar](https://github.com/VathsalaAchar)
1313
* [Graeme Britz](https://github.com/grbritz)
14-
14+
* [Russ Goldin](https://github.com/tagyoureit)
15+
* [William Lang](https://github.com/williamlang)
16+
* [Jim Morris](https://github.com/jimbodriven)
1517

1618
## Core Team
1719

18-
* [shinchris](https://github.com/shinchris)
19-
* [lgraber](https://github.com/lgraber)
20-
* [t8y8](https://github.com/t8y8)
21-
* [RussTheAerialist](https://github.com/RussTheAerialist)
20+
* [Shin Chris](https://github.com/shinchris)
21+
* [Lee Graber](https://github.com/lgraber)
22+
* [Tyler Doyle](https://github.com/t8y8)
23+
* [Russell Hay](https://github.com/RussTheAerialist)
2224
* [Ben Lower](https://github.com/benlower)
2325
* [Jared Dominguez](https://github.com/jdomingu)
2426
* [Jackson Huang](https://github.com/jz-huang)

LICENSE.versioneer

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## License
2+
3+
To make Versioneer easier to embed, all its code is dedicated to the public
4+
domain. The `_version.py` that it creates is also in the public domain.
5+
Specifically, both are released under the Creative Commons "Public Domain
6+
Dedication" license (CC0-1.0), as described in
7+
https://creativecommons.org/publicdomain/zero/1.0/ .

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
include versioneer.py
22
include tableauserverclient/_version.py
3+
include LICENSE
4+
include LICENSE.versioneer

docs/docs/samples.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ The following list describes the samples available in the repository:
3434

3535
* `create_group.py`. Create a user group.
3636

37+
* `create_project.py`. Create new projects at the top level as well as nested projects.
38+
3739
* `create_schedules.py`. Create schedules for extract refreshes and subscriptions.
3840

3941
* `explore_datasource.py`. Queries datasources, selects a datasource, populates connections for the datasource, then updates the datasource.
@@ -54,4 +56,3 @@ The following list describes the samples available in the repository:
5456

5557
**Note**: 1241 For all of the samples, ensure that your Tableau Server user account has permission to access the resources
5658
requested by the samples.
57-

docs/docs/versions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import tableauserverclient as TSC
3232

3333
server = TSC.Server('http://SERVER_URL')
3434

35-
server.version = 2.4
35+
server.version = '2.4'
3636
```
3737

3838
## Supported versions

samples/create_project.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
####
2+
# This script demonstrates how to use the Tableau Server Client
3+
# to create new projects, both at the root level and how to nest them using
4+
# parent_id.
5+
#
6+
#
7+
# To run the script, you must have installed Python 2.7.X or 3.3 and later.
8+
####
9+
10+
import argparse
11+
import getpass
12+
import logging
13+
import sys
14+
15+
import tableauserverclient as TSC
16+
17+
18+
def create_project(server, project_item):
19+
try:
20+
project_item = server.projects.create(project_item)
21+
print('Created a new project called: %s' % project_item.name)
22+
return project_item
23+
except TSC.ServerResponseError:
24+
print('We have already created this project: %s' % project_item.name)
25+
sys.exit(1)
26+
27+
def main():
28+
parser = argparse.ArgumentParser(description='Get all of the refresh tasks available on a server')
29+
parser.add_argument('--server', '-s', required=True, help='server address')
30+
parser.add_argument('--username', '-u', required=True, help='username to sign into server')
31+
parser.add_argument('--site', '-S', default=None)
32+
parser.add_argument('-p', default=None, help='password')
33+
34+
parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error',
35+
help='desired logging level (set to error by default)')
36+
37+
args = parser.parse_args()
38+
39+
if args.p is None:
40+
password = getpass.getpass("Password: ")
41+
else:
42+
password = args.p
43+
44+
# Set logging level based on user input, or error by default
45+
logging_level = getattr(logging, args.logging_level.upper())
46+
logging.basicConfig(level=logging_level)
47+
48+
tableau_auth = TSC.TableauAuth(args.username, password)
49+
server = TSC.Server(args.server)
50+
51+
with server.auth.sign_in(tableau_auth):
52+
# Use highest Server REST API version available
53+
server.use_server_version()
54+
55+
# Without parent_id specified, projects are created at the top level.
56+
top_level_project = TSC.ProjectItem(name='Top Level Project')
57+
top_level_project = create_project(server, top_level_project)
58+
59+
# Specifying parent_id creates a nested projects.
60+
child_project = TSC.ProjectItem(name='Child Project', parent_id=top_level_project.id)
61+
child_project = create_project(server, child_project)
62+
63+
# Projects can be nested at any level.
64+
grand_child_project = TSC.ProjectItem(name='Grand Child Project', parent_id=child_project.id)
65+
grand_child_project = create_project(server, grand_child_project)
66+
67+
if __name__ == '__main__':
68+
main()

samples/filter_sort_groups.py

Lines changed: 91 additions & 0 deletions
C2EE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
####
2+
# This script demonstrates how to filter groups using the Tableau
3+
# Server Client.
4+
#
5+
# To run the script, you must have installed Python 2.7.9 or later.
6+
####
7+
8+
9+
import argparse
10+
import getpass
11+
import logging
12+
13+
import tableauserverclient as TSC
14+
15+
16+
def create_example_group(group_name='Example Group', server=None):
17+
new_group = TSC.GroupItem(group_name)
18+
try:
19+
new_group = server.groups.create(new_group)
20+
print('Created a new project called: \'%s\'' % group_name)
21+
print(new_group)
22+
except TSC.ServerResponseError:
23+
print('Group \'%s\' already existed' % group_name)
24+
25+
26+
def main():
27+
parser = argparse.ArgumentParser(description='Filter on groups')
28+
parser.add_argument('--server', '-s', required=True, help='server address')
29+
parser.add_argument('--username', '-u', required=True, help='username to sign into server')
30+
parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error',
31+
help='desired logging level (set to error by default)')
32+
parser.add_argument('-p', default=None)
33+
args = parser.parse_args()
34+
35+
if args.p is None:
36+
password = getpass.getpass("Password: ")
37+
else:
38+
password = args.p
39+
40+
# Set logging level based on user input, or error by default
41+
logging_level = getattr(logging, args.logging_level.upper())
42+
logging.basicConfig(level=logging_level)
43+
44+
tableau_auth = TSC.TableauAuth(args.username, password)
45+
server = TSC.Server(args.server)
46+
47+
with server.auth.sign_in(tableau_auth):
48+
49+
# Determine and use the highest api version for the server
50+
server.use_server_version()
51+
52+
group_name = 'SALES NORTHWEST'
53+
# Try to create a group named "SALES NORTHWEST"
54+
create_example_group(group_name, server)
55+
56+
group_name = 'SALES ROMANIA'
57+
# Try to create a group named "SALES ROMANIA"
58+
create_example_group(group_name, server)
59+
60+
# URL Encode the name of the group that we want to filter on
61+
# i.e. turn spaces into plus signs
62+
filter_group_name = 'SALES+ROMANIA'
63+
options = TSC.RequestOptions()
64+
options.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,
65+
TSC.RequestOptions.Operator.Equals,
66+
filter_group_name))
67+
68+
filtered_groups, _ = server.groups.get(req_options=options)
69+
# Result can either be a matching group or an empty list
70+
if filtered_groups:
71+
group_name = filtered_groups.pop().name
72+
print(group_name)
73+
else:
74+
error = "No project named '{}' found".format(filter_group_name)
75+
print(error)
76+
77+
options = TSC.RequestOptions()
78+
options.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,
79+
TSC.RequestOptions.Operator.In,
80+
['SALES+NORTHWEST', 'SALES+ROMANIA', 'this_group']))
81+
82+
options.sort.add(TSC.Sort(TSC.RequestOptions.Field.Name,
83+
TSC.RequestOptions.Direction.Desc))
84+
85+
matching_groups, pagination_item = server.groups.get(req_options=options)
86+
print('Filtered groups are:')
87+
for group in matching_groups:
88+
print(group.name)
89+
90+
if __name__ == '__main__':
91+
main()

samples/filter_sort_projects.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
####
2+
# This script demonstrates how to use the Tableau Server Client
3+
# to filter and sort on the name of the projects present on site.
4+
#
5+
#
6+
# To run the script, you must have installed Python 2.7.X or 3.3 and later.
7+
####
8+
9+
import argparse
10+
import getpass
11+
import logging
12+
13+
import tableauserverclient as TSC
14+
15+
16+
def create_example_project(name='Example Project', content_permissions='LockedToProject',
17+
description='Project created for testing', server=None):
18+
19+
new_project = TSC.ProjectItem(name=name, content_permissions=content_permissions,
20+
description=description)
21+
try:
22+
server.projects.create(new_ 48DA project)
23+
print('Created a new project called: %s' % name)
24+
except TSC.ServerResponseError:
25+
print('We have already created this resource: %s' % name)
26+
27+
28+
def main():
29+
parser = argparse.ArgumentParser(description='Get all of the refresh tasks available on a server')
30+
parser.add_argument('--server', '-s', required=True, help='server address')
31+
parser.add_argument('--username', '-u', required=True, help='username to sign into server')
32+
parser.add_argument('--site', '-S', default=None)
33+
parser.add_argument('-p', default=None)
34+
35+
parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error',
36+
help='desired logging level (set to error by default)')
37+
38+
args = parser.parse_args()
39+
40+
if args.p is None:
41+
password = getpass.getpass("Password: ")
42+
else:
43+
password = args.p
44+
45+
# Set logging level based on user input, or error by default
46+
logging_level = getattr(logging, args.logging_level.upper())
47+
logging.basicConfig(level=logging_level)
48+
49+
tableau_auth = TSC.TableauAuth(args.username, password)
50+
server = TSC.Server(args.server)
51+
52+
with server.auth.sign_in(tableau_auth):
53+
# Use highest Server REST API version available
54+
server.use_server_version()
55+
56+
filter_project_name = 'default'
57+
options = TSC.RequestOptions()
58+
59+
options.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,
60+
TSC.RequestOptions.Operator.Equals,
61+
filter_project_name))
62+
63+
filtered_projects, _ = server.projects.get(req_options=options)
64+
# Result can either be a matching project or an empty list
65+
if filtered_projects:
66+
project_name = filtered_projects.pop().name
67+
print(project_name)
68+
else:
69+
error = "No project named '{}' found".format(filter_project_name)
70+
print(error)
71+
72+
create_example_project(name='Example 1', server=server)
73+
create_example_project(name='Example 2', server=server)
74+
create_example_project(name='Example 3', server=server)
75+
create_example_project(name='Proiect ca Exemplu', server=server)
76+
77+
options = TSC.RequestOptions()
78+
79+
# don't forget to URL encode the query names
80+
options.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,
81+
TSC.RequestOptions.Operator.In,
82+
['Example+1', 'Example+2', 'Example+3']))
83+
84+
options.sort.add(TSC.Sort(TSC.RequestOptions.Field.Name,
85+
TSC.RequestOptions.Direction.Desc))
86+
87+
matching_projects, pagination_item = server.projects.get(req_options=options)
88+
print('Filtered projects are:')
89+
for project in matching_projects:
90+
print(project.name, project.id)
91+
92+
93+
if __name__ == '__main__':
94+
main()

0 commit comments

Comments
 (0)
0