@@ -14,13 +14,23 @@ class AAPIJob:
14
14
15
15
16
16
class AAPIObject :
17
- def as_aapi_dict (self ):
17
+ def as_aapi_dict (self , ignore_event_type = True ):
18
+
19
+ # Import inside the method to prevent circular import issues
20
+ from aapi .ifbase import IfCompletionStatus
21
+
18
22
res = {}
19
23
20
- if "_type" in attrs .fields_dict (self .__class__ ):
21
- if not self ._type .startswith ("Condition" ) or self ._type .startswith ("Event" ):
22
- res ["Type" ] = self ._type
24
+ if '_type' in attrs .fields_dict (self .__class__ ):
25
+ is_condition_or_event = self ._type .startswith (('Condition' , 'Event' ))
26
+
27
+ if ignore_event_type :
28
+ if not is_condition_or_event :
29
+ res ['Type' ] = self ._type
30
+ elif self ._type .startswith ('Event' ):
31
+ res ['Type' ] = self ._type
23
32
33
+
24
34
if attrs .has (self ):
25
35
for field in attrs .fields (self .__class__ ):
26
36
value = self .__getattribute__ (field .name )
@@ -49,7 +59,10 @@ def as_aapi_dict(self):
49
59
50
60
elif field .metadata .get ("_abstract_aapi_container_" ):
51
61
for obj in value :
52
- res [obj .object_name ] = obj .as_aapi_dict ()
62
+ obj_ignore_type = ignore_event_type
63
+ if isinstance (self , IfCompletionStatus ):
64
+ obj_ignore_type = False
65
+ res [obj .object_name ] = obj .as_aapi_dict (ignore_event_type = obj_ignore_type )
53
66
54
67
else :
55
68
res ["attrsibutes_valid" ] = False
0 commit comments