Skip to content

list_executions

list_executions(
    *,
    config_overrides: Optional[SFNClientConfig] = None,
    state_machine_arn: Optional[Arn] = None,
    status_filter: Optional[ExecutionStatus] = None,
    max_results: Optional[PageSize] = None,
    next_token: Optional[ListExecutionsPageToken] = None,
    map_run_arn: Optional[LongArn] = None,
    redrive_filter: Optional[ExecutionRedriveFilter] = None,
) -> ListExecutionsOutput

Lists all executions of a state machine or a Map Run. You can list all executions related to a state machine by specifying a state machine Amazon Resource Name (ARN), or those related to a Map Run by specifying a Map Run ARN. Using this API action, you can also list all redriven executions.

You can also provide a state machine alias ARN or version ARN to list the executions associated with a specific alias or version.

Results are sorted by time, with the most recent execution first. Running executions are sorted by their startDate or redriveDate, and other executions are sorted by their stopDate.

If nextToken is returned, there are more results available. The value of nextToken is a unique pagination token for each page. Make the call again using the returned token to retrieve the next page. Keep all other arguments unchanged. Each pagination token expires after 24 hours. Using an expired pagination token will return an HTTP 400 InvalidToken error.

This operation is eventually consistent. The results are best effort and may not reflect very recent updates and changes.

This API action is not supported by EXPRESS state machines. However, you may list EXPRESS children started by a map run using the mapRunArn parameter.

Parameters:

  • state_machine_arn (Optional[Arn], default: None ) –

    The Amazon Resource Name (ARN) of the state machine whose executions is listed.

    You can specify either a mapRunArn or a stateMachineArn, but not both.

    You can also return a list of executions associated with a specific alias or version, by specifying an alias ARN or a version ARN in the stateMachineArn parameter.

  • status_filter (Optional[ExecutionStatus], default: None ) –

    If specified, only list the executions whose current execution status matches the given filter.

    If you provide a PENDING_REDRIVE statusFilter, you must specify mapRunArn. For more information, see Child workflow execution redrive behaviour in the Step Functions Developer Guide.

    If you provide a stateMachineArn and a PENDING_REDRIVE statusFilter, the API returns a validation exception.

  • max_results (Optional[PageSize], default: None ) –

    The maximum number of results that are returned per call. You can use nextToken to obtain further pages of results. The default is 100 and the maximum allowed page size is 1000. A value of 0 uses the default.

    This is only an upper limit. The actual number of results returned per call might be fewer than the specified maximum.

  • next_token (Optional[ListExecutionsPageToken], default: None ) –

    If nextToken is returned, there are more results available. The value of nextToken is a unique pagination token for each page. Make the call again using the returned token to retrieve the next page. Keep all other arguments unchanged. Each pagination token expires after 24 hours. Using an expired pagination token will return an HTTP 400 InvalidToken error.

  • map_run_arn (Optional[LongArn], default: None ) –

    The Amazon Resource Name (ARN) of the Map Run that started the child workflow executions. If the mapRunArn field is specified, a list of all of the child workflow executions started by a Map Run is returned. For more information, see Examining Map Run in the Step Functions Developer Guide.

    You can specify either a mapRunArn or a stateMachineArn, but not both.

  • redrive_filter (Optional[ExecutionRedriveFilter], default: None ) –

    Sets a filter to list executions based on whether or not they have been redriven.

    For a Distributed Map, redriveFilter sets a filter to list child workflow executions based on whether or not they have been redriven.

    If you do not provide a redriveFilter, Step Functions returns a list of both redriven and non-redriven executions.

    If you provide a state machine ARN in redriveFilter, the API returns a validation exception.

Raises:

Source code in docs_src/capo_sfn/_services/sfn.py
def list_executions(
    self,
    *,
    config_overrides: Optional[SFNClientConfig] = None,
    state_machine_arn: Optional["capo_sfn.types.arn.Arn"] = None,
    status_filter: Optional[
        "capo_sfn.types.execution_status.ExecutionStatus"
    ] = None,
    max_results: Optional["capo_sfn.types.page_size.PageSize"] = None,
    next_token: Optional[
        "capo_sfn.types.list_executions_page_token.ListExecutionsPageToken"
    ] = None,
    map_run_arn: Optional["capo_sfn.types.long_arn.LongArn"] = None,
    redrive_filter: Optional[
        "capo_sfn.types.execution_redrive_filter.ExecutionRedriveFilter"
    ] = None,
) -> "capo_sfn.types.list_executions_output.ListExecutionsOutput":
    """<p>Lists all executions of a state machine or a Map Run. You can list all executions related to a state machine by specifying a state machine Amazon Resource Name (ARN), or those related to a Map Run by specifying a Map Run ARN. Using this API action, you can also list all <a href="https://docs.aws.amazon.com/step-functions/latest/dg/redrive-executions.html">redriven</a> executions.</p> <p>You can also provide a state machine <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-state-machine-alias.html">alias</a> ARN or <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-state-machine-version.html">version</a> ARN to list the executions associated with a specific alias or version.</p> <p>Results are sorted by time, with the most recent execution first. Running executions are sorted by their <code>startDate</code> or <code>redriveDate</code>, and other executions are sorted by their <code>stopDate</code>.</p> <p>If <code>nextToken</code> is returned, there are more results available. The value of <code>nextToken</code> is a unique pagination token for each page. Make the call again using the returned token to retrieve the next page. Keep all other arguments unchanged. Each pagination token expires after 24 hours. Using an expired pagination token will return an <i>HTTP 400 InvalidToken</i> error.</p> <note> <p>This operation is eventually consistent. The results are best effort and may not reflect very recent updates and changes.</p> </note> <p>This API action is not supported by <code>EXPRESS</code> state machines. However, you may list <code>EXPRESS</code> children started by a map run using the <code>mapRunArn</code> parameter.</p>

    Args:
        state_machine_arn: <p>The Amazon Resource Name (ARN) of the state machine whose executions is listed.</p> <p>You can specify either a <code>mapRunArn</code> or a <code>stateMachineArn</code>, but not both.</p> <p>You can also return a list of executions associated with a specific <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-state-machine-alias.html">alias</a> or <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-state-machine-version.html">version</a>, by specifying an alias ARN or a version ARN in the <code>stateMachineArn</code> parameter.</p>
        status_filter: <p>If specified, only list the executions whose current execution status matches the given filter.</p> <p>If you provide a <code>PENDING_REDRIVE</code> statusFilter, you must specify <code>mapRunArn</code>. For more information, see <a href="https://docs.aws.amazon.com/step-functions/latest/dg/redrive-map-run.html#redrive-child-workflow-behavior">Child workflow execution redrive behaviour</a> in the <i>Step Functions Developer Guide</i>. </p> <p>If you provide a stateMachineArn and a <code>PENDING_REDRIVE</code> statusFilter, the API returns a validation exception.</p>
        max_results: <p>The maximum number of results that are returned per call. You can use <code>nextToken</code> to obtain further pages of results. The default is 100 and the maximum allowed page size is 1000. A value of 0 uses the default.</p> <p>This is only an upper limit. The actual number of results returned per call might be fewer than the specified maximum.</p>
        next_token: <p>If <code>nextToken</code> is returned, there are more results available. The value of <code>nextToken</code> is a unique pagination token for each page. Make the call again using the returned token to retrieve the next page. Keep all other arguments unchanged. Each pagination token expires after 24 hours. Using an expired pagination token will return an <i>HTTP 400 InvalidToken</i> error.</p>
        map_run_arn: <p>The Amazon Resource Name (ARN) of the Map Run that started the child workflow executions. If the <code>mapRunArn</code> field is specified, a list of all of the child workflow executions started by a Map Run is returned. For more information, see <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-examine-map-run.html">Examining Map Run</a> in the <i>Step Functions Developer Guide</i>.</p> <p>You can specify either a <code>mapRunArn</code> or a <code>stateMachineArn</code>, but not both.</p>
        redrive_filter: <p>Sets a filter to list executions based on whether or not they have been redriven.</p> <p>For a Distributed Map, <code>redriveFilter</code> sets a filter to list child workflow executions based on whether or not they have been redriven.</p> <p>If you do not provide a <code>redriveFilter</code>, Step Functions returns a list of both redriven and non-redriven executions.</p> <p>If you provide a state machine ARN in <code>redriveFilter</code>, the API returns a validation exception.</p>

    Raises:
        capo_sfn.errors.invalid_arn.InvalidArn: <p>The provided Amazon Resource Name (ARN) is not valid.</p>
        capo_sfn.errors.invalid_token.InvalidToken: <p>The provided token is not valid.</p>
        capo_sfn.errors.resource_not_found.ResourceNotFound: <p>Could not find the referenced resource.</p>
        capo_sfn.errors.state_machine_does_not_exist.StateMachineDoesNotExist: <p>The specified state machine does not exist.</p>
        capo_sfn.errors.state_machine_type_not_supported.StateMachineTypeNotSupported: <p>State machine type is not supported.</p>
        capo_sfn.errors.validation_exception.ValidationException: <p>The input does not satisfy the constraints specified by an Amazon Web Services service.</p>
        capo_sfn.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sfn.types.list_executions_input.ListExecutionsInput]",
    ) -> OperationResponse[
        "capo_sfn.types.list_executions_output.ListExecutionsOutput"
    ]:
        import capo_sfn._operations.aws_step_functions.list_executions

        output, http_response = (
            capo_sfn._operations.aws_step_functions.list_executions.list_executions(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListExecutions")
    )
    input_: capo_sfn.types.list_executions_input.ListExecutionsInput = {}
    if state_machine_arn is not None:
        input_["state_machine_arn"] = state_machine_arn
    if status_filter is not None:
        input_["status_filter"] = status_filter
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if map_run_arn is not None:
        input_["map_run_arn"] = map_run_arn
    if redrive_filter is not None:
        input_["redrive_filter"] = redrive_filter

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output