Links
albert.collections.links
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
Link
Bases: BaseResource
A link in Albert.
Attributes:
| Name | Type | Description |
|---|---|---|
parent |
EntityLink
|
The parent entity of the link. |
child |
EntityLink
|
The child entity of the link. |
category |
LinkCategory
|
The category of the link. Allowed values are |
id |
str | None
|
The Albert ID of the link. Set when the link is retrieved from Albert. |
counter |
int | None
|
The counter of the link. Optional. |
LinkCategory
LinksCollection
LinksCollection(*, session: AlbertSession)
Bases: BaseCollection
LinksCollection is a collection class for managing Link entities in the Albert platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Methods:
| Name | Description |
|---|---|
create |
Creates a new link entity. |
delete |
Deletes a link entity by its ID. |
get_all |
Get all link entities with optional filters. |
get_by_id |
Retrieves a link entity by its ID. |
Source code in src/albert/collections/links.py
create
Creates a new link entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
links
|
list[Link]
|
List of Link entities to create. |
required |
Returns:
| Type | Description |
|---|---|
Link
|
The created link entity. |
Source code in src/albert/collections/links.py
delete
delete(*, id: str) -> None
Deletes a link entity by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the link entity to delete. |
required |
get_all
get_all(
*,
limit: int = 100,
type: str | None = None,
category: LinkCategory | None = None,
id: str | None = None,
) -> Iterator[Link]
Get all link entities with optional filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int
|
The maximum number of link entities to return. |
100
|
type
|
str
|
The type of the link entities to return. Allowed values are |
None
|
category
|
LinkCategory
|
The category of the link entities to return. Allowed values are |
None
|
id
|
str
|
The ID of the link entity to return. (Use with |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[Link]
|
An iterator of Links. |