Teams
Teams in Albert allow organizations to manage groups of users that can be assigned in bulk to projects.
albert.collections.teams.TeamCollection
Bases: BaseCollection
Manage Teams in the Albert platform.
A Team is a named group of users
(User). Each member holds a team role
(owner or viewer) that governs their rights within the team. Teams are used
to share access: entity ACLs and Task assignments can reference a whole team
rather than individual users. A team is identified by its Team ID (format
TEM..., e.g. "TEM1").
This collection is accessed as client.teams.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
str
|
The base API route for team requests. |
Methods:
| Name | Description |
|---|---|
get_all |
Lists all teams with optional filters. |
get_by_id |
Get a team by its ID. |
create |
Create a new team, optionally with initial members. |
update |
Update a team's name and membership. |
delete |
Deletes a team by its ID. |
add_users |
Adds users to a team. |
remove_users |
Removes users from a team. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/teams.py
get_all
get_all(
*,
name: str | list[str] | None = None,
exact_match: bool = True,
created_by: str | None = None,
updated_by: str | None = None,
user_id: str | list[str] | None = None,
max_items: int | None = None,
) -> Iterator[Team]
List all teams with optional filters.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str or list[str]
|
Filter teams by one or more names. |
None
|
exact_match
|
bool
|
Whether to match the name(s) exactly. Default is True. |
True
|
created_by
|
str
|
Filter teams by the user ID of their creator. |
None
|
updated_by
|
str
|
Filter teams by the user ID of their last updater. |
None
|
user_id
|
str or list[str]
|
Filter teams by user membership. |
None
|
max_items
|
int
|
Maximum total number of items to return. If None, fetches all available items. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[Team]
|
An iterator of Team entities matching the filters. |
Source code in src/albert/collections/teams.py
get_by_id
Get a team by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
TeamId
|
The ID of the team. |
required |
Returns:
| Type | Description |
|---|---|
Team
|
The fully populated team. |
Source code in src/albert/collections/teams.py
create
create(
*, name: str, members: list[TeamMember] | None = None
) -> Team
Create a new team, optionally with initial members.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the team. |
required |
members
|
list[TeamMember]
|
Members to add to the team on creation, each with a User ID and a
team role. Members default to the |
None
|
Returns:
| Type | Description |
|---|---|
Team
|
The created Team, populated with its assigned Team ID. |
Source code in src/albert/collections/teams.py
update
Update a team's name and membership.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team
|
Team
|
The team with desired changes applied. Modify the |
required |
Returns:
| Type | Description |
|---|---|
Team
|
The updated Team. |
Notes
The following can be updated: the team name, its membership (adding
or removing TeamMember entries), and
each member's role. Setting members to an empty list removes all
members; leaving it as None leaves membership unchanged.
Source code in src/albert/collections/teams.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
delete
delete(*, id: TeamId) -> None
Delete a team by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
TeamId
|
The ID of the team to delete. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/teams.py
add_users
add_users(*, id: TeamId, members: list[TeamMember]) -> Team
Add users to a team.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
TeamId
|
The ID of the team. |
required |
members
|
list[TeamMember]
|
The members to add, each with a User ID and a team role. Members
default to the |
required |
Raises:
| Type | Description |
|---|---|
AlbertException
|
If any of the provided users is already a member. Use |
Returns:
| Type | Description |
|---|---|
Team
|
The updated Team. |
Source code in src/albert/collections/teams.py
remove_users
Remove users from a team.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
TeamId
|
The ID of the team. |
required |
users
|
list[User | UserId]
|
The users to remove. Accepts User objects or user ID strings. |
required |
Raises:
| Type | Description |
|---|---|
AlbertException
|
If none of the provided users are members of the team. |
Returns:
| Type | Description |
|---|---|
Team
|
The updated Team. |