From 4f5f63b2262fb3354fd2ffa1ca80e7c8a719c2d2 Mon Sep 17 00:00:00 2001 From: Ayush Shah Date: Tue, 8 Feb 2022 23:02:56 +0530 Subject: [PATCH] Issue-2672: Added support for personal access token name and secret and upgraded tableau version (#2682) --- ingestion/examples/workflows/tableau.json | 2 ++ ingestion/setup.py | 4 +-- .../src/metadata/ingestion/source/tableau.py | 33 +++++++++++++------ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/ingestion/examples/workflows/tableau.json b/ingestion/examples/workflows/tableau.json index 03b071aba6f..9f06899c2d4 100644 --- a/ingestion/examples/workflows/tableau.json +++ b/ingestion/examples/workflows/tableau.json @@ -2,6 +2,8 @@ "source": { "type": "tableau", "config": { + "personal_access_token_secret": "personal_access_token_secret", + "personal_access_token_name": "personal_access_token_name", "username": "username", "password": "password", "service_name": "local_tableau", diff --git a/ingestion/setup.py b/ingestion/setup.py index 69fbb9a1429..819551fc7d3 100644 --- a/ingestion/setup.py +++ b/ingestion/setup.py @@ -105,7 +105,7 @@ plugins: Dict[str, Set[str]] = { "snowflake-usage": {"snowflake-sqlalchemy<=1.3.2"}, "sample-entity": {"faker~=8.1.1"}, "superset": {}, - "tableau": {"tableau-api-lib==0.1.22"}, + "tableau": {"tableau-api-lib==0.1.29"}, "vertica": {"sqlalchemy-vertica[vertica-python]>=0.0.5"}, "report-server": report_requirements, "airflow": {"apache-airflow >= 1.10.2"}, @@ -113,7 +113,7 @@ plugins: Dict[str, Set[str]] = { "okta": {"okta~=2.3.0"}, "mlflow": {"mlflow-skinny~=1.22.0"}, "sklearn": {"scikit-learn==1.0.2"}, - "db2":{"ibm-db-sa==0.3.7"}, + "db2": {"ibm-db-sa==0.3.7"}, } dev = { "boto3==1.20.14", diff --git a/ingestion/src/metadata/ingestion/source/tableau.py b/ingestion/src/metadata/ingestion/source/tableau.py index 1063261ca5e..9e512e44a1d 100644 --- a/ingestion/src/metadata/ingestion/source/tableau.py +++ b/ingestion/src/metadata/ingestion/source/tableau.py @@ -42,8 +42,8 @@ logger = logging.getLogger(__name__) class TableauSourceConfig(ConfigModel): """Tableau pydantic source model""" - username: str - password: SecretStr + username: Optional[str] = None + password: Optional[SecretStr] = None server: str api_version: str env: Optional[str] = "tableau_prod" @@ -51,6 +51,8 @@ class TableauSourceConfig(ConfigModel): site_url: str service_name: str service_type: str = "Tableau" + personal_access_token_name: Optional[str] = None + personal_access_token_secret: Optional[str] = None dashboard_pattern: IncludeFilterPattern = IncludeFilterPattern.allow_all() chart_pattern: IncludeFilterPattern = IncludeFilterPattern.allow_all() @@ -87,12 +89,12 @@ class TableauSource(Source[Entity]): self.metadata_config = metadata_config self.client = self.tableau_client() self.service = get_dashboard_service_or_create( - config.service_name, - DashboardServiceType.Tableau.name, - config.username, - config.password.get_secret_value(), - config.server, - metadata_config, + service_name=config.service_name, + dashboard_service_type=DashboardServiceType.Tableau.name, + username=config.username, + password=config.password.get_secret_value() if config.password else None, + dashboard_url=config.server, + metadata_config=metadata_config, ) self.status = SourceStatus() self.dashboards = get_workbooks_dataframe(self.client).to_dict() @@ -107,12 +109,23 @@ class TableauSource(Source[Entity]): f"{self.config.env}": { "server": self.config.server, "api_version": self.config.api_version, - "username": self.config.username, - "password": self.config.password.get_secret_value(), "site_name": self.config.site_name, "site_url": self.config.site_url, } } + if self.config.username and self.config.password: + tableau_server_config[self.config.env]["username"] = self.config.username + tableau_server_config[self.config.env]["password"] = self.config.password + elif ( + self.config.personal_access_token_name + and self.config.personal_access_token_secret + ): + tableau_server_config[self.config.env][ + "personal_access_token_name" + ] = self.config.personal_access_token_name + tableau_server_config[self.config.env][ + "personal_access_token_secret" + ] = self.config.personal_access_token_secret try: conn = TableauServerConnection( config_json=tableau_server_config, env="tableau_prod"