Waziup / WaziGate

Waziup LoRa Edge gateway
21 stars 20 forks source link

Entity Id aliases #161

Open j-forster opened 3 years ago

j-forster commented 3 years ago

The idea of name aliases is taken from docker images tags.

Right now, Waziup sensor-, actuator- and device-Ids can be any arbitrary string when creating any entity. However, strong unique Ids (either serial or random) should be preferred to avoid Id collisions and to improve database fields (to favor primitive integer keys over string keys).

For that, the server should no longer accept user-defined Ids as entity Ids.

To maintain backwards compatibility, I would like to introduce name aliases. Name aliases can be used instead of entity Ids at any place (e.g. at URL on API calls). Each entity can have a (maybe empty) set of name aliases, and can be addressed by any of that name. Names can be added or removed from the set through new API endpoints. Existing endpoints that allow the creation of entities with a specific Id will use that Id as an alias, making it possible to used the initial Id/alias instead of a real Id.

cdupont commented 3 years ago

We need to include that as part of the new architecture specification. In particular, entities ids probably need to be the same between the various places (Cloud, GW1, GW2...). So it's not clear for me at the moment...

Regarding aliases, I think there is already the field "name", which is not necessarily unique. You can query it like this on the Cloud:

GET /devices?name=XXX

That returns a list of devices.