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

Should be "append" in "actionType" notif metadata if we use POST v2/entities/<id>? #2549

Closed
iariasleon opened this issue Sep 29, 2016 · 4 comments
Assignees
Milestone

Comments

@iariasleon
Copy link
Contributor

Should be "append" in "actionType" notification metadata, if we use POST v2/entities/<id>?

subscription request:

POST http://localhost:1026/v2/subscriptions
{"notification": {"http": {"url": "http://localhost:1045/notify"}, "metadata": ["actionType", "previousValue", "*"]}, "subject": {"entities": [{"idPattern": ".*"}]}}

entity create request

POST http://localhost:1026/v2/entities
{"temperature_2": {"type": "celsius", "value": "MI0bS", "metadata": {"very_hot_1": {"type": "alarm", "value": "hot"}, "very_hot_0": {"type": "alarm", "value": "hot"}}}, "temperature_0": {"type": "celsius", "value": "MI0bS", "metadata": {"very_hot_1": {"type": "alarm", "value": "hot"}, "very_hot_0": {"type": "alarm", "value": "hot"}}}, "temperature_1": {"type": "celsius", "value": "MI0bS", "metadata": {"very_hot_1": {"type": "alarm", "value": "hot"}, "very_hot_0": {"type": "alarm", "value": "hot"}}}, "type": "od9", "id": "room2"}

entity update request

POST http://localhost:1026/v2/entities/room2/attrs
payload: {"temperature_2": {"type": "Fahrenheit", "value": "xb2Ztqje", "metadata": {"very_hot_1": {"type": "alarm", "value": "cold"}, "very_hot_0": {"type": "alarm", "value": "cold"}}}, "temperature_0": {"type": "Fahrenheit", "value": "xb2Ztqje", "metadata": {"very_hot_1": {"type": "alarm", "value": "cold"}, "very_hot_0": {"type": "alarm", "value": "cold"}}}, "temperature_1": {"type": "Fahrenheit", "value": "xb2Ztqje", "metadata": {"very_hot_1": {"type": "alarm", "value": "cold"}, "very_hot_0": {"type": "alarm", "value": "cold"}}}}

notification sent

{"subscriptionId":"57ecdf1e33c958a1c9cb4264","data":[{"id":"room2","type":"od9","temperature_0":{"type":"Fahrenheit","value":"xb2Ztqje","metadata":{"very_hot_0":{"type":"alarm","value":"cold"},"very_hot_1":{"type":"alarm","value":"cold"},"actionType":{"type":"Text","value":"append"},"previousValue":{"type":"celsius","value":"MI0bS"}}},"temperature_1":{"type":"Fahrenheit","value":"xb2Ztqje","metadata":{"very_hot_0":{"type":"alarm","value":"cold"},"very_hot_1":{"type":"alarm","value":"cold"},"actionType":{"type":"Text","value":"append"},"previousValue":{"type":"celsius","value":"MI0bS"}}},"temperature_2":{"type":"Fahrenheit","value":"xb2Ztqje","metadata":{"very_hot_0":{"type":"alarm","value":"cold"},"very_hot_1":{"type":"alarm","value":"cold"},"actionType":{"type":"Text","value":"append"},"previousValue":{"type":"celsius","value":"MI0bS"}}}}]}
@fgalan fgalan added this to the 1.5.0 milestone Sep 29, 2016
@fgalan
Copy link
Member

fgalan commented Oct 6, 2016

POST /v2/entities/<id> could be either actual append (if the attribute doesn't exist) or update (if the attribute exists). I think the desired behaviour should be that CB detect what is going on in each case and use the right actionType in the notification.

I mean:

  • If the attribute included in the notification was created with that operation, then actionType metadata = append
  • If the attribute included in the notification was updated with that operation (it previously exists), then actionType metadata = update.

kzangeli pushed a commit that referenced this issue Oct 6, 2016
fgalan pushed a commit that referenced this issue Oct 7, 2016
* functest ready

* fix for issue #2549

* One more step in functest

* CHANGES_NEXT_RELEASE

* fixed a comment in functest

* new step in functest
fgalan pushed a commit that referenced this issue Oct 7, 2016
* functest ready

* fix for issue #2549

* One more step in functest

* CHANGES_NEXT_RELEASE

* fixed a comment in functest

* new step in functest
@fgalan
Copy link
Member

fgalan commented Oct 7, 2016

Fixed in PR #2580 (release/1.4.0) and #2586 (master)

@fgalan
Copy link
Member

fgalan commented Oct 7, 2016

Both PR merged. Ready to be tested by @iariasleon and closed if it is ok.

@iariasleon
Copy link
Contributor Author

LGTM

 {"subscriptionId":"57fb7b90935d80668dd5b7e3","data":[{"id":"room2","type":"7HP","temperature_0":{"type":"Fahrenheit","value":"rL8fvs92","metadata":{"actionType":{"type":"Text","value":"update"},"previousValue":{"type":"celsius","value":"Oxrby"}}},"temperature_1":{"type":"Fahrenheit","value":"rL8fvs92","metadata":{"actionType":{"type":"Text","value":"update"},"previousValue":{"type":"celsius","value":"Oxrby"}}},"temperature_2":{"type":"Fahrenheit","value":"rL8fvs92","metadata":{"actionType":{"type":"Text","value":"update"},"previousValue":{"type":"celsius","value":"Oxrby"}}}}]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants