From b4ddc173e5520917c941f239260a2dafe4037966 Mon Sep 17 00:00:00 2001 From: Iakov Gan Date: Fri, 22 Mar 2024 21:24:21 +0100 Subject: [PATCH 1/3] support theme --- cid/export.py | 14 +++++++++++++- cid/helpers/quicksight/__init__.py | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cid/export.py b/cid/export.py index 84bb1b5d..133a4328 100644 --- a/cid/export.py +++ b/cid/export.py @@ -69,6 +69,16 @@ def choose_analysis(qs): return choices[choice]['AnalysisId'] +def get_theme(analysis): + theme_arn = analysis.get('ThemeArn') + if not theme_arn: + return None + if theme_arn.startswith('arn:aws:quicksight::aws:theme/'): + return theme_arn.split('/')[-1] + logger.warning('theme {theme_arn} is not standard and is not supported yet') + return None + + def export_analysis(qs, athena): """ Export analysis to yaml resource File """ @@ -94,7 +104,7 @@ def export_analysis(qs, athena): resources = {} resources['dashboards'] = {} resources['datasets'] = {} - + theme_id = get_theme(analysis) cur_helper = CUR(session=athena.session) resources_datasets = [] @@ -270,6 +280,8 @@ def export_analysis(qs, athena): dashboard_resource['name'] = analysis['Name'] dashboard_resource['dashboardId'] = dashboard_id dashboard_resource['category'] = get_parameters().get('category', 'Custom') + if theme_id: + dashboard_resource['theme'] = theme_id dashboard_export_method = None if get_parameters().get('template-id'): diff --git a/cid/helpers/quicksight/__init__.py b/cid/helpers/quicksight/__init__.py index 1a4ab36b..c3015bba 100644 --- a/cid/helpers/quicksight/__init__.py +++ b/cid/helpers/quicksight/__init__.py @@ -1317,6 +1317,13 @@ def _build_params_for_create_update_dash(self, definition: dict, permissions: bo 'Name': definition.get('name'), 'ValidationStrategy': {'Mode': 'LENIENT'}, } + theme = definition.get('theme') + if theme: + if not theme.startswith('arn:') + theme_arn = 'arn:aws:quicksight::aws:theme/' + theme + else: + raise NotImplementedError('Only standard themes are supported now.') + create_parameters['ThemeArn'] = theme_arn if definition.get('sourceTemplate'): dataset_references = [ From 3602e3c39f1e9f28d493dcc4642a37c5e7b8358a Mon Sep 17 00:00:00 2001 From: Iakov Gan Date: Fri, 22 Mar 2024 21:34:46 +0100 Subject: [PATCH 2/3] support theme --- cid/helpers/quicksight/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cid/helpers/quicksight/__init__.py b/cid/helpers/quicksight/__init__.py index c3015bba..ea44b8b7 100644 --- a/cid/helpers/quicksight/__init__.py +++ b/cid/helpers/quicksight/__init__.py @@ -1319,7 +1319,7 @@ def _build_params_for_create_update_dash(self, definition: dict, permissions: bo } theme = definition.get('theme') if theme: - if not theme.startswith('arn:') + if not theme.startswith('arn:'): theme_arn = 'arn:aws:quicksight::aws:theme/' + theme else: raise NotImplementedError('Only standard themes are supported now.') From 4511dabe349c6280c57502cccb1cb009e166282d Mon Sep 17 00:00:00 2001 From: Iakov GAN <82834333+iakov-aws@users.noreply.github.com> Date: Sat, 23 Mar 2024 09:30:02 +0100 Subject: [PATCH 3/3] Update cid/export.py --- cid/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cid/export.py b/cid/export.py index 133a4328..18d058fe 100644 --- a/cid/export.py +++ b/cid/export.py @@ -75,7 +75,7 @@ def get_theme(analysis): return None if theme_arn.startswith('arn:aws:quicksight::aws:theme/'): return theme_arn.split('/')[-1] - logger.warning('theme {theme_arn} is not standard and is not supported yet') + logger.warning(f'Theme {theme_arn} is not standard and is not supported yet. Theme will be ignored.') return None