From c7902344cbfe0e27dc4d143df7a6ee432b76bd25 Mon Sep 17 00:00:00 2001 From: Onkar Ravgan Date: Fri, 5 May 2023 18:29:50 +0530 Subject: [PATCH] Added tableau owner test connection step (#11436) * Added tableau owner test connection * typo fixed * remvoed generic exception --- .../source/dashboard/tableau/client.py | 18 +++++++++++++++++- .../source/dashboard/tableau/connection.py | 1 + .../testConnections/dashboard/tableau.json | 6 ++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ingestion/src/metadata/ingestion/source/dashboard/tableau/client.py b/ingestion/src/metadata/ingestion/source/dashboard/tableau/client.py index 28cf50ebbb6..ea4bd99838c 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/tableau/client.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/tableau/client.py @@ -11,7 +11,7 @@ """ Wrapper module of TableauServerConnection client """ -from typing import Any, Callable, Dict, List +from typing import Any, Callable, Dict, List, Optional from cached_property import cached_property from tableau_api_lib import TableauServerConnection @@ -24,6 +24,7 @@ from metadata.ingestion.source.dashboard.tableau import ( from metadata.ingestion.source.dashboard.tableau.models import ( TableauChart, TableauDashboard, + TableauOwner, TableauSheets, ) from metadata.ingestion.source.dashboard.tableau.queries import ( @@ -34,6 +35,12 @@ from metadata.utils.logger import ometa_logger logger = ometa_logger() +class TableauOwnersNotFound(Exception): + """ + Raise when Owner information is not retrieved from the Tableau APIs + """ + + class TableauClient: """ Wrapper to TableauServerConnection @@ -69,6 +76,15 @@ class TableauClient: def query_views_for_site(self) -> Callable: return self._client.query_views_for_site + def get_owners(self) -> Optional[List[TableauOwner]]: + owners = [workbook.owner for workbook in self.get_workbooks()] + if len(owners) > 0: + return owners + raise TableauOwnersNotFound( + "Unable to fetch Dashboard Owners from tableau\n" + "Please check if the user has permissions to access the Owner information" + ) + def get_workbooks(self) -> List[TableauDashboard]: return [ TableauDashboard(**workbook) diff --git a/ingestion/src/metadata/ingestion/source/dashboard/tableau/connection.py b/ingestion/src/metadata/ingestion/source/dashboard/tableau/connection.py index d0da97e8079..03d8de61ae6 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/tableau/connection.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/tableau/connection.py @@ -87,6 +87,7 @@ def test_connection( content_id=client.site_id, parameter_dict=TABLEAU_GET_VIEWS_PARAM_DICT, ), + "GetOwners": client.get_owners, } test_connection_steps( diff --git a/openmetadata-service/src/main/resources/json/data/testConnections/dashboard/tableau.json b/openmetadata-service/src/main/resources/json/data/testConnections/dashboard/tableau.json index 53c780e6454..f17d58ed5a6 100644 --- a/openmetadata-service/src/main/resources/json/data/testConnections/dashboard/tableau.json +++ b/openmetadata-service/src/main/resources/json/data/testConnections/dashboard/tableau.json @@ -22,6 +22,12 @@ "description": "List the Views (charts) from a given Workbook.", "errorMessage": "Failed to fetch views(charts), please validate if user has access to fetch views", "mandatory": false + }, + { + "name": "GetOwners", + "description": "Validate if the Owner information is retrieved for Workbooks", + "errorMessage": "Failed to fetch Workbook Owners, please validate if user has access to fetch Owners", + "mandatory": false } ] }