mirror of https://github.com/apache/superset.git
fix: ID param for DELETE ssh_tunnel endpoint (#27130)
Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
This commit is contained in:
parent
eabee9dedd
commit
7c7deb960d
|
@ -30,6 +30,7 @@ assists people when migrating to a new version.
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
|
|
||||||
|
- [27130](https://github.com/apache/superset/pull/27130): Fixes the DELETE `/database/{id}/ssh_tunnel/`` endpoint to now correctly accept a database ID as a parameter, rather than an SSH tunnel ID.
|
||||||
- [27117](https://github.com/apache/superset/pull/27117): Removes the following deprecated endpoints: `/superset/sqllab`, `/superset/sqllab/history`, `/sqllab/my_queries` use `/sqllab`, `/sqllab/history`, `/savedqueryview/list/?_flt_0_user={get_user_id()}` instead.
|
- [27117](https://github.com/apache/superset/pull/27117): Removes the following deprecated endpoints: `/superset/sqllab`, `/superset/sqllab/history`, `/sqllab/my_queries` use `/sqllab`, `/sqllab/history`, `/savedqueryview/list/?_flt_0_user={get_user_id()}` instead.
|
||||||
- [26347](https://github.com/apache/superset/issues/26347): Removes the deprecated `VERSIONED_EXPORT` feature flag. The previous value of the feature flag was `True` and now the feature is permanently enabled.
|
- [26347](https://github.com/apache/superset/issues/26347): Removes the deprecated `VERSIONED_EXPORT` feature flag. The previous value of the feature flag was `True` and now the feature is permanently enabled.
|
||||||
- [26328](https://github.com/apache/superset/issues/26328): Removes the deprecated Filter Box code and it's associated dependencies `react-select` and `array-move`. It also removes the `DeprecatedSelect` and `AsyncSelect` components that were exclusively used by filter boxes. Existing filter boxes will be automatically migrated to native filters.
|
- [26328](https://github.com/apache/superset/issues/26328): Removes the deprecated Filter Box code and it's associated dependencies `react-select` and `array-move`. It also removes the `DeprecatedSelect` and `AsyncSelect` components that were exclusively used by filter boxes. Existing filter boxes will be automatically migrated to native filters.
|
||||||
|
|
|
@ -22,6 +22,7 @@ from io import BytesIO
|
||||||
from typing import Any, cast, Optional
|
from typing import Any, cast, Optional
|
||||||
from zipfile import is_zipfile, ZipFile
|
from zipfile import is_zipfile, ZipFile
|
||||||
|
|
||||||
|
from deprecation import deprecated
|
||||||
from flask import request, Response, send_file
|
from flask import request, Response, send_file
|
||||||
from flask_appbuilder.api import expose, protect, rison, safe
|
from flask_appbuilder.api import expose, protect, rison, safe
|
||||||
from flask_appbuilder.models.sqla.interface import SQLAInterface
|
from flask_appbuilder.models.sqla.interface import SQLAInterface
|
||||||
|
@ -48,7 +49,6 @@ from superset.commands.database.ssh_tunnel.delete import DeleteSSHTunnelCommand
|
||||||
from superset.commands.database.ssh_tunnel.exceptions import (
|
from superset.commands.database.ssh_tunnel.exceptions import (
|
||||||
SSHTunnelDeleteFailedError,
|
SSHTunnelDeleteFailedError,
|
||||||
SSHTunnelingNotEnabledError,
|
SSHTunnelingNotEnabledError,
|
||||||
SSHTunnelNotFoundError,
|
|
||||||
)
|
)
|
||||||
from superset.commands.database.tables import TablesDatabaseCommand
|
from superset.commands.database.tables import TablesDatabaseCommand
|
||||||
from superset.commands.database.test_connection import TestConnectionDatabaseCommand
|
from superset.commands.database.test_connection import TestConnectionDatabaseCommand
|
||||||
|
@ -1447,6 +1447,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
|
||||||
@expose("/<int:pk>/ssh_tunnel/", methods=("DELETE",))
|
@expose("/<int:pk>/ssh_tunnel/", methods=("DELETE",))
|
||||||
@protect()
|
@protect()
|
||||||
@statsd_metrics
|
@statsd_metrics
|
||||||
|
@deprecated(deprecated_in="4.0")
|
||||||
@event_logger.log_this_with_context(
|
@event_logger.log_this_with_context(
|
||||||
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
|
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
|
||||||
f".delete_ssh_tunnel",
|
f".delete_ssh_tunnel",
|
||||||
|
@ -1483,10 +1484,15 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
|
||||||
500:
|
500:
|
||||||
$ref: '#/components/responses/500'
|
$ref: '#/components/responses/500'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
database = DatabaseDAO.find_by_id(pk)
|
||||||
|
if not database:
|
||||||
|
return self.response_404()
|
||||||
try:
|
try:
|
||||||
DeleteSSHTunnelCommand(pk).run()
|
existing_ssh_tunnel_model = database.ssh_tunnels
|
||||||
return self.response(200, message="OK")
|
if existing_ssh_tunnel_model:
|
||||||
except SSHTunnelNotFoundError:
|
DeleteSSHTunnelCommand(existing_ssh_tunnel_model.id).run()
|
||||||
|
return self.response(200, message="OK")
|
||||||
return self.response_404()
|
return self.response_404()
|
||||||
except SSHTunnelDeleteFailedError as ex:
|
except SSHTunnelDeleteFailedError as ex:
|
||||||
logger.error(
|
logger.error(
|
||||||
|
|
|
@ -458,7 +458,9 @@ def test_delete_ssh_tunnel(
|
||||||
assert 1 == response_tunnel.database_id
|
assert 1 == response_tunnel.database_id
|
||||||
|
|
||||||
# Delete the recently created SSHTunnel
|
# Delete the recently created SSHTunnel
|
||||||
response_delete_tunnel = client.delete("/api/v1/database/1/ssh_tunnel/")
|
response_delete_tunnel = client.delete(
|
||||||
|
f"/api/v1/database/{database.id}/ssh_tunnel/"
|
||||||
|
)
|
||||||
assert response_delete_tunnel.json["message"] == "OK"
|
assert response_delete_tunnel.json["message"] == "OK"
|
||||||
|
|
||||||
response_tunnel = DatabaseDAO.get_ssh_tunnel(1)
|
response_tunnel = DatabaseDAO.get_ssh_tunnel(1)
|
||||||
|
|
Loading…
Reference in New Issue