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 support querying applications by UUID #1016

Closed
pdcastro opened this issue Nov 2, 2020 · 3 comments · Fixed by #1074
Closed

Should support querying applications by UUID #1016

pdcastro opened this issue Nov 2, 2020 · 3 comments · Fixed by #1074
Assignees

Comments

@pdcastro
Copy link

pdcastro commented Nov 2, 2020

The balena API has support for querying applications by UUID:
https://github.com/balena-io/open-balena-api/pull/491/files

The SDK should support this too. As for the model interface / function signatures, given that UUIDs and app names are both strings that cannot be readily unambiguously distinguished, the SDK should provide a way for the caller to explicitly specify whether the identifier is a UUID or application, for example:

application.get({ uuid: 'decade2' }, opts)

Some additional discussion took place in a private thread. Extract:

Any application name with exactly 32 or 62 characters in the set [a-fA-F0-9] would be indistinguishable from an application UUID (while not necessarily being a UUID, or at least not a UUID in balena's database, perhaps a UUID in the user's own database), and thus subject to a query error. It's a rare corner case, but we are better off avoiding them. It would be an unnecessary restriction to tell users that they shouldn't name applications with 32 or 62 characters from a particular character set. I like application.get({ uuid: '123456' }, opts) better than trial-and-error heuristic probabilistic auto detection. :-)

There is also the case of short UUIDs. For device UUIDs, I gather that the SDK currently issues a filtered query with $startswith: uuidOrId:
https://github.com/balena-io/balena-sdk/blob/v15.17.0/lib/models/device.ts#L514
For devices, the SDK only needs to do this when the UUID is not a number (JS data type), so at least it knows that the short UUID is actually a UUID. With applications, 7-char UUIDs would more easily be confused with names. For example, the word "decade2" is both a valid app name and valid short UUID. I am OK with the occasional conflict and error if the user chooses to use an ambiguous command line option/syntax like --application decade2 (in fact in this thread I have voiced my preference to keep allowing this kind of auto detection for backwards compatibility even in future major versions of the CLI, when others suggested that the next major version of the CLI should disallow auto detection / ambiguous identifier specification). But I also think that the SDK and the CLI should provide a way of unambiguously specifying whether the identifier is a name, UUID or database ID. So while the SDK could provide the feature of best effort filtering by long UUID, short UUID, app name, slug and database ID, I think there should also be a way of querying only by a specific identifier type like UUID. Like application.get({ uuid: 'decade2' }, opts).

See: https://www.flowdock.com/app/rulemotion/i-cli/threads/g26bVg0Nc518ZZknqxtX0GmWhwb

@thgreasi
Copy link
Member

thgreasi commented Nov 2, 2020

Only the open-balena-api has support for querying the application's uuid.
At the cloud API doesn't expose the application uuid in the v6 model.

@thgreasi
Copy link
Member

thgreasi commented Feb 1, 2021

Will become part of the v6 model with:
See: https://github.com/balena-io/balena-api/pull/2981

thgreasi added a commit that referenced this issue Feb 10, 2021
Change-type: minor
Depends-on: balena-io/balena-api#2981
See: #1016
Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
thgreasi added a commit that referenced this issue Feb 10, 2021
Change-type: minor
Depends-on: balena-io/balena-api#2981
See: #1016
Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
thgreasi added a commit that referenced this issue Apr 7, 2021
Resolves: #1016
Change-type: minor
Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
thgreasi added a commit that referenced this issue Apr 7, 2021
Resolves: #1016
Change-type: minor
Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
thgreasi added a commit that referenced this issue Apr 7, 2021
Resolves: #1016
Change-type: minor
Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
@thgreasi thgreasi self-assigned this Apr 7, 2021
thgreasi added a commit that referenced this issue Apr 7, 2021
Resolves: #1016
Change-type: minor
Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
thgreasi added a commit that referenced this issue Dec 30, 2021
Resolves: #1016
Change-type: minor
Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
@ghost ghost closed this as completed in #1074 Dec 30, 2021
@thgreasi
Copy link
Member

Splitted the alternate key object notation to:
See: #1176

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

Successfully merging a pull request may close this issue.

2 participants