1
votes

We are researching about the Orion Context Broker technology using local Docker containers and trying to integrate the local Context Broker with an external Context Provider.

Specifically, we are trying to retrieve data from this Context provider:

https://streams.lab.fiware.org/v2/entities?type=AirQualityObserved&options=keyValues

Using the headers:

fiware-service: environment

fiware-servicePath: /Madrid

Concretely, our objective is to achieve a registration from our Context Broker to this node of the provider, in order to get some attributes that we don't have in local (in that example, the attribute is called "NO").

The request we are sending for the registration is the following one:

curl -iX POST \
  'http://localhost:1026/v2/registrations' \
  -H 'Content-Type: application/json' \
  -d '{
  "description": "Air Quality Madrid",
  "dataProvided": {
    "entities": [
      {
        "id": "Madrid-AirQualityObserved-28079059-latest",
        "type": "AirQualityObserved"
      }
    ],
    "attrs": [
      "NO"
    ]
  },
  "provider": {
    "http": {
      "url": "https://streams.lab.fiware.org"
    }
  }
}'

Additionally, we have created a local entity with the same id as in the request: Madrid-AirQualityObserved-28079059-latest

After that information, the question is:

Is it possible to include the specific fiware-service and fiware-servicePath headers into the registration request? What is the way to include them?

Thanks in advance.

EDIT:

I've been doing more tests with the following commands:

For registering to the context provider, using the specific headers for the desired service. For now, the local entity is not created in the local context broker.

curl -iX POST \
  'http://localhost:1026/v2/registrations' \
  -H 'Content-Type: application/json' \
  -H 'fiware-service: environment' \
  -H 'fiware-servicepath: /Madrid' \
  -d '{
  "description": "Air Quality Madrid",
  "dataProvided": {
    "entities": [
      {
        "id": "Madrid-AirQualityObserved-28079059-latest",
        "type": "AirQualityObserved"
      }
    ],
    "attrs": [
      "NO"
    ]
  },
  "provider": {
    "http": {
      "url": "https://streams.lab.fiware.org"
    }
  }
}'

Then, I've check if the registration has been correctly registered:

curl -X GET http://localhost:1026/v2/registrations \
    -H 'fiware-service: environment'   
    -H 'fiware-servicepath: /Madrid'

Finally, I've tried to retrieve the entity from the provider:

curl -X GET http://localhost:1026/v2/entities/Madrid-AirQualityObserved-28079059-latest \
  -H 'fiware-service: environment' \
  -H 'fiware-servicepath: /Madrid' 

But the response indicates that there is not any entity for that request. Because of that, I've created the entity in the local context broker, excluding the field that I'm trying to obtain from the provider "NO".

curl -iX POST \
  'http://localhost:1026/v2/entities' \
  -H 'Content-Type: application/json' \
  -H 'fiware-service: environment' \
  -H 'fiware-servicepath: /Madrid' \
  -d '
{
    "id": "Madrid-AirQualityObserved-28079059-latest",
    "type": "AirQualityObserved"
}'

However, if I consult the entity with the ID Madrid-AirQualityObserved-28079059-latest, I'm receiving the local data, and the field "NO" is not being retrieved from the provider. That is the response (missing the NO field):

{
    "id": "Madrid-AirQualityObserved-28079059-latest",
    "type": "AirQualityObserved"
}

What I am doing wrong?

1

1 Answers

0
votes

Yes, it's possible.

They are included as regular headers. For instance, if you are using curl, it would be something like -H 'fiware-service: environment' -H 'fiware-servicepath: /Madrid'.

EDIT:

Looking to the query request you are using:

curl -X GET http://localhost:1026/v2/entities/Madrid-AirQualityObserved-28079059-latest \
  -H 'fiware-service: environment' \
  -H 'fiware-servicepath: /Madrid' 

I see are not incluing the entity type in the query, contrary to the recomendation in the context providers and request forwarding documentantation:

On forwarding, any type of entity in the NGSIv2 update/query matches registrations without entity type. However, the opposite doesn't work, so if you have registrations with types, then you must use ?type in NGSIv2 update/query in order to obtain a match. Otherwise you may encounter problems, like the one described in this post at StackOverflow.

So maybe you should use:

curl -X GET http://localhost:1026/v2/entities/Madrid-AirQualityObserved-28079059-latest?type=AirQualityObserved \
  -H 'fiware-service: environment' \
  -H 'fiware-servicepath: /Madrid'