diff --git a/samples/download_view_image.py b/samples/download_view_image.py index b95a8628b..df2331596 100644 --- a/samples/download_view_image.py +++ b/samples/download_view_image.py @@ -25,6 +25,7 @@ def main(): parser.add_argument('--view-name', '-v', required=True, help='name of view to download an image of') parser.add_argument('--filepath', '-f', required=True, help='filepath to save the image returned') + parser.add_argument('--maxage', '-m', required=False, help='max age of the image in the cache in minutes.') parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error', help='desired logging level (set to error by default)') @@ -55,8 +56,12 @@ def main(): raise LookupError("View with the specified name was not found.") view_item = all_views[0] - # Step 3: Query the image endpoint and save the image to the specified location - image_req_option = TSC.ImageRequestOptions(imageresolution=TSC.ImageRequestOptions.Resolution.High) + max_age = args.maxage + if not max_age: + max_age = 1 + + image_req_option = TSC.ImageRequestOptions(imageresolution=TSC.ImageRequestOptions.Resolution.High, + maxage=max_age) server.views.populate_image(view_item, image_req_option) with open(args.filepath, "wb") as image_file: diff --git a/tableauserverclient/server/request_options.py b/tableauserverclient/server/request_options.py index 0e3601a25..9f3247e7b 100644 --- a/tableauserverclient/server/request_options.py +++ b/tableauserverclient/server/request_options.py @@ -108,14 +108,17 @@ class ImageRequestOptions(_FilterOptionsBase): class Resolution: High = 'high' - def __init__(self, imageresolution=None): + def __init__(self, imageresolution=None, maxage=None): super(ImageRequestOptions, self).__init__() self.image_resolution = imageresolution + self.max_age = maxage def apply_query_params(self, url): params = [] if self.image_resolution: params.append('resolution={0}'.format(self.image_resolution)) + if self.max_age: + params.append('maxAge={0}'.format(self.max_age)) self._append_view_filters(params)