in cid/helpers/quicksight.py [0:0]
def discover_dashboard(self, dashboardId: str):
"""Discover single dashboard"""
dashboard = self.describe_dashboard(DashboardId=dashboardId)
# Look for dashboard definition by DashboardId
_definition = next((v for v in self.supported_dashboards.values() if v['dashboardId'] == dashboard.id), None)
if not _definition:
# Look for dashboard definition by templateId
_definition = next((v for v in self.supported_dashboards.values() if v['templateId'] == dashboard.templateId), None)
if not _definition:
logger.info(f'Unsupported dashboard "{dashboard.name}" ({dashboard.deployed_arn})')
else:
logger.info(f'Supported dashboard "{dashboard.name}" ({dashboard.deployed_arn})')
dashboard.definition = _definition
logger.info(f'Found definition for "{dashboard.name}" ({dashboard.deployed_arn})')
for dataset in dashboard.version.get('DataSetArns'):
dataset_id = dataset.split('/')[-1]
try:
_dataset = self.describe_dataset(id=dataset_id)
if not _dataset:
dashboard.datasets.update({dataset_id: 'missing'})
logger.info(f'Dataset "{dataset_id}" is missing')
else:
logger.info(f"Using dataset \"{_dataset.get('Name')}\" ({_dataset.get('DataSetId')} for {dashboard.name})")
dashboard.datasets.update({_dataset.get('Name'): _dataset.get('Arn')})
except self.client.exceptions.AccessDeniedException:
logger.info(f'Looking local config for {dashboardId}')
dashboard.find_local_config()
except self.client.exceptions.InvalidParameterValueException:
logger.info(f'Invalid dataset {dataset_id}')
templateAccountId = _definition.get('sourceAccountId')
templateId = _definition.get('templateId')
try:
template = self.describe_template(templateId, account_id=templateAccountId)
dashboard.sourceTemplate = template
except:
logger.info(f'Unable to describe template {templateId} in {templateAccountId}')
self._dashboards.update({dashboardId: dashboard})
logger.info(f"{dashboard.name} has {len(dashboard.datasets)} datasets")
logger.info(f'"{dashboard.name}" ({dashboardId}) discover complete')