Beispiel #1
0
 def get_datasets(self, id_or_slug: str) -> Response:
     """Gets a dashboard's datasets
     ---
     get:
       description: >-
         Returns a list of a dashboard's datasets. Each dataset includes only
         the information necessary to render the dashboard's charts.
       parameters:
       - in: path
         schema:
           type: string
         name: id_or_slug
         description: Either the id of the dashboard, or its slug
       responses:
         200:
           description: Dashboard dataset definitions
           content:
             application/json:
               schema:
                 type: object
                 properties:
                   result:
                     type: array
                     items:
                       $ref: '#/components/schemas/DashboardDatasetSchema'
         400:
           $ref: '#/components/responses/400'
         401:
           $ref: '#/components/responses/401'
         403:
           $ref: '#/components/responses/403'
         404:
           $ref: '#/components/responses/404'
     """
     try:
         datasets = DashboardDAO.get_datasets_for_dashboard(id_or_slug)
         result = [
             self.dashboard_dataset_schema.dump(dataset)
             for dataset in datasets
         ]
         return self.response(200, result=result)
     except (TypeError, ValueError) as err:
         return self.response_400(message=gettext(
             "Dataset schema is invalid, caused by: %(error)s",
             error=str(err)))
     except DashboardAccessDeniedError:
         return self.response_403()
     except DashboardNotFoundError:
         return self.response_404()
Beispiel #2
0
 def get_datasets(self, id_or_slug: str) -> Response:
     """Gets a dashboard's datasets
     ---
     get:
       description: >-
         Returns a list of a dashboard's datasets. Each dataset includes only
         the information necessary to render the dashboard's charts.
       parameters:
       - in: path
         schema:
           type: string
         name: id_or_slug
         description: Either the id of the dashboard, or its slug
       responses:
         200:
           description: Dashboard dataset definitions
           content:
             application/json:
               schema:
                 type: object
                 properties:
                   result:
                     type: array
                     items:
                       $ref: '#/components/schemas/DashboardDatasetSchema'
         302:
           description: Redirects to the current digest
         400:
           $ref: '#/components/responses/400'
         401:
           $ref: '#/components/responses/401'
         404:
           $ref: '#/components/responses/404'
     """
     try:
         datasets = DashboardDAO.get_datasets_for_dashboard(id_or_slug)
         result = [
             self.dashboard_dataset_schema.dump(dataset)
             for dataset in datasets
         ]
         return self.response(200, result=result)
     except DashboardNotFoundError:
         return self.response_404()