DeleteStateMachine搭配使用 AWS SDK - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

DeleteStateMachine搭配使用 AWS SDK

以下代码示例演示如何使用 DeleteStateMachine

操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:

.NET
AWS SDK for .NET
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

/// <summary> /// Delete a Step Functions state machine. /// </summary> /// <param name="stateMachineArn">The Amazon Resource Name (ARN) of the /// state machine.</param> /// <returns>A Boolean value indicating the success of the action.</returns> public async Task<bool> DeleteStateMachine(string stateMachineArn) { var response = await _amazonStepFunctions.DeleteStateMachineAsync(new DeleteStateMachineRequest { StateMachineArn = stateMachineArn }); return response.HttpStatusCode == System.Net.HttpStatusCode.OK; }
  • 有关API详细信息,请参阅 “AWS SDK for .NET API参考 DeleteStateMachine” 中的。

Java
SDK适用于 Java 2.x
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

public static void deleteMachine(SfnClient sfnClient, String stateMachineArn) { try { DeleteStateMachineRequest deleteStateMachineRequest = DeleteStateMachineRequest.builder() .stateMachineArn(stateMachineArn) .build(); sfnClient.deleteStateMachine(deleteStateMachineRequest); DescribeStateMachineRequest describeStateMachine = DescribeStateMachineRequest.builder() .stateMachineArn(stateMachineArn) .build(); while (true) { DescribeStateMachineResponse response = sfnClient.describeStateMachine(describeStateMachine); System.out.println("The state machine is not deleted yet. The status is " + response.status()); Thread.sleep(3000); } } catch (SfnException | InterruptedException e) { System.err.println(e.getMessage()); } System.out.println(stateMachineArn + " was successfully deleted."); }
  • 有关API详细信息,请参阅 “AWS SDK for Java 2.x API参考 DeleteStateMachine” 中的。

Kotlin
SDK对于 Kotlin 来说
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

suspend fun deleteMachine(stateMachineArnVal: String?) { val deleteStateMachineRequest = DeleteStateMachineRequest { stateMachineArn = stateMachineArnVal } SfnClient { region = "us-east-1" }.use { sfnClient -> sfnClient.deleteStateMachine(deleteStateMachineRequest) println("$stateMachineArnVal was successfully deleted.") } }
Python
SDK适用于 Python (Boto3)
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

class StateMachine: """Encapsulates Step Functions state machine actions.""" def __init__(self, stepfunctions_client): """ :param stepfunctions_client: A Boto3 Step Functions client. """ self.stepfunctions_client = stepfunctions_client def delete(self, state_machine_arn): """ Delete a state machine and all of its run data. :param state_machine_arn: The ARN of the state machine to delete. """ try: response = self.stepfunctions_client.delete_state_machine( stateMachineArn=state_machine_arn ) except ClientError as err: logger.error( "Couldn't delete state machine %s. Here's why: %s: %s", state_machine_arn, err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return response
  • 有关API详细信息,请参阅DeleteStateMachine中的 AWS SDKPython (Boto3) API 参考。