ayon_api.entity_hub module¶
- class Attributes(attrib_keys, values=<UNKNOWN_VALUE>)[source]¶
Bases:
object
Object representing attribs of entity.
- Todos:
This could be enhanced to know attribute schema and validate values based on the schema.
- Parameters:
attrib_keys (
Iterable[str]
) – Keys that are available in attribs of the entity.values (
Optional[Dict[str, Any]]
) – Values of attributes.
- property changes¶
Attribute value changes.
- Returns:
Key mapping with new values.
- Return type:
Dict[str, Any]
- get(key, default=None)[source]¶
Get value of attribute.
- Parameters:
key (
str
) – Attribute name.default (
Any
) – Default value to return when attribute was not found.
- get_attribute(key)[source]¶
Access to attribute object.
- Parameters:
key (
str
) – Name of attribute.- Returns:
Object of attribute value.
- Return type:
- Raises:
KeyError – When attribute is not available.
- class BaseEntity(entity_id: ~typing.Optional[str] = None, parent_id: ~typing.Optional[Union[str, _CustomNone]] = <UNKNOWN_VALUE>, attribs: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, data: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, active: ~typing.Optional[bool] = <UNKNOWN_VALUE>, created: ~typing.Optional[bool] = None, entity_hub: ~ayon_api.entity_hub.EntityHub = None, name=None, label=None, status: ~typing.Optional[str] = <UNKNOWN_VALUE>, tags: ~typing.Optional[~typing.List[str]] = None, thumbnail_id: ~typing.Optional[str] = <UNKNOWN_VALUE>)[source]¶
Bases:
ABC
Object representation of entity from server which is capturing changes.
All data on created object are expected as “current data” on server entity unless the entity has set ‘created’ to ‘True’. So if new data should be stored to server entity then fill entity with server data first and then change them.
Calling ‘lock’ method will mark entity as “saved” and all changes made on entity are set as “current data” on server.
- Parameters:
entity_id (
Optional[str]
) – Entity id. New id is created if not passed.parent_id (
Optional[str]
) – Parent entity id.attribs (
Optional[Dict[str, Any]]
) – Attribute values.data (
Optional[Dict[str, Any]]
) – Entity data (custom data).thumbnail_id (
Optional[str]
) – Thumbnail id.active (
Optional[bool]
) – Is entity active.entity_hub (
EntityHub
) – Object of entity hub which created object of the entity.created (
Optional[bool]
) – Entity is new. When ‘None’ is passed the value is defined based on value of ‘entity_id’.
- add_child(child)[source]¶
Add child entity.
- Parameters:
child (
BaseEntity
) – Child object to add.- Raises:
TypeError – When child object has invalid type to be children.
- property attribs¶
Entity attributes based on server configuration.
- Returns:
- Attributes object handling changes and values of
attributes on entity.
- Return type:
- abstract property changes: Optional[Dict[str, Any]]¶
Receive entity changes.
- Returns:
- All values that have changed on
entity. New entity must return None.
- Return type:
Optional[Dict[str, Any]]
- property children¶
Access to children objects.
- Returns:
Children iterator.
- Return type:
Union[List[BaseEntity], Type[UNKNOWN_VALUE]]
- property children_ids¶
Access to children objects.
- Todos:
- Children should be maybe handled by EntityHub instead of entities
themselves. That would simplify ‘set_entity_parent’, ‘unset_entity_parent’ and other logic related to changing hierarchy.
- Returns:
Children iterator.
- Return type:
Union[List[str], Type[UNKNOWN_VALUE]]
- property created¶
Entity is new.
- Returns:
Entity is newly created.
- Return type:
bool
- property data¶
Entity custom data that are not stored by any deterministic model.
- Be aware that ‘data’ can’t be queried using GraphQl and cannot be
updated partially.
- Returns:
Custom data on entity.
- Return type:
- abstract property entity_type: EntityType¶
Entity type corresponding to server.
- Returns:
Entity type.
- Return type:
EntityType
- fill_children_ids(children_ids)[source]¶
Fill children ids on entity.
Warning
This is not an api call but is called from entity hub.
- abstract classmethod from_entity_data(entity_data: Dict[str, Any], entity_hub: EntityHub) BaseEntity [source]¶
Create entity based on queried data from server.
- Parameters:
entity_data (
Dict[str, Any]
) – Entity data from server.entity_hub (
EntityHub
) – Hub which handle the entity.
- Returns:
Object of the class.
- Return type:
- get_children(allow_fetch=True)[source]¶
Access to children objects.
- Returns:
Children iterator.
- Return type:
Union[List[BaseEntity], Type[UNKNOWN_VALUE]]
- get_children_ids(allow_fetch=True)[source]¶
Access to children objects.
- Todos:
- Children should be maybe handled by EntityHub instead of entities
themselves. That would simplify ‘set_entity_parent’, ‘unset_entity_parent’ and other logic related to changing hierarchy.
- Returns:
Children iterator.
- Return type:
Union[List[str], Type[UNKNOWN_VALUE]]
- get_parent(allow_fetch=True)[source]¶
Parent entity.
- Returns:
Parent object.
- Return type:
Optional[BaseEntity]
- get_parent_id()[source]¶
Parent entity id.
- Returns:
Parent entity id or none if is not set.
- Return type:
Optional[str]
- get_status() Union[str, _CustomNone] [source]¶
Folder status.
- Returns:
Folder status or ‘UNKNOWN_VALUE’.
- Return type:
Union[str, UNKNOWN_VALUE]
- get_thumbnail_id()[source]¶
Thumbnail id of entity.
- Returns:
Thumbnail id or none if is not set.
- Return type:
Optional[str]
- property has_cached_immutable_hierarchy: bool¶
- property id: str¶
Access to entity id under which is entity available on server.
- Returns:
Entity id.
- Return type:
str
- property immutable_for_hierarchy: bool¶
Entity is immutable for hierarchy changes.
Hierarchy changes can be considered as change of name or parents.
- Returns:
Entity is immutable for hierarchy changes.
- Return type:
bool
- property label: Optional[str]¶
- property name¶
- property orig_parent_id¶
- property parent¶
Parent entity.
- Returns:
Parent object.
- Return type:
Optional[BaseEntity]
- abstract property parent_entity_types: List[str]¶
Entity type corresponding to server.
- Returns:
Possible entity types of parent.
- Return type:
List[str]
- property parent_id¶
Parent entity id.
- Returns:
Parent entity id or none if is not set.
- Return type:
Optional[str]
- property project_name: str¶
Quick access to project from entity hub.
- Returns:
Name of project under which entity lives.
- Return type:
str
- remove_child(child)[source]¶
Remove child entity.
Is ignored if child is not in children.
- Parameters:
child (
Union[str, BaseEntity]
) – Child object or child id to remove.
- property removed: bool¶
- reset_immutable_for_hierarchy_cache(bottom_to_top: Optional[bool] = True)[source]¶
Clear cache of immutable hierarchy property.
This is used when entity changed parent or a child was added.
- Parameters:
bottom_to_top (
bool
) – Reset cache from top hierarchy to bottom or from bottom hierarchy to top.
- set_parent(parent)[source]¶
Change parent object.
- Parameters:
parent (
BaseEntity
) – New parent for entity.- Raises:
TypeError – If validation of parent does not pass.
- set_parent_id(parent_id)[source]¶
Change parent by id.
- Parameters:
parent_id (
Optional[str]
) – Id of new parent for entity.- Raises:
ValueError – If parent was not found by id.
TypeError – If validation of parent does not pass.
- set_status(status_name: str)[source]¶
Set folder status.
- Parameters:
status_name (
str
) – Status name.
- set_thumbnail_id(thumbnail_id)[source]¶
Change thumbnail id.
- Parameters:
thumbnail_id (
Union[str, None]
) – Thumbnail id for entity.
- property status: Union[str, _CustomNone]¶
Folder status.
- Returns:
Folder status or ‘UNKNOWN_VALUE’.
- Return type:
Union[str, UNKNOWN_VALUE]
- property tags¶
Task tags.
- Returns:
Task tags.
- Return type:
list[str]
- property thumbnail_id¶
Thumbnail id of entity.
- Returns:
Thumbnail id or none if is not set.
- Return type:
Optional[str]
- class EntityData(*args, **kwargs)[source]¶
Bases:
dict
Wrapper for ‘data’ key on entity.
Data on entity are arbitrary data that are not stored in any deterministic model. It is possible to store any data that can be parsed to json.
It is not possible to store ‘None’ to root key. In that case the key is not stored, and removed if existed on entity. To be able to store ‘None’ value use nested data structure:
{ "sceneInfo": { "description": None, "camera": "camera1" } }
- get_changes()[source]¶
Changes in entity data.
Removed keys have value set to ‘None’.
- Returns:
Key mapping with changed values.
- Return type:
dict[str, Any]
- class EntityHub(project_name, connection=None, allow_data_changes=None)[source]¶
Bases:
object
Helper to create, update or remove entities in project.
The hub is a guide to operation with folder entities and update of project. Project entity must already exist on server (can be only updated).
Object is caching entities queried from server. They won’t be required once they were queried, so it is recommended to create new hub or clear cache frequently.
- Todos:
- Listen to server events about entity changes to be able to update
already queried entities.
- Parameters:
project_name (
str
) – Name of project where changes will happen.connection (
ServerAPI
) – Connection to server with logged user.allow_data_changes (
bool
) – This option gives ability to change ‘data’ key on entities. This is not recommended as ‘data’ may be used for secure information and would also slow down server queries. Content of ‘data’ key can’t be received only GraphQl.
- add_entity(entity)[source]¶
Add entity to hub cache.
- Parameters:
entity (
BaseEntity
) – Entity that should be added to hub’s cache.
- add_folder(folder)[source]¶
Create folder object and add it to entity hub.
- Parameters:
folder (
Dict[str, Any]
) – Folder entity data.- Returns:
Added folder entity.
- Return type:
- add_new_folder(name: str, folder_type: str, parent_id: ~typing.Optional[str] = <UNKNOWN_VALUE>, label: ~typing.Optional[str] = None, path: ~typing.Optional[str] = None, status: ~typing.Optional[str] = <UNKNOWN_VALUE>, tags: ~typing.Optional[~typing.List[str]] = None, attribs: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, data: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, thumbnail_id: ~typing.Optional[str] = <UNKNOWN_VALUE>, active: bool = <UNKNOWN_VALUE>, entity_id: ~typing.Optional[str] = None, created: ~typing.Optional[bool] = True)[source]¶
Create folder object and add it to entity hub.
- Parameters:
name (
str
) – Name of entity.folder_type (
str
) – Type of folder. Folder type must be available in config of project folder types.parent_id (
Union[str, None]
) – Id of parent entity.label (
Optional[str]
) – Folder label.path (
Optional[str]
) – Folder path. Path consist of all parent names with slash(‘/’) used as separator.status (
Optional[str]
) – Folder status.tags (
Optional[List[str]]
) – Folder tags.attribs (
Dict[str, Any]
) – Attribute values.data (
Dict[str, Any]
) – Entity data (custom data).thumbnail_id (
Union[str, None]
) – Id of entity’s thumbnail.active (
bool
) – Is entity active.entity_id (
Optional[str]
) – Id of the entity. New id is created if not passed.created (
Optional[bool]
) – Entity is new. When ‘None’ is passed the value is defined based on value of ‘entity_id’.
- Returns:
Added folder entity.
- Return type:
- add_new_product(name: str, product_type: str, folder_id: ~typing.Optional[Union[str, _CustomNone]] = <UNKNOWN_VALUE>, tags: ~typing.Optional[~typing.Iterable[str]] = None, attribs: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, data: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, active: ~typing.Optional[bool] = <UNKNOWN_VALUE>, entity_id: ~typing.Optional[str] = None, created: ~typing.Optional[bool] = True)[source]¶
Create task object and add it to entity hub.
- Parameters:
name (
str
) – Name of entity.product_type (
str
) – Type of product.folder_id (
Union[str, None]
) – Parent folder id.tags (
Optional[Iterable[str]]
) – Folder tags.attribs (
Dict[str, Any]
) – Attribute values.data (
Dict[str, Any]
) – Entity data (custom data).active (
bool
) – Is entity active.entity_id (
Optional[str]
) – Id of the entity. New id is created if not passed.created (
Optional[bool]
) – Entity is new. When ‘None’ is passed the value is defined based on value of ‘entity_id’.
- Returns:
Added product entity.
- Return type:
- add_new_task(name: str, task_type: str, folder_id: ~typing.Optional[str] = <UNKNOWN_VALUE>, label: ~typing.Optional[str] = None, status: ~typing.Optional[str] = <UNKNOWN_VALUE>, tags: ~typing.Optional[~typing.Iterable[str]] = None, attribs: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, data: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, assignees: ~typing.Optional[~typing.Iterable[str]] = None, thumbnail_id: ~typing.Optional[str] = <UNKNOWN_VALUE>, active: ~typing.Optional[bool] = <UNKNOWN_VALUE>, entity_id: ~typing.Optional[str] = None, created: ~typing.Optional[bool] = True, parent_id: ~typing.Optional[str] = <UNKNOWN_VALUE>)[source]¶
Create task object and add it to entity hub.
- Parameters:
name (
str
) – Name of entity.task_type (
str
) – Type of task. Task type must be available in config of project task types.folder_id (
Union[str, None]
) – Parent folder id.label (
Optional[str]
) – Task label.status (
Optional[str]
) – Task status.tags (
Optional[Iterable[str]]
) – Folder tags.attribs (
Dict[str, Any]
) – Attribute values.data (
Dict[str, Any]
) – Entity data (custom data).assignees (
Optional[Iterable[str]]
) – User assignees to the task.thumbnail_id (
Union[str, None]
) – Id of entity’s thumbnail.active (
bool
) – Is entity active.entity_id (
Optional[str]
) – Id of the entity. New id is created if not passed.created (
Optional[bool]
) – Entity is new. When ‘None’ is passed the value is defined based on value of ‘entity_id’.parent_id (
Union[str, None]
) – DEPRECATED Parent folder id.
- Returns:
Added task entity.
- Return type:
- add_new_version(version: int, product_id: ~typing.Optional[Union[str, _CustomNone]] = <UNKNOWN_VALUE>, task_id: ~typing.Optional[Union[str, _CustomNone]] = <UNKNOWN_VALUE>, status: ~typing.Optional[str] = <UNKNOWN_VALUE>, tags: ~typing.Optional[~typing.Iterable[str]] = None, attribs: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, data: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, thumbnail_id: ~typing.Optional[str] = <UNKNOWN_VALUE>, active: ~typing.Optional[bool] = <UNKNOWN_VALUE>, entity_id: ~typing.Optional[str] = None, created: ~typing.Optional[bool] = True)[source]¶
Create task object and add it to entity hub.
- Parameters:
version (
int
) – Version.product_id (
Union[str, None]
) – Parent product id.task_id (
Union[str, None]
) – Parent task id.status (
Optional[str]
) – Task status.tags (
Optional[Iterable[str]]
) – Folder tags.attribs (
Dict[str, Any]
) – Attribute values.data (
Dict[str, Any]
) – Entity data (custom data).thumbnail_id (
Union[str, None]
) – Id of entity’s thumbnail.active (
bool
) – Is entity active.entity_id (
Optional[str]
) – Id of the entity. New id is created if not passed.created (
Optional[bool]
) – Entity is new. When ‘None’ is passed the value is defined based on value of ‘entity_id’.
- Returns:
Added version entity.
- Return type:
- add_product(product)[source]¶
Create version object and add it to entity hub.
- Parameters:
product (
Dict[str, Any]
) – Version entity data.- Returns:
Added version entity.
- Return type:
- add_task(task)[source]¶
Create task object and add it to entity hub.
- Parameters:
task (
Dict[str, Any]
) – Task entity data.- Returns:
Added task entity.
- Return type:
- add_version(version)[source]¶
Create version object and add it to entity hub.
- Parameters:
version (
Dict[str, Any]
) – Version entity data.- Returns:
Added version entity.
- Return type:
- property allow_data_changes¶
Entity hub allows changes of ‘data’ key on entities.
Data are private and not all users may have access to them.
Older version of AYON server allowed to get ‘data’ for entity only using REST api calls, which means to query each entity on-by-one from server.
- Returns:
Data changes are allowed.
- Return type:
bool
- property entities¶
Iterator over available entities.
- Returns:
All queried/created entities cached in hub.
- Return type:
Iterator[BaseEntity]
- fill_project_from_server()[source]¶
Query project data from server and create project entity.
This method will invalidate previous object of Project entity.
- Returns:
Entity that was updated with server data.
- Return type:
- Raises:
ValueError – When project was not found on server.
- folder_path_reseted(folder_id)[source]¶
Method called from ‘FolderEntity’ on path reset.
This should reset cache of folder paths on all children entities.
The path cache is always propagated from top to bottom so if an entity has not cached path it means that any children can’t have it cached.
- get_attributes_for_type(entity_type: EntityType)[source]¶
Get attributes available for a type.
Attributes are based on entity types.
- Todos:
Use attribute schema to validate values on entities.
- Parameters:
entity_type (
EntityType
) – Entity type for which should be attributes received.- Returns:
- Attribute schemas that are available
for entered entity type.
- Return type:
Dict[str, Dict[str, Any]]
- get_entity_by_id(entity_id: str) Optional[BaseEntity] [source]¶
Receive entity by its id without entity type.
The entity must be already existing in cached objects.
- Parameters:
entity_id (
str
) – Id of entity.- Returns:
Entity object or None.
- Return type:
Optional[BaseEntity]
- get_folder_by_id(entity_id: str, allow_fetch: Optional[bool] = True) Optional[FolderEntity] [source]¶
Get folder entity by id.
- Parameters:
entity_id (
str
) – Folder entity id.allow_fetch (
bool
) – Try to fetch entity from server if is not available in cache.
- Returns:
Folder entity object.
- Return type:
Optional[FolderEntity]
- get_or_fetch_entity_by_id(entity_id: str, entity_types: List[EntityType])[source]¶
Get or query entity based on it’s id and possible entity types.
This is a helper function when entity id is known but entity type may have multiple possible options.
- Parameters:
entity_id (
str
) – Entity id.entity_types (
Iterable[str]
) – Possible entity types that can the id represent. e.g. ‘[“folder”, “project”]’
- get_product_by_id(entity_id: str, allow_fetch: Optional[bool] = True) Optional[ProductEntity] [source]¶
Get product entity by id.
- Parameters:
entity_id (
str
) – Product id.allow_fetch (
bool
) – Try to fetch entity from server if is not available in cache.
- Returns:
Product entity object or None.
- Return type:
Optional[ProductEntity]
- get_task_by_id(entity_id: str, allow_fetch: Optional[bool] = True) Optional[TaskEntity] [source]¶
Get task entity by id.
- Parameters:
entity_id (
str
) – Id of task entity.allow_fetch (
bool
) – Try to fetch entity from server if is not available in cache.
- Returns:
Task entity object or None.
- Return type:
Optional[TaskEntity]
- get_version_by_id(entity_id: str, allow_fetch: Optional[bool] = True) Optional[VersionEntity] [source]¶
Get version entity by id.
- Parameters:
entity_id (
str
) – Version id.allow_fetch (
bool
) – Try to fetch entity from server if is not available in cache.
- Returns:
Version entity object or None.
- Return type:
Optional[VersionEntity]
- property path_start_with_slash¶
Folder path should start with slash.
This changed in 0.6.x server version.
- Returns:
Path starts with slash.
- Return type:
bool
- property project_entity¶
Project entity.
- Returns:
Project entity.
- Return type:
- property project_name¶
Project name which is maintained by hub.
- Returns:
Name of project.
- Return type:
str
- class FolderEntity(name: str, folder_type: str, parent_id: ~typing.Optional[str] = <UNKNOWN_VALUE>, label: ~typing.Optional[str] = None, path: ~typing.Optional[str] = None, status: ~typing.Optional[str] = <UNKNOWN_VALUE>, tags: ~typing.Optional[~typing.List[str]] = None, attribs: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, data: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, thumbnail_id: ~typing.Optional[str] = <UNKNOWN_VALUE>, active: bool = <UNKNOWN_VALUE>, entity_id: ~typing.Optional[str] = None, created: ~typing.Optional[bool] = None, entity_hub: ~typing.Optional[~ayon_api.entity_hub.EntityHub] = None)[source]¶
Bases:
BaseEntity
Entity representing a folder on AYON server.
- Parameters:
name (
str
) – Name of entity.folder_type (
str
) – Type of folder. Folder type must be available in config of project folder types.parent_id (
Union[str, None]
) – Id of parent entity.label (
Optional[str]
) – Folder label.path (
Optional[str]
) – Folder path. Path consist of all parent names with slash(‘/’) used as separator.status (
Optional[str]
) – Folder status.tags (
Optional[List[str]]
) – Folder tags.attribs (
Dict[str, Any]
) – Attribute values.data (
Dict[str, Any]
) – Entity data (custom data).thumbnail_id (
Union[str, None]
) – Id of entity’s thumbnail.active (
bool
) – Is entity active.entity_id (
Union[str, None]
) – Id of the entity. New id is created if not passed.created (
Optional[bool]
) – Entity is new. When ‘None’ is passed the value is defined based on value of ‘entity_id’.entity_hub (
EntityHub
) – Object of entity hub which created object of the entity.
- property changes¶
Receive entity changes.
- Returns:
- All values that have changed on
entity. New entity must return None.
- Return type:
Optional[Dict[str, Any]]
- entity_type = 'folder'¶
- property folder_type: str¶
- classmethod from_entity_data(folder, entity_hub) FolderEntity [source]¶
Create entity based on queried data from server.
- Parameters:
entity_data (
Dict[str, Any]
) – Entity data from server.entity_hub (
EntityHub
) – Hub which handle the entity.
- Returns:
Object of the class.
- Return type:
- property has_published_content¶
- parent_entity_types = ['folder', 'project']¶
- property path¶
- class ProductEntity(name: str, product_type: str, folder_id: ~typing.Optional[Union[str, _CustomNone]] = <UNKNOWN_VALUE>, tags: ~typing.Optional[~typing.Iterable[str]] = None, attribs: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, data: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, active: ~typing.Optional[bool] = <UNKNOWN_VALUE>, entity_id: ~typing.Optional[str] = None, created: ~typing.Optional[bool] = None, entity_hub: ~ayon_api.entity_hub.EntityHub = None)[source]¶
Bases:
BaseEntity
- property changes¶
Receive entity changes.
- Returns:
- All values that have changed on
entity. New entity must return None.
- Return type:
Optional[Dict[str, Any]]
- entity_type = 'product'¶
- property folder_id¶
- classmethod from_entity_data(product, entity_hub)[source]¶
Create entity based on queried data from server.
- Parameters:
entity_data (
Dict[str, Any]
) – Entity data from server.entity_hub (
EntityHub
) – Hub which handle the entity.
- Returns:
Object of the class.
- Return type:
- parent_entity_types = ['folder']¶
- property product_type¶
- class ProjectEntity(name: str, project_code: str, library: bool, folder_types: ~typing.List[~typing.Dict[str, ~typing.Any]], task_types: ~typing.List[~typing.Dict[str, ~typing.Any]], statuses: ~typing.List[~typing.Dict[str, ~typing.Any]], attribs: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, data: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, active: ~typing.Optional[bool] = <UNKNOWN_VALUE>, entity_hub: ~typing.Optional[~ayon_api.entity_hub.EntityHub] = None)[source]¶
Bases:
BaseEntity
Entity representing project on AYON server.
- Parameters:
name (
str
) – Name of entity.project_code (
str
) – Project code.library (
bool
) – Is project library project.folder_types (
list[dict[str, Any]]
) – Folder types definition.task_types (
list[dict[str, Any]]
) – Task types definition.statuses – (list[dict[str, Any]]): Statuses definition.
attribs (
Optional[Dict[str, Any]]
) – Attribute values.data (
Dict[str, Any]
) – Entity data (custom data).active (
bool
) – Is entity active.entity_hub (
EntityHub
) – Object of entity hub which created object of the entity.
- property changes¶
Receive entity changes.
- Returns:
- All values that have changed on
entity. New entity must return None.
- Return type:
Optional[Dict[str, Any]]
- default_folder_type_icon = 'folder'¶
- default_task_type_icon = 'task_alt'¶
- entity_type = 'project'¶
- property folder_types¶
- classmethod from_entity_data(project, entity_hub) ProjectEntity [source]¶
Create entity based on queried data from server.
- Parameters:
entity_data (
Dict[str, Any]
) – Entity data from server.entity_hub (
EntityHub
) – Hub which handle the entity.
- Returns:
Object of the class.
- Return type:
- get_parent(*args, **kwargs)[source]¶
Parent entity.
- Returns:
Parent object.
- Return type:
Optional[BaseEntity]
- get_status_by_slugified_name(name)[source]¶
Find status by name.
- Parameters:
name (
str
) – Status name.- Returns:
Status object or None.
- Return type:
Union[ProjectStatus, None]
- property parent¶
Parent entity.
- Returns:
Parent object.
- Return type:
Optional[BaseEntity]
- parent_entity_types = []¶
- set_parent(parent)[source]¶
Change parent object.
- Parameters:
parent (
BaseEntity
) – New parent for entity.- Raises:
TypeError – If validation of parent does not pass.
- property statuses¶
- property task_types¶
- class ProjectStatus(name, short_name=None, state=None, icon=None, color=None, scope=None, index=None, project_statuses=None, is_new=None)[source]¶
Bases:
object
Project status class.
- Parameters:
name (
str
) – Name of the status. e.g. ‘In progress’short_name (
Optional[str]
) – Short name of the status. e.g. ‘IP’state (
Optional[StatusState]
) – A state of the status.icon (
Optional[str]
) – Icon of the status. e.g. ‘play_arrow’.color (
Optional[str]
) – Color of the status. e.g. ‘#eeeeee’.scope (
Optional[Iterable[str]]
) – Scope of the status. e.g. [‘folder’].index (
Optional[int]
) – Index of the status.project_statuses (
Optional[_ProjectStatuses]
) – Project statuses wrapper.
- property changed¶
Status has changed.
- Returns:
Status has changed.
- Return type:
bool
- property color¶
Get color of project status.
- Returns:
Status color.
- Return type:
str
- color_regex = re.compile('#([a-f0-9]{6})$')¶
- default_color = '#eeeeee'¶
- default_state = 'in_progress'¶
- classmethod from_data(data, index=None, project_statuses=None)[source]¶
Create project status from data.
- Parameters:
data (
dict[str, str]
) – Status data.index (
Optional[int]
) – Status index.project_statuses (
Optional[ProjectStatuses]
) – Project statuses object which wraps the status for a project.
- get_index()[source]¶
Get index of status.
- Returns:
- Index of status or None if status is not under
project.
- Return type:
Union[int, None]
- get_project_statuses()[source]¶
Internal logic method.
- Returns:
Project statuses object.
- Return type:
_ProjectStatuses
- get_short_name()[source]¶
Status short name 3 letters tops.
- Returns:
Status short name.
- Return type:
str
- get_state()[source]¶
Get state of project status.
- Returns:
General state of status.
- Return type:
StatusState
- property icon¶
Name of icon to use for status.
- Returns:
Name of the icon.
- Return type:
str
- property index¶
Get index of status.
- Returns:
- Index of status or None if status is not under
project.
- Return type:
Union[int, None]
- move_after(other)[source]¶
Move status after other status.
- Parameters:
other (
ProjectStatus
) – Status to move after.
- move_before(other)[source]¶
Move status before other status.
- Parameters:
other (
ProjectStatus
) – Status to move before.
- property name¶
Status name.
- Returns:
Status name.
- Return type:
str
- property project_statuses¶
Internal logic method.
- Returns:
Project statuses object.
- Return type:
_ProjectStatuses
- property scope¶
Get scope of the status.
- Returns:
Scope of the status.
- Return type:
Set[str]
- set_color(color)[source]¶
Set color of project status.
- Parameters:
color (
str
) – Color in hex format. Example: ‘#ff0000’.
- set_index(index, **kwargs)[source]¶
Change status index.
- Returns:
- Index of status or None if status is not under
project.
- Return type:
Union[int, None]
- set_project_statuses(project_statuses)[source]¶
Internal logic method to change parent object.
- Parameters:
project_statuses (
_ProjectStatuses
) – Project statuses object.
- set_scope(scope)[source]¶
Get scope of the status.
- Returns:
Scope of the status.
- Return type:
scope (Iterable[str])
- set_short_name(short_name)[source]¶
Change status short name.
- Parameters:
short_name (
str
) – New status short name. 3 letters tops.
- set_state(state)[source]¶
Set color of project status.
- Parameters:
state (
StatusState
) – General state of status.
- property short_name¶
Status short name 3 letters tops.
- Returns:
Status short name.
- Return type:
str
- property slugified_name¶
Slugified and lowere status name.
- Can be used for comparison of existing statuses. e.g. ‘In Progress’
vs. ‘in-progress’.
- Returns:
Slugified and lower status name.
- Return type:
str
- static slugify_name(name)[source]¶
Slugify status name for name comparison.
- Parameters:
name (
str
) – Name of the status.- Returns:
Slugified name.
- Return type:
str
- property state¶
Get state of project status.
- Returns:
General state of status.
- Return type:
StatusState
- unset_project_statuses(project_statuses)[source]¶
Internal logic method to unset parent object.
- Parameters:
project_statuses (
_ProjectStatuses
) – Project statuses object.
- valid_scope = {'folder', 'product', 'representation', 'task', 'version', 'workfile'}¶
- valid_states = {'blocked', 'done', 'in_progress', 'not_started'}¶
- class TaskEntity(name: str, task_type: str, folder_id: ~typing.Optional[str] = <UNKNOWN_VALUE>, label: ~typing.Optional[str] = None, status: ~typing.Optional[str] = <UNKNOWN_VALUE>, tags: ~typing.Optional[~typing.Iterable[str]] = None, attribs: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, data: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, assignees: ~typing.Optional[~typing.Iterable[str]] = None, thumbnail_id: ~typing.Optional[str] = <UNKNOWN_VALUE>, active: ~typing.Optional[bool] = <UNKNOWN_VALUE>, entity_id: ~typing.Optional[str] = None, created: ~typing.Optional[bool] = None, entity_hub: ~typing.Optional[~ayon_api.entity_hub.EntityHub] = None)[source]¶
Bases:
BaseEntity
Entity representing a task on AYON server.
- Parameters:
name (
str
) – Name of entity.task_type (
str
) – Type of task. Task type must be available in config of project task types.folder_id (
Union[str, None]
) – Parent folder id.label (
Optional[str]
) – Task label.status (
Optional[str]
) – Task status.tags (
Optional[Iterable[str]]
) – Folder tags.attribs (
Dict[str, Any]
) – Attribute values.data (
Dict[str, Any]
) – Entity data (custom data).assignees (
Optional[Iterable[str]]
) – User assignees to the task.thumbnail_id (
Union[str, None]
) – Id of entity’s thumbnail.active (
bool
) – Is entity active.entity_id (
Union[str, None]
) – Id of the entity. New id is created if not passed.created (
Optional[bool]
) – Entity is new. When ‘None’ is passed the value is defined based on value of ‘entity_id’.entity_hub (
EntityHub
) – Object of entity hub which created object of the entity.
- add_child(child)[source]¶
Add child entity.
- Parameters:
child (
BaseEntity
) – Child object to add.- Raises:
TypeError – When child object has invalid type to be children.
- property assignees¶
Task assignees.
- Returns:
Task assignees.
- Return type:
list[str]
- property changes¶
Receive entity changes.
- Returns:
- All values that have changed on
entity. New entity must return None.
- Return type:
Optional[Dict[str, Any]]
- entity_type = 'task'¶
- property folder_id¶
- classmethod from_entity_data(task, entity_hub) TaskEntity [source]¶
Create entity based on queried data from server.
- Parameters:
entity_data (
Dict[str, Any]
) – Entity data from server.entity_hub (
EntityHub
) – Hub which handle the entity.
- Returns:
Object of the class.
- Return type:
- parent_entity_types = ['folder']¶
- set_assignees(assignees)[source]¶
Change assignees.
- Parameters:
assignees (
Iterable[str]
) – assignees.
- property task_type: str¶
- class VersionEntity(version: int, product_id: ~typing.Optional[Union[str, _CustomNone]] = <UNKNOWN_VALUE>, task_id: ~typing.Optional[Union[str, _CustomNone]] = <UNKNOWN_VALUE>, status: ~typing.Optional[str] = <UNKNOWN_VALUE>, tags: ~typing.Optional[~typing.Iterable[str]] = None, attribs: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, data: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = <UNKNOWN_VALUE>, thumbnail_id: ~typing.Optional[str] = <UNKNOWN_VALUE>, active: ~typing.Optional[bool] = <UNKNOWN_VALUE>, entity_id: ~typing.Optional[str] = None, created: ~typing.Optional[bool] = None, entity_hub: ~ayon_api.entity_hub.EntityHub = None)[source]¶
Bases:
BaseEntity
- property changes¶
Receive entity changes.
- Returns:
- All values that have changed on
entity. New entity must return None.
- Return type:
Optional[Dict[str, Any]]
- entity_type = 'version'¶
- classmethod from_entity_data(version, entity_hub)[source]¶
Create entity based on queried data from server.
- Parameters:
entity_data (
Dict[str, Any]
) – Entity data from server.entity_hub (
EntityHub
) – Hub which handle the entity.
- Returns:
Object of the class.
- Return type:
- parent_entity_types = ['product']¶
- property product_id¶
- property task_id¶
- to_create_body_data()[source]¶
Convert object of entity to data for server on creation.
- Returns:
Entity data.
- Return type:
Dict[str, Any]
- property version¶