D'autres AWS SDK exemples sont disponibles dans le GitHub dépôt AWS Doc SDK Examples.
Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
À utiliser DeleteActivity
avec un AWS SDK
Les exemples de code suivants montrent comment utiliserDeleteActivity
.
Les exemples d’actions sont des extraits de code de programmes de plus grande envergure et doivent être exécutés en contexte. Vous pouvez voir cette action en contexte dans l’exemple de code suivant :
- .NET
-
- AWS SDK for .NET
-
/// <summary>
/// Delete a Step Machine activity.
/// </summary>
/// <param name="activityArn">The Amazon Resource Name (ARN) of
/// the activity.</param>
/// <returns>A Boolean value indicating the success of the action.</returns>
public async Task<bool> DeleteActivity(string activityArn)
{
var response = await _amazonStepFunctions.DeleteActivityAsync(new DeleteActivityRequest { ActivityArn = activityArn });
return response.HttpStatusCode == System.Net.HttpStatusCode.OK;
}
- Java
-
- SDKpour Java 2.x
-
public static void deleteActivity(SfnClient sfnClient, String actArn) {
try {
DeleteActivityRequest activityRequest = DeleteActivityRequest.builder()
.activityArn(actArn)
.build();
sfnClient.deleteActivity(activityRequest);
System.out.println("You have deleted " + actArn);
} catch (SfnException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
- Kotlin
-
- SDKpour Kotlin
-
suspend fun deleteActivity(actArn: String?) {
val activityRequest =
DeleteActivityRequest {
activityArn = actArn
}
SfnClient { region = "us-east-1" }.use { sfnClient ->
sfnClient.deleteActivity(activityRequest)
println("You have deleted $actArn")
}
}
- Python
-
- SDKpour Python (Boto3)
-
class Activity:
"""Encapsulates Step Function activity actions."""
def __init__(self, stepfunctions_client):
"""
:param stepfunctions_client: A Boto3 Step Functions client.
"""
self.stepfunctions_client = stepfunctions_client
def delete(self, activity_arn):
"""
Delete an activity.
:param activity_arn: The ARN of the activity to delete.
"""
try:
response = self.stepfunctions_client.delete_activity(
activityArn=activity_arn
)
except ClientError as err:
logger.error(
"Couldn't delete activity %s. Here's why: %s: %s",
activity_arn,
err.response["Error"]["Code"],
err.response["Error"]["Message"],
)
raise
else:
return response