Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Business Requirement

Sunbird generates a number of datasets for reporting purposes. Some of these are downloaded by users via the UI (the Course progress exhaust, for example), whereas others are used by the Sunbird portal to generate reports and charts, which can then be viewed by users. The portal also allows for download of the underlying data files that are used for chart creation via the UI. There is a need for making all such datasets that are generated accessible via APIs. This will permit for these datasets to be used as per different requirements of the adopters, and enable them to create custom reports/ visualisations of their own.

As part of access to the datasets, the adopter should also be able to mark a dataset as Public or Private - determining whether a dataset can be accessed publicly using the API without any additional authorisation, or whether it needs additional approval from admins for access.

Dataset generation currently happens for:

  1. Custom reports such as the course progress exhaust or the user PII data - these are generated by data products that run on a daily/ on-demand basis

  2. Portal based reports and charts - these are datasets generated from Druid, and power the charts shown on the ‘admin dashboard’ of the portal. These are generated based on the frequency of the reports as configured.

  3. Other custom data files such as Consent files and master data files (geo data, for example)

Sunbird needs to make all these datasets accessible via API, with different levels of access permissions, based on the sensitivity of the data that resides within the dataset. Some may be publicly accessible (having only anonymous data), some may require consent based access (say, files that have PII), and others may be restricted for access only to certain roles (say administrators only)

Sunbird should enable access based on configurations that can enable this.

Problem Statement

As part of opening of DIKSHA Infrastructure to wider ecosystem, there is a need to provide access to open anonymized data to third party ecosystem players to develop custom solutions on top of DIKSHA.


Current Implementation

  • Currently, Sunbird Observation supports Reports Service API to list and access all published reports. However, only metadata of a report is accessible through this API. There are associated data files that contain the detailed data of a given report. These are currently not accessible through API.

  • There is an internal endpoint at the portal backend layer which downloads the respective datasets from the azure reports container. This endpoint is accessible only by the logged in person(session based) having roles (REPORT_ADMIN , REPORT_VIEWER, ORG_ADMIN).

  • Moreover, there is a slug based validation so that they do not access other tenant’s data.

  • For parameterized reports, respective endpoints are injected based on the logged in user’s context.

  • As part of current implementation datasets cannot be accessed by non logged in person or any third party.

  • Supported parameters

    • $slug

    • $channel

    • $state

    • $board


Current Api Structure

 GET- /report/get/:reportId

This API is associated with viewing and reading out the specific report on the Sunbird Platform. It returns only the metadata information for the report.

Response

{
  "id": "string",
  "ver": "string",
  "params": {
    "resmsgid": "string",
    "msgid": "string",
    "status": "success",
    "err": "string",
    "errmsg": "string"
  },
  "responseCode": "OK",
  "result": {
    "reports": [
      {
        "reportid": "string",
        "title": "string",
        "description": "string",
        "authorizedroles": [
          "string"
        ],
        "status": "string",
        "type": "string",
        "reportaccessurl": "string",
        "createdon": "string",
        "updatedon": "string",
        "createdby": "string",
        "reportconfig": {
          "id": "string",
          "label": "string",
          "table": [
            {
              "name": "string",
              "valuesExpr": "string",
              "columnsExpr": "string"
            }
          ],
          "title": "string",
          "charts": [
            {
              "colors": [
                {
                  "borderColor": "string",
                  "backgroundColor": "string"
                }
              ],
              "options": {
                "title": {
                  "text": "string",
                  "display": true,
                  "fontSize": 16
                },
                "legend": {
                  "display": false
                },
                "scales": {
                  "xAxes": [
                    {
                      "scaleLabel": {
                        "display": true,
                        "labelString": "string"
                      }
                    }
                  ],
                  "yAxes": [
                    {
                      "scaleLabel": {
                        "display": true,
                        "labelString": "string"
                      }
                    }
                  ]
                },
                "tooltips": {
                  "mode": "string",
                  "intersect": false,
                  "bodySpacing": 5,
                  "titleSpacing": 5
                },
                "responsive": true
              },
              "datasets": [
                {
                  "label": "string",
                  "dataExpr": "string"
                }
              ],
              "chartType": "string",
              "labelsExpr": "string",
              "dataSource": {
                "ids": [
                  "parameterizedPath"
                ],
                "commonDimension": "string"
              }
            }
          ],
          "dataSource": [
            {
              "id": "parameterizedPath",
              "path": "/reports/$state/abc.json"
            },
            {
            "id": "nonParameterizedPath",
            "path": "/reports/tn/abc.json"
            }
          ],
          "description": "string",
          "downloadUrl": "string"
        },
        "slug": "string",
        "reportgenerateddate": "string",
        "reportduration": {
          "enddate": "string",
          "startdate": "string"
        },
        "tags": [
          "string"
        ],
        "updatefrequency": "string",
        "parameters": [
          "string"
        ],
        "report_type": "string"
      }
    ],
    "count": 1
  }
}

Datasource Schema :-

id -: job_id

path -: endpoint to the portal-backend layer which download the dataset file - the path can be both parameterized and non parameterized . Portal backend populates the parameters using logged in user context details and downloads the respective file.


Proposed Solution

There is a need to create API in report service that will provide access to the meta data as well as the report data files that are used to generate the reports in the 'Admin dashboards' page on the Sunbird portal with certain access controls.

Proposed API Structure to get the metadata + datasets.

METHOD - GET

URL: /report/datasets/get/:reportId

 API to get meta data + datasets

Proposed response structure - to get meta + datasets.

Success Scenario - Status Code 200

{
    "id": "api.report.read",
    "ver": "string",
    "ts": "timestamp",
    "params": {
      "resmsgid": "string",
      "msgid": "string",
      "status": "success",
      "err": "string",
      "errmsg": "string"
    },
    "responseCode": "OK",
    "result": {
        "metadata": {... similar to above API},
        "datasets": {
            "dataset_one_example": {
                "isParameterized": true,
                "parameters": ["$state"],
                "data": {
                    "rj": {
                        "signedUrl": "url"
                    },
                    "tn": {
                        "signedUrl": "url"
                    }
                }
            },
            "dataset_two_example": {
                "isParameterized": false,
                "parameters": null,
                "data": {
                    "default": {
                        "signedUrl": "url"
                    }
                }
            }
        }
    }
}


Error Response

Unauthorized Access - Status Code 401

{
    "id": "api.report.read",
    "ver": "v1",
    "ts": "timestamp",
    "params": {
        "resmsgid": null,
        "msgid": "string",
        "err": "UNAUTHORIZED_USER",
        "status": "UNAUTHORIZED_USER",
        "errmsg": "You are not authorized."
    },
    "responseCode": "UNAUTHORIZED",
    "result": {}
}


Internal Server Error - Status Code - 500

{
  "id": "api.report.read",
  "ver": "v1",
  "ts": "timestamp",
  "params": {
    "resmsgid": null,
    "msgid": "string",
    "err": "string",
    "status": "SERVER_ERROR",
    "errmsg": "string"
  },
  "responseCode": "SERVER_ERROR",
  "result": {}
}


Invalid Report Id - Status Code 404

{
  "id": "api.report.read",
  "ver": "1.0.0",
  "params": {
    "resmsgid": "string",
    "msgid": null,
    "status": "failed",
    "err": null,
    "errmsg": "no report found"
  },
  "responseCode": "string",
  "result": {}
}


Access Controls

  • visibility :

    • Type - string

    • Enum - [ Public, private ]

    • Description - Validates the visibility of the report whether it’s public or private

  • authorizedRoles:

    • Type - [string] or string

    • Description - Roles authorized to read the report

  • tenant :

    • Type - [string] or string

    • Description - tenants authorized to read the report.

  • showOnDashboard:

    • Type - boolean

    • Default: true

    • Description - Whether to show the report on Portal Admin Dashboard or not.


Resources

  • No labels