outcome_to_dict

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

outcome_to_dict(outcome: Outcome) → dict[source]

Serialise an endpoint declaration to a plain mapping for YAML/JSON.

The task field is the discriminator outcome_from_dict() reads; the remaining keys mirror the dataclass fields, so the mapping is both human-writable and losslessly reversible.

Parameters:

outcome – The endpoint declaration to serialise.

Returns:

A dict with a task key plus the endpoint’s fields.

Raises:

HABITAPIError – If the outcome’s task is not a built-in one.