You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by dp...@apache.org on 2023/06/16 14:14:53 UTC
[superset] branch master updated: chore: remove deprecated apis /slice_json/ and /annotation_json/ (#24423)
This is an automated email from the ASF dual-hosted git repository.
dpgaspar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new d6a61c125a chore: remove deprecated apis /slice_json/ and /annotation_json/ (#24423)
d6a61c125a is described below
commit d6a61c125a557fc614cf2292bf5669f94b23bfbc
Author: Daniel Vaz Gaspar <da...@gmail.com>
AuthorDate: Fri Jun 16 15:14:46 2023 +0100
chore: remove deprecated apis /slice_json/ and /annotation_json/ (#24423)
---
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 5a413b14e9..2d455f1e87 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 d9771a5ee9..d6c6f71668 100644
--- a/UPDATING.md
+++ b/UPDATING.md
@@ -34,6 +34,7 @@ assists people when migrating to a new version.
### Breaking Changes
+- [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`
diff --git a/superset/views/core.py b/superset/views/core.py
index 6af3d500cc..f75a8f77e1 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -41,13 +41,12 @@ from superset import (
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 @@ from superset.views.utils import (
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 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
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/<int:slice_id>")
- @etag_cache()
- @check_resource_permissions(check_slice_perms)
- @deprecated(new_target="/api/v1/chart/<int:id>/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/<int:layer_id>")
- @deprecated(new_target="/api/v1/chart/<int:id>/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 75ab4ebe4f..1f3b3930eb 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]: