Versions Compared

Key

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

...

  • 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 Report Config Structure

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'

New Column Additions

  • visibility

    • type - varchar(10)

    • enum - [public, private, protected, parent]

    • Details - Link

  • accessPath

    • type - jsonb

    • Details - Link

...

Current Api Structure

...

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_oneid_example1": {
                "isParameterized": true,
                "parameters": ["$state"],
                "data": {
                    "rj": {
                        "signedUrl": "url"
                    },
                    "tn": {
                        "signedUrl": "url"
                    },
                    "...otherParameters": {
                        "signedUrl": "url"
                    }
                }
            },
            "dataset_twoid_example2": {
                "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": {}
}

...

Access Control Spec

  • Controls who can access a report based on certain rules.

  • This can be achieved using two attributes visibility and accessPath.

...