Payload Module

action_triggers.payload.get_payload_generator(config: Config) Callable[[Model], dict | str][source]

Returns a function that generates a payload from a model instance and config.

Parameters:

config – The configuration object to use for generating the payload.

Returns:

If the config has a payload, the function will return a callable that generates the payload using the provided payload in the config object. Otherwise, it will return a callable that generates the payload from the model instance

action_triggers.payload.parse_payload(instance: Model, payload: str) dict | str[source]

Parse a payload dictionary with a model instance and return the parsed object. If the parsed object is JSON serializable, it will be returned as a dictionary, otherwise it will be returned as a string.

Parameters:
  • instance – The model instance to parse the payload for.

  • payload – The payload to parse.

Returns:

The parsed payload - either a dictionary or a string depending on whether the parsed object is JSON serializable.

action_triggers.payload.payload_from_instance(instance: Model) dict[source]

Generates a payload from a model instance.

Parameters:

instance – The model instance to generate the payload from.

Returns:

A dictionary representing the payload derived from the model instance.