MCPcopy Create free account
hub / github.com/StackStorm/st2 / to_model

Method to_model

st2common/st2common/models/api/trace.py:114–137  ·  view source on GitHub ↗
(cls, instance)

Source from the content-addressed store, hash-verified

112
113 @classmethod
114 def to_model(cls, instance):
115 values = {"trace_tag": instance.trace_tag}
116 action_executions = getattr(instance, "action_executions", [])
117 action_executions = [
118 TraceAPI.to_component_model(component=action_execution)
119 for action_execution in action_executions
120 ]
121 values["action_executions"] = action_executions
122
123 rules = getattr(instance, "rules", [])
124 rules = [TraceAPI.to_component_model(component=rule) for rule in rules]
125 values["rules"] = rules
126
127 trigger_instances = getattr(instance, "trigger_instances", [])
128 trigger_instances = [
129 TraceAPI.to_component_model(component=trigger_instance)
130 for trigger_instance in trigger_instances
131 ]
132 values["trigger_instances"] = trigger_instances
133
134 start_timestamp = getattr(instance, "start_timestamp", None)
135 if start_timestamp:
136 values["start_timestamp"] = isotime.parse(start_timestamp)
137 return cls.model(**values)
138
139 @classmethod
140 def from_component_model(cls, component_model):

Callers

nothing calls this directly

Calls 2

to_component_modelMethod · 0.80
parseMethod · 0.80

Tested by

no test coverage detected