Lists
albert.collections.lists
AlbertPaginator
AlbertPaginator(
*,
path: str,
mode: PaginationMode,
session: AlbertSession,
deserialize: Callable[
[Iterable[dict]], Iterable[ItemType]
],
params: dict[str, str] | None = None,
)
Bases: Iterator[ItemType]
Helper class for pagination through Albert endpoints.
Two pagination modes are possible:
- Offset-based via by the offset query parameter
- Key-based via by the startKey query parameter and 'lastKey' response field
A custom deserialize function is provided when additional logic is required to load
the raw items returned by the search listing, e.g., making additional Albert API calls.
Source code in src/albert/core/pagination.py
AlbertSession
AlbertSession(
*,
base_url: str,
token: str | None = None,
auth_manager: AlbertClientCredentials
| AlbertSSOClient
| None = None,
retries: int | None = None,
)
Bases: Session
A session that has a base URL, which is prefixed to all request URLs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
The base URL to prefix to all relative request paths (e.g., "https://app.albertinvent.com"). |
required |
token
|
str | None
|
A static JWT token for authentication. Ignored if |
None
|
auth_manager
|
AlbertClientCredentials | AlbertSSOClient
|
An authentication manager used to dynamically fetch and refresh tokens.
If provided, it overrides |
None
|
retries
|
int
|
The number of automatic retries on failed requests (default is 3). |
None
|
Methods:
| Name | Description |
|---|---|
request |
|
Source code in src/albert/core/session.py
request
Source code in src/albert/core/session.py
BaseCollection
BaseCollection(*, session: AlbertSession)
BaseCollection is the base class for all collection classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert API Session instance. |
required |
Source code in src/albert/collections/base.py
ListItem
Bases: BaseResource
An item in a list.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the list item. |
id |
str | None
|
The Albert ID of the list item. Set when the list item is retrieved from Albert. |
category |
ListItemCategory | None
|
The category of the list item. Allowed values are |
list_type |
str | None
|
The type of the list item. Allowed values are |
Methods:
| Name | Description |
|---|---|
validate_list_type |
|
list_type
class-attribute
instance-attribute
list_type: str | None = Field(
default=None, alias="listType"
)
validate_list_type
validate_list_type() -> ListItem
Source code in src/albert/resources/lists.py
ListItemCategory
ListsCollection
ListsCollection(*, session: AlbertSession)
Bases: BaseCollection
ListsCollection is a collection class for managing ListItem entities in the Albert platform.
Example
stages = [
"1. Discovery",
"2. Concept Validation",
"3. Proof of Concept",
"4. Prototype Development",
"5. Preliminary Evaluation",
"6. Feasibility Study",
"7. Optimization",
"8. Scale-Up",
"9. Regulatory Assessment",
]
# Initialize the Albert client
client = Albert()
# Get the custom field this list is associated with
stage_gate_field = client.custom_fields.get_by_id(id="CF123")
# Create the list items
for s in stages:
item = ListItem(
name=s,
category=stage_gate_field.category,
list_type=stage_gate_field.name,
)
client.lists.create(list_item=item)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Methods:
| Name | Description |
|---|---|
create |
Creates a list entity. |
delete |
Delete a lists entry item by its ID. |
get_all |
Get all list entities with optional filters. |
get_by_id |
Retrieves a list entity by its ID. |
get_matching_item |
Get a list item by name and list type. |
update |
Update a list item. |
Source code in src/albert/collections/lists.py
create
Creates a list entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
list_item
|
ListItem
|
The list entity to create. |
required |
Returns:
| Type | Description |
|---|---|
List
|
The created list entity. |
Source code in src/albert/collections/lists.py
delete
delete(*, id: str) -> None
Delete a lists entry item by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the lists item. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/lists.py
get_all
get_all(
*,
limit: int = 100,
names: list[str] | None = None,
category: ListItemCategory | None = None,
list_type: str | None = None,
start_key: str | None = None,
) -> Iterator[ListItem]
Get all list entities with optional filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int
|
The maximum number of list entities to return. |
100
|
names
|
list[str]
|
A list of names of the list entity to retrieve. |
None
|
category
|
ListItemCategory
|
The category of the list entity to retrieve. |
None
|
list_type
|
str
|
The type of list entity to retrieve. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[ListItem]
|
An iterator of ListItems. |
Source code in src/albert/collections/lists.py
get_by_id
Retrieves a list entity by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the list entity to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
List
|
A list entity. |
Source code in src/albert/collections/lists.py
get_matching_item
Get a list item by name and list type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of it item to retrieve. |
required |
list_type
|
str
|
The type of list (can be the name of the custom field) |
required |
Returns:
| Type | Description |
|---|---|
ListItem | None
|
A list item with the provided name and list type, or None if not found. |
Source code in src/albert/collections/lists.py
update
Update a list item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
list_item
|
ListItem
|
The list item to update. |
ListItem
|
Returns:
| Type | Description |
|---|---|
ListItem
|
The updated list item. |