Versions Compared

Key

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

...

Overview

CPS temporal data query will allow allows the user to fetch data based on multiple filtering criteria. This data can be used to create graphs and help the by analytical system to take decisions.

Filtering

...

Criteria

As it is time-series data, it can be filtered based on three main criteria:

Datetime Datetime
  • Data in last X hours 
  • Data after a particular DateTime (To be supported in version 1)
  • Data between a date range
  • Last X network datarecords
DataTypes in CPS Core
  • Dataspace & schema-set (To be supported in version 1)

  • Dataspace & anchor (To be supported in version 1)
  • Dataspace & multiple anchors - To improve performance, if there is a need to fetch data for multiple anchors.
Payload (To be partially supported in version 1)
  • Based on a field or subsection in the payload, but it is important to provide the entire path from the root. These criteria need schema-set to be fixed to search in the same set of anchors. The details of the format are defined here

...

NoNameTypeDefaultPurposeExample
1indexint0

The query output can have many rows so it is important to limit the fetched data. To limit the number of records and to provide pagination, these two parameters can be used. 

"index" parameter represents the page number, starts with 0, and maxSize is the page size.


2maxSizeint1000
3pointInTimeDateTimeCurrentDateTime

When a user uses the APIs with pagination (by running several stateless requests), the result set can be impacted by new states stored while navigating. This can be a challenge to retrieve a consistent result set. 

This parameter must be used

Pagination does not work well if new data gets added which fulfils the search criteria. The user must provide this value

to avoid this issue.



Assumptions

...

  1. after - timestamp ( ISO Format) to consider date data created after the specified Timestamp
  2. payload - to define data payload filtering criteria
  3. index - defined to define the page number and (required for pagination)
  4. maxSize - To to limit the response size
  5. pointInTime - to consider data changed or added before this time.

The response format for all get GET APIs is the same and defined here

...

By Anchor Name

URL: GET /dataspaces/{dataspace-name}​/anchors/{anchor-name}​

Example: GET /dataspaces/{dataspace-name}​/anchors/{anchor-name}​?after=2021-03-21T00:00:00-0:00&payload=/device/port/interface[status=up]&maxSize=500

...

By Dataspace and Schema-set

URL: ​GET /dataspaces/{dataspace-name}/schema-sets/{schema-set}

...

Code Block
{
  "nextRecordsLink": "cps-temporal/api/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}?after=2021-03-21T00:00:00-0:00&maxSize=500&pointInTime=2021-04-21T00:00:00-0:00&index=2",
  "previousRecordsLink": "cps-temporal/api/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}?after=2021-03-21T00:00:00-0:00&maxSize=500&pointInTime=2021-04-21T00:00:00-0:00&index=0",
  "records": [
    {
      "timestamp": "1234567788889", // TODO change the format2021-03-21T00:00:00-0:00",
      "dataspace": "my-dataspace",
      "schemaSet": "my-schema-set",
      "anchor": "my-anchor",
      "data": {
        "status" : "UP"
      }
    }
  ]
}

...