fisjac commented on code in PR #27962: URL: https://github.com/apache/superset/pull/27962#discussion_r1640004076
########## superset/dashboards/api.py: ########## @@ -395,6 +399,64 @@ def get_datasets(self, id_or_slug: str) -> Response: except DashboardNotFoundError: return self.response_404() + @expose("/<id_or_slug>/tabs", methods=("GET",)) + @protect() + @safe + @statsd_metrics + @event_logger.log_this_with_context( + action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get_tabs", + log_to_statsd=False, + ) + def get_tabs(self, id_or_slug: str) -> Response: + """Get dashboard's tabs. + --- + get: + summary: Get dashboard's tabs + description: >- + Returns a list of a dashboard's tabs and dashboard's nested tree structure for associated tabs. + parameters: + - in: path + schema: + type: string + name: id_or_slug + description: Either the id of the dashboard, or its slug + responses: + 200: + description: Dashboard tabs + content: + application/json: + schema: + type: object + properties: + result: + type: object + items: + $ref: '#/components/schemas/TabsPayloadSchema' + 400: + $ref: '#/components/responses/400' + 401: + $ref: '#/components/responses/401' + 403: + $ref: '#/components/responses/403' + 404: + $ref: '#/components/responses/404' + """ + try: + tabs = DashboardDAO.get_tabs_for_dashboard(id_or_slug) + result = self.tab_schema.dump(tabs) + return self.response(200, result=result) + + except (TypeError, ValueError) as err: + return self.response_400( + message=gettext( + "Tab schema is invalid, caused by: %(error)s", error=str(err) Review Comment: I borrowed this error handler from the `GET dashboard/<id>/datasets` endpoint, which throws when an invalid schema is detected. My thought was to ensure consistent validation behavior for similar endpoints. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org