You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/11/15 22:04:58 UTC

[GitHub] [superset] Antonio-RiveroMartnez opened a new pull request, #22132: feat(ssh_tunnel): Update command & exceptions

Antonio-RiveroMartnez opened a new pull request, #22132:
URL: https://github.com/apache/superset/pull/22132

   ### SUMMARY
   - Adding the new UPDATE command and its exception to our SSH Tunnel
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #22132: feat(ssh_tunnel): Update command & exceptions

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #22132:
URL: https://github.com/apache/superset/pull/22132#discussion_r1025495275


##########
superset/databases/ssh_tunnel/commands/exceptions.py:
##########
@@ -26,3 +31,11 @@ class SSHTunnelDeleteFailedError(DeleteFailedError):
 class SSHTunnelNotFoundError(CommandException):
     status = 404
     message = _("SSH Tunnel not found.")
+
+
+class SSHTunnelInvalidError(CommandInvalidError):

Review Comment:
   add status 400 here



##########
superset/databases/ssh_tunnel/commands/exceptions.py:
##########
@@ -26,3 +31,11 @@ class SSHTunnelDeleteFailedError(DeleteFailedError):
 class SSHTunnelNotFoundError(CommandException):
     status = 404
     message = _("SSH Tunnel not found.")
+
+
+class SSHTunnelInvalidError(CommandInvalidError):
+    message = _("SSH Tunnel parameters are invalid.")
+
+
+class SSHTunnelUpdateFailedError(UpdateFailedError):

Review Comment:
   add status 500 here



-- 
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-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #22132: feat(ssh_tunnel): Update command & exceptions

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #22132:
URL: https://github.com/apache/superset/pull/22132#discussion_r1024261033


##########
superset/databases/commands/update_ssh_tunnel.py:
##########
@@ -0,0 +1,63 @@
+# Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   lets make a sub directory for ssh tunnel
   `superset/databases/ssh_tunnel/update.py`



-- 
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-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #22132: feat(ssh_tunnel): Update command & exceptions

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #22132:
URL: https://github.com/apache/superset/pull/22132#discussion_r1025495741


##########
superset/databases/ssh_tunnel/commands/update.py:
##########
@@ -0,0 +1,64 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import logging
+from typing import Any, Dict, List, Optional
+
+from flask_appbuilder.models.sqla import Model
+from marshmallow import ValidationError
+
+from superset.commands.base import BaseCommand
+from superset.dao.exceptions import DAOUpdateFailedError
+from superset.databases.ssh_tunnel.commands.exceptions import (
+    SSHTunnelDeleteFailedError,
+    SSHTunnelInvalidError,
+    SSHTunnelNotFoundError,
+    SSHTunnelUpdateFailedError,
+)
+from superset.databases.ssh_tunnel.dao import SSHTunnelDAO
+from superset.databases.ssh_tunnel.models import SSHTunnel
+
+logger = logging.getLogger(__name__)
+
+
+class UpdateSSHTunnelCommand(BaseCommand):
+    def __init__(self, model_id: int, data: Dict[str, Any]):
+        self._properties = data.copy()
+        self._model_id = model_id
+        self._model: Optional[SSHTunnel] = None
+
+    def run(self) -> Model:
+        self.validate()
+        if not self._model:
+            raise SSHTunnelNotFoundError()
+
+        try:
+            tunnel = SSHTunnelDAO.update(self._model, self._properties, commit=True)
+        except DAOUpdateFailedError as ex:
+            logger.exception(ex.exception)

Review Comment:
   don't log exception we want them to bubble up to the API



-- 
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-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh merged pull request #22132: feat(ssh_tunnel): Update command & exceptions

Posted by GitBox <gi...@apache.org>.
hughhhh merged PR #22132:
URL: https://github.com/apache/superset/pull/22132


-- 
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-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org