eclipse-hono / hono

Eclipse Hono™ Project
https://eclipse.dev/hono
Eclipse Public License 2.0
447 stars 138 forks source link

Implement search devices operation in the JDBC based device registry #2311

Open kaniyan opened 3 years ago

kaniyan commented 3 years ago

The Open API spec for the Device Registry Management API offers an API for searching devices belonging to a tenant. This has been already implemented in the MongoDB and file-based device registries. This has not been yet implemented in the JDBC based device registry.

matthiasfeurer commented 1 year ago

Is there an update on this issue or already some work done on it? We would also need a way to list devices as well as tenants, so we could help here.

sophokles73 commented 1 year ago

There has not been any development on this so far. Please note that this issue is about implementing the functionality for the JDBC based registry. The MongoDB based registry already supports this.

matthiasfeurer commented 1 year ago

Thanks for the reply. We are currently using Google CloudSQL (PostgreSQL) in our setup...

matthiasfeurer commented 1 year ago

@sophokles73 the implementation as it is proposed by the PR of @gdimitropoulos-sotec is using the data field of the device_registrations table which contains a JSON structure. Therefore it would not be possible to do a wildcard search by deviceId as deviceId is a separate column in this table. Would you think this should be possible as well using the filter expression in the API or should this rather be done by a separate parameter or even a completely new API call? How does this work in MongoDB?

sophokles73 commented 1 year ago

I am not sure I fully understand your question. Can you maybe spell out the query (in natural language) that you want to ask the system, e.g.

Give me all devices that have been provisioned more than 15 days ago

or something like that?

matthiasfeurer commented 12 months ago

No, we would like to execute queries like:

Give me all devices that have a deviceId starting with "abc4711"

or

Give me all devices that have a deviceId containing the string "xyz"

sophokles73 commented 12 months ago

I see. IIRC queries like that were never in scope of the registry. In fact, we never intended the Device Registry to support elaborate queries at all. Instead, its purpose was mainly to provide the data required by protocol adapters to authenticate devices and process messages.

That said, personally I would rather keep support for queries based on filters to an absolute minimum. Finding the right balance between keeping the code simple (enough) and usefulness of the registry implementations is not easy.

If I am not mistaken then you are striving for using Hono's Device Registry Management API as the basis for replacing the Google IoT Core device management console which (I guess) supports all kinds of searching and filtering. If that is true then maybe we can identify the set of query options that you are currently missing and, based on that, discuss whether it is realistic to add all of those to Hono's registry. WDYT?

matthiasfeurer commented 11 months ago

Thanks for the feedback, makes sense. Although we think it would be a nice feature at least from UI perspective when dealing with hundred of thousands of devices, we will not pursue this topic further for now.

harism commented 1 month ago

Just a quick heads up that I will try to find time to get to this issue now after latest H2 versions seem to have JSON datatype queries implemented and it should be possible to make same functionality with it as PostgreSQL has had for some time already.