Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support theme #758

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion cid/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(f'Theme {theme_arn} is not standard and is not supported yet. Theme will be ignored.')
return None


def export_analysis(qs, athena):
""" Export analysis to yaml resource File
"""
Expand All @@ -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 = []
Expand Down Expand Up @@ -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'):
Expand Down
7 changes: 7 additions & 0 deletions cid/helpers/quicksight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Loading