Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Business Requirement

...

In order to enable different types of access, SB will support configurations that can make the datasets ‘PUBLIC’ or ‘PRIVATE’ - as the adopter may choose - this will determine whether a dataset can be accessed publicly using the API without any additional authorisation, or whether it needs additional approval from admins for access.

...

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

Below Diagram explains the High Level Working flow on how the reports are rendered on the Portal Admin Dashboard.

...

Pages

REPORT_ADMIN <SUPER_ADMIN>

State REPORT_ADMIN

REPORT_VIEWER

List Page

  • Can see all Reports.

  • If report is parameterized, can see all the resolved parameterized versions of that report.

  • Can see all live, retired and draft versions for all reports.

  • Can see reports + parameterised reports from only the resolved parameter value.

  • For Example - if Report is parametersed by state. Then REPORT_ADMIN belonging to rajasthan can see only the rajasthan report version, not others.

  • Can see all live, retired and draft versions of all reports

  • Can see only live reports .

Report Detail Page

  • Can Publish, Retire, Add Report/Chart Summaries for all the reports + their parameterized versions.

  • Switch b/w other parameter versions.

  • Can publish, Retire, Add Report/Chart Summaries for that report.

  • Can view only live reports

  • Cannot perform any other action.

...

Current Report Config

...

Expand
titleCurrent Report Config
Code Block
reportid varchar(40) NOT NULL PRIMARY KEY,
title text NOT NULL,
description text NOT NULL,
authorizedroles jsonb NOT NULL,
status varchar(8) NOT NULL CHECK (status IN ('live', 'draft', 'retired')) DEFAULT 'draft',
type varchar(8) NOT NULL CHECK (type in ('public', 'private')) DEFAULT 'private',
reportaccessurl text NOT NULL UNIQUE,
createdon timestamptz NOT NULL DEFAULT now(),
updatedon timestamptz NOT NULL DEFAULT now(),
createdby varchar(50) NOT NULL,
reportconfig jsonb NOT NULL,
templateurl text,
slug varchar(10) NOT NULL,
reportgenerateddate timestamptz NOT NULL DEFAULT now(),
reportduration jsonb NOT NULL DEFAULT jsonb_build_object('startDate', now()::timestamptz, 'endDate', now()::timestamptz),
tags jsonb NOT NULL,
updatefrequency text NOT NULL
reportType varchar(8) NOT NULL DEFAULT 'report'

...

Expand
titleGET- /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

Code Block
languagejson
{
  "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 :-

Code Block
languagejson
interface IDatasource {
  id: string
  path: string
}

id -: job _ id responsible for generating the dataset

path -: endpoint to the portal-backend layer which will 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.

...

Expand
titleAPI to get meta data + datasets

Proposed response structure - to get meta + datasets.

Success Scenario - Status Code 200

Code Block
languagejson
{
    "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_id_1": {
                "isParameterized": true,
                "parameters": ["$state"],
                "data": {
                    "rj": {
                        "signedUrl": "url"
                    },
                    "tn": {
                        "signedUrl": "url"
                    },
                    "...otherParameters": {
                        "signedUrl": "url"
                    }
                }
            },
            "dataset_id_2": {
                "isParameterized": false,
                "parameters": null,
                "data": {
                    "default": {
                        "signedUrl": "url"
                    }
                }
            }
        }
    }
}

Explaination -

  • If the report dataset file path is parameterized then

    • isParameterized - true

    • parameters - paramater attribute

    • data object will contain all resolved parameter values along with the signed Url to download the file

  • Else

    • data object will have default key with the signed Url to download the file.


Error Response

Unauthorized Access - Status Code 401

Code Block
languagejson
{
    "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

Code Block
languagejson
{
  "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

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

...