workflows.modelsΒΆ

Workflow models: definitions, scopes, instances, and enrollment requests.

AttributesΒΆ

StatusBadge

Tuple of (label, bootstrap_badge_class).

BADGE_MAP

ClassesΒΆ

State

Workflow and enrollment states.

WorkflowDefinition

Blueprint of a workflow: event, steps, transitions.

WorkflowScope

Assign a workflow to CAs, domains, or devices (NULL = any).

DeviceRequest

Represents a device lifecycle request (creation, deletion, onboarding).

EnrollmentRequest

A single logical certificate enrollment attempt (EST simpleenroll fan-out parent).

WorkflowInstance

An initialized workflows.

FunctionsΒΆ

get_status_badge(raw)

Return a badge (label, CSS class) for a workflow/enrollment state.

Module ContentsΒΆ

class workflows.models.State(*args, **kwds)[source]ΒΆ

Bases: django.db.models.TextChoices

Workflow and enrollment states.

RUNNING = ('Running', 'Running')[source]ΒΆ
AWAITING = ('AwaitingApproval', 'AwaitingApproval')[source]ΒΆ
APPROVED = ('Approved', 'Approved')[source]ΒΆ
PASSED = ('Passed', 'Passed')[source]ΒΆ
FINALIZED = ('Finalized', 'Finalized')[source]ΒΆ
REJECTED = ('Rejected', 'Rejected')[source]ΒΆ
FAILED = ('Failed', 'Failed')[source]ΒΆ
ABORTED = ('Aborted', 'Aborted')[source]ΒΆ
workflows.models.StatusBadge[source]ΒΆ

Tuple of (label, bootstrap_badge_class).

workflows.models.BADGE_MAP: dict[str, StatusBadge][source]ΒΆ
workflows.models.get_status_badge(raw)[source]ΒΆ

Return a badge (label, CSS class) for a workflow/enrollment state.

Parameters:

raw (str | State | None)

Return type:

StatusBadge

class workflows.models.WorkflowDefinition(*args, **kwargs)[source]ΒΆ

Bases: django.db.models.Model

Blueprint of a workflow: event, steps, transitions.

id[source]ΒΆ
name[source]ΒΆ
version[source]ΒΆ
published[source]ΒΆ
definition[source]ΒΆ
created_at[source]ΒΆ
updated_at[source]ΒΆ
class Meta[source]ΒΆ

Database configuration for workflow definitions.

db_table = 'workflow_definitions'[source]ΒΆ
ordering = ('-created_at',)[source]ΒΆ
__str__()[source]ΒΆ

Return human-readable representation with version.

Return type:

str

class workflows.models.WorkflowScope(*args, **kwargs)[source]ΒΆ

Bases: django.db.models.Model

Assign a workflow to CAs, domains, or devices (NULL = any).

id[source]ΒΆ
workflow[source]ΒΆ
ca_id[source]ΒΆ
domain_id[source]ΒΆ
device_id[source]ΒΆ
class Meta[source]ΒΆ

Database configuration for Workflow Scope.

db_table = 'workflow_scopes'[source]ΒΆ
unique_together = (('workflow', 'ca_id', 'domain_id', 'device_id'),)[source]ΒΆ
__str__()[source]ΒΆ

Return human-readable representation.

Return type:

str

class workflows.models.DeviceRequest(*args, **kwargs)[source]ΒΆ

Bases: django.db.models.Model

Represents a device lifecycle request (creation, deletion, onboarding).

id[source]ΒΆ

UUID primary key.

device[source]ΒΆ

Target device.

domain[source]ΒΆ

Domain at the time of event (may be null).

ca[source]ΒΆ

CA for domain (if applicable).

action[source]ΒΆ

Device action type (β€œcreated”, β€œonboarded”, β€œdeleted”).

payload[source]ΒΆ

Raw event payload from the handler.

aggregated_state[source]ΒΆ

Aggregate state over all workflow instances.

finalized[source]ΒΆ

True if all workflow instances have reached terminal states.

created_at[source]ΒΆ

Request creation timestamp.

updated_at[source]ΒΆ

Last update timestamp.

id[source]ΒΆ
device[source]ΒΆ
domain[source]ΒΆ
ca[source]ΒΆ
action[source]ΒΆ
payload[source]ΒΆ
aggregated_state[source]ΒΆ
finalized[source]ΒΆ
created_at[source]ΒΆ
updated_at[source]ΒΆ
class Meta[source]ΒΆ

Database configuration for device workflow parent.

ordering = ('-created_at',)[source]ΒΆ
__str__()[source]ΒΆ

Return a human-readable representation of the device request.

Return type:

str

recompute_and_save()[source]ΒΆ

Recompute the aggregate final state from instances.

Return type:

None

property badge_class: str[source]ΒΆ

Return the CSS class for the aggregated state badge.

Return type:

str

class workflows.models.EnrollmentRequest(*args, **kwargs)[source]ΒΆ

Bases: django.db.models.Model

A single logical certificate enrollment attempt (EST simpleenroll fan-out parent).

  • Aggregates all child WorkflowInstances that must approve/reject this attempt.

  • Identity tuple groups repeated polls for the same CSR until a terminal outcome.

  • We keep request-level states distinct from instance-level strings to avoid confusion.

id[source]ΒΆ
protocol[source]ΒΆ
operation[source]ΒΆ
device[source]ΒΆ
domain[source]ΒΆ
ca[source]ΒΆ
fingerprint[source]ΒΆ
template[source]ΒΆ
aggregated_state[source]ΒΆ
finalized[source]ΒΆ
created_at[source]ΒΆ
updated_at[source]ΒΆ
class Meta[source]ΒΆ

Database configuration for enrollment request.

db_table = 'enrollment_requests'[source]ΒΆ
indexes[source]ΒΆ
__str__()[source]ΒΆ

Return human-readable representation.

Return type:

str

property badge_label: str[source]ΒΆ

Return the human-readable badge label for the aggregated state.

Return type:

str

property badge_class: str[source]ΒΆ

Return the CSS class for the aggregated state badge.

Return type:

str

recompute_status()[source]ΒΆ

Compute aggregate status from child instances.

Returns:

The new aggregated state derived from child instance states.

Return type:

State

is_valid()[source]ΒΆ

Return True if the enrollment request is in a successful terminal state.

Return type:

bool

recompute_and_save()[source]ΒΆ

Recalculate the aggregated state and persist changes if it changed.

Returns:

The (possibly unchanged) aggregated state.

Return type:

State

finalize(final_status=None)[source]ΒΆ

Finalize this request and all non-finalized child workflow instances.

Parameters:

final_status (str | State | None) – Optional final aggregated state to set for the request.

Return type:

None

abort()[source]ΒΆ

Abort this request and all non-finalized child workflow instances.

Return type:

None

class workflows.models.WorkflowInstance(*args, **kwargs)[source]ΒΆ

Bases: django.db.models.Model

An initialized workflows.

id[source]ΒΆ
definition[source]ΒΆ
enrollment_request[source]ΒΆ
device_request[source]ΒΆ
current_step[source]ΒΆ
state[source]ΒΆ
payload[source]ΒΆ
step_contexts[source]ΒΆ
finalized[source]ΒΆ
created_at[source]ΒΆ
updated_at[source]ΒΆ
class Meta[source]ΒΆ

Database configuration and indexes for workflow instances.

db_table = 'workflow_instances'[source]ΒΆ
indexes[source]ΒΆ
__str__()[source]ΒΆ

Return a short identifier containing definition name, PK, and state.

Return type:

str

property badge_label: str[source]ΒΆ

Return the human-readable badge label for this instance’s state.

Return type:

str

property badge_class: str[source]ΒΆ

Return the CSS class for this instance’s state badge.

Return type:

str

finalize(state=None)[source]ΒΆ

Mark this instance as fully done and optionally set a final state.

Parameters:

state (str | State | None) – Optional final state to set before marking as finalized.

Return type:

None

get_steps()[source]ΒΆ

Return the ordered list of steps from the workflow definition.

Returns:

List of step dictionaries from the workflow definition JSON.

Return type:

list[dict[str, Any]]

get_current_step_index()[source]ΒΆ

Return the index of self.current_step in the steps list, or raise.

Return type:

int

get_next_step()[source]ΒΆ

Return the step-ID of the next step, or None if at the end.

Returns:

Step ID string of the next step, or None if there is no next step.

Return type:

str | None

is_last_approval_step()[source]ΒΆ

Return True if the current step is the last Approval step in the workflow.

Return type:

bool