diff --git a/ingestion/src/metadata/ingestion/source/dashboard/mode/client.py b/ingestion/src/metadata/ingestion/source/dashboard/mode/client.py index 22ce527d3dc..0b0f490f1a7 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/mode/client.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/mode/client.py @@ -74,23 +74,18 @@ class ModeApiClient: Returns: dict """ - try: - all_reports = [] - response_collections = self.client.get(f"/{workspace_name}/{COLLECTIONS}") - collections = response_collections[EMBEDDED]["spaces"] - for collection in collections: - response_reports = self.get_all_reports_for_collection( - workspace_name=workspace_name, - collection_token=collection.get(TOKEN), - ) + all_reports = [] + response_collections = self.client.get(f"/{workspace_name}/{COLLECTIONS}") + collections = response_collections[EMBEDDED]["spaces"] + for collection in collections: + response_reports = self.get_all_reports_for_collection( + workspace_name=workspace_name, + collection_token=collection.get(TOKEN), + ) + if response_reports: reports = response_reports[EMBEDDED][REPORTS] all_reports.extend(reports) - return all_reports - except Exception as exc: # pylint: disable=broad-except - logger.debug(traceback.format_exc()) - logger.warning(f"Error fetching all reports: {exc}") - - return None + return all_reports def get_all_reports_for_collection( self, workspace_name: str, collection_token: str @@ -180,11 +175,3 @@ class ModeApiClient: logger.warning(f"Error fetching all data sources: {exc}") return None - - def get_user_account(self) -> dict: - """Method to fetch account details - Returns: - dict - """ - response = self.client.get("/account") - return response diff --git a/ingestion/src/metadata/ingestion/source/dashboard/mode/connection.py b/ingestion/src/metadata/ingestion/source/dashboard/mode/connection.py index 1276b580cae..339931b4c84 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/mode/connection.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/mode/connection.py @@ -12,6 +12,7 @@ """ Source connection handler """ +from functools import partial from typing import Optional from metadata.generated.schema.entity.automations.workflow import ( @@ -43,7 +44,11 @@ def test_connection( of a metadata workflow or during an Automation Workflow """ - test_fn = {"CheckAccess": client.get_user_account} + test_fn = { + "CheckDashboards": partial( + client.fetch_all_reports, service_connection.workspaceName + ) + } test_connection_steps( metadata=metadata, diff --git a/openmetadata-service/src/main/resources/json/data/testConnections/dashboard/mode.json b/openmetadata-service/src/main/resources/json/data/testConnections/dashboard/mode.json index 6a400d9bf27..db1075ae1b8 100644 --- a/openmetadata-service/src/main/resources/json/data/testConnections/dashboard/mode.json +++ b/openmetadata-service/src/main/resources/json/data/testConnections/dashboard/mode.json @@ -4,9 +4,9 @@ "description": "This Test Connection validates the access against the server and basic metadata extraction of dashboards and charts.", "steps": [ { - "name": "CheckAccess", - "description": "Validate that the API is accessible with the given credentials", - "errorMessage": "Failed to connect to mode, please validate the credentials", + "name": "CheckDashboards", + "description": "Validate that the Dashboards(Reports) API is accessible with the given credentials", + "errorMessage": "Failed to connect to mode to get the dashboards, please validate the credentials", "shortCircuit": true, "mandatory": true }