workflows.models
Workflow models: definitions, scopes, instances, and enrollment requests.
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