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
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
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
CustomTemplateSearchItem
pydantic-model
Bases: BaseAlbertModel, HydrationMixin[CustomTemplate]
Show JSON schema:
{
"$defs": {
"ACLType": {
"enum": [
"team",
"member",
"owner",
"viewer"
],
"title": "ACLType",
"type": "string"
},
"AccessControlLevel": {
"description": "The fine grain control",
"enum": [
"ProjectOwner",
"ProjectEditor",
"ProjectViewer",
"ProjectAllTask",
"ProjectPropertyTask",
"InventoryOwner",
"InventoryViewer",
"CustomTemplateOwner",
"CustomTemplateViewer"
],
"title": "AccessControlLevel",
"type": "string"
},
"CustomTemplateSearchItemACL": {
"properties": {
"id": {
"description": "The id of the user for which this ACL applies",
"title": "Id",
"type": "string"
},
"fgc": {
"anyOf": [
{
"$ref": "#/$defs/AccessControlLevel"
},
{
"type": "null"
}
],
"default": null,
"description": "The Fine-Grain Control Level"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Name"
},
"userType": {
"anyOf": [
{
"$ref": "#/$defs/UserClass"
},
{
"type": "null"
}
],
"default": null
},
"type": {
"$ref": "#/$defs/ACLType"
}
},
"required": [
"id",
"type"
],
"title": "CustomTemplateSearchItemACL",
"type": "object"
},
"CustomTemplateSearchItemData": {
"properties": {
"Designs": {
"default": null,
"items": {
"$ref": "#/$defs/DesignLink"
},
"title": "Designs",
"type": "array"
},
"FormulaInfo": {
"items": {},
"title": "Formulainfo",
"type": "array"
},
"TaskRows": {
"items": {
"$ref": "#/$defs/EntityLink"
},
"title": "Taskrows",
"type": "array"
}
},
"title": "CustomTemplateSearchItemData",
"type": "object"
},
"CustomTemplateSearchItemTeam": {
"properties": {
"id": {
"title": "Id",
"type": "string"
},
"name": {
"title": "Name",
"type": "string"
},
"type": {
"anyOf": [
{
"$ref": "#/$defs/ACLType"
},
{
"type": "null"
}
],
"default": null
},
"fgc": {
"anyOf": [
{
"$ref": "#/$defs/AccessControlLevel"
},
{
"type": "null"
}
],
"default": null
}
},
"required": [
"id",
"name"
],
"title": "CustomTemplateSearchItemTeam",
"type": "object"
},
"DesignLink": {
"properties": {
"id": {
"title": "Id",
"type": "string"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Name"
},
"type": {
"$ref": "#/$defs/DesignType"
}
},
"required": [
"id",
"type"
],
"title": "DesignLink",
"type": "object"
},
"DesignType": {
"description": "The type of Design",
"enum": [
"apps",
"products",
"results",
"process"
],
"title": "DesignType",
"type": "string"
},
"EntityLink": {
"properties": {
"id": {
"title": "Id",
"type": "string"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Name"
}
},
"required": [
"id"
],
"title": "EntityLink",
"type": "object"
},
"SecurityClass": {
"description": "The security class of a resource",
"enum": [
"shared",
"restricted",
"confidential",
"private",
"public"
],
"title": "SecurityClass",
"type": "string"
},
"Status": {
"description": "The status of a resource",
"enum": [
"active",
"inactive"
],
"title": "Status",
"type": "string"
},
"UserClass": {
"description": "The ACL class level of the user",
"enum": [
"guest",
"standard",
"trusted",
"privileged",
"admin"
],
"title": "UserClass",
"type": "string"
}
},
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"albertId": {
"title": "Albertid",
"type": "string"
},
"createdByName": {
"title": "Createdbyname",
"type": "string"
},
"createdAt": {
"title": "Createdat",
"type": "string"
},
"category": {
"title": "Category",
"type": "string"
},
"status": {
"anyOf": [
{
"$ref": "#/$defs/Status"
},
{
"type": "null"
}
],
"default": null
},
"resourceClass": {
"anyOf": [
{
"$ref": "#/$defs/SecurityClass"
},
{
"type": "null"
}
],
"default": null
},
"data": {
"anyOf": [
{
"$ref": "#/$defs/CustomTemplateSearchItemData"
},
{
"type": "null"
}
],
"default": null
},
"acl": {
"items": {
"$ref": "#/$defs/CustomTemplateSearchItemACL"
},
"title": "Acl",
"type": "array"
},
"team": {
"items": {
"$ref": "#/$defs/CustomTemplateSearchItemTeam"
},
"title": "Team",
"type": "array"
}
},
"required": [
"name",
"albertId",
"createdByName",
"createdAt",
"category",
"acl",
"team"
],
"title": "CustomTemplateSearchItem",
"type": "object"
}
Fields:
-
_collection(BaseCollection | None) -
name(str) -
id(str) -
created_by_name(str) -
created_at(str) -
category(str) -
status(Status | None) -
resource_class(SecurityClass | None) -
data(CustomTemplateSearchItemData | None) -
acl(list[CustomTemplateSearchItemACL]) -
team(list[CustomTemplateSearchItemTeam])
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_all |
Retrieve fully hydrated CustomTemplate entities with optional filters. |
get_by_id |
Get a Custom Template by ID |
search |
Search for CustomTemplate matching the provided criteria. |
Source code in src/albert/collections/custom_templates.py
get_all
get_all(
*,
text: str | None = None,
limit: int = 50,
offset: int = 0,
) -> Iterator[CustomTemplate]
Retrieve fully hydrated CustomTemplate entities with optional filters.
This method returns complete entity data using get_by_id.
Use :meth:search for faster retrieval when you only need lightweight, partial (unhydrated) entities.
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
search
search(
*,
text: str | None = None,
limit: int = 50,
offset: int = 0,
) -> Iterator[CustomTemplateSearchItem]
Search for CustomTemplate matching the provided criteria.
⚠️ This method returns partial (unhydrated) entities to optimize performance.
To retrieve fully detailed entities, use :meth:get_all instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The text to search for, by default None |
None
|
Yields:
| Type | Description |
|---|---|
Iterator[CustomTemplateSearchItem]
|
An iterator of CustomTemplateSearchItem items matching the search criteria. |