sasvi.workflows
Public surface for the SAS Visual Investigator workflows feature layer.
Handwritten service layer for SAS Visual Investigator workflows.
Wraps the generated Workflows API with curated handles for workflow definitions, runtime process instances, tasks, and their actions. Workflow processes model a review lifecycle over an entity document: a definition is started against a target document, which produces an instance whose tasks users claim, act on, and complete until the process reaches a terminal state.
WorkflowListFilter
WorkflowDocumentRef Objects
@dataclass(frozen=True, slots=True)
class WorkflowDocumentRef()
Reference to a workflow target document by type and id.
entity_type_name
document_id
from_document
@classmethod
def from_document(
cls,
document: Document | DocumentHandleProtocol) -> WorkflowDocumentRef
Build a workflow document reference from a bound document.
Arguments:
document- Bound document to reference.
Returns:
Workflow document reference using the document type and id.
to_dict
def to_dict() -> dict[str, str]
Return the workflow payload shape used for lightweight document refs.
WorkflowVariable Objects
@dataclass
class WorkflowVariable(RawBackedHandle)
Curated workflow variable wrapper.
id
@property
def id() -> str | None
The workflow variable's unique identifier.
name
@property
def name() -> str | None
The variable's machine name as referenced by the workflow definition.
label
@property
def label() -> str | None
The variable's human-readable display label.
type
@property
def type() -> str | None
The variable's declared data type (e.g. "STRING", "USER_GROUP").
is_entity
@property
def is_entity() -> bool
Whether the variable is bound to a field on the target entity document.
default_value
@property
def default_value() -> object | None
The variable's default value applied when a process starts without one.
to_dict
def to_dict() -> JsonObject
Return a JSON-serializable snapshot of the workflow variable.
WorkflowTaskActionVariable Objects
@dataclass
class WorkflowTaskActionVariable(RawBackedHandle)
Curated workflow action variable wrapper.
source
id
@property
def id() -> str | None
The action variable's unique identifier.
name
@property
def name() -> str | None
The variable's machine name used when supplying override values.
label
@property
def label() -> str | None
The variable's human-readable prompt label shown to the acting user.
type
@property
def type() -> str | None
The variable's declared data type (e.g. "STRING", "USER_GROUP").
value
@property
def value() -> object | None
The value currently carried on the action payload for this variable.
default_value
@property
def default_value() -> object | None
The variable's default value applied when no explicit value is supplied.
constraining_list_name
@property
def constraining_list_name() -> str | None
Name of the reference list that constrains this variable's allowed values.
verify_value_is_set
@property
def verify_value_is_set() -> bool
Whether the workflow requires a non-empty value before the action runs.
allow_multiple_selections
@property
def allow_multiple_selections() -> bool
Whether the variable accepts multiple values from its constraining list.
set_to_null
@property
def set_to_null() -> bool
Whether completing the action deliberately clears this variable's value.
required
@property
def required() -> bool
Whether the caller must supply a value before completing the action.
True when the workflow verifies the value is set, or when neither a value nor a default is present and the variable is not being nulled.
to_dict
def to_dict() -> JsonObject
Return a JSON-serializable snapshot of the action variable.
WorkflowTaskAction Objects
@dataclass
class WorkflowTaskAction(RawBackedHandle)
Curated workflow task action wrapper.
id
@property
def id() -> str | None
The action's unique identifier.
name
@property
def name() -> str | None
The action's display name (e.g. "Approve", "Reject").
disabled
@property
def disabled() -> bool
Whether the action is currently disabled and cannot be taken.
entity_field_variables
@property
def entity_field_variables() -> list[WorkflowTaskActionVariable]
Action variables that write back to fields on the target entity document.
process_variables
@property
def process_variables() -> list[WorkflowTaskActionVariable]
Action variables scoped to the workflow process rather than the document.
variables
@property
def variables() -> list[WorkflowTaskActionVariable]
All action variables, both entity-field and process-scoped.
required_inputs
@property
def required_inputs() -> list[WorkflowTaskActionVariable]
Action variables that require a value before the action can complete.
required_action_variables
@property
def required_action_variables() -> list[WorkflowTaskActionVariable]
Action variables missing values in the action payload itself.
page_prompt_names
@property
def page_prompt_names() -> list[str]
Names of the prompt pages the UI presents when taking this action.
to_dict
def to_dict() -> JsonObject
Return a JSON-serializable snapshot of the task action.
WorkflowDefinition Objects
@dataclass
class WorkflowDefinition(RawBackedHandle)
Curated workflow definition wrapper.
Definitions returned by client.workflows.definitions are bound to the
API and can start processes and refresh themselves. A
definition built directly from a payload (WorkflowDefinition(raw)) is a
read-only view.
id
@property
def id() -> str | None
The workflow definition's unique identifier.
name
@property
def name() -> str | None
The definition's machine name used to start processes.
label
@property
def label() -> str | None
The definition's human-readable display label.
description
@property
def description() -> str | None
The definition's descriptive text, if configured.
entity_name
@property
def entity_name() -> str | None
Machine name of the entity type this workflow runs against.
entity_label
@property
def entity_label() -> str | None
Display label of the entity type this workflow runs against.
version
@property
def version() -> int | None
The definition's version number.
enabled
@property
def enabled() -> bool
Whether the definition is enabled and available to start new processes.
created_at
@property
def created_at() -> str | None
ISO-8601 timestamp of when the definition was created.
updated_at
@property
def updated_at() -> str | None
ISO-8601 timestamp of the definition's most recent update.
solution_name
@property
def solution_name() -> str | None
Machine name of the VI solution that owns this workflow definition.
solution_label
@property
def solution_label() -> str | None
Display label of the VI solution that owns this workflow definition.
workflow_version
@property
def workflow_version() -> int | None
Version of the workflow model; bumps whenever the model itself changes.
entity_id
@property
def entity_id() -> int | None
Numeric identifier of the entity type this workflow runs against.
use_for_auto_start
@property
def use_for_auto_start() -> bool
Whether the definition is eligible for automatic starts.
start_on_new_entity_instance
@property
def start_on_new_entity_instance() -> bool
Whether a process starts automatically when a new entity document is created.
created_by
@property
def created_by() -> str | None
User id who created the definition.
updated_by
@property
def updated_by() -> str | None
User id who most recently updated the definition.
xml_model
@property
def xml_model() -> str | None
The BPMN XML model; only present when fetched with include_xml_model=True.
entity_defined_variable_names
@property
def entity_defined_variable_names() -> builtins.list[str]
Names of the process variables the target entity type contributes.
variables
@property
def variables() -> builtins.list[WorkflowVariable]
User-defined process variables declared by this workflow definition.
to_dict
def to_dict() -> JsonObject
Return a JSON-serializable snapshot of the workflow definition.
The XML model is deliberately left out; read it from xml_model
or raw_dict when the definition was fetched with it.
start
def start(*,
document_ref: Document | WorkflowDocumentRef | tuple[str, str]
| None = None,
document_id: str | None = None,
variables: Mapping[str, Any] | WorkflowInstanceContextRepVariables
| None = None,
body: Any | None = None) -> WorkflowInstance
Start a workflow process from this definition by id.
Arguments:
document_ref- Bound document,WorkflowDocumentRef, or(entity_type_name, document_id)tuple for the workflow target.document_id- Workflow target id; the entity type comes from this definition.variables- Optional workflow instance variables for the started process.body- Advanced escape hatch for raw workflow context payloads.
Returns:
The created workflow instance wrapper.
Raises:
WorkflowOperationError- When the definition is unbound or has no id; whenbodyis combined with the structured arguments; when bothdocument_refanddocument_idare given; when the target's entity type does not match this definition; whendocument_idis used but the definition declares no entity type; or when no target is provided at all.WorkflowNotFoundError- When the definition no longer exists.WorkflowStateError- When the service rejects the start because of the target's current state.
start_async
async def start_async(*,
document_ref: Document | WorkflowDocumentRef
| tuple[str, str] | None = None,
document_id: str | None = None,
variables: Mapping[str, Any]
| WorkflowInstanceContextRepVariables | None = None,
body: Any | None = None) -> WorkflowInstance
Asynchronously start a workflow process from this definition by id.
Arguments:
document_ref- Bound document,WorkflowDocumentRef, or(entity_type_name, document_id)tuple for the workflow target.document_id- Workflow target id; the entity type comes from this definition.variables- Optional workflow instance variables for the started process.body- Advanced escape hatch for raw workflow context payloads.
Returns:
The created workflow instance wrapper.
Raises:
WorkflowOperationError- When the definition is unbound or has no id; whenbodyis combined with the structured arguments; when bothdocument_refanddocument_idare given; when the target's entity type does not match this definition; whendocument_idis used but the definition declares no entity type; or when no target is provided at all.WorkflowNotFoundError- When the definition no longer exists.WorkflowStateError- When the service rejects the start because of the target's current state.
refresh
def refresh() -> WorkflowDefinition
Reload the definition from the workflow service.
The XML model is requested again when the current snapshot carries one.
Returns:
This definition, updated in place.
Raises:
WorkflowOperationError- When the definition is unbound or has no id.WorkflowNotFoundError- When the definition no longer exists.
refresh_async
async def refresh_async() -> WorkflowDefinition
Asynchronously reload the definition from the workflow service.
The XML model is requested again when the current snapshot carries one.
Returns:
This definition, updated in place.
Raises:
WorkflowOperationError- When the definition is unbound or has no id.WorkflowNotFoundError- When the definition no longer exists.
WorkflowDefinitionsService Objects
class WorkflowDefinitionsService()
Workflow definition catalog: listing, lookup, revisions and delete.
Mounted as client.workflows.definitions and, for the configuration
view, as client.admin.workflows. Both are stateless views over the
same API. Definitions are authored in the VI designer: the API offers no
create or update operation.
Arguments:
workflows_api- Generated Workflows API namespace used for definition operations.documents- Optional bound document collection handed to started instances so their tasks can update documents.
list
def list(*,
start: int = 0,
limit: int = 20,
filter: str | None = None) -> builtins.list[WorkflowDefinition]
List workflow definitions available in the tenant.
Arguments:
start- Zero-based page offset.limit- Maximum number of definitions to return.filter- Optional raw workflow-service filter expression, for exampleeq(entityName,'investigation').
Returns:
Bound workflow definition wrappers.
list_async
async def list_async(
*,
start: int = 0,
limit: int = 20,
filter: str | None = None) -> builtins.list[WorkflowDefinition]
Asynchronously list workflow definitions available in the tenant.
Arguments:
start- Zero-based page offset.limit- Maximum number of definitions to return.filter- Optional raw workflow-service filter expression, for exampleeq(entityName,'investigation').
Returns:
Bound workflow definition wrappers.
list_all
def list_all(*,
batch_size: int = 100,
filter: str | None = None) -> builtins.list[WorkflowDefinition]
List all workflow definitions by paging until the service is exhausted.
Arguments:
batch_size- Page size used for each generated API request.filter- Optional raw workflow-service filter expression.
Returns:
Bound workflow definition wrappers.
Raises:
WorkflowOperationError- Whenbatch_sizeis not greater than 0.
list_all_async
async def list_all_async(
*,
batch_size: int = 100,
filter: str | None = None) -> builtins.list[WorkflowDefinition]
Asynchronously list all workflow definitions by paging exhaustively.
Arguments:
batch_size- Page size used for each generated API request.filter- Optional raw workflow-service filter expression.
Returns:
Bound workflow definition wrappers.
Raises:
WorkflowOperationError- Whenbatch_sizeis not greater than 0.
get
def get(*,
definition_id: str,
include_xml_model: bool = False) -> WorkflowDefinition | None
Fetch one workflow definition by id.
Arguments:
definition_id- Workflow definition identifier.include_xml_model- Whether to include the BPMN XML model in the response (exposed asWorkflowDefinition.xml_model).
Returns:
The bound definition, or None when it does not exist.
get_async
async def get_async(
*,
definition_id: str,
include_xml_model: bool = False) -> WorkflowDefinition | None
Asynchronously fetch one workflow definition by id.
Arguments:
definition_id- Workflow definition identifier.include_xml_model- Whether to include the BPMN XML model in the response (exposed asWorkflowDefinition.xml_model).
Returns:
The bound definition, or None when it does not exist.
get_by_name
def get_by_name(*, name: str) -> WorkflowDefinition | None
Fetch the current workflow definition with an exact machine name.
Arguments:
name- Workflow definition machine name (definition.name).
Returns:
The bound definition, or None when no definition has that name.
Raises:
WorkflowOperationError- Whennameis empty.
get_by_name_async
async def get_by_name_async(*, name: str) -> WorkflowDefinition | None
Asynchronously fetch the current workflow definition with an exact name.
Arguments:
name- Workflow definition machine name (definition.name).
Returns:
The bound definition, or None when no definition has that name.
Raises:
WorkflowOperationError- Whennameis empty.
delete
def delete(*, definition_id: str) -> None
Delete a workflow definition by id.
Arguments:
definition_id- Workflow definition identifier.
Raises:
WorkflowNotFoundError- When the definition does not exist.WorkflowStateError- When the service refuses because processes still depend on the definition.WorkflowOperationError- When the service rejects the delete for any other reason.
delete_async
async def delete_async(*, definition_id: str) -> None
Asynchronously delete a workflow definition by id.
Arguments:
definition_id- Workflow definition identifier.
Raises:
WorkflowNotFoundError- When the definition does not exist.WorkflowStateError- When the service refuses because processes still depend on the definition.WorkflowOperationError- When the service rejects the delete for any other reason.
revisions
def revisions(*,
name: str | None = None,
start: int = 0,
limit: int = 20,
sort_by: str = "workflowVersion:descending",
filter: str | None = None) -> builtins.list[WorkflowDefinition]
List stored revisions of workflow definitions.
Revisions are keyed by name rather than by definition id: every
revision of one workflow shares the name and carries its own id, so an
id would select a single revision rather than the family.
Arguments:
name- Restrict to revisions of the workflow with this machine name.start- Zero-based page offset.limit- Maximum number of revisions to return.sort_by- Server sort expression.filter- Optional raw filter expression combined withnamethroughand(...).
Returns:
Bound workflow definition wrappers, one per revision.
revisions_async
async def revisions_async(
*,
name: str | None = None,
start: int = 0,
limit: int = 20,
sort_by: str = "workflowVersion:descending",
filter: str | None = None) -> builtins.list[WorkflowDefinition]
Asynchronously list stored revisions of workflow definitions.
See revisions for why revisions are keyed by name.
Arguments:
name- Restrict to revisions of the workflow with this machine name.start- Zero-based page offset.limit- Maximum number of revisions to return.sort_by- Server sort expression.filter- Optional raw filter expression combined withnamethroughand(...).
Returns:
Bound workflow definition wrappers, one per revision.
revisions_all
def revisions_all(
*,
name: str | None = None,
batch_size: int = 100,
sort_by: str = "workflowVersion:descending",
filter: str | None = None) -> builtins.list[WorkflowDefinition]
List every stored revision by paging until the service is exhausted.
Arguments:
name- Restrict to revisions of the workflow with this machine name.batch_size- Page size used for each generated API request.sort_by- Server sort expression.filter- Optional raw filter expression combined withname.
Returns:
Bound workflow definition wrappers, one per revision.
Raises:
WorkflowOperationError- Whenbatch_sizeis not greater than 0.
revisions_all_async
async def revisions_all_async(
*,
name: str | None = None,
batch_size: int = 100,
sort_by: str = "workflowVersion:descending",
filter: str | None = None) -> builtins.list[WorkflowDefinition]
Asynchronously list every stored revision, paging exhaustively.
Arguments:
name- Restrict to revisions of the workflow with this machine name.batch_size- Page size used for each generated API request.sort_by- Server sort expression.filter- Optional raw filter expression combined withname.
Returns:
Bound workflow definition wrappers, one per revision.
Raises:
WorkflowOperationError- Whenbatch_sizeis not greater than 0.
revision
def revision(*,
revision_id: str,
include_xml_model: bool = False) -> WorkflowDefinition | None
Fetch one stored workflow revision by its id.
Arguments:
revision_id- Identifier of the revision (each revision has its own definition id; seerevisions).include_xml_model- Whether to include the BPMN XML model.
Returns:
The bound revision, or None when it does not exist.
revision_async
async def revision_async(
*,
revision_id: str,
include_xml_model: bool = False) -> WorkflowDefinition | None
Asynchronously fetch one stored workflow revision by its id.
Arguments:
revision_id- Identifier of the revision (each revision has its own definition id; seerevisions).include_xml_model- Whether to include the BPMN XML model.
Returns:
The bound revision, or None when it does not exist.
WorkflowHistoryEntry Objects
@dataclass
class WorkflowHistoryEntry(RawBackedHandle)
Normalized view of one workflow history record.
id
@property
def id() -> str | None
The history record's unique identifier.
process_instance_id
@property
def process_instance_id() -> str | None
Identifier of the workflow process instance this record belongs to.
task_name
@property
def task_name() -> str | None
Name of the task that was acted on in this history record.
action
@property
def action() -> str | None
Name of the action taken (e.g. "Approve") that produced this record.
started_at
@property
def started_at() -> str | None
ISO-8601 timestamp of when the task became active.
completed_at
@property
def completed_at() -> str | None
ISO-8601 timestamp of when the task was completed.
assignee
@property
def assignee() -> str | None
User id who was assigned the task at the time it was acted on.
entity_instance_id
@property
def entity_instance_id() -> str | None
Identifier of the target entity document this process runs against.
workflow_name
@property
def workflow_name() -> str | None
Name of the workflow definition this history record belongs to.
to_dict
def to_dict() -> JsonObject
Return a JSON-serializable snapshot of the history entry.
WorkflowTask Objects
class WorkflowTask(RawBackedHandle)
Bound workflow task with convenience methods for common task actions.
Arguments:
workflows_api- Generated Workflows API namespace used for task actions.raw- Generated workflow-task payload.documents- Optional bound document collection used for document updates.current_username- Optional username used when auto-resolving task claims.
id
@property
def id() -> str | None
The task's unique identifier.
name
@property
def name() -> str | None
The task's display name within the workflow process.
assignee
@property
def assignee() -> str | None
User id the task is currently claimed by, or None when unassigned.
description
@property
def description() -> str | None
The task's descriptive text, if configured.
process_instance_id
@property
def process_instance_id() -> str | None
Identifier of the workflow process instance that owns this task.
workflow_instance_id
@property
def workflow_instance_id() -> str | None
Alias for process_instance_id in workflow-instance terms.
entity_instance_id
@property
def entity_instance_id() -> str | None
Identifier of the target entity document the task acts on.
entity_name
@property
def entity_name() -> str | None
Machine name of the entity type the task's target document belongs to.
workflow_name
@property
def workflow_name() -> str | None
Name of the workflow definition this task belongs to.
actions
@property
def actions() -> list[WorkflowTaskAction]
The actions available to complete this task (e.g. approve, reject).
action
def action(name: str) -> WorkflowTaskAction
Look up one workflow task action by its display name.
Arguments:
name- Action name (e.g."Approve","Reject").
Returns:
The matching WorkflowTaskAction.
Raises:
WorkflowOperationError- When no action with this name exists.
to_dict
def to_dict() -> JsonObject
Return a JSON-serializable snapshot of the task.
refresh
def refresh() -> WorkflowTask
Reload the task from the workflow service.
Raises:
WorkflowOperationError- When the task has no id.WorkflowNotFoundError- When the task no longer exists on the server.
refresh_async
async def refresh_async() -> WorkflowTask
Asynchronously reload the task from the workflow service.
Raises:
WorkflowOperationError- When the task has no id.WorkflowNotFoundError- When the task no longer exists on the server.
claim
def claim(*, assignee: str | None = None) -> WorkflowTask
Claim the task and refresh the snapshot.
Arguments:
assignee- Optional explicit user id to claim the task for. When omitted, the SDK falls back to the task assignee or configured username when available.
Raises:
WorkflowOperationError- When the task has no id, or when no assignee can be resolved (no argument, task assignee, or configured username).
claim_async
async def claim_async(*, assignee: str | None = None) -> WorkflowTask
Asynchronously claim the task and refresh the snapshot.
Arguments:
assignee- Optional explicit user id to claim the task for. When omitted, the SDK falls back to the task assignee or configured username when available.
Raises:
WorkflowOperationError- When the task has no id, or when no assignee can be resolved (no argument, task assignee, or configured username).
assign
def assign(assignee: str) -> WorkflowTask
Assign the task to a specific user id.
Arguments:
assignee- Target user identifier expected by the workflow service.
Returns:
The updated bound task.
Raises:
WorkflowOperationError- When the task has no id.
assign_async
async def assign_async(assignee: str) -> WorkflowTask
Asynchronously assign the task to a specific user id.
Arguments:
assignee- Target user identifier expected by the workflow service.
Returns:
The updated bound task.
Raises:
WorkflowOperationError- When the task has no id.
release
def release(*, administrator: bool = False) -> WorkflowTask
Release the task claim and refresh the snapshot.
Arguments:
administrator- WhenTrue, use the administrator release endpoint that can release another user's claim.
Raises:
WorkflowOperationError- When the task has no id.
release_async
async def release_async(*, administrator: bool = False) -> WorkflowTask
Asynchronously release the task claim and refresh the snapshot.
Arguments:
administrator- WhenTrue, use the administrator release endpoint that can release another user's claim.
Raises:
WorkflowOperationError- When the task has no id.
complete
def complete(
*,
action: WorkflowTaskAction | ActionRep | Mapping[str, JsonValue] | str,
document_field_values: Mapping[str, Any] | None = None,
prompt_field_values: Mapping[str, Any] | None = None,
entity_field_values: Mapping[str, Any] | None = None,
process_variable_values: Mapping[str, Any] | None = None
) -> WorkflowTask
Complete the task using one of its advertised workflow actions.
Arguments:
action- The action to take: aWorkflowTaskActionfromtask.actions, the action's display name (looked up withaction), a generatedActionRep, or a raw mapping.document_field_values- Optional updates written to the underlying entity document after the workflow action completes. The field names are validated before the completion is sent.prompt_field_values- Backward-compatible alias fordocument_field_values.entity_field_values- Optional actionentityFieldVariablesoverrides keyed by variable name or id.process_variable_values- Optional actionprocessVariablesoverrides keyed by variable name or id.
Returns:
The refreshed bound task when still retrievable. When the completed
task is gone from the server, or its body cannot be read, the
snapshot from before the completion is returned and a WARNING is
logged on the sasvi.workflows.service logger.
Raises:
WorkflowOperationError- When the task has no id; whenactionnames no action on this task, or is not a shape that can be sent; when bothdocument_field_valuesandprompt_field_valuesare supplied; when document field updates are requested without a bound document collection; when the task lacks the entity name or instance id needed to locate the target; or when the target document cannot be found. All of these are raised before the completion is sent, so the task is still open.DocumentRuntimeError- When a field is unknown or not writable, or the entity type is SOURCE. Raised before the completion is sent.WorkflowDocumentUpdateError- When the task completed and the document update then failed. Do not retrycomplete(), retry the document update.WorkflowOperationError- When the completion was accepted but reading the task back failed for a reason other than the task being gone, for example a 5xx or 403. The task is complete; do not retrycomplete().
complete_async
async def complete_async(
*,
action: WorkflowTaskAction | ActionRep | Mapping[str, JsonValue] | str,
document_field_values: Mapping[str, Any] | None = None,
prompt_field_values: Mapping[str, Any] | None = None,
entity_field_values: Mapping[str, Any] | None = None,
process_variable_values: Mapping[str, Any] | None = None
) -> WorkflowTask
Asynchronously complete the task using one of its advertised actions.
Arguments:
action- The action to take: aWorkflowTaskActionfromtask.actions, the action's display name (looked up withaction), a generatedActionRep, or a raw mapping.document_field_values- Optional updates written to the underlying entity document after the workflow action completes. The field names are validated before the completion is sent.prompt_field_values- Backward-compatible alias fordocument_field_values.entity_field_values- Optional actionentityFieldVariablesoverrides keyed by variable name or id.process_variable_values- Optional actionprocessVariablesoverrides keyed by variable name or id.
Returns:
The refreshed bound task when still retrievable. When the completed
task is gone from the server, or its body cannot be read, the
snapshot from before the completion is returned and a WARNING is
logged on the sasvi.workflows.service logger.
Raises:
WorkflowOperationError- When the task has no id; whenactionnames no action on this task, or is not a shape that can be sent; when bothdocument_field_valuesandprompt_field_valuesare supplied; when document field updates are requested without a bound document collection; when the task lacks the entity name or instance id needed to locate the target; or when the target document cannot be found. All of these are raised before the completion is sent, so the task is still open.DocumentRuntimeError- When a field is unknown or not writable, or the entity type is SOURCE. Raised before the completion is sent.WorkflowDocumentUpdateError- When the task completed and the document update then failed. Do not retrycomplete(), retry the document update.WorkflowOperationError- When the completion was accepted but reading the task back failed for a reason other than the task being gone, for example a 5xx or 403. The task is complete; do not retrycomplete().
WorkflowTasksService Objects
class WorkflowTasksService()
Runtime task service under client.workflows.tasks.
Arguments:
workflows_api- Generated Workflows API namespace used for task operations.documents- Optional bound document collection used for task completion helpers.current_username- Optional username used when auto-resolving task claims.
list
def list(*,
start: int = 0,
limit: int = 20,
include_only_workable_tasks: bool = True,
filter: str | None = None) -> builtins.list[WorkflowTask]
List runtime tasks with optional raw filter expression.
Arguments:
start- Zero-based page offset.limit- Maximum number of tasks to return.include_only_workable_tasks- Whether to omit non-workable tasks.filter- Optional raw workflow-service filter expression.
Returns:
Bound workflow task wrappers.
list_async
async def list_async(*,
start: int = 0,
limit: int = 20,
include_only_workable_tasks: bool = True,
filter: str | None = None) -> builtins.list[WorkflowTask]
Asynchronously list runtime tasks with optional filter expression.
Arguments:
start- Zero-based page offset.limit- Maximum number of tasks to return.include_only_workable_tasks- Whether to omit non-workable tasks.filter- Optional raw workflow-service filter expression.
Returns:
Bound workflow task wrappers.
list_all
def list_all(*,
batch_size: int = 100,
include_only_workable_tasks: bool = True,
filter: str | None = None) -> builtins.list[WorkflowTask]
List all runtime tasks by paging until the service is exhausted.
Arguments:
batch_size- Page size used for each generated API request.include_only_workable_tasks- Whether to omit non-workable tasks.filter- Optional generated Workflows filter expression.
Returns:
Bound workflow task wrappers.
Raises:
WorkflowOperationError- Whenbatch_sizeis not greater than 0.
list_all_async
async def list_all_async(
*,
batch_size: int = 100,
include_only_workable_tasks: bool = True,
filter: str | None = None) -> builtins.list[WorkflowTask]
Asynchronously list all runtime tasks, paging exhaustively.
Arguments:
batch_size- Page size used for each generated API request.include_only_workable_tasks- Whether to omit non-workable tasks.filter- Optional generated Workflows filter expression.
Returns:
Bound workflow task wrappers.
Raises:
WorkflowOperationError- Whenbatch_sizeis not greater than 0.
get
def get(*, task_id: str) -> WorkflowTask | None
Fetch one workflow task by id.
Arguments:
task_id- Workflow task identifier.
Returns:
The bound task, or None when it does not exist.
get_async
async def get_async(*, task_id: str) -> WorkflowTask | None
Asynchronously fetch one workflow task by id.
Arguments:
task_id- Workflow task identifier.
Returns:
The bound task, or None when it does not exist.
claim_many
def claim_many(
*,
task_ids: Sequence[str],
assignee: str,
client_application: WorkflowClientApplication = "desktop") -> None
Claim several tasks for one user in batches of 100.
The ids are validated up front, then sent in order in chunks of at most
100 per request (the selection endpoint's cap). An empty list issues no
request. The endpoint reports no per-item outcome, so this returns
nothing. Unlike WorkflowTask.claim, no assignee is resolved
automatically.
Arguments:
task_ids- Workflow task identifiers.assignee- User id to claim the tasks for.client_application-VI-Client-Applicationheader value ("desktop"or"mobile").
Raises:
WorkflowOperationError- Whenassigneeis empty or any id is not a non-emptystr(no request is sent), or when the service rejects a chunk for a reason other than not-found or state.WorkflowNotFoundError- When a task in a chunk does not exist.WorkflowStateError- When a task in a chunk cannot be claimed.
claim_many_async
async def claim_many_async(
*,
task_ids: Sequence[str],
assignee: str,
client_application: WorkflowClientApplication = "desktop") -> None
Asynchronously claim several tasks for one user in batches of 100.
See claim_many for the chunking contract.
Arguments:
task_ids- Workflow task identifiers.assignee- User id to claim the tasks for.client_application-VI-Client-Applicationheader value ("desktop"or"mobile").
Raises:
WorkflowOperationError- Whenassigneeis empty or any id is not a non-emptystr(no request is sent), or when the service rejects a chunk for a reason other than not-found or state.WorkflowNotFoundError- When a task in a chunk does not exist.WorkflowStateError- When a task in a chunk cannot be claimed.
release_many
def release_many(*,
task_ids: Sequence[str],
administrator: bool = False) -> None
Release the claims on several tasks in batches of 100.
See claim_many for the chunking contract.
Arguments:
task_ids- Workflow task identifiers.administrator- WhenTrue, use the administrator release endpoint that can release other users' claims.
Raises:
WorkflowOperationError- When any id is not a non-emptystr(no request is sent), or when the service rejects a chunk for a reason other than not-found or state.WorkflowNotFoundError- When a task in a chunk does not exist.WorkflowStateError- When a task in a chunk cannot be released.
release_many_async
async def release_many_async(*,
task_ids: Sequence[str],
administrator: bool = False) -> None
Asynchronously release the claims on several tasks in batches of 100.
See claim_many for the chunking contract.
Arguments:
task_ids- Workflow task identifiers.administrator- WhenTrue, use the administrator release endpoint that can release other users' claims.
Raises:
WorkflowOperationError- When any id is not a non-emptystr(no request is sent), or when the service rejects a chunk for a reason other than not-found or state.WorkflowNotFoundError- When a task in a chunk does not exist.WorkflowStateError- When a task in a chunk cannot be released.
WorkflowInstance Objects
class WorkflowInstance(RawBackedHandle)
Curated runtime workflow instance wrapper.
Arguments:
workflows_api- Generated Workflows API namespace used for instance operations.raw- Generated or normalized workflow-instance payload.documents- Optional bound document collection used for hydration helpers.current_username- Optional username handed to the instance's tasks for auto-resolving claims.
id
@property
def id() -> str | None
The workflow process instance's unique identifier.
workflow_name
@property
def workflow_name() -> str | None
Name of the workflow definition this instance was started from.
workflow_definition_id
@property
def workflow_definition_id() -> str | None
Identifier of the workflow definition this instance was started from.
workflow_version
@property
def workflow_version() -> int | None
Version of the workflow definition this instance is running.
entity_name
@property
def entity_name() -> str | None
Machine name of the entity type the target document belongs to.
entity_instance_id
@property
def entity_instance_id() -> str | None
Identifier of the target entity document this process runs against.
entity_instance_label
@property
def entity_instance_label() -> str | None
Human-readable label of the target entity document.
started_at
@property
def started_at() -> str | None
ISO-8601 timestamp of when the process instance started.
completed_at
@property
def completed_at() -> str | None
ISO-8601 timestamp of when the process instance completed, if it has.
started_by
@property
def started_by() -> str | None
User id who started the process instance.
state
@property
def state() -> str | None
The instance's current state code (e.g. "RUNNING", "COMPLETE").
complete_reason
@property
def complete_reason() -> str | None
Reason the process reached its terminal state, if recorded.
is_suspended
@property
def is_suspended() -> bool
Whether the process instance is currently suspended.
is_active
@property
def is_active() -> bool
Whether the instance is still running (state is running or suspended).
is_completed
@property
def is_completed() -> bool
Whether the instance has reached the completed terminal state.
is_canceled
@property
def is_canceled() -> bool
Whether the instance was canceled before completing.
to_dict
def to_dict() -> JsonObject
Return a JSON-serializable snapshot of the workflow instance.
refresh
def refresh() -> WorkflowInstance
Reload the workflow instance from the workflow service.
Raises:
WorkflowOperationError- When the instance has no id.WorkflowNotFoundError- When the process no longer exists on the server.
refresh_async
async def refresh_async() -> WorkflowInstance
Asynchronously reload the workflow instance from the workflow service.
Raises:
WorkflowOperationError- When the instance has no id.WorkflowNotFoundError- When the process no longer exists on the server.
current_tasks
def current_tasks(
*,
include_only_workable_tasks: bool = False
) -> builtins.list[WorkflowTask]
List every current task that belongs to this workflow instance.
Pages through the service until it is exhausted, so a process whose parallel branches or group assignments fan out past one page is listed in full.
Arguments:
include_only_workable_tasks- Whether to omit non-workable tasks.
Returns:
Bound workflow task wrappers for this instance.
Raises:
IncompleteListingError- When the listing stops advancing or hits the page cap before the service is exhausted.
current_tasks_async
async def current_tasks_async(
*,
include_only_workable_tasks: bool = False
) -> builtins.list[WorkflowTask]
Asynchronously list every current task that belongs to this instance.
See current_tasks: the listing pages until the service is
exhausted.
Arguments:
include_only_workable_tasks- Whether to omit non-workable tasks.
Returns:
Bound workflow task wrappers for this instance.
Raises:
IncompleteListingError- When the listing stops advancing or hits the page cap before the service is exhausted.
history
def history(*,
start: int = 0,
limit: int = 50) -> builtins.list[WorkflowHistoryEntry]
List workflow-history entries for this instance.
Arguments:
start- Zero-based page offset.limit- Maximum number of history entries to return.
Returns:
Normalized workflow history entries.
history_async
async def history_async(
*,
start: int = 0,
limit: int = 50) -> builtins.list[WorkflowHistoryEntry]
Asynchronously list workflow-history entries for this instance.
Arguments:
start- Zero-based page offset.limit- Maximum number of history entries to return.
Returns:
Normalized workflow history entries.
cancel
def cancel() -> None
Cancel this workflow instance.
Raises:
WorkflowOperationError- When the instance has no id, or when the service rejects the request for a reason other than not-found or state.WorkflowNotFoundError- When the process no longer exists.WorkflowStateError- When the process cannot be canceled in its current state.
cancel_async
async def cancel_async() -> None
Asynchronously cancel this workflow instance.
Raises:
WorkflowOperationError- When the instance has no id, or when the service rejects the request for a reason other than not-found or state.WorkflowNotFoundError- When the process no longer exists.WorkflowStateError- When the process cannot be canceled in its current state.
suspend
def suspend() -> WorkflowInstance
Suspend this workflow instance and refresh the snapshot.
Returns:
This instance, refreshed; is_suspended reflects the new state.
Raises:
WorkflowOperationError- When the instance has no id.WorkflowNotFoundError- When the process no longer exists.WorkflowStateError- When the process cannot be suspended in its current state.
suspend_async
async def suspend_async() -> WorkflowInstance
Asynchronously suspend this workflow instance and refresh the snapshot.
Returns:
This instance, refreshed; is_suspended reflects the new state.
Raises:
WorkflowOperationError- When the instance has no id.WorkflowNotFoundError- When the process no longer exists.WorkflowStateError- When the process cannot be suspended in its current state.
resume
def resume() -> WorkflowInstance
Resume this suspended workflow instance and refresh the snapshot.
Returns:
This instance, refreshed; is_suspended reflects the new state.
Raises:
WorkflowOperationError- When the instance has no id.WorkflowNotFoundError- When the process no longer exists.WorkflowStateError- When the process is not suspended.
resume_async
async def resume_async() -> WorkflowInstance
Asynchronously resume this suspended workflow instance and refresh it.
Returns:
This instance, refreshed; is_suspended reflects the new state.
Raises:
WorkflowOperationError- When the instance has no id.WorkflowNotFoundError- When the process no longer exists.WorkflowStateError- When the process is not suspended.
WorkflowsService Objects
class WorkflowsService()
Runtime service for workflow instances and workflow tasks.
Arguments:
workflows_api- Generated Workflows API namespace used for runtime operations.documents- Optional bound document collection used for hydration helpers.current_username- Optional username used when auto-resolving task claims.
definitions
list
def list(*,
start: int = 0,
limit: int = 20,
filter: WorkflowListFilter = "active"
) -> builtins.list[WorkflowInstance]
List workflow instances for one runtime view.
Arguments:
start- Zero-based page offset.limit- Maximum number of instances to return.filter-"active","all", or"completed".
Returns:
Bound workflow instance wrappers.
Raises:
WorkflowOperationError- Whenfilteris not one of"active","all", or"completed".
list_async
async def list_async(*,
start: int = 0,
limit: int = 20,
filter: WorkflowListFilter = "active"
) -> builtins.list[WorkflowInstance]
Asynchronously list workflow instances for one runtime view.
Arguments:
start- Zero-based page offset.limit- Maximum number of instances to return.filter-"active","all", or"completed".
Returns:
Bound workflow instance wrappers.
Raises:
WorkflowOperationError- Whenfilteris not one of"active","all", or"completed".
list_all
def list_all(
*,
batch_size: int = 100,
filter: WorkflowListFilter = "active"
) -> builtins.list[WorkflowInstance]
List all workflow instances for one runtime view.
Arguments:
batch_size- Page size used for each generated API request.filter- Runtime view to page through: active, all, or completed.
Returns:
Bound workflow instance wrappers.
Raises:
WorkflowOperationError- Whenbatch_sizeis not greater than 0.
list_all_async
async def list_all_async(*,
batch_size: int = 100,
filter: WorkflowListFilter = "active"
) -> builtins.list[WorkflowInstance]
Asynchronously list all workflow instances for one runtime view.
Arguments:
batch_size- Page size used for each generated API request.filter- Runtime view to page through: active, all, or completed.
Returns:
Bound workflow instance wrappers.
Raises:
WorkflowOperationError- Whenbatch_sizeis not greater than 0.
get
def get(*, instance_id: str) -> WorkflowInstance | None
Fetch one workflow instance by process id.
Arguments:
instance_id- Workflow process instance identifier.
Returns:
The bound workflow instance, or None when it does not exist.
get_async
async def get_async(*, instance_id: str) -> WorkflowInstance | None
Asynchronously fetch one workflow instance by process id.
Arguments:
instance_id- Workflow process instance identifier.
Returns:
The bound workflow instance, or None when it does not exist.
cancel
def cancel(*, instance_id: str) -> None
Cancel one workflow instance by process id.
Arguments:
instance_id- Workflow process instance identifier.
Raises:
WorkflowNotFoundError- When the process does not exist.WorkflowStateError- When the process cannot be canceled in its current state.WorkflowOperationError- When the service rejects the request for any other reason.
cancel_async
async def cancel_async(*, instance_id: str) -> None
Asynchronously cancel one workflow instance by process id.
Arguments:
instance_id- Workflow process instance identifier.
Raises:
WorkflowNotFoundError- When the process does not exist.WorkflowStateError- When the process cannot be canceled in its current state.WorkflowOperationError- When the service rejects the request for any other reason.
suspend
def suspend(*, instance_id: str) -> None
Suspend one workflow instance by process id.
Arguments:
instance_id- Workflow process instance identifier.
Raises:
WorkflowNotFoundError- When the process does not exist.WorkflowStateError- When the process cannot be suspended in its current state.WorkflowOperationError- When the service rejects the request for any other reason.
suspend_async
async def suspend_async(*, instance_id: str) -> None
Asynchronously suspend one workflow instance by process id.
Arguments:
instance_id- Workflow process instance identifier.
Raises:
WorkflowNotFoundError- When the process does not exist.WorkflowStateError- When the process cannot be suspended in its current state.WorkflowOperationError- When the service rejects the request for any other reason.
resume
def resume(*, instance_id: str) -> None
Resume one suspended workflow instance by process id.
Arguments:
instance_id- Workflow process instance identifier.
Raises:
WorkflowNotFoundError- When the process does not exist.WorkflowStateError- When the process is not suspended.WorkflowOperationError- When the service rejects the request for any other reason.
resume_async
async def resume_async(*, instance_id: str) -> None
Asynchronously resume one suspended workflow instance by process id.
Arguments:
instance_id- Workflow process instance identifier.
Raises:
WorkflowNotFoundError- When the process does not exist.WorkflowStateError- When the process is not suspended.WorkflowOperationError- When the service rejects the request for any other reason.
suspend_many
def suspend_many(*, instance_ids: Sequence[str]) -> None
Suspend several workflow instances in batches of 100.
The ids are validated up front, then sent in order in chunks of at most 100 per request (the selection endpoint's cap). Duplicates are sent as given. An empty list issues no request. The endpoint reports no per-item outcome, so this returns nothing; a failing chunk raises and earlier chunks stay applied.
Arguments:
instance_ids- Workflow process instance identifiers.
Raises:
WorkflowOperationError- When any id is not a non-emptystr(no request is sent), or when the service rejects a chunk for a reason other than not-found or state.WorkflowNotFoundError- When a process in a chunk does not exist.WorkflowStateError- When a process in a chunk cannot be suspended.
suspend_many_async
async def suspend_many_async(*, instance_ids: Sequence[str]) -> None
Asynchronously suspend several workflow instances in batches of 100.
See suspend_many for the chunking contract.
Arguments:
instance_ids- Workflow process instance identifiers.
Raises:
WorkflowOperationError- When any id is not a non-emptystr(no request is sent), or when the service rejects a chunk for a reason other than not-found or state.WorkflowNotFoundError- When a process in a chunk does not exist.WorkflowStateError- When a process in a chunk cannot be suspended.
resume_many
def resume_many(*, instance_ids: Sequence[str]) -> None
Resume several suspended workflow instances in batches of 100.
See suspend_many for the chunking contract.
Arguments:
instance_ids- Workflow process instance identifiers.
Raises:
WorkflowOperationError- When any id is not a non-emptystr(no request is sent), or when the service rejects a chunk for a reason other than not-found or state.WorkflowNotFoundError- When a process in a chunk does not exist.WorkflowStateError- When a process in a chunk is not suspended.
resume_many_async
async def resume_many_async(*, instance_ids: Sequence[str]) -> None
Asynchronously resume several suspended instances in batches of 100.
See suspend_many for the chunking contract.
Arguments:
instance_ids- Workflow process instance identifiers.
Raises:
WorkflowOperationError- When any id is not a non-emptystr(no request is sent), or when the service rejects a chunk for a reason other than not-found or state.WorkflowNotFoundError- When a process in a chunk does not exist.WorkflowStateError- When a process in a chunk is not suspended.
cancel_many
def cancel_many(*, instance_ids: Sequence[str]) -> None
Cancel several workflow instances in batches of 100.
See suspend_many for the chunking contract. Cancellation is
irreversible.
Arguments:
instance_ids- Workflow process instance identifiers.
Raises:
WorkflowOperationError- When any id is not a non-emptystr(no request is sent), or when the service rejects a chunk for a reason other than not-found or state.WorkflowNotFoundError- When a process in a chunk does not exist.WorkflowStateError- When a process in a chunk cannot be canceled.
cancel_many_async
async def cancel_many_async(*, instance_ids: Sequence[str]) -> None
Asynchronously cancel several workflow instances in batches of 100.
See suspend_many for the chunking contract. Cancellation is
irreversible.
Arguments:
instance_ids- Workflow process instance identifiers.
Raises:
WorkflowOperationError- When any id is not a non-emptystr(no request is sent), or when the service rejects a chunk for a reason other than not-found or state.WorkflowNotFoundError- When a process in a chunk does not exist.WorkflowStateError- When a process in a chunk cannot be canceled.
start
def start(*,
workflow_name: str | None = None,
definition_id: str | None = None,
document_ref: Document | WorkflowDocumentRef | tuple[str, str]
| None = None,
document_id: str | None = None,
variables: Mapping[str, Any] | WorkflowInstanceContextRepVariables
| None = None,
body: Any | None = None) -> WorkflowInstance
Start a workflow process by definition name or definition id.
Arguments:
workflow_name- Workflow definition name; resolves the current definition with that name.definition_id- Workflow definition identifier; starts that exact definition (a specific revision when the id is a revision id).document_ref- Bound document,WorkflowDocumentRef, or(entity_type_name, document_id)tuple for the workflow target.document_id- Workflow target id when the workflow definition already implies the entity type.variables- Optional workflow instance variables for the started process.body- Advanced escape hatch for raw workflow context payloads.
Returns:
The created workflow instance wrapper.
Raises:
WorkflowOperationError- When neither or both ofworkflow_nameanddefinition_idare given; whenbodyis combined with any ofdocument_ref/document_id/variables; when bothdocument_refanddocument_idare given; when the resolved document's entity type does not match the workflow definition; whendocument_idis used but the definition declares no entity type; or when none ofdocument_ref,document_id, orbodyis provided.WorkflowNotFoundError- When the workflow definition cannot be found.WorkflowStateError- When the service rejects the start because of the target's current state.
start_async
async def start_async(*,
workflow_name: str | None = None,
definition_id: str | None = None,
document_ref: Document | WorkflowDocumentRef
| tuple[str, str] | None = None,
document_id: str | None = None,
variables: Mapping[str, Any]
| WorkflowInstanceContextRepVariables | None = None,
body: Any | None = None) -> WorkflowInstance
Asynchronously start a workflow process by definition name or id.
See start for full argument semantics. This async sibling shares
the same normalization logic; only the API calls are awaited.
Arguments:
workflow_name- Workflow definition name; resolves the current definition with that name.definition_id- Workflow definition identifier; starts that exact definition (a specific revision when the id is a revision id).document_ref- Bound document,WorkflowDocumentRef, or(entity_type_name, document_id)tuple for the workflow target.document_id- Workflow target id when the workflow definition already implies the entity type.variables- Optional workflow instance variables for the started process.body- Advanced escape hatch for raw workflow context payloads.
Returns:
The created workflow instance wrapper.
Raises:
WorkflowOperationError- When neither or both ofworkflow_nameanddefinition_idare given; whenbodyis combined with any ofdocument_ref/document_id/variables; when bothdocument_refanddocument_idare given; when the resolved document's entity type does not match the workflow definition; whendocument_idis used but the definition declares no entity type; or when none ofdocument_ref,document_id, orbodyis provided.WorkflowNotFoundError- When the workflow definition cannot be found.WorkflowStateError- When the service rejects the start because of the target's current state.