def get_look(title: str) -> models.Look: title = title.lower() look = next(iter(sdk.search_looks(title=title)), None) if not look: raise sdk_exceptions.NotFoundError(f"look '{title}' was not found") assert isinstance(look, models.Look) return look
def get_dashboard(title: str) -> Optional[models.Dashboard]: """Get a dashboard by title.""" title = title.lower() dashboard = next(iter(sdk.search_dashboards(title=title)), None) if not dashboard: raise sdk_exceptions.NotFoundError(f'dashboard "{title}" not found') assert isinstance(dashboard, models.Dashboard) return dashboard
def get_dashboards(title: str) -> Sequence[models.Dashboard]: """Get dashboards with matching title""" lc_title = title.lower() results = sdk.search_dashboards(title=lc_title) if not results: raise sdk_exceptions.NotFoundError(f'dashboard "{title}" not found') assert isinstance(results, Sequence) return results
def get_look_query(id: int) -> models.Query: """Returns the query associated with a given look id.""" try: look = sdk.look(id) except error.SDKError: raise sdk_exceptions.NotFoundError(f"Error getting Look {id}") else: query = look.query assert isinstance(query, models.Query) return query