mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-07-31 05:04:39 +00:00
* fix: get dashboard by id * fix: function param name id->dashboard_id | python checkstyle * refactor: used api version and rename get dashboard function * fix: used clean uri
This commit is contained in:
parent
c09c504178
commit
20f567b8da
@ -13,6 +13,7 @@ REST Auth & Client for Redash
|
||||
"""
|
||||
|
||||
from metadata.ingestion.ometa.client import REST, ClientConfig
|
||||
from metadata.utils.helpers import clean_uri
|
||||
from metadata.utils.logger import utils_logger
|
||||
|
||||
logger = utils_logger()
|
||||
@ -28,8 +29,8 @@ class RedashApiClient:
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
client_config = ClientConfig(
|
||||
base_url=str(config.hostPort),
|
||||
api_version="",
|
||||
base_url=clean_uri(config.hostPort),
|
||||
api_version="api",
|
||||
access_token=config.apiKey.get_secret_value(),
|
||||
auth_header="Authorization",
|
||||
auth_token_mode="Key",
|
||||
@ -41,16 +42,11 @@ class RedashApiClient:
|
||||
"""GET api/dashboards"""
|
||||
|
||||
params_data = {"page": page, "page_size": page_size}
|
||||
return self.client.get(path="api/dashboards", data=params_data)
|
||||
return self.client.get(path="/dashboards", data=params_data)
|
||||
|
||||
def get_dashboard(self, slug):
|
||||
"""GET api/dashboards/<slug>"""
|
||||
|
||||
# The API changed from redash v9 onwards
|
||||
# legacy=true allows us to get the results in the old way
|
||||
return self.client.get(
|
||||
f"api/dashboards/{slug}?legacy=true",
|
||||
)
|
||||
def get_dashboard(self, dashboard_id: int):
|
||||
"""GET api/dashboards/<id>"""
|
||||
return self.client.get(f"/dashboards/{dashboard_id}")
|
||||
|
||||
def paginate(self, resource, page=1, page_size=25, **kwargs):
|
||||
"""Load all items of a paginated resource"""
|
||||
|
@ -115,7 +115,7 @@ class RedashSource(DashboardServiceSource):
|
||||
return dashboard["name"]
|
||||
|
||||
def get_dashboard_details(self, dashboard: dict) -> dict:
|
||||
return self.client.get_dashboard(dashboard["slug"])
|
||||
return self.client.get_dashboard(dashboard["id"])
|
||||
|
||||
def get_owner_ref(self, dashboard_details) -> Optional[EntityReferenceList]:
|
||||
"""
|
||||
@ -160,9 +160,9 @@ class RedashSource(DashboardServiceSource):
|
||||
dashboard_request = CreateDashboardRequest(
|
||||
name=EntityName(str(dashboard_details["id"])),
|
||||
displayName=dashboard_details.get("name"),
|
||||
description=Markdown(dashboard_description)
|
||||
if dashboard_description
|
||||
else None,
|
||||
description=(
|
||||
Markdown(dashboard_description) if dashboard_description else None
|
||||
),
|
||||
charts=[
|
||||
FullyQualifiedEntityName(
|
||||
fqn.build(
|
||||
@ -275,9 +275,11 @@ class RedashSource(DashboardServiceSource):
|
||||
yield Either(
|
||||
right=CreateChartRequest(
|
||||
name=EntityName(str(widgets["id"])),
|
||||
displayName=chart_display_name
|
||||
if visualization and visualization["query"]
|
||||
else "",
|
||||
displayName=(
|
||||
chart_display_name
|
||||
if visualization and visualization["query"]
|
||||
else ""
|
||||
),
|
||||
chartType=get_standard_chart_type(
|
||||
visualization["type"] if visualization else ""
|
||||
),
|
||||
@ -285,9 +287,11 @@ class RedashSource(DashboardServiceSource):
|
||||
self.context.get().dashboard_service
|
||||
),
|
||||
sourceUrl=SourceUrl(self.get_dashboard_url(dashboard_details)),
|
||||
description=Markdown(visualization["description"])
|
||||
if visualization
|
||||
else None,
|
||||
description=(
|
||||
Markdown(visualization["description"])
|
||||
if visualization
|
||||
else None
|
||||
),
|
||||
)
|
||||
)
|
||||
except Exception as exc:
|
||||
|
Loading…
x
Reference in New Issue
Block a user