From 422bd64d53f18cf9ac0edc27807c6a5f48b16962 Mon Sep 17 00:00:00 2001 From: Daniel Gaspar Date: Fri, 16 Jun 2023 11:19:23 +0100 Subject: [PATCH 1/2] chore: remove deprecated apis /slice_json/ and /annotation_json/ --- RESOURCES/STANDARD_ROLES.md | 2 -- UPDATING.md | 1 + superset/views/core.py | 63 +------------------------------------ superset/views/utils.py | 33 ------------------- 4 files changed, 2 insertions(+), 97 deletions(-) diff --git a/RESOURCES/STANDARD_ROLES.md b/RESOURCES/STANDARD_ROLES.md index 5a413b14e9c56..2d455f1e8706b 100644 --- a/RESOURCES/STANDARD_ROLES.md +++ b/RESOURCES/STANDARD_ROLES.md @@ -69,12 +69,10 @@ |can slice on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| |can sync druid source on Superset|:heavy_check_mark:|O|O|O| |can explore on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| -|can slice json on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| |can approve on Superset|:heavy_check_mark:|O|O|O| |can explore json on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| |can fetch datasource metadata on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| |can csrf token on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| -|can annotation json on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| |can sqllab on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| |can select star on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| |can warm up cache on Superset|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|O| diff --git a/UPDATING.md b/UPDATING.md index d9771a5ee927a..ceabb3b7180d8 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -34,6 +34,7 @@ assists people when migrating to a new version. ### Breaking Changes +- [---](https://github.com/apache/superset/pull/---): Removed deprecated APIs `/superset/slice_json/...`, `/superset/annotation_json/...` - [24400](https://github.com/apache/superset/pull/24400): Removed deprecated APIs `/superset/recent_activity/...`, `/superset/fave_dashboards_by_username/...`, `/superset/fave_dashboards/...`, `/superset/created_dashboards/...`, `/superset/user_slices/`, `/superset/created_slices/...`, `/superset/fave_slices/...`, `/superset/favstar/...`, - [24401](https://github.com/apache/superset/pull/24401): Removes the deprecated `metrics` column (which was blossomed in [20732](https://github.com/apache/superset/pull/20732)) from the `/api/v1/dataset/` API. - [24375](https://github.com/apache/superset/pull/24375): Removed deprecated API `/superset/get_or_create_table/...`, `/superset/sqllab_viz` diff --git a/superset/views/core.py b/superset/views/core.py index 6af3d500ccce9..f75a8f77e16fd 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -41,13 +41,12 @@ event_logger, is_feature_enabled, security_manager, - viz, ) from superset.charts.commands.exceptions import ChartNotFoundError from superset.charts.dao import ChartDAO from superset.common.chart_data import ChartDataResultFormat, ChartDataResultType from superset.connectors.base.models import BaseDatasource -from superset.connectors.sqla.models import AnnotationDatasource, SqlaTable +from superset.connectors.sqla.models import SqlaTable from superset.dashboards.commands.exceptions import DashboardAccessDeniedError from superset.dashboards.commands.importers.v0 import ImportDashboardsCommand from superset.dashboards.permalink.commands.get import GetDashboardPermalinkCommand @@ -96,7 +95,6 @@ check_datasource_perms, check_explore_cache_perms, check_resource_permissions, - check_slice_perms, get_dashboard_extra_filters, get_datasource_info, get_form_data, @@ -216,65 +214,6 @@ def generate_json( payload = viz_obj.get_payload() return self.send_data_payload_response(viz_obj, payload) - @event_logger.log_this - @api - @has_access_api - @expose("/slice_json/") - @etag_cache() - @check_resource_permissions(check_slice_perms) - @deprecated(new_target="/api/v1/chart//data/") - def slice_json(self, slice_id: int) -> FlaskResponse: - form_data, slc = get_form_data(slice_id, use_slice_data=True) - if not slc: - return json_error_response("The slice does not exist") - - if not slc.datasource: - return json_error_response("The slice's datasource does not exist") - - try: - viz_obj = get_viz( - datasource_type=slc.datasource.type, - datasource_id=slc.datasource.id, - form_data=form_data, - force=False, - ) - return self.generate_json(viz_obj) - except SupersetException as ex: - return json_error_response(utils.error_msg_from_exception(ex)) - - @api - @has_access_api - @event_logger.log_this - @expose("/annotation_json/") - @deprecated(new_target="/api/v1/chart//data/") - def annotation_json( # pylint: disable=no-self-use - self, layer_id: int - ) -> FlaskResponse: - form_data = get_form_data()[0] - force = utils.parse_boolean_string(request.args.get("force")) - - form_data["layer_id"] = layer_id - form_data["filters"] = [{"col": "layer_id", "op": "==", "val": layer_id}] - # Set all_columns to ensure the TableViz returns the necessary columns to the - # frontend. - form_data["all_columns"] = [ - "created_on", - "changed_on", - "id", - "start_dttm", - "end_dttm", - "layer_id", - "short_descr", - "long_descr", - "json_metadata", - "created_by_fk", - "changed_by_fk", - ] - datasource = AnnotationDatasource() - viz_obj = viz.viz_types["table"](datasource, form_data=form_data, force=force) - payload = viz_obj.get_payload() - return data_payload_response(*viz_obj.payload_json_and_has_error(payload)) - @event_logger.log_this @api @has_access_api diff --git a/superset/views/utils.py b/superset/views/utils.py index 75ab4ebe4fe85..1f3b3930eb727 100644 --- a/superset/views/utils.py +++ b/superset/views/utils.py @@ -516,39 +516,6 @@ def check_datasource_perms( viz_obj.raise_for_access() -def check_slice_perms(_self: Any, slice_id: int) -> None: - """ - Check if user can access a cached response from slice_json. - - This function takes `self` since it must have the same signature as the - the decorated method. - - :param slice_id: The slice ID - :raises SupersetSecurityException: If the user cannot access the resource - """ - - form_data, slc = get_form_data(slice_id, use_slice_data=True) - - if slc and slc.datasource: - try: - viz_obj = get_viz( - datasource_type=slc.datasource.type, - datasource_id=slc.datasource.id, - form_data=form_data, - force=False, - ) - except NoResultFound as ex: - raise SupersetSecurityException( - SupersetError( - error_type=SupersetErrorType.UNKNOWN_DATASOURCE_TYPE_ERROR, - level=ErrorLevel.ERROR, - message="Could not find viz object", - ) - ) from ex - - viz_obj.raise_for_access() - - def _deserialize_results_payload( payload: Union[bytes, str], query: Query, use_msgpack: Optional[bool] = False ) -> dict[str, Any]: From 59ca5f7dd1bbb51ae7b83673c1baf44efa5dee5a Mon Sep 17 00:00:00 2001 From: Daniel Gaspar Date: Fri, 16 Jun 2023 12:18:44 +0100 Subject: [PATCH 2/2] update UPDATING.md --- UPDATING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPDATING.md b/UPDATING.md index ceabb3b7180d8..d6c6f71668fe5 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -34,7 +34,7 @@ assists people when migrating to a new version. ### Breaking Changes -- [---](https://github.com/apache/superset/pull/---): Removed deprecated APIs `/superset/slice_json/...`, `/superset/annotation_json/...` +- [24423](https://github.com/apache/superset/pull/24423): Removed deprecated APIs `/superset/slice_json/...`, `/superset/annotation_json/...` - [24400](https://github.com/apache/superset/pull/24400): Removed deprecated APIs `/superset/recent_activity/...`, `/superset/fave_dashboards_by_username/...`, `/superset/fave_dashboards/...`, `/superset/created_dashboards/...`, `/superset/user_slices/`, `/superset/created_slices/...`, `/superset/fave_slices/...`, `/superset/favstar/...`, - [24401](https://github.com/apache/superset/pull/24401): Removes the deprecated `metrics` column (which was blossomed in [20732](https://github.com/apache/superset/pull/20732)) from the `/api/v1/dataset/` API. - [24375](https://github.com/apache/superset/pull/24375): Removed deprecated API `/superset/get_or_create_table/...`, `/superset/sqllab_viz`