forked from tableau/server-client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: TableauIDWithMFA added to the user_item model to allow creating users on Tableau Cloud with MFA enabled (tableau#1216) * fix: make project optional in datasources tableau#1210 * fix: allow setting timeout on workbook endpoint tableau#1087 * fix: can't certify datasource on publish tableau#1058 * fix filter in operator spaces bug (tableau#1259) * fix: remove logging configuration from TSC (tableau#1248) * Hotfix schedule_item.py for issue 1237 (tableau#1239), Remove duplicate assignments to fields (tableau#1244) * Fix shared attribute for custom views (tableau#1280) New functionality * enable filtering for Excel downloads tableau#1209, tableau#1281 * query view by content url tableau#456 * update datasource to use bridge (tableau#1224) * Add JWTAuth, add repr using qualname * Add publish samples attribute (tableau#1264) * add support for custom schedules in TOL (tableau#1273) * Enable asJob for group update (tableau#1276) Co-authored-by: Tim Payne <[email protected]> Co-authored-by: Lars Breddemann <[email protected]> Co-authored-by: jorwoods <[email protected]> Co-authored-by: Austin <[email protected]> Co-authored-by: Yasuhisa Yoshida <[email protected]> Co-authored-by: Brian Cantoni <[email protected]> Co-authored-by: a-torres-2 <[email protected]> Co-authored-by: Łukasz Włodarczyk <[email protected]>
- Loading branch information
1 parent
307d8a2
commit 341dcd2
Showing
36 changed files
with
541 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#### | ||
# This script demonstrates how to create extract tasks in Tableau Cloud | ||
# using the Tableau Server Client. | ||
# | ||
# To run the script, you must have installed Python 3.7 or later. | ||
#### | ||
|
||
|
||
import argparse | ||
import logging | ||
|
||
from datetime import time | ||
|
||
import tableauserverclient as TSC | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="Creates sample extract refresh task.") | ||
# Common options; please keep those in sync across all samples | ||
parser.add_argument("--server", "-s", help="server address") | ||
parser.add_argument("--site", "-S", help="site name") | ||
parser.add_argument("--token-name", "-p", help="name of the personal access token used to sign into the server") | ||
parser.add_argument("--token-value", "-v", help="value of the personal access token used to sign into the server") | ||
parser.add_argument( | ||
"--logging-level", | ||
"-l", | ||
choices=["debug", "info", "error"], | ||
default="error", | ||
help="desired logging level (set to error by default)", | ||
) | ||
# Options specific to this sample: | ||
# This sample has no additional options, yet. If you add some, please add them here | ||
|
||
args = parser.parse_args() | ||
|
||
# Set logging level based on user input, or error by default | ||
logging_level = getattr(logging, args.logging_level.upper()) | ||
logging.basicConfig(level=logging_level) | ||
|
||
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site) | ||
server = TSC.Server(args.server, use_server_version=False) | ||
server.add_http_options({"verify": False}) | ||
server.use_server_version() | ||
with server.auth.sign_in(tableau_auth): | ||
# Monthly Schedule | ||
# This schedule will run on the 15th of every month at 11:30PM | ||
monthly_interval = TSC.MonthlyInterval(start_time=time(23, 30), interval_value=15) | ||
monthly_schedule = TSC.ScheduleItem( | ||
None, | ||
None, | ||
None, | ||
None, | ||
monthly_interval, | ||
) | ||
|
||
# Default to using first workbook found in server | ||
all_workbook_items, pagination_item = server.workbooks.get() | ||
my_workbook: TSC.WorkbookItem = all_workbook_items[0] | ||
|
||
target_item = TSC.Target( | ||
my_workbook.id, # the id of the workbook or datasource | ||
"workbook", # alternatively can be "datasource" | ||
) | ||
|
||
extract_item = TSC.TaskItem( | ||
None, | ||
"FullRefresh", | ||
None, | ||
None, | ||
None, | ||
monthly_schedule, | ||
None, | ||
target_item, | ||
) | ||
|
||
try: | ||
response = server.tasks.create(extract_item) | ||
print(response) | ||
except Exception as e: | ||
print(e) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#### | ||
# Getting started Part One of Three | ||
# This script demonstrates how to use the Tableau Server Client to connect to a server | ||
# You don't need to have a site or any experience with Tableau to run it | ||
# | ||
#### | ||
|
||
import tableauserverclient as TSC | ||
|
||
|
||
def main(): | ||
# This is the domain for Tableau's Developer Program | ||
server_url = "https://10ax.online.tableau.com" | ||
server = TSC.Server(server_url) | ||
print("Connected to {}".format(server.server_info.baseurl)) | ||
print("Server information: {}".format(server.server_info)) | ||
print("Sign up for a test site at https://www.tableau.com/developer") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#### | ||
# Getting started Part Two of Three | ||
# This script demonstrates how to use the Tableau Server Client to | ||
# view the content on an existing site on Tableau Server/Online | ||
# It assumes that you have already got a site and can visit it in a browser | ||
# | ||
#### | ||
|
||
import getpass | ||
import tableauserverclient as TSC | ||
|
||
|
||
# 0 - launch your Tableau site in a web browser and look at the url to set the values below | ||
def main(): | ||
# 1 - replace with your server domain: stop at the slash | ||
server_url = "https://10ax.online.tableau.com" | ||
|
||
# 2 - optional - change to false **for testing only** if you get a certificate error | ||
use_ssl = True | ||
|
||
server = TSC.Server(server_url, use_server_version=True, http_options={"verify": use_ssl}) | ||
print("Connected to {}".format(server.server_info.baseurl)) | ||
|
||
# 3 - replace with your site name exactly as it looks in the url | ||
# e.g https://my-server/#/site/this-is-your-site-url-name/not-this-part | ||
site_url_name = "" # leave empty if there is no site name in the url (you are on the default site) | ||
|
||
# 4 - replace with your username. | ||
# REMEMBER: if you are using Tableau Online, your username is the entire email address | ||
username = "your-username-here" | ||
password = getpass.getpass("Your password:") # so you don't save it in this file | ||
tableau_auth = TSC.TableauAuth(username, password, site_id=site_url_name) | ||
|
||
# OR instead of username+password, uncomment this section to use a Personal Access Token | ||
# token_name = "your-token-name" | ||
# token_value = "your-token-value-long-random-string" | ||
# tableau_auth = TSC.PersonalAccessTokenAuth(token_name, token_value, site_id=site_url_name) | ||
|
||
with server.auth.sign_in(tableau_auth): | ||
projects, pagination = server.projects.get() | ||
if projects: | ||
print("{} projects".format(pagination.total_available)) | ||
project = projects[0] | ||
print(project.name) | ||
|
||
print("Done") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.