-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add route to list organization per users. #9807
base: master
Are you sure you want to change the base?
Conversation
user_email: str | ||
|
||
|
||
@administration_router.get("/administration/users/organizations") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this API is about getting back organization ID, it should be
@administration_router.get("/administration/users/organizations") | |
@administration_router.get("/administration/organizations") |
Used as GET /administration/[email protected]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However if we want to also provide information about the users with the given human handle in each organization, then we probably provide this route with a more specialized name, for instance:
$ curl https://parsec.cloud/administration/[email protected]
{
organizations: [
{
organization_id: CoolOrg,
users: [ // Ordered by created_on
{
user_id: b63f033a5a0042faa81be96c9e6f3ee7,
created_on: "2000-01-02T00:00:00Z",
current_profile: ADMINISTRATOR,
frozen: false,
revoked_on: None,
},
{
user_id: b63f033a5a0042faa81be96c9e6f3ee7,
created_on: "2000-01-01T00:00:00Z",
current_profile: STANDARD,
frozen: false,
revoked_on: "2000-01-02T00:00:00Z",
}
]
}
]
}
|
||
|
||
class AdministrationUsersOrganizations(BaseModel): | ||
user_email: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Parsec, user refers to a user certificate with a UserID
Here we want to know all the organizations that contains a given email, so we should uses human (as in Parsec human correspond to the email+label couple)
so basically you should replace every occurence of user in this PR by human ^^
@@ -489,6 +499,11 @@ async def list_frozen_users( | |||
) -> list[UserID] | UserListFrozenUsersBadOutcome: | |||
raise NotImplementedError | |||
|
|||
async def list_organizations( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this in the organization component since it is about retrieving organizations
@@ -366,6 +372,10 @@ class UserListFrozenUsersBadOutcome(BadOutcomeEnum): | |||
AUTHOR_REVOKED = auto() | |||
|
|||
|
|||
class UserListOrganizationsBadOutcome(BadOutcomeEnum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed: all organization not containing the email are simply omitted from the result, so returning an empty list as a result is enough
Fix #9710
TODO
Some other fields could be added to know more about how a user is in an organization:
Also note that in memory we must iterate on every user of every organization because of the way the datamodel is build. One may want to keep that index aside to improve performance, but the memory implementation is mostly used to test.