absmach / magistrala

Industrial IoT Messaging and Device Management Platform
https://www.abstractmachines.fr/magistrala.html
Apache License 2.0
2.46k stars 668 forks source link

Feature: Return response other than error for connecting existing connection of thing and channel #2303

Open arvindh123 opened 2 months ago

arvindh123 commented 2 months ago

Is your feature request related to a problem? Please describe.

In Bootstrap, for the request to change the state to 1, we need to send request to things service to connect the thing and channel from bootstrap service using SDK. If the thing and channel are already connected, things service returns an error.

Therefore, we should check if the thing and channel are connected before sending the connect request from Bootstrap.

To check if the thing and channel are connected, the only way we have now is to list the channels to which the thing is connected and then check if the channel ID is present in that list.

Listing is not an efficient process. For example, if the thing has 100 channel connections, we need to retrieve the entire list of 100 channels and then check if the connection requested channel ID is present in that list.

Describe the feature you are requesting, as well as the possible use case(s) for it.

In the Things service, instead of returning an error for an already connected thing and channel on a connect request, we can return a no-error HTTP status 204.

This might requires changes in spiceDB at add relation function, this might not be even possible to implement So another solution for this issue explained here https://github.com/absmach/magistrala/issues/2304

Indicate the importance of this feature to you.

Must-have

Anything else?

arvindh123 commented 1 month ago

This need to aligned with other similar endpoints like assign endpoints will also throw error if tried to assign again same entity

This can be implemented later in all endpoints