Custom Templates
albert.collections.custom_templates.CustomTemplatesCollection
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 |
|---|---|
create |
Creates one or more custom templates. |
get_by_id |
Get a Custom Template by ID |
search |
Search for CustomTemplate matching the provided criteria. |
get_all |
Iterate over CustomTemplate entities with optional filters. |
delete |
Delete a custom template by id. |
update_acl |
Replace a template's ACL class and/or entries with the provided values. |
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
|
Source code in src/albert/collections/custom_templates.py
create
create(
*,
custom_template: CustomTemplate | list[CustomTemplate],
) -> list[CustomTemplate]
Creates one or more custom templates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
custom_template
|
CustomTemplate | list[CustomTemplate]
|
The template entities to create. |
required |
Returns:
| Type | Description |
|---|---|
list[CustomTemplate]
|
The created CustomTemplate entities. |
Source code in src/albert/collections/custom_templates.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 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 | |
get_by_id
get_by_id(*, id: CustomTemplateId) -> 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 |
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 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
|
Free text search term. |
None
|
offset
|
int
|
Starting offset for pagination. |
0
|
sort_by
|
str
|
Field to sort on. |
None
|
order_by
|
OrderBy
|
Sort direction for |
None
|
status
|
Status | str
|
Filter results by template status. |
None
|
created_by
|
str
|
Filter by creator id. |
None
|
category
|
TemplateCategory | list[TemplateCategory]
|
Filter by template categories. |
None
|
created_by_name
|
str | list[str]
|
Filter by creator display name(s). |
None
|
collaborator
|
str | list[str]
|
Filter by collaborator ids. |
None
|
facet_text
|
str
|
Filter text within a facet. |
None
|
facet_field
|
str
|
Facet field to search inside. |
None
|
contains_field
|
str | list[str]
|
Fields to apply contains search to. |
None
|
contains_text
|
str | list[str]
|
Text values for contains search. |
None
|
my_role
|
str | list[str]
|
Restrict templates to roles held by the calling user. |
None
|
max_items
|
int
|
Maximum number of items to yield client-side. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[CustomTemplateSearchItem]
|
An iterator of CustomTemplateSearchItem items. |
Source code in src/albert/collections/custom_templates.py
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 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
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 CustomTemplate entities with optional filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | list[str]
|
Filter by template name(s). |
None
|
created_by
|
str
|
Filter by creator id. |
None
|
category
|
TemplateCategory
|
Filter by category. |
None
|
start_key
|
str
|
Provide the |
None
|
max_items
|
int
|
Maximum number of items to return. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[CustomTemplate]
|
An iterator of CustomTemplates. |
Source code in src/albert/collections/custom_templates.py
delete
delete(*, id: CustomTemplateId) -> None
Delete a custom template by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
CustomTemplateId
|
The id of the custom template to delete. |
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 entries with the provided values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
custom_template_id
|
CustomTemplateId
|
The id of the custom template to update. |
required |
acl_class
|
str | None
|
The ACL class to set (if provided). |
None
|
acls
|
list[ACL] | None
|
The ACL entries to replace on the template. |
None
|
Returns:
| Type | Description |
|---|---|
CustomTemplate
|
The updated CustomTemplate. |
Source code in src/albert/collections/custom_templates.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |