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

Add route to list organization per users. #9807

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AureliaDolo
Copy link
Contributor

Fix #9710

TODO

Some other fields could be added to know more about how a user is in an organization:

  • human name is trivial
  • user_id, if they are revoked, or frozen, their initial and current profile are a join with _user table away

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.

user_email: str


@administration_router.get("/administration/users/organizations")
Copy link
Member

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

Suggested change
@administration_router.get("/administration/users/organizations")
@administration_router.get("/administration/organizations")

Used as GET /administration/[email protected]

Copy link
Member

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
Copy link
Member

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(
Copy link
Member

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):
Copy link
Member

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

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.

List all organizations for a given user
2 participants