@@ -26,7 +26,15 @@ def get_entity_lists(
2626 active : Optional [bool ] = None ,
2727 fields : Optional [Iterable [str ]] = None ,
2828 ) -> Generator [dict [str , Any ], None , None ]:
29- """Fetch entity lists from server.
29+ """Fetch entity lists from AYON server.
30+
31+ Warnings:
32+ You can't get list items for lists with different 'entityType' in
33+ one call.
34+
35+ Notes:
36+ To get list items, you have to pass 'items' field or
37+ 'items.{sub-fields you want}' to 'fields' argument.
3038
3139 Args:
3240 project_name (str): Project name where entity lists are.
@@ -42,7 +50,30 @@ def get_entity_lists(
4250 """
4351 if fields is None :
4452 fields = self .get_default_fields_for_type ("entityList" )
45- fields = set (fields )
53+
54+ # List does not have 'attrib' field but has 'allAttrib' field
55+ # which is json string and contains only values that are set
56+ o_fields = tuple (fields )
57+ fields = set ()
58+ requires_attrib = False
59+ for field in o_fields :
60+ if field == "attrib" or field .startswith ("attrib." ):
61+ requires_attrib = True
62+ field = "allAttrib"
63+ fields .add (field )
64+
65+ if "items" in fields :
66+ fields .discard ("items" )
67+ fields |= {
68+ "items.id" ,
69+ "items.entityId" ,
70+ "items.entityType" ,
71+ "items.position" ,
72+ }
73+
74+ available_attribs = []
75+ if requires_attrib :
76+ available_attribs = self .get_attributes_for_type ("list" )
4677
4778 if active is not None :
4879 fields .add ("active" )
@@ -66,6 +97,15 @@ def get_entity_lists(
6697 if isinstance (attributes , str ):
6798 entity_list ["attributes" ] = json .loads (attributes )
6899
100+ if requires_attrib :
101+ all_attrib = json .loads (
102+ entity_list .get ("allAttrib" ) or "{}"
103+ )
104+ entity_list ["attrib" ] = {
105+ attrib_name : all_attrib .get (attrib_name )
106+ for attrib_name in available_attribs
107+ }
108+
69109 self ._convert_entity_data (entity_list )
70110
71111 yield entity_list
@@ -170,9 +210,8 @@ def create_entity_list(
170210 kwargs [key ] = value
171211
172212 response = self .post (
173- f"projects/{ project_name } /lists/ { list_id } /items " ,
213+ f"projects/{ project_name } /lists" ,
174214 ** kwargs
175-
176215 )
177216 response .raise_for_status ()
178217 return list_id
@@ -343,7 +382,7 @@ def update_entity_list_items(
343382 mode (EntityListItemMode): Mode of items update.
344383
345384 """
346- response = self .post (
385+ response = self .patch (
347386 f"projects/{ project_name } /lists/{ list_id } /items" ,
348387 items = items ,
349388 mode = mode ,
0 commit comments