8000 Merge pull request #612 from tableau/development · cfmayden/server-client-python@188be71 · GitHub
[go: up one dir, main page]

Skip to content

Commit 188be71

Browse files
author
Chris Shin
authored
Merge pull request tableau#612 from tableau/development
Merge development into master for v0.11 release v0.11 (1 May 2020) -Added more fields to Data Acceleration config (tableau#588) -Added OpenID as an auth setting enum (tableau#610) -Added support for Data Acceleration Reports (tableau#596) -Added support for view permissions (tableau#526) -Materialized views changed to Data Acceleration (tableau#576) -Improved consistency across workbook/datasource endpoints (tableau#570) -Fixed print error in update_connection.py (tableau#602) -Fixed log error in add user endpoint (tableau#608)
2 parents 977b3d9 + 03f7629 commit 188be71

Some content is hidden

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

48 files changed

+711
-446
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 0.11 (1 May 2020)
2+
3+
* Added more fields to Data Acceleration config (#588)
4+
* Added OpenID as an auth setting enum (#610)
5+
* Added support for Data Acceleration Reports (#596)
6+
* Added support for view permissions (#526)
7+
* Materialized views changed to Data Acceleration (#576)
8+
* Improved consistency across workbook/datasource endpoints (#570)
9+
* Fixed print error in update_connection.py (#602)
10+
* Fixed log error in add user endpoint (#608)
11+
112
## 0.10 (21 Feb 2020)
213

314
* Added a way to handle non-xml errors (#515)

CONTRIBUTORS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ The following people have contributed to this project to make it possible, and w
3434
* [Kacper Wolkiewicz](https://github.com/wolkiewiczk)
3535
* [Dahai Guo](https://github.com/guodah)
3636
* [Geraldine Zanolli](https://github.com/illonage)
37+
* [Jordan Woods](https://github.com/jorwoods)
38+
* [Reba Magier](https://github.com/rmagier1)
3739

3840
## Core Team
3941

@@ -42,7 +44,6 @@ The following people have contributed to this project to make it possible, and w
4244
* [Tyler Doyle](https://github.com/t8y8)
4345
* [Russell Hay](https://github.com/RussTheAerialist)
4446
* [Ben Lower](https://github.com/benlower)
45-
* [Jackson Huang](https://github.com/jz-huang)
4647
* [Ang Gao](https://github.com/gaoang2148)
4748
* [Priya Reguraman](https://github.com/preguraman)
4849
* [Jac Fitzgerald](https://github.com/jacalata)

samples/add_default_permission.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
####
2+
# This script demonstrates how to add default permissions using TSC
3+
# To run the script, you must have installed Python 3.5 and later.
4+
#
5+
# In order to demonstrate adding a new default permission, this sample will create
6+
# a new project and add a new capability to the new project, for the default "All users" group.
7+
#
8+
# Example usage: 'python add_default_permission.py -s
9+
# https://10ax.online.tableau.com --site devSite123 -u tabby@tableau.com'
10+
####
11+
12+
import argparse
13+
import getpass
14+
import logging
15+
16+
import tableauserverclient as TSC
17+
18+
19+
def main():
20+
parser = argparse.ArgumentParser(description='Add workbook default permission for a given project')
21+
parser.add_argument('--server', '-s', required=True, help='Server address')
22+
parser.add_argument('--username', '-u', required=True, help='Username to sign into server')
23+
parser.add_argument('--site', '-S', default=None, help='Site to sign into - default site if not provided')
24+
parser.add_argument('-p', default=None, help='Password to sign into server')
25+
26+
parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error',
27+
help='desired logging level (set to error by default)')
28+
29+
args = parser.parse_args()
30+
31+
if args.p is None:
32+
password = getpass.getpass("Password: ")
33+
else:
34+
password = args.p
35+
36+
# Set logging level based on user input, or error by default
37+
logging_level = getattr(logging, args.logging_level.upper())
38+
logging.basicConfig(level=logging_level)
39+
40+
# Sign in
41+
tableau_auth = TSC.TableauAuth(args.username, password, args.site)
42+
server = TSC.Server(args.server, use_server_version=True)
43+
with server.auth.sign_in(tableau_auth):
44+
45+
# Create a sample project
46+
project = TSC.ProjectItem("sample_project")
47+
project = server.projects.create(project)
48+
49+
# Query for existing workbook default-permissions
50+
server.projects.populate_workbook_default_permissions(project)
51+
default_permissions = project.default_workbook_permissions[0] # new projects have 1 grantee group
52+
53+
# Add "ExportXml (Allow)" workbook capability to "All Users" default group if it does not already exist
54+
if TSC.Permission.Capability.ExportXml not in default_permissions.capabilities:
55+
new_capabilities = {TSC.Permission.Capability.ExportXml: TSC.Permission.Mode.Allow}
56+
57+
# Each PermissionRule in the list contains a grantee and a dict of capabilities
58+
new_rules = [TSC.PermissionsRule(
59+
grantee=default_permissions.grantee,
60+
capabilities=new_capabilities
61+
)]
62+
63+
new_default_permissions = server.projects.update_workbook_default_permissions(project, new_rules)
64+
65+
# Print result from adding a new default permission
66+
for permission in new_default_permissions:
67+
grantee = permission.grantee
68+
capabilities = permission.capabilities
69+
print("\nCapabilities for {0} {1}:".format(grantee.tag_name, grantee.id))
70+
71+
for capability in capabilities:
72+
print("\t{0} - {1}".format(capability, capabilities[capability]))
73+
74+
# Uncomment lines below to DELETE the new capability and the new project
75+
# rules_to_delete = TSC.PermissionsRule(
76+
# grantee=default_permissions.grantee,
77+
# capabilities=new_capabilities
78+
# )
79+
# server.projects.delete_workbook_default_permissions(project, rules_to_delete)
80+
# server.projects.delete(project.id)
81+
82+
83+
if __name__ == '__main__':
84+
main()

0 commit comments

Comments
 (0)
0