Users
The Flywheel SDK provides methods for managing user accounts on the site. Most user-management operations require admin permissions.
User model overview
A Flywheel user account has the following key fields:
| Field | Description |
|---|---|
id | The user's email address (used as the unique identifier) |
firstname | First name |
lastname | Last name |
email | Email address (same as id) |
roles | List of site-level role assignments |
avatar | URL of the user's avatar image |
Note
User IDs in Flywheel are email addresses. Pass the email address wherever a user_id parameter is required.
User provisioning
Users are typically provisioned via single sign-on (SSO) or Lightweight Directory Access Protocol (LDAP). The SDK supplements those mechanisms and is useful for scripted onboarding, bulk modifications, or querying user state. It is not a replacement for your organization's identity provider.
Getting the current user
Any authenticated user can retrieve their own account:
me = fw.get_current_user()
print(me.id, me.firstname, me.lastname)
Listing all users
Listing all users requires admin permissions:
for user in fw.get_all_users():
print(user.id, user.firstname, user.lastname)
Getting a user by ID
Adding a user
fw.add_user(
flywheel.User(
id=user_email,
firstname="Jane",
lastname="Doe",
email=user_email,
)
)
Modifying a user
fw.modify_user(user_email, {"firstname": "Jane", "lastname": "Smith"})
Deleting a user
Warning
Deleting a user removes their account from the site but does not remove their permission entries from groups and projects. Clean up their permissions separately if needed.