Custom Templates
albert.collections.custom_templates.CustomTemplatesCollection
Bases: BaseCollection
Manage Custom Templates in the Albert platform.
A Custom Template is a reusable, pre-configured template that seeds a new
entity with a standard setup. Depending on its
TemplateCategory, a template can
prefill a Property task, Batch task, Sheet, Notebook, or a general task with
default fields such as project, location, assignee, inventories, workflow,
priority, and metadata. Applying a template saves users from rebuilding the
same configuration each time.
Custom Template IDs use the CTP prefix. This is configuration/schema-level
data.
This collection is accessed as client.custom_templates.
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 custom template requests. |
Methods:
| Name | Description |
|---|---|
create |
Create one or more custom templates (up to 10 at once). |
get_by_id |
Get a single fully populated template by its ID. |
search |
Fast, lightweight search returning partial templates. |
get_all |
Iterate over fully populated templates matching optional filters. |
delete |
Delete a template by its ID. |
update_acl |
Replace a template's ACL class and/or access entries. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/custom_templates.py
create
create(
*,
custom_template: CustomTemplate | list[CustomTemplate],
) -> list[CustomTemplate]
Create one or more custom templates.
Up to 10 templates can be created in a single call. Each created template is re-fetched so the returned entities are fully populated.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
custom_template
|
CustomTemplate or list[CustomTemplate]
|
The template(s) to create. At least one and at most 10 are required. |
required |
Returns:
| Type | Description |
|---|---|
list[CustomTemplate]
|
The newly created templates, each populated with its assigned Custom Template ID. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no templates are provided, or if more than 10 are provided. |
Source code in src/albert/collections/custom_templates.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
get_by_id
get_by_id(*, id: CustomTemplateId) -> CustomTemplate
Get a single, fully populated custom template by its ID.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
CustomTemplateId
|
The Custom Template ID (format |
required |
Returns:
| Type | Description |
|---|---|
CustomTemplate
|
The fully populated template. |
Source code in src/albert/collections/custom_templates.py
search
search(
*,
text: str | None = None,
offset: int | None = 0,
sort_by: str | None = None,
order_by: OrderBy | None = None,
status: Status | None = None,
created_by: str | None = None,
category: TemplateCategory
| list[TemplateCategory]
| None = None,
created_by_name: str | list[str] | None = None,
collaborator: str | list[str] | None = None,
facet_text: str | None = None,
facet_field: str | None = None,
contains_field: str | list[str] | None = None,
contains_text: str | list[str] | None = None,
my_role: str | list[str] | None = None,
max_items: int | None = None,
) -> Iterator[CustomTemplateSearchItem]
Search for custom templates matching the given filters.
Returns lightweight, partially populated results and is the fastest way to
look templates up. When you need complete templates, use get_all,
or pass a resulting ID to get_by_id. Results are returned as a
lazily paginated iterator.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Free-text search term. |
None
|
sort_by
|
str
|
Field to sort on. |
None
|
order_by
|
OrderBy
|
Sort direction for |
None
|
status
|
Status
|
Filter results by template status. |
None
|
created_by
|
str
|
Filter by creator ID. |
None
|
category
|
TemplateCategory or list[TemplateCategory]
|
Filter by template category (or categories). |
None
|
created_by_name
|
str or list[str]
|
Filter by creator display name(s). |
None
|
collaborator
|
str or list[str]
|
Filter by collaborator ID(s). |
None
|
facet_text
|
str
|
Text to match within a facet. |
None
|
facet_field
|
str
|
The facet field to search inside. |
None
|
contains_field
|
str or list[str]
|
Field(s) to apply a "contains" search to. |
None
|
contains_text
|
str or list[str]
|
Text value(s) for the "contains" search. |
None
|
my_role
|
str or list[str]
|
Restrict results to templates where the calling user holds the given role(s). |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, iterates over all matches. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[CustomTemplateSearchItem]
|
A lazily paginated iterator of partially populated search results. |
Source code in src/albert/collections/custom_templates.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
get_all
get_all(
*,
name: str | list[str] | None = None,
created_by: str | None = None,
category: TemplateCategory | None = None,
start_key: str | None = None,
max_items: int | None = None,
) -> Iterator[CustomTemplate]
Iterate over fully populated custom templates matching the filters.
Returns complete CustomTemplate entities rather than lightweight
search results, so prefer search when you only need names, IDs, or
counts. Results are returned as a lazily paginated iterator.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str or list[str]
|
Filter by template name(s). |
None
|
created_by
|
str
|
Filter by creator ID. |
None
|
category
|
TemplateCategory
|
Filter by template category. |
None
|
start_key
|
str
|
Provide the |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, iterates over all matches. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[CustomTemplate]
|
A lazily paginated iterator of fully populated templates. |
Source code in src/albert/collections/custom_templates.py
delete
delete(*, id: CustomTemplateId) -> None
Delete a custom template by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
CustomTemplateId
|
The Custom Template ID to delete (format |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/custom_templates.py
update_acl
update_acl(
*,
custom_template_id: CustomTemplateId,
acl_class: str | None = None,
acls: list[ACL] | None = None,
) -> CustomTemplate
Replace a template's ACL class and/or access entries.
Updates who can access a template. Provide acl_class to change the
ACL class, acls to replace the list of access entries, or both. When
acls is given, the template's current entries are diffed against it so
that entries are added, updated, or removed as needed.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
custom_template_id
|
CustomTemplateId
|
The Custom Template ID to update (format |
required |
acl_class
|
str
|
The ACL class to set on the template. |
None
|
acls
|
list[ACL]
|
The full set of ACL entries the template should end up with. |
None
|
Returns:
| Type | Description |
|---|---|
CustomTemplate
|
The updated template. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither |
Source code in src/albert/collections/custom_templates.py
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |