mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
feat: initial work to make v1 API compatible with SIP-40 and SIP-41 (#13960)
* WIP * Use errorhandler * Add response schema * Fix status on HTTPException * s/found/encountered/g * Fix test * Fix lint * Fix lint and test
This commit is contained in:
@@ -41,7 +41,6 @@ from superset.databases.commands.exceptions import (
|
||||
DatabaseImportError,
|
||||
DatabaseInvalidError,
|
||||
DatabaseNotFoundError,
|
||||
DatabaseTestConnectionFailedError,
|
||||
DatabaseUpdateFailedError,
|
||||
)
|
||||
from superset.databases.commands.export import ExportDatabasesCommand
|
||||
@@ -64,7 +63,6 @@ from superset.databases.schemas import (
|
||||
TableMetadataResponseSchema,
|
||||
)
|
||||
from superset.databases.utils import get_table_metadata
|
||||
from superset.exceptions import SupersetErrorException
|
||||
from superset.extensions import security_manager
|
||||
from superset.models.core import Database
|
||||
from superset.typing import FlaskResponse
|
||||
@@ -558,7 +556,6 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
|
||||
|
||||
@expose("/test_connection", methods=["POST"])
|
||||
@protect()
|
||||
@safe
|
||||
@statsd_metrics
|
||||
@event_logger.log_this_with_context(
|
||||
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
|
||||
@@ -604,13 +601,8 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
|
||||
# This validates custom Schema with custom validations
|
||||
except ValidationError as error:
|
||||
return self.response_400(message=error.messages)
|
||||
try:
|
||||
TestConnectionDatabaseCommand(g.user, item).run()
|
||||
return self.response(200, message="OK")
|
||||
except DatabaseTestConnectionFailedError as ex:
|
||||
return self.response_422(message=str(ex))
|
||||
except SupersetErrorException as ex:
|
||||
return self.response(ex.status, message=ex.error.message)
|
||||
TestConnectionDatabaseCommand(g.user, item).run()
|
||||
return self.response(200, message="OK")
|
||||
|
||||
@expose("/<int:pk>/related_objects/", methods=["GET"])
|
||||
@protect()
|
||||
|
||||
@@ -118,6 +118,7 @@ class DatabaseDeleteFailedReportsExistError(DatabaseDeleteFailedError):
|
||||
|
||||
|
||||
class DatabaseTestConnectionFailedError(CommandException):
|
||||
status = 422
|
||||
message = _("Connection failed, please check your connection settings")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user