FIWARE / context.Orion-LD

Context Broker and CEF building block for context data management which supports both the NGSI-LD and the NGSI-v2 APIs
https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.06.01_60/gs_CIM009v010601p.pdf
GNU Affero General Public License v3.0
50 stars 41 forks source link

Unsupported sysAttrs and showChanges notification parameters for subscription operations #1394

Open daniel-gonzalez-sanchez opened 1 year ago

daniel-gonzalez-sanchez commented 1 year ago

Hi everyone,

I was playing with NGSI-LD subscriptions when I discovered an issue. Following the ETSI CIM standard and the specification document for the NGSI-LD API V1.6.1 (i.e., ETSI GS CIM 009 V1.6.1), which is supported by ORION-LD Context Broker, according to the section 5.2.14 NotificationParams (Table 5.2.14.1-1: NotificationParams data type definition on page 82), there is a notification parameter named sysAttrs that "if true, the system generated attributes createdAt and modifiedAt are included in the response payload body, in the case of a deletion also deletedAt". But I've checked that creating a simple subscription with the sysAttrs notification parameter does not work well because the sysAttrs parameter is not recognize. The same issue happens with the showChanges notification parameter (also described in Table 5.2.14.1-1: NotificationParams data type definition on page 82).

Let me show an example:

Environment

Making the following HTTP GET request for getting the ORION-LD Context Broker version:

curl --location 'http://localhost:1026/version'

, the regarding response body is the following:

{
    "orionld version": "post-v1.2.0",
    "orion version": "1.15.0-next",
    "uptime": "0 d, 0 h, 13 m, 55 s",
    "git_hash": "nogitversion",
    "compile_time": "Tue May 30 09:49:52 UTC 2023",
    "compiled_by": "root",
    "compiled_in": "",
    "release_date": "Tue May 30 09:49:52 UTC 2023",
    "doc": "https://fiware-orion.readthedocs.org/en/master/"
}

Steps to reproduce

  1. Creating a subscription to a sample Sensor NGSI-LD Entity with the sysAttrs notification parameter:

    curl --location --request POST 'localhost:1026/ngsi-ld/v1/subscriptions/' \
    --header 'Content-Type: application/json' \
    --header 'Link: <https://fiware.github.io/data-models/full-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
    --data-raw '{
    "id": "urn:ngsi-ld:Subscription:Sensor",
    "type": "Subscription",
    "entities": [{
        "type": "Sensor"
     }],
    "description": "On-change subscription to Sensor entities for changes within temperature property.",
    "watchedAttributes": ["temperature"],
    "notification": {
           "endpoint": {
           "uri": "http://consumer:8082/notify",
           "accept": "application/json"
           },
           "sysAttrs": true
    }
    }'

    , the regarding response body is the following:

    {
    "type": "https://uri.etsi.org/ngsi-ld/errors/BadRequestData",
    "title": "Unknown Notification field",
    "detail": "sysAttrs"
    }
  2. Creating a subscription to a sample Sensor NGSI-LD Entity with the showChanges notification parameter:

    curl --location --request POST 'localhost:1026/ngsi-ld/v1/subscriptions/' \
    --header 'Content-Type: application/json' \
    --header 'Link: <https://fiware.github.io/data-models/full-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
    --data-raw '{
    "id": "urn:ngsi-ld:Subscription:Sensor",
    "type": "Subscription",
    "entities": [{
        "type": "Sensor"
     }],
    "description": "On-change subscription to Sensor entities for changes within temperature property.",
    "watchedAttributes": ["temperature"],
    "notification": {
           "endpoint": {
           "uri": "http://consumer:8082/notify",
           "accept": "application/json"
           },
           "showChanges": true
    }
    }'

    , the regarding response body is the following:

    {
    "type": "https://uri.etsi.org/ngsi-ld/errors/BadRequestData",
    "title": "Unknown Notification field",
    "detail": "showChanges"
    }

Many thanks in advance!

Dani

kzangeli commented 1 year ago

Hello there, thanks for reporting!

Yeah, both "showChanges" and "sysAttrs" in Subscriptions are new additions to the NGSI-LD API spec (added in v1.6.1). They aren't supported yet by Orion-LD.

Curiously a few days ago I had another user asking for "showChanges", and I just finished implementing part 1 of that. Part 1 is the basic case, not including BATCH operations, deletions, nor distributed operations: https://github.com/FIWARE/context.Orion-LD/pull/1396 I hope to merge this PR today.

About "sysAttrs", sure, if you need that feature I can start implementing that pretty much right now.

You'll see the progress in this very issue.

daniel-gonzalez-sanchez commented 1 year ago

Hello @kzangeli,

Thank you so much for your quick answer! From my point of view, it would be very interesting to be able to indicate whether or not to receive those "createdAt", "modifiedAt", and "deletedAt" fields in the notifications received for a demanded subscription. This "sysAttrs" field seems a great decision from the ETSI CIM specification for the NGSI-LD API :)

Thanks again!

kzangeli commented 1 year ago

Yeah, I'm on it. Found a few bugs on the way and I have to fix those. Will probably take a few days more, but, it's coming! :)

daniel-gonzalez-sanchez commented 1 year ago

Great! Thank you so much again! :)