FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
server-client-python/samples/create_extract_task.py at development · tableau/server-client-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
tableau
/
server-client-python
Public
Notifications
You must be signed in to change notification settings
Fork
447
Star
714
Code
Issues
84
Pull requests
25
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
server-client-python
/
samples
/
create_extract_task.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
89 lines (73 loc) · 2.83 KB
Breadcrumbs
server-client-python
/
samples
/
create_extract_task.py
Copy path
File metadata and controls
89 lines (73 loc) · 2.83 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
####
# 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:
parser
.
add_argument
(
"resource_type"
,
choices
=
[
"workbook"
,
"datasource"
])
parser
.
add_argument
(
"resource_id"
)
parser
.
add_argument
(
"--incremental"
,
default
=
False
)
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
)
print
(
monthly_interval
)
monthly_schedule
=
TSC
.
ScheduleItem
(
None
,
None
,
None
,
None
,
monthly_interval
,
)
my_workbook
:
TSC
.
WorkbookItem
=
server
.
workbooks
.
get_by_id
(
args
.
resource_id
)
target_item
=
TSC
.
Target
(
my_workbook
.
id
,
# the id of the workbook or datasource
"workbook"
,
# alternatively can be "datasource"
)
refresh_type
=
"FullRefresh"
if
args
.
incremental
:
refresh_type
=
"Incremental"
scheduled_extract_item
=
TSC
.
TaskItem
(
None
,
refresh_type
,
None
,
None
,
None
,
monthly_schedule
,
None
,
target_item
,
)
try
:
response
=
server
.
tasks
.
create
(
scheduled_extract_item
)
print
(
response
)
except
Exception
as
e
:
print
(
e
)
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL