| 37 | |
| 38 | |
| 39 | class ActionExecutionDB(stormbase.StormFoundationDB): |
| 40 | RESOURCE_TYPE = ResourceType.EXECUTION |
| 41 | UID_FIELDS = ["id"] |
| 42 | |
| 43 | trigger = stormbase.EscapedDictField() |
| 44 | trigger_type = stormbase.EscapedDictField() |
| 45 | trigger_instance = stormbase.EscapedDictField() |
| 46 | rule = stormbase.EscapedDictField() |
| 47 | action = stormbase.EscapedDictField(required=True) |
| 48 | runner = stormbase.EscapedDictField(required=True) |
| 49 | # Only the diff between the liveaction type and what is replicated |
| 50 | # in the ActionExecutionDB object. |
| 51 | liveaction = stormbase.EscapedDictField(required=True) |
| 52 | workflow_execution = me.StringField() |
| 53 | task_execution = me.StringField() |
| 54 | status = me.StringField( |
| 55 | required=True, help_text="The current status of the liveaction." |
| 56 | ) |
| 57 | start_timestamp = ComplexDateTimeField( |
| 58 | default=date_utils.get_datetime_utc_now, |
| 59 | help_text="The timestamp when the liveaction was created.", |
| 60 | ) |
| 61 | end_timestamp = ComplexDateTimeField( |
| 62 | help_text="The timestamp when the liveaction has finished." |
| 63 | ) |
| 64 | parameters = stormbase.EscapedDynamicField( |
| 65 | default={}, |
| 66 | help_text="The key-value pairs passed as to the action runner & action.", |
| 67 | ) |
| 68 | result = JSONDictEscapedFieldCompatibilityField( |
| 69 | default={}, help_text="Action defined result." |
| 70 | ) |
| 71 | result_size = me.IntField(default=0, help_text="Serialized result size in bytes") |
| 72 | context = me.DictField( |
| 73 | default={}, help_text="Contextual information on the action execution." |
| 74 | ) |
| 75 | parent = me.StringField() |
| 76 | children = me.ListField(field=me.StringField()) |
| 77 | log = me.ListField(field=me.DictField()) |
| 78 | delay = me.IntField(min_value=0) |
| 79 | # Do not use URLField for web_url. If host doesn't have FQDN set, URLField validation blows. |
| 80 | web_url = me.StringField(required=False) |
| 81 | |
| 82 | meta = { |
| 83 | "indexes": [ |
| 84 | {"fields": ["rule.ref"]}, |
| 85 | {"fields": ["action.ref"]}, |
| 86 | {"fields": ["liveaction.id"]}, |
| 87 | {"fields": ["start_timestamp"]}, |
| 88 | {"fields": ["end_timestamp"]}, |
| 89 | {"fields": ["status"]}, |
| 90 | {"fields": ["parent"]}, |
| 91 | {"fields": ["rule.name"]}, |
| 92 | {"fields": ["runner.name"]}, |
| 93 | {"fields": ["trigger.name"]}, |
| 94 | {"fields": ["trigger_type.name"]}, |
| 95 | {"fields": ["trigger_instance.id"]}, |
| 96 | {"fields": ["context.user"]}, |