diff --git a/ingestion/src/metadata/ingestion/source/dashboard/redash/client.py b/ingestion/src/metadata/ingestion/source/dashboard/redash/client.py index 30cc9e9cd6c..40a0e925aad 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/redash/client.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/redash/client.py @@ -13,6 +13,7 @@ REST Auth & Client for Redash """ from metadata.ingestion.ometa.client import REST, ClientConfig +from metadata.utils.helpers import clean_uri from metadata.utils.logger import utils_logger logger = utils_logger() @@ -28,8 +29,8 @@ class RedashApiClient: def __init__(self, config): self.config = config client_config = ClientConfig( - base_url=str(config.hostPort), - api_version="", + base_url=clean_uri(config.hostPort), + api_version="api", access_token=config.apiKey.get_secret_value(), auth_header="Authorization", auth_token_mode="Key", @@ -41,16 +42,11 @@ class RedashApiClient: """GET api/dashboards""" params_data = {"page": page, "page_size": page_size} - return self.client.get(path="api/dashboards", data=params_data) + return self.client.get(path="/dashboards", data=params_data) - def get_dashboard(self, slug): - """GET api/dashboards/""" - - # The API changed from redash v9 onwards - # legacy=true allows us to get the results in the old way - return self.client.get( - f"api/dashboards/{slug}?legacy=true", - ) + def get_dashboard(self, dashboard_id: int): + """GET api/dashboards/""" + return self.client.get(f"/dashboards/{dashboard_id}") def paginate(self, resource, page=1, page_size=25, **kwargs): """Load all items of a paginated resource""" diff --git a/ingestion/src/metadata/ingestion/source/dashboard/redash/metadata.py b/ingestion/src/metadata/ingestion/source/dashboard/redash/metadata.py index 94ae4a0cb7d..1067e1afcc7 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/redash/metadata.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/redash/metadata.py @@ -115,7 +115,7 @@ class RedashSource(DashboardServiceSource): return dashboard["name"] def get_dashboard_details(self, dashboard: dict) -> dict: - return self.client.get_dashboard(dashboard["slug"]) + return self.client.get_dashboard(dashboard["id"]) def get_owner_ref(self, dashboard_details) -> Optional[EntityReferenceList]: """ @@ -160,9 +160,9 @@ class RedashSource(DashboardServiceSource): dashboard_request = CreateDashboardRequest( name=EntityName(str(dashboard_details["id"])), displayName=dashboard_details.get("name"), - description=Markdown(dashboard_description) - if dashboard_description - else None, + description=( + Markdown(dashboard_description) if dashboard_description else None + ), charts=[ FullyQualifiedEntityName( fqn.build( @@ -275,9 +275,11 @@ class RedashSource(DashboardServiceSource): yield Either( right=CreateChartRequest( name=EntityName(str(widgets["id"])), - displayName=chart_display_name - if visualization and visualization["query"] - else "", + displayName=( + chart_display_name + if visualization and visualization["query"] + else "" + ), chartType=get_standard_chart_type( visualization["type"] if visualization else "" ), @@ -285,9 +287,11 @@ class RedashSource(DashboardServiceSource): self.context.get().dashboard_service ), sourceUrl=SourceUrl(self.get_dashboard_url(dashboard_details)), - description=Markdown(visualization["description"]) - if visualization - else None, + description=( + Markdown(visualization["description"]) + if visualization + else None + ), ) ) except Exception as exc: