Skip to content

Commit

Permalink
cli doc enhancements and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov-aws committed Nov 2, 2023
1 parent 8de55d3 commit 12584c8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
4 changes: 3 additions & 1 deletion cid/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def deploy(ctx, **kwargs):
\b
Command options:
--category TEXT The dashboards category to choose from. Not needed if dashboard-id provided directly
--dashboard-id TEXT QuickSight dashboard id (cudos, cost_intelligence_dashboard, kpi_dashboard, ta-organizational-view, trends-dashboard etc)
--athena-database TEXT Athena database
--athena-workgroup TEXT Athena workgroup
Expand All @@ -134,7 +135,7 @@ def deploy(ctx, **kwargs):
@click.option('-y', '--yes', help='confirm all', is_flag=True, default=False)
@cid_command
def export(ctx, **kwargs):
"""Expot Dashboard
"""Export Dashboard
\b
Command options:
Expand All @@ -148,6 +149,7 @@ def export(ctx, **kwargs):
(definition|template) A method (definition=pull json definition of Analysis OR template=create QuickSight Template)
--export-known-datasets
(no|yes) If 'yes' the export will include DataSets that are already in resources file. Default = no
--category TEXT The dashboards category. Default = Custom
--output A filename (.yaml)
"""
ctx.obj.export(**kwargs)
Expand Down
35 changes: 17 additions & 18 deletions cid/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ def load_resource_file(self, source):
with open(source, encoding='utf-8') as file_:
resources = yaml.safe_load(file_)
except Exception as exc:
raise CidCritical(f'Failed to load resources from {source}.') from exc
logger.warning(f'Failed to load resources from {source}: {exc}')
return
self.resources = always_merger.merge(self.resources, resources)

def load_catalog(self, catalog_url=None):
Expand Down Expand Up @@ -385,33 +386,31 @@ def _deploy(self, dashboard_id: str=None, recursive=True, update=False, **kwargs

dashboard_id = dashboard_id or get_parameters().get('dashboard-id')
if not dashboard_id:
standard_categories = ['Foundational', 'Advanced', 'Additional']
all_categories = set([f"{dashboard.get('category', 'Custom')}" for dashboard in self.resources.get('dashboards').values()])
non_standard_categories = [cat for cat in all_categories if cat not in standard_categories]
while True:
category_options = ['Foundational', 'Advanced', 'Additional'] + \
sorted(list(set([
f"{dashboard.get('category', 'Custom')}"
for k, dashboard in self.resources.get('dashboards').items()
if f"{dashboard.get('category', 'Custom')}" not in ('Foundational', 'Advanced', 'Additional')
])))
category_options = standard_categories + sorted(non_standard_categories)
category = get_parameter(
param_name='category',
message="Please select a category of dashboard to install",
message="Please select a category of dashboard to deploy",
choices=category_options,
)
dashboard_options = {
f"[{dashboard.get('dashboardId')}] {dashboard.get('name')}" : dashboard.get('dashboardId')
for k, dashboard in self.resources.get('dashboards').items()
if dashboard.get('category', 'Custom') == category
}
dashboard_options = {}
for dashboard in self.resources.get('dashboards').values():
if dashboard.get('category', 'Custom') == category:
dashboard_options[f"[{dashboard.get('dashboardId')}] {dashboard.get('name')}"] = dashboard.get('dashboardId')
dashboard_options['<<< back'] = '<<< back'
dashboard_id = get_parameter(
param_name='dashboard-id',
message="Please select dashboard to install",
message="Please select a dashboard to deploy",
choices=dashboard_options,
)
if dashboard_id != '<<< back':
break
unset_parameter('category')
unset_parameter('dashboard-id')
if dashboard_id == '<<< back':
unset_parameter('category')
unset_parameter('dashboard-id')
continue
break

if not dashboard_id:
print('No dashboard selected')
Expand Down
1 change: 1 addition & 0 deletions cid/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def export_analysis(qs, athena):
}
dashboard_resource['name'] = analysis['Name']
dashboard_resource['dashboardId'] = dashboard_id
dashboard_resource['category'] = get_parameters().get('category', 'Custom')

dashboard_export_method = None
if get_parameters().get('template-id'):
Expand Down

0 comments on commit 12584c8

Please sign in to comment.