Cumulocity-IoT / cumulocity-remote-access-local-proxy

Cumulocity IoT Remote Access Local Proxy
Apache License 2.0
7 stars 9 forks source link

feat: allow users to provide device's managed object id instead of the external identity #186

Open reubenmiller opened 5 months ago

reubenmiller commented 5 months ago

Allowing user's to provide the managed object id allows better integration with other tooling (e.g. go-c8y-cli). This allows other tooling to perform custom lookups to retrieve the managed object id and just pass that to c8ylp when it it started.

The new managed object id/external identity logic is as follows:

If the given input is numeric (only digits), then try looking up if it corresponds to a managed object id. If successful, then use the managed object result, otherwise try treat the input as an external identity. If the input is not numeric, then assume the input is an external identity (same behaviour as before).

Below shows an example that should now work:

c8ylp connect ssh 12345 --ssh-user linuxuser
switschel commented 5 months ago

Just a small clarification question: I saw in the code that it will first try to retrieve the MO and if non existing try to retrieve it via external ID. So even when the external ID is numeric only e.g. 12345 this case should work, correct?

reubenmiller commented 5 months ago

Just a small clarification question: I saw in the code that it will first try to retrieve the MO and if non existing try to retrieve it via external ID. So even when the external ID is numeric only e.g. 12345 this case should work, correct?

Yes that will also work, though the client do one extra request (as it will think the given value is a managed object id get a 404 back which is ignored)