MINOR: Tableau proxy url for sourceurl (#21799)

This commit is contained in:
harshsoni2024 2025-06-18 10:52:08 +05:30 committed by harshsoni2024
parent db2081cf4a
commit 88a0219b35
5 changed files with 39 additions and 2 deletions

View File

@ -16,6 +16,7 @@ source:
hostPort: http://localhost
siteName: site_name
paginationLimit: 10
proxyURL: http://proxyTableuHost
sourceConfig:
config:
type: DashboardMetadata

View File

@ -299,8 +299,9 @@ class TableauSource(DashboardServiceSource):
topology. And they are cleared after processing each Dashboard because of the 'clear_cache' option.
"""
try:
base_url = self.get_base_url()
dashboard_url = (
f"{clean_uri(str(self.config.serviceConnection.root.config.hostPort))}"
f"{clean_uri(str(base_url))}"
f"/#{urlparse(dashboard_details.webpageUrl).fragment}/views"
)
dashboard_request = CreateDashboardRequest(
@ -731,8 +732,9 @@ class TableauSource(DashboardServiceSource):
)
workbook_chart_name = ChartUrl(chart.contentUrl)
base_url = self.get_base_url()
chart_url = (
f"{clean_uri(self.service_connection.hostPort)}/"
f"{clean_uri(str(base_url))}"
f"#{site_url}"
f"views/{workbook_chart_name.workbook_name}"
f"/{workbook_chart_name.chart_url_name}"
@ -1084,3 +1086,11 @@ class TableauSource(DashboardServiceSource):
stackTrace=traceback.format_exc(),
)
)
def get_base_url(self) -> str:
"""
Get the proxy url for the tableau server
"""
if self.config.serviceConnection.root.config.proxyURL:
return str(self.config.serviceConnection.root.config.proxyURL)
return str(self.config.serviceConnection.root.config.hostPort)

View File

@ -456,3 +456,16 @@ class TableauUnitTest(TestCase):
):
dashboards = list(self.tableau.get_dashboard())
self.assertEqual(len(dashboards), 0)
def test_generate_dashboard_url(self):
"""
Test that the dashboard url is generated correctly with proxyURL
"""
self.tableau.config.serviceConnection.root.config.proxyURL = (
"http://mockTableauServer.com"
)
result = list(self.tableau.yield_dashboard(MOCK_DASHBOARD))
self.assertEqual(
result[0].right.sourceUrl.root,
"http://mockTableauServer.com/#/site/hidarsite/workbooks/897790/views",
)

View File

@ -58,6 +58,14 @@
"type": "string",
"default": null
},
"proxyURL": {
"expose": true,
"title": "Proxy URL",
"description": "Proxy URL for the tableau server. If not provided, the hostPort will be used. This is used to generate the dashboard & Chart URL.",
"type": "string",
"format": "uri",
"default": null
},
"verifySSL": {
"$ref": "../../../../security/ssl/verifySSLConfig.json#/definitions/verifySSL",
"default": "no-ssl"

View File

@ -46,6 +46,11 @@ export interface TableauConnection {
* Regex to exclude or include projects that matches the pattern.
*/
projectFilterPattern?: FilterPattern;
/**
* Proxy URL for the tableau server. If not provided, the hostPort will be used. This is
* used to generate the dashboard & Chart URL.
*/
proxyURL?: string;
/**
* Tableau Site Name.
*/