Given a State, return the essential string parts of it for use in an
event payload
Source code in src/prefect/server/models/events.py
256
257
258
259
260
261
262
263
264
265
266
267
268 | def state_payload(state: Optional[schemas.states.State]) -> Optional[Dict[str, str]]:
"""Given a State, return the essential string parts of it for use in an
event payload"""
if not state:
return None
payload: Dict[str, str] = {"type": state.type.value}
if state.name:
payload["name"] = state.name
if state.message:
payload["message"] = truncated_to(TRUNCATE_STATE_MESSAGES_AT, state.message)
if state.is_paused():
payload["pause_reschedule"] = str(state.state_details.pause_reschedule).lower()
return payload
|