diff --git a/ingestion/src/metadata/ingestion/source/dashboard/mode/client.py b/ingestion/src/metadata/ingestion/source/dashboard/mode/client.py index e7d52b56e9f..7f263af356c 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/mode/client.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/mode/client.py @@ -67,15 +67,27 @@ class ModeApiClient: ) self.client = REST(client_config) - def fetch_all_reports(self, workspace_name: str) -> Optional[list]: + def fetch_all_reports( + self, workspace_name: str, filter: Optional[str] = "all" + ) -> Optional[list]: """Method to fetch all reports for Mode Args: workspace_name: + filter: Returns: dict """ + if filter not in ["custom", "all"]: + logger.warning( + "Invalid value for filter. Should be one of ['custom', 'all']" + ) + return + all_reports = [] - response_collections = self.client.get(f"/{workspace_name}/{COLLECTIONS}") + filter_param = f"?filter={filter}" + response_collections = self.client.get( + f"/{workspace_name}/{COLLECTIONS}{filter_param}" + ) collections = response_collections[EMBEDDED]["spaces"] for collection in collections: response_reports = self.get_all_reports_for_collection( @@ -175,3 +187,19 @@ class ModeApiClient: logger.warning(f"Error fetching all data sources: {exc}") return None + + def get_workspace(self, workspace_name: str) -> Optional[dict]: + """Method to get info about a workspace + Args: + workspace_name: + Returns: + dict + """ + try: + response = self.client.get(f"/{workspace_name}") + return response.json() + except Exception as exc: # pylint: disable=broad-except + logger.debug(traceback.format_exc()) + logger.warning(f"Error testing workspace connection: {exc}") + + return None diff --git a/ingestion/src/metadata/ingestion/source/dashboard/mode/connection.py b/ingestion/src/metadata/ingestion/source/dashboard/mode/connection.py index 96a670538a4..46500553268 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/mode/connection.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/mode/connection.py @@ -51,7 +51,7 @@ def test_connection( test_fn = { "CheckDashboards": partial( - client.fetch_all_reports, service_connection.workspaceName + client.get_workspace, service_connection.workspaceName ) } diff --git a/ingestion/src/metadata/ingestion/source/dashboard/mode/metadata.py b/ingestion/src/metadata/ingestion/source/dashboard/mode/metadata.py index da7478fda40..d02329a0220 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/mode/metadata.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/mode/metadata.py @@ -62,6 +62,7 @@ class ModeSource(DashboardServiceSource): ): super().__init__(config, metadata) self.workspace_name = config.serviceConnection.root.config.workspaceName + self.filter_query_param = config.serviceConnection.root.config.filterQueryParam self.data_sources = self.client.get_all_data_sources(self.workspace_name) @classmethod @@ -80,7 +81,9 @@ class ModeSource(DashboardServiceSource): """ Get List of all dashboards """ - return self.client.fetch_all_reports(self.workspace_name) + # If filter param field was empty, we will default to passing "all" to the API + filter_param = "all" if not self.filter_query_param else self.filter_query_param + return self.client.fetch_all_reports(self.workspace_name, filter_param) def get_dashboard_name(self, dashboard: dict) -> str: """ diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/dashboard/modeConnection.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/dashboard/modeConnection.json index 3a03cafb368..ff79fca991d 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/dashboard/modeConnection.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/dashboard/modeConnection.json @@ -44,6 +44,11 @@ "description": "Mode Workspace Name", "type": "string" }, + "filterQueryParam": { + "title": "Filter Query Param", + "description": "Filter query parameter for some of the Mode API calls", + "type": "string" + }, "supportsMetadataExtraction": { "title": "Supports Metadata Extraction", "$ref": "../connectionBasicType.json#/definitions/supportsMetadataExtraction" diff --git a/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Dashboard/Mode.md b/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Dashboard/Mode.md index 0286a25d9d3..df957875e6d 100644 --- a/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Dashboard/Mode.md +++ b/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Dashboard/Mode.md @@ -42,3 +42,14 @@ $$section Name of the Mode workspace. $$ + +$$section +### Filter Query Param $(id="filterQueryParam") + +This value is the `filter` query parameter that is passed to the Mode API. Different API +calls use different types of acceptable values. Currently this parameter is only implemented +to [list all collections](https://mode.com/developer/api-reference/management/collections/#listCollections). +The valid values that is currently supported are: `all` +and `custom`. If this field is left empty, `all` will be used. + +$$ \ No newline at end of file