cdupont
cdupont

Reputation: 1188

FIWARE Orion: Filter subscriptions

We use Orion to register subscriptions. There are two kinds of subscriptions in our application:

The problem is to distinguish the two, in order to present the user with only user-oriented subscriptions. Which field of the subscriptions can I use? It would be nice to have a field "type", for instance.

Upvotes: 2

Views: 154

Answers (3)

Emiliano Viotti
Emiliano Viotti

Reputation: 1709

I agree with what Jose Manuel says, it would be a really nice feature.

In addition to his reply, in the meantime I think you can use "metadata" field in subscriptions for distinguish between user subscriptions and internal subscriptions. Just have in mind that this field is not supposed for this purposes and its kind a "dark" way to implement the behavior that you want.

Here is an example of a subscription creation with my approach. In this case you create a subscription with the metadata field "isInternal" that just tells you that this is an internal subscription. Then you can use another different metadata field as a token, just to identify a user subscription:

curl -X POST \
  http://localhost:1026/v2/subscriptions \
  -H 'Content-Type: application/json' \
  -d '{
       "description": "A subscription to get info about Room1",
       "subject": {
         "entities": [
           {
             "id": "Room1",
             "type": "Room"
           }
         ],
         "condition": {
           "attrs": [
             "temperature"
           ]
         }
       },
       "notification": {
         "http": {
           "url": "http://localhost:1028/accumulate"
         },
         "attrs": ["temperature"],
         "metadata": ["isInternal"]
       }
     }'

For more information about metadata field in subscriptions and his normal use please refer to this documentation.

Upvotes: 2

Jose Manuel Cantera
Jose Manuel Cantera

Reputation: 853

In the future probably it would be nice to open the possibility to extra fields in a subscription (application defined) and to be able make queries over subscriptions (something which cannot be currently done).

Upvotes: 1

fgalan
fgalan

Reputation: 12294

A solution could be to make use of the description field associated to subscription to distinghuish between both types.

Upvotes: 0

Related Questions