py_swf.clients.workflow

class py_swf.clients.workflow.WorkflowClient(workflow_client_config, boto_client)[source]

A client that provides a pythonic API for starting and terminating workflows through an SWF boto3 client.

Parameters:
  • workflow_client_config (WorkflowClientConfig) – Contains SWF values commonly used when making SWF api calls.
  • boto_client (Client) – A raw SWF boto3 client.
count_closed_workflow_executions(oldest_start_date=None, latest_start_date=None, oldest_close_date=None, latest_close_date=None, workflow_name=None, version=None, tag=None, workflow_id=None, close_status=None)[source]

Count the number of closed workflows for a domain. You can pass in filtering criteria. This operation is eventually consistent. The results are best effort and may not exactly reflect recent updates and changes. Worklfows started or closed near the time when calling count_open_workflow_executions may not be reflected

Passthrough to :meth:~SWF.Client.count_closed_workflow_executions``

startTimeFilter and closeTimeFilter are mutually exclusive. You MUST specify one of these in a request but not both. closeStatusFilter , executionFilter , typeFilter and tagFilter are mutually exclusive. You can specify at most

one of these in a request.
Parameters:
  • oldest_start_date – datetime. Specifies the oldest start date and time to return.
  • latest_start_date – datetime. Specifies the latest start date and time to return.
  • oldest_close_date – datetime. Specifies the oldest close date and time to return.
  • latest_close_date – datetime. Specifies the latest close date and time to return.
  • workflow_name – string. Required for typeFilter. Specifies the type of the workflow executions to be counted.
  • version – string. Optional for typeFilter. Version of the workflow type.
  • tag – string. Required for tagFilter. Specifies the tag that must be associated with the execution for it to meet the filter criteria.
  • workflow_id – string. Required for executionFilter. The workflowId to pass of match the criteria of this filter.
  • close_status – string. valid status are (‘COMPLETED’, ‘FAILED’, ‘CANCELED’, ‘TERMINATED’, ‘CONTINUED_AS_NEW’, ‘TIMED_OUT’) This filter has an affect only if executionStatus is specified as CLOSED
Returns:

total number of closed workflows that meet the filter criteria

count_open_workflow_executions(oldest_start_date, latest_start_date=None, workflow_name=None, version=None, tag=None, workflow_id=None)[source]

Count the number of open workflows for a domain. You can pass in filtering criteria. This operation is eventually consistent. The results are best effort and may not exactly reflect recent updates and changes. Worklfows started or closed near the time when calling count_open_workflow_executions may not be reflected

Passthrough to :meth:~SWF.Client.count_open_workflow_executions``

executionFilter , typeFilter and tagFilter are mutually exclusive. You can specify at most one of these in a request.

Parameters:
  • oldest_start_date – datetime. Specifies the oldest start date and time to return.
  • latest_start_date – datetime. Specifies the latest start date and time to return.
  • workflow_name – string. Required for typeFilter. Specifies the type of the workflow executions to be counted.
  • version – string. Optional for typeFilter. Version of the workflow type.
  • tag – string. Required for tagFilter. Specifies the tag that must be associated with the execution for it to meet the filter criteria.
  • workflow_id – string. Required for executionFilter. The workflowId to pass of match the criteria of this filter.
Returns:

number of open workflows within time range

start_workflow(input, id, workflow_name, version, workflow_start_to_close_timeout=None)[source]

Enqueues and starts a workflow to SWF.

Passthrough to start_workflow_execution().

Parameters:
  • input (string) – Freeform string arguments describing inputs to the workflow.
  • id (string) – Freeform string that represents a unique identifier for the workflow.
  • workflow_name (string) – The name of the workflow type. The combination of workflow type name and version must be unique with in a domain.
  • version (string) – The version of the workflow type.
Returns:

An AWS generated uuid that represents a unique identifier for the run of this workflow.

Return type:

string

terminate_workflow(workflow_id, reason)[source]

Forcefully terminates a workflow by preventing further responding and executions of future decision tasks and activity tasks.

Passthrough to terminate_workflow_execution().

Parameters:
  • workflow_id – Freeform string that represents a unique identifier for the workflow.
  • reason – Freeform string describing why the workflow was forcefully terminated.
Returns:

None.

Return type:

NoneType