forked from tableau/server-client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_http_options.py
More file actions
52 lines (39 loc) · 2.13 KB
/
set_http_options.py
File metadata and controls
52 lines (39 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
####
# This script demonstrates how to set http options. It will set the option
# to not verify SSL certificate, and query all workbooks on site.
#
# To run the script, you must have installed Python 3.6 or later.
####
import argparse
import logging
import tableauserverclient as TSC
def main():
parser = argparse.ArgumentParser(description='List workbooks on site, with option set to ignore SSL verification.')
# Common options; please keep those in sync across all samples
parser.add_argument('--server', '-s', required=True, help='server address')
parser.add_argument('--site', '-S', help='site name')
parser.add_argument('--token-name', '-p', required=True,
help='name of the personal access token used to sign into the server')
parser.add_argument('--token-value', '-v', required=True,
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)
# Step 1: Create required objects for sign in
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server)
# Step 2: Set http options to disable verifying SSL
server.add_http_options({'verify': False})
with server.auth.sign_in(tableau_auth):
# Step 3: Query all workbooks and list them
all_workbooks, pagination_item = server.workbooks.get()
print('{0} workbooks found. Showing {1}:'.format(pagination_item.total_available, pagination_item.page_size))
for workbook in all_workbooks:
print('\t{0} (ID: {1})'.format(workbook.name, workbook.id))
if __name__ == '__main__':
main()