Links
albert.collections.links.LinksCollection
Bases: BaseCollection
Manage Links in the Albert platform.
A Link represents a directional relationship between two entities in Albert:
a parent and a child. Links capture cross-entity relationships such as a
mention, a linked Task, a synthesis relationship, or a linked Inventory
Item (see LinkCategory). Links have no
updatable fields; they are created, retrieved, and deleted.
This collection is accessed as client.links.
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 link requests. |
Methods:
| Name | Description |
|---|---|
create |
Create one or more links. |
get_all |
Iterate over links, optionally filtered by entity, type, and category. |
get_by_id |
Get a single link by its ID. |
delete |
Delete a link by its ID. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/links.py
create
Create one or more links.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
links
|
list[Link]
|
The links to create. Each requires a |
required |
Returns:
| Type | Description |
|---|---|
list[Link]
|
The created links, each populated with its assigned Link ID. |
Source code in src/albert/collections/links.py
get_all
get_all(
*,
type: str | None = None,
category: LinkCategory | None = None,
id: str | None = None,
start_key: str | None = None,
max_items: int | None = None,
) -> Iterator[Link]
Iterate over links, with optional filters.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
str
|
Which side of the relationship to return relative to |
None
|
category
|
LinkCategory
|
The link category to filter by (e.g. |
None
|
id
|
str
|
The ID of the entity to fetch links for. Must include the full entity
prefix (e.g. |
None
|
start_key
|
str
|
The pagination key to start from. |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, fetches all available items. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[Link]
|
An iterator over the matching links. |
Source code in src/albert/collections/links.py
get_by_id
Get a link by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
LinkId
|
The Link ID (format |
required |
Returns:
| Type | Description |
|---|---|
Link
|
The fully populated link. |
Source code in src/albert/collections/links.py
delete
delete(*, id: LinkId) -> None
Delete a link by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
LinkId
|
The Link ID to delete (format |
required |
Returns:
| Type | Description |
|---|---|
None
|
|