-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #573 from tableau/development
Merging v0.10 changes from development to master * Added a way to handle non-xml errors (#515) * Added Webhooks endpoints for create, delete, get, list, and test (#523, #532) * Added delete method in the tasks endpoint (#524) * Added description attribute to WorkbookItem (#533) * Added support for materializeViews as schedule and task types (#542) * Added warnings to schedules (#550, #551) * Added ability to update parent_id attribute of projects (#560, #567) * Improved filename behavior for download endpoints (#517) * Improved logging (#508) * Fixed runtime error in permissions endpoint (#513) * Fixed move_workbook_sites sample (#503) * Fixed project permissions endpoints (#527) * Fixed login.py sample to accept site name (#549)
- Loading branch information
Showing
53 changed files
with
984 additions
and
175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
dist: xenial | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.5" | ||
- "3.6" | ||
- "3.7" | ||
|
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,82 @@ | ||
#### | ||
# This script demonstrates how to use the Tableau Server Client | ||
# to interact with webhooks. It explores the different | ||
# functions that the Server API supports on webhooks. | ||
# | ||
# With no flags set, this sample will query all webhooks, | ||
# pick one webhook and print the name of the webhook. | ||
# Adding flags will demonstrate the specific feature | ||
# on top of the general operations. | ||
#### | ||
|
||
import argparse | ||
import getpass | ||
import logging | ||
import os.path | ||
|
||
import tableauserverclient as TSC | ||
|
||
|
||
def main(): | ||
|
||
parser = argparse.ArgumentParser(description='Explore webhook functions supported by the Server API.') | ||
parser.add_argument('--server', '-s', required=True, help='server address') | ||
parser.add_argument('--username', '-u', required=True, help='username to sign into server') | ||
parser.add_argument('--site', '-S', default=None) | ||
parser.add_argument('-p', default=None, help='password') | ||
parser.add_argument('--create', '-c', help='create a webhook') | ||
parser.add_argument('--delete', '-d', help='delete a webhook', action='store_true') | ||
parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error', | ||
help='desired logging level (set to error by default)') | ||
|
||
args = parser.parse_args() | ||
if args.p is None: | ||
password = getpass.getpass("Password: ") | ||
else: | ||
password = args.p | ||
|
||
# Set logging level based on user input, or error by default | ||
logging_level = getattr(logging, args.logging_level.upper()) | ||
logging.basicConfig(level=logging_level) | ||
|
||
# SIGN IN | ||
tableau_auth = TSC.TableauAuth(args.username, password, args.site) | ||
print("Signing in to " + args.server + " [" + args.site + "] as " + args.username) | ||
server = TSC.Server(args.server) | ||
|
||
# Set http options to disable verifying SSL | ||
server.add_http_options({'verify': False}) | ||
|
||
server.use_server_version() | ||
|
||
with server.auth.sign_in(tableau_auth): | ||
|
||
# Create webhook if create flag is set (-create, -c) | ||
if args.create: | ||
|
||
new_webhook = TSC.WebhookItem() | ||
new_webhook.name = args.create | ||
new_webhook.url = "https://ifttt.com/maker-url" | ||
new_webhook.event = "datasource-created" | ||
print(new_webhook) | ||
new_webhook = server.webhooks.create(new_webhook) | ||
print("Webhook created. ID: {}".format(new_webhook.id)) | ||
|
||
# Gets all webhook items | ||
all_webhooks, pagination_item = server.webhooks.get() | ||
print("\nThere are {} webhooks on site: ".format(pagination_item.total_available)) | ||
print([webhook.name for webhook in all_webhooks]) | ||
|
||
if all_webhooks: | ||
# Pick one webhook from the list and delete it | ||
sample_webhook = all_webhooks[0] | ||
# sample_webhook.delete() | ||
print("+++"+sample_webhook.name) | ||
|
||
if (args.delete): | ||
print("Deleting webhook " + sample_webhook.name) | ||
server.webhooks.delete(sample_webhook.id) | ||
|
||
|
||
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
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 |
---|---|---|
@@ -1,6 +1,22 @@ | ||
import os | ||
ALLOWED_SPECIAL = (' ', '.', '_', '-') | ||
|
||
|
||
def to_filename(string_to_sanitize): | ||
sanitized = (c for c in string_to_sanitize if c.isalnum() or c in ALLOWED_SPECIAL) | ||
return "".join(sanitized) | ||
|
||
|
||
def make_download_path(filepath, filename): | ||
download_path = None | ||
|
||
if filepath is None: | ||
download_path = filename | ||
|
||
elif os.path.isdir(filepath): | ||
download_path = os.path.join(filepath, filename) | ||
|
||
else: | ||
download_path = filepath + os.path.splitext(filename)[1] | ||
|
||
return download_path |
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
Oops, something went wrong.