Entity Types
albert.collections.entity_types.EntityTypeCollection
Bases: BaseCollection
Manage Entity Types in the Albert platform.
An Entity Type is a configurable definition that determines how a particular
kind of entity (a Task, Inventory Item, Project, Data Template, Parameter
Group, or Lot) looks and behaves. It groups together the custom category the
entity falls under, which CustomField
values appear on it, how the standard Notes/Tags/Due Date fields are shown or
required, and how searches for related entities are built.
Entity Types come in two flavors (see
EntityTypeType): system types
ship with the platform, while custom types are defined by an organization
to model its own categories of work. Each type is scoped to a single service
(see EntityServiceType), such as
tasks or inventories.
Entity Types are referenced by their Entity Type ID (format ETT...).
This is configuration/schema-level data; most users read Entity Types to
understand how their platform is set up rather than creating them frequently.
This collection is accessed as client.entity_types.
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 entity type requests. |
Methods:
| Name | Description |
|---|---|
create |
Create a new entity type. |
get_by_id |
Get a single entity type by its ID. |
get_all |
Iterate over entity types, optionally filtered by service. |
update |
Update an existing entity type. |
delete |
Delete an entity type by its ID. |
get_rules |
Get the conditional field rules configured for an entity type. |
set_rules |
Create or replace the conditional field rules for an entity type. |
delete_rules |
Remove the conditional field rules for an entity type. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/entity_types.py
get_by_id
get_by_id(*, id: EntityTypeId) -> EntityType
Get a single entity type by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
EntityTypeId
|
The Entity Type ID (format |
required |
Returns:
| Type | Description |
|---|---|
EntityType
|
The fully populated entity type. |
Source code in src/albert/collections/entity_types.py
create
create(*, entity_type: EntityType) -> EntityType
Create a new entity type.
Example
from albert import Albert
from albert.resources.entity_types import (
EntityCategory,
EntityServiceType,
EntityType,
)
client = Albert()
new_type = EntityType(
label="Stability Task",
service=EntityServiceType.TASKS,
category=EntityCategory.PROPERTY,
)
created = client.entity_types.create(entity_type=new_type)
created.id
# 'ETT1'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_type
|
EntityType
|
The entity type to create. |
required |
Returns:
| Type | Description |
|---|---|
EntityType
|
The newly created entity type, populated with its assigned Entity Type ID. |
Source code in src/albert/collections/entity_types.py
update
update(*, entity_type: EntityType) -> EntityType
Update an existing entity type.
Fetch the entity type (e.g. with get_by_id), modify the updatable
fields on the returned object, then pass it here. Only the fields listed
in Notes are applied; changes to other fields are ignored.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_type
|
EntityType
|
The entity type to update. Must have a valid |
required |
Returns:
| Type | Description |
|---|---|
EntityType
|
The updated entity type. |
Notes
The following fields can be updated: custom_fields, label,
locked_template, search_query_string, standard_field_required,
standard_field_visibility, template_based.
Source code in src/albert/collections/entity_types.py
delete
delete(*, id: EntityTypeId) -> None
Delete an entity type by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
EntityTypeId
|
The Entity Type ID to delete (format |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/entity_types.py
get_rules
get_rules(*, id: EntityTypeId) -> list[EntityTypeRule]
Get the conditional field rules configured for an entity type.
A rule (see EntityTypeRule) makes
one field's behavior depend on the value of another: for example, showing,
hiding, requiring, or setting default options on a target field when a
trigger custom field takes a certain value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
EntityTypeId
|
The Entity Type ID to get the rules for (format |
required |
Returns:
| Type | Description |
|---|---|
list[EntityTypeRule]
|
The configured rules for the entity type. |
Source code in src/albert/collections/entity_types.py
set_rules
set_rules(
*, id: EntityTypeId, rules: list[EntityTypeRule]
) -> list[EntityTypeRule]
Create or replace the conditional field rules for an entity type.
This replaces the entity type's full set of rules with the ones provided.
To read the current rules first, use get_rules; to remove all
rules, use delete_rules.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
EntityTypeId
|
The Entity Type ID to set the rules for (format |
required |
rules
|
list[EntityTypeRule]
|
The rules to apply to the entity type. |
required |
Returns:
| Type | Description |
|---|---|
list[EntityTypeRule]
|
The updated rules as registered in Albert. |
Source code in src/albert/collections/entity_types.py
delete_rules
delete_rules(*, id: EntityTypeId) -> None
Delete all conditional field rules for an entity type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
EntityTypeId
|
The Entity Type ID to remove rules from (format |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/entity_types.py
get_all
get_all(
*,
service: EntityServiceType | None = None,
start_key: str | None = None,
order: OrderBy | None = None,
max_items: int | None = None,
) -> Iterator[EntityType]
Iterate over entity types matching the given filters.
Results are returned as a lazily paginated iterator, so iterating fetches additional pages on demand.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service
|
EntityServiceType
|
Only return entity types associated with this service (e.g. |
None
|
start_key
|
str
|
Provide the |
None
|
order
|
OrderBy
|
Sort direction (ascending or descending). Defaults to the server order. |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, iterates over all matches. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[EntityType]
|
A lazily paginated iterator of matching entity types. |