sync worked
This commit is contained in:
@@ -829,6 +829,34 @@ class SupersetClient:
|
||||
raise SupersetAPIError(f"Архив {zip_path} не содержит 'metadata.yaml'")
|
||||
# [/DEF:_validate_import_file:Function]
|
||||
|
||||
# [DEF:get_all_resources:Function]
|
||||
# @PURPOSE: Fetches all resources of a given type with id, uuid, and name columns.
|
||||
# @PARAM: resource_type (str) - One of "chart", "dataset", "dashboard".
|
||||
# @PRE: Client is authenticated. resource_type is valid.
|
||||
# @POST: Returns a list of resource dicts with at minimum id, uuid, and name fields.
|
||||
# @RETURN: List[Dict]
|
||||
def get_all_resources(self, resource_type: str) -> List[Dict]:
|
||||
with belief_scope("SupersetClient.get_all_resources", f"type={resource_type}"):
|
||||
column_map = {
|
||||
"chart": {"endpoint": "/chart/", "columns": ["id", "uuid", "slice_name"]},
|
||||
"dataset": {"endpoint": "/dataset/", "columns": ["id", "uuid", "table_name"]},
|
||||
"dashboard": {"endpoint": "/dashboard/", "columns": ["id", "uuid", "slug", "dashboard_title"]},
|
||||
}
|
||||
config = column_map.get(resource_type)
|
||||
if not config:
|
||||
app_logger.warning("[get_all_resources][Warning] Unknown resource type: %s", resource_type)
|
||||
return []
|
||||
|
||||
query = {"columns": config["columns"]}
|
||||
validated = self._validate_query_params(query)
|
||||
data = self._fetch_all_pages(
|
||||
endpoint=config["endpoint"],
|
||||
pagination_options={"base_query": validated, "results_field": "result"},
|
||||
)
|
||||
app_logger.info("[get_all_resources][Exit] Fetched %d %s resources.", len(data), resource_type)
|
||||
return data
|
||||
# [/DEF:get_all_resources:Function]
|
||||
|
||||
# [/SECTION]
|
||||
|
||||
# [/DEF:SupersetClient:Class]
|
||||
|
||||
Reference in New Issue
Block a user