8000 Merge pull request #360 from tableau/Add_MaxAge_Param2 · jmt1992/server-client-python@c50e080 · GitHub
[go: up one dir, main page]

Skip to content

Commit c50e080

Browse files
authored
Merge pull request tableau#360 from tableau/Add_MaxAge_Param2
Add max age param2
2 parents 78a3538 + 4afd7ec commit c50e080

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

samples/download_view_image.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def main():
2525
parser.add_argument('--view-name', '-v', required=True,
2626
help='name of view to download an image of')
2727
parser.add_argument('--filepath', '-f', required=True, help='filepath to save the image returned')
28+
parser.add_argument('--maxage', '-m', required=False, help='max age of the image in the cache in minutes.')
2829
parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error',
2930
help='desired logging level (set to error by default)')
3031

@@ -55,8 +56,12 @@ def main():
5556
raise LookupError("View with the specified name was not found.")
5657
view_item = all_views[0]
5758

58-
# Step 3: Query the image endpoint and save the image to the specified location
59-
image_req_option = TSC.ImageRequestOptions(imageresolution=TSC.ImageRequestOptions.Resolution.High)
59+
max_age = args.maxage
60+
if not max_age:
61+
max_age = 1
62+
63+
image_req_option = TSC.ImageRequestOptions(imageresolution=TSC.ImageRequestOptions.Resolution.High,
64+
maxage=max_age)
6065
server.views.populate_image(view_item, image_req_option)
6166

6267
with open(args.filepath, "wb") as image_file:

tableauserverclient/server/request_options.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,17 @@ class ImageRequestOptions(_FilterOptionsBase):
108108
class Resolution:
109109
High = 'high'
110110

111-
def __init__(self, imageresolution=None):
111+
def __init__(self, imageresolution=None, maxage=None):
112112
super(ImageRequestOptions, self).__init__()
113113
self.image_resolution = imageresolution
114+
self.max_age = maxage
114115

115116
def apply_query_params(self, url):
116117
params = []
117118
if self.image_resolution:
118119
params.append('resolution={0}'.format(self.image_resolution))
120+
if self.max_age:
121+
params.append('maxAge={0}'.format(self.max_age))
119122

120123
self._append_view_filters(params)
121124

0 commit comments

Comments
 (0)
0