Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send ngsiv2 measure as ngsiv2 request #773

Closed
wants to merge 13 commits into from

Conversation

AlvaroVega
Copy link
Member

@AlvaroVega AlvaroVega commented Oct 20, 2023

Needs telefonicaid/iotagent-node-lib#1520

This PR enables a new endpoint '/iot/ngsiv2' to send a ngsiv2 format
Not sure if it should be a new endpoint or just a new query param flag to existing endpoint. Ideas?

@AlvaroVega
Copy link
Member Author

AlvaroVega commented Oct 20, 2023

With this approach ngsiv2 payload as:

curl -i -X POST 'http://localhost:7897/iot/ngsiv2?i=disp5&k=izc9cokegoy7kyfgdd6etipt6' -d '[{
      "id": "disp6:thing2",
      "type": "thing2",
      "temperature": {
         "type":"Number",
         "value":33
      }
   }]' -H 'content-type: application/json'

is progressing to CB as:

msg=Options: {
    "url": "http://iot-orion:1026/v2/op/update",
    "method": "POST",
    "headers": {
        "fiware-service": "smartcity",
        "fiware-servicepath": "/"
    },
    "json": {
        "actionType": "append",
        "entities": [
            {
                "id": "disp6:thing2",
                "type": "thing2",
                "temperature": {
                    "type": "Number",
                    "value": 33
                }
            }
        ]
    }
} | comp=IoTAgent

Measure needs provide a valid apikey and deviceId in order to get service and subservice. But deviceId is not really necessary.

@AlvaroVega AlvaroVega changed the title send ngsiv2 measure as ngsiv2 request [WIP] send ngsiv2 measure as ngsiv2 request Oct 20, 2023
@AlvaroVega
Copy link
Member Author

AlvaroVega commented Oct 23, 2023

@fgalan in this feature, which should be a NGSIv2 measure? There are two options.

  • Option 1:
{
   "actionType": "append",
   "entities":[ {
      "id": "entity1",
      "type": "type1",
      "temperature": {
         "type":"Number",
         "value":33
      }
    },{
      "id": "entity2",
      "type": "type2",
      "temperature": {
         "type":"Number",
         "value":44
      }
   }]
}
  • Option 2:
{
 [ {
      "id": "entity1",
      "type": "type1",
      "temperature": {
         "type":"Number",
         "value":33
      }
   },
   {
      "id": "entity2",
      "type": "type2",
      "temperature": {
         "type":"Number",
         "value":44
      }
   }]
}

@fgalan
Copy link
Member

fgalan commented Oct 23, 2023

Is you mean the payload for a POST /v2/op/update request, then Option 1 is the right one. Ref: https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md#update-post-v2opupdate

@AlvaroVega
Copy link
Member Author

Is you mean the payload for a POST /v2/op/update request, then Option 1 is the right one. Ref: https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md#update-post-v2opupdate

Not really for POST /v2/op/update , just what should be the way of represent several ngsiv2 entities which are going to be sent as measures.

@fgalan
Copy link
Member

fgalan commented Oct 27, 2023

Is you mean the payload for a POST /v2/op/update request, then Option 1 is the right one. Ref: https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md#update-post-v2opupdate

Not really for POST /v2/op/update , just what should be the way of represent several ngsiv2 entities which are going to be sent as measures.

Discussed at Teams

Option 2 is the suitable one.

@AlvaroVega
Copy link
Member Author

AlvaroVega commented Oct 30, 2023

TBD: do not use iotaUtils.retrieveDevice in new flow to avoid a fake device creation

@AlvaroVega AlvaroVega changed the title [WIP] send ngsiv2 measure as ngsiv2 request send ngsiv2 measure as ngsiv2 request Oct 31, 2023
@AlvaroVega AlvaroVega marked this pull request as ready for review November 2, 2023 09:58
@@ -1,3 +1,4 @@
- Add: endpoit to send ngsiv2 measure to Context Broker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issue number?

@fgalan
Copy link
Member

fgalan commented Nov 3, 2023

I understand this PR enables a new format to receive measures in the southbound interface. That new format should be documented. Maybe @mapedraza could help with this.

@mapedraza
Copy link
Collaborator

mapedraza commented Nov 3, 2023

@fgalan Ok! I will push a commit with the new doc.

Just a couple of questions regarding this feature:

  • There is type verification? I mean, when receiving payloads with entity type different from the one defined in the device provision, it is persisted?
  • All parameters (I.E entity ID, type etc) are part of the JEXL context?
  • It is compatible with entity name expressions?
  • There is any device provision?

Additionaly, it could be interesting:

  • Adding a regex expression or JEXL sentence to verify if the entity ID and type to let progress the request only if match

@AlvaroVega
Copy link
Member Author

AlvaroVega commented Nov 3, 2023

@fgalan Ok! I will push a commit with the new doc.

Just a couple of questions regarding this feature:

  • There is type verification? I mean, when receiving payloads with entity type different from the one defined in the device provision, it is persisted?
  • All parameters (I.E entity ID, type etc) are part of the JEXL context?
  • It is compatible with entity name expressions?
  • There is any device provision?

Additionaly, it could be interesting:

  • Adding a regex expression or JEXL sentence to verify if the entity ID and type to let progress the request only if match

I understand the ngsiv2 received is not checked by iotagent, just sent to ContextBroker.

@fgalan
Copy link
Member

fgalan commented Nov 3, 2023

I understand the ngsiv2 received is not checked by iotagent, just sent to ContextBroker.

I understand the same. IOTA is mostly a pass-through here. In the case of error response from ContextBroker, it should be logged at WARN or ERROR level but no actual checking at IOTA should be done.

@AlvaroVega AlvaroVega closed this Nov 3, 2023
@fgalan fgalan deleted the task/allow_ngsiv2_as_measure branch November 3, 2023 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants