Skip to content

/v1/groups/{group}#2455

Merged
david-crespo merged 2 commits into
mainfrom
api-group-detail-endpoint
Mar 2, 2023
Merged

/v1/groups/{group}#2455
david-crespo merged 2 commits into
mainfrom
api-group-detail-endpoint

Conversation

@david-crespo

@david-crespo david-crespo commented Feb 28, 2023

Copy link
Copy Markdown
Contributor

We need this endpoint to power a group detail page in the console where we fetch the group by ID and display its name and the list of users in it.

As mentioned in a comment, groups have an external_id instead of a name and therefore don't implement ObjectIdentity, which makes doing a lookup by external ID a little less cute than lookup by name. external_id is unique per silo, so looking up by it with the silo implicit is perfectly possible in theory. However, unlike with Name, we do not (and probably cannot) enforce that the external_id of a group is not a UUID, which means our usual technique of falling back to name only once the thing fails to parse as a UUID does not work. If an external ID was a UUID, there would be no way to fetch a group by it because we would always assume it was one of our DB UUIDs.

One option would be to add a query param that allows the caller to specify that the given identifier is meant to be treated as the group external ID and not our DB ID. Another option, which we can do in a followup, is what @zephraph suggested in #2442 (comment): implement the external_id filter on the list endpoint instead. Because external_id is unique per silo, we know this will return either 1 or 0 results. It's a bit odd but it is conceptually consistent and requires no shenanigans.

@david-crespo david-crespo marked this pull request as ready for review March 2, 2023 17:46

@just-be-dev just-be-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty straight forward. 👍

#[endpoint {
method = GET,
path = "/v1/groups/{group}",
tags = ["silos"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder about the tag here. Isn't anything to be changed in this PR, but should silo scoped resources be listed in the silos tag?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it's weird. Perhaps even weirder: it seems to only be silo-scoped resources that get this tag. All the /system/silos/* endpoints for working with silos themselves are tagged system. We could probably stand to rework all the tags.

API operations found with tag "silos"
OPERATION ID                             URL PATH
group_list                               /groups
group_list_v1                            /v1/groups
group_view                               /v1/groups/{group}
policy_update                            /policy
policy_update_v1                         /v1/policy
policy_view                              /policy
policy_view_v1                           /v1/policy
user_list                                /users
user_list_v1                             /v1/user

@david-crespo david-crespo merged commit e6fb7df into main Mar 2, 2023
@david-crespo david-crespo deleted the api-group-detail-endpoint branch March 2, 2023 18:29
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 this pull request may close these issues.

2 participants