diegomedina248 commented on code in PR #22501:
URL: https://github.com/apache/superset/pull/22501#discussion_r1060866967


##########
superset/databases/api.py:
##########
@@ -493,6 +500,76 @@ def schemas(self, pk: int, **kwargs: Any) -> FlaskResponse:
         except SupersetException as ex:
             return self.response(ex.status, message=ex.message)
 
+    @expose("/<int:pk>/tables/")
+    @protect()
+    @safe
+    @rison(database_tables_query_schema)
+    @statsd_metrics
+    @event_logger.log_this_with_context(
+        action=lambda self, *args, **kwargs: f"{self.__class__.__name__}" 
f".tables",
+        log_to_statsd=False,
+    )
+    def tables(self, pk: int, **kwargs: Any) -> FlaskResponse:
+        """Get a list of tables for given database
+        ---
+        get:
+          description: Get a list of tables for given database
+          parameters:
+          - in: path
+            schema:
+              type: integer
+            name: pk
+            description: The database id
+          - in: query
+            name: q
+            content:
+              application/json:
+                schema:
+                  $ref: '#/components/schemas/database_tables_query_schema'
+          responses:
+            200:
+              description: Tables list
+              content:
+                application/json:
+                  schema:
+                    type: object
+                    properties:
+                      result:
+                        description: >-
+                          A List of tables for given database
+                        type: object
+                        properties:
+                          tableLength:
+                            type: integer
+                          options:
+                            type: array
+                            items:
+                              $ref: 
'#/components/schemas/DatabaseTablesResponse'
+            400:
+              $ref: '#/components/responses/400'
+            401:
+              $ref: '#/components/responses/401'
+            404:
+              $ref: '#/components/responses/404'
+            500:
+              $ref: '#/components/responses/500'
+        """
+        force = kwargs["rison"].get("force", False)
+        schema_name = kwargs["rison"].get("schema_name", "")
+        if not schema_name:
+            return self.response_422("Schema undefined")
+
+        try:
+            command = TablesDatabaseCommand(pk, schema_name, force)
+            payload = command.run()
+            return self.response(200, result=payload)
+        except DatabaseNotFoundError:
+            return self.response_404()
+        except SupersetException as ex:
+            return self.response(ex.status, message=ex.message)
+        except DatabaseTablesUnexpectedError as ex:
+            return self.response_500(ex.message)

Review Comment:
   it was like that in the deprecated endpoint, though we can certainly use any 
other status code. Which one would be best here, to maintain consistency across 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to