Custom Templates
albert.collections.custom_templates
AlbertHTTPError
Bases: AlbertException
Base class for all erors due to HTTP responses.
Source code in src/albert/exceptions.py
AlbertSession
AlbertSession(
*,
base_url: str,
token: str | None = None,
client_credentials: ClientCredentials | 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 requests. (e.g., "https://sandbox.albertinvent.com") |
required |
retries
|
int
|
The number of retries for failed requests. Defaults to 3. |
None
|
client_credentials
|
ClientCredentials | None
|
The client credentials for programmatic authentication. Optional if token is provided. |
None
|
token
|
str | None
|
The JWT token for authentication. Optional if client credentials are provided. |
None
|
Methods:
Name | Description |
---|---|
request |
|
Source code in src/albert/session.py
request
Source code in src/albert/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
CustomTemplate
Bases: BaseTaggedResource
A custom template entity.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the template. |
id |
str
|
The Albert ID of the template. Set when the template is retrieved from Albert. |
category |
TemplateCategory
|
The category of the template. Allowed values are |
metadata |
Dict[str, str | List[EntityLink] | EntityLink] | None
|
The metadata of the template. Allowed Metadata fields can be found using Custim Fields. |
data |
CustomTemplateData | None
|
The data of the template. |
team |
List[TeamACL] | None
|
The team of the template. |
acl |
TemplateACL | None
|
|
Methods:
Name | Description |
---|---|
add_missing_category |
Initialize private attributes from the incoming data dictionary before the model is fully constructed. |
acl
class-attribute
instance-attribute
acl: TemplateACL | None = Field(
default_factory=list, alias="ACL"
)
data
class-attribute
instance-attribute
metadata
class-attribute
instance-attribute
add_missing_category
classmethod
Initialize private attributes from the incoming data dictionary before the model is fully constructed.
Source code in src/albert/resources/custom_templates.py
CustomTemplatesCollection
CustomTemplatesCollection(*, session: AlbertSession)
Bases: BaseCollection
CustomTemplatesCollection is a collection class for managing CustomTemplate entities in the Albert platform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Methods:
Name | Description |
---|---|
get_by_id |
Get a Custom Template by ID |
list |
Searches for custom templates matching the provided criteria. |
Source code in src/albert/collections/custom_templates.py
get_by_id
get_by_id(*, id) -> CustomTemplate
Get a Custom Template by ID
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
id of the custom template |
required |
Returns:
Type | Description |
---|---|
CustomTemplate
|
The CutomTemplate with the provided ID (or None if not found) |
Source code in src/albert/collections/custom_templates.py
list
list(
*,
text: str | None = None,
limit: int = 50,
offset: int = 0,
) -> Iterator[CustomTemplate]
Searches for custom templates matching the provided criteria.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str | None
|
The text to search for, by default None |
None
|
Yields:
Type | Description |
---|---|
Iterator[CustomTemplate]
|
An iterator of CustomTemplate items matching the search criteria. |