Use ListExecutions with an AWS SDK - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use ListExecutions with an AWS SDK

The following code examples show how to use ListExecutions.

.NET
AWS SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

/// <summary> /// Retrieve information about executions of a Step Functions /// state machine. /// </summary> /// <param name="stateMachineArn">The Amazon Resource Name (ARN) of the /// Step Functions state machine.</param> /// <returns>A list of ExecutionListItem objects.</returns> public async Task<List<ExecutionListItem>> ListExecutionsAsync(string stateMachineArn) { var executions = new List<ExecutionListItem>(); ListExecutionsResponse response; var request = new ListExecutionsRequest { StateMachineArn = stateMachineArn }; do { response = await _amazonStepFunctions.ListExecutionsAsync(request); executions.AddRange(response.Executions); if (response.NextToken is not null) { request.NextToken = response.NextToken; } } while (response.NextToken is not null); return executions; }
  • For API details, see ListExecutions in AWS SDK for .NET API Reference.

Java
SDK for Java 2.x
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

public static void getExeHistory(SfnClient sfnClient, String exeARN) { try { GetExecutionHistoryRequest historyRequest = GetExecutionHistoryRequest.builder() .executionArn(exeARN) .maxResults(10) .build(); GetExecutionHistoryResponse historyResponse = sfnClient.getExecutionHistory(historyRequest); List<HistoryEvent> events = historyResponse.events(); for (HistoryEvent event : events) { System.out.println("The event type is " + event.type().toString()); } } catch (SfnException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
  • For API details, see ListExecutions in AWS SDK for Java 2.x API Reference.

Kotlin
SDK for Kotlin
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

suspend fun getExeHistory(exeARN: String?) { val historyRequest = GetExecutionHistoryRequest { executionArn = exeARN maxResults = 10 } SfnClient { region = "us-east-1" }.use { sfnClient -> val response = sfnClient.getExecutionHistory(historyRequest) response.events?.forEach { event -> println("The event type is ${event.type}") } } }
  • For API details, see ListExecutions in AWS SDK for Kotlin API reference.