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 |
|---|---|
search |
Search teams with free text and filters, returning partial items. |
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
search
search(
*,
text: str | None = None,
status: str | None = None,
team_id: str | list[str] | None = None,
search_field: str | list[str] | None = None,
source_field: str | list[str] | None = None,
additional_field: str | list[str] | None = None,
sort_by: str | None = None,
order: OrderBy | None = None,
max_items: int | None = None,
) -> Iterator[TeamSearchItem]
Search for teams matching the given filters.
Returns partial (unhydrated)
TeamSearchItem entities, best for
free-text lookups and pulling IDs. Results are returned lazily as an
iterator that pages through matches on demand. Call hydrate() on an item
to fetch its full Team. For exact name
listing, use get_all.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Free-text query matched against team fields. |
None
|
status
|
str
|
Filter by team status. |
None
|
team_id
|
str or list[str]
|
Filter by Team ID(s) (format |
None
|
search_field
|
str or list[str]
|
Restrict which indexed fields the free-text query searches. |
None
|
source_field
|
str or list[str]
|
Restrict which fields are returned on each search hit. |
None
|
additional_field
|
str or list[str]
|
Additional fields to include on each search hit. |
None
|
sort_by
|
str
|
Attribute to sort results by. |
None
|
order
|
OrderBy
|
The order in which to sort results ( |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, iterates over all matching items. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[TeamSearchItem]
|
A lazy iterator of matching partial teams. Call |
Source code in src/albert/collections/teams.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
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.
Best for exact name listing. For free-text search, use
search.
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
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. |