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
TeamCollection manages Team entities in the Albert platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
str
|
The base URL for team API requests. |
Methods:
| Name | Description |
|---|---|
get_all |
Lists all teams with optional filters. |
get_by_id |
Retrieves a team by its ID. |
create |
Creates a new team, optionally with initial members. |
update |
Updates 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 Albert session instance. |
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.
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
create
create(
*, name: str, members: list[TeamMember] | None = None
) -> Team
Create a new team, optionally with initial members.
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 an ID and role. |
None
|
Returns:
| Type | Description |
|---|---|
Team
|
The created Team. |
Source code in src/albert/collections/teams.py
update
Update a team's name and membership.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team
|
Team
|
The team with desired changes applied. Modify the |
required |
Returns:
| Type | Description |
|---|---|
Team
|
The updated Team. |
Source code in src/albert/collections/teams.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 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 | |
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
TeamId
|
The ID of the team. |
required |
members
|
list[TeamMember]
|
The members to add, each with an ID and role. |
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. |