///<summary>/// Create a Step Functions state machine.///</summary>///<param name="stateMachineName">Name for the new Step Functions state/// machine.</param>///<param name="definition">A JSON string that defines the Step Functions/// state machine.</param>///<param name="roleArn">The Amazon Resource Name (ARN) of the role.</param>///<returns></returns>publicasync Task<string> CreateStateMachine(string stateMachineName, string definition, string roleArn){var request = new CreateStateMachineRequest
{
Name = stateMachineName,
Definition = definition,
RoleArn = roleArn
};
var response =
await _amazonStepFunctions.CreateStateMachineAsync(request);
return response.StateMachineArn;
}
classStateMachine:"""Encapsulates Step Functions state machine actions."""def__init__(self, stepfunctions_client):"""
:param stepfunctions_client: A Boto3 Step Functions client.
"""
self.stepfunctions_client = stepfunctions_client
defcreate(self, name, definition, role_arn):"""
Creates a state machine with the specific definition. The state machine assumes
the provided role before it starts a run.
:param name: The name to give the state machine.
:param definition: The Amazon States Language definition of the steps in the
the state machine.
:param role_arn: The Amazon Resource Name (ARN) of the role that is assumed by
Step Functions when the state machine is run.
:return: The ARN of the newly created state machine.
"""try:
response = self.stepfunctions_client.create_state_machine(
name=name, definition=definition, roleArn=role_arn
)
except ClientError as err:
logger.error(
"Couldn't create state machine %s. Here's why: %s: %s",
name,
err.response["Error"]["Code"],
err.response["Error"]["Message"],
)
raiseelse:
return response["stateMachineArn"]
///<summary>/// Create a Step Functions state machine.///</summary>///<param name="stateMachineName">Name for the new Step Functions state/// machine.</param>///<param name="definition">A JSON string that defines the Step Functions/// state machine.</param>///<param name="roleArn">The Amazon Resource Name (ARN) of the role.</param>///<returns></returns>publicasync Task<string> CreateStateMachine(string stateMachineName, string definition, string roleArn){var request = new CreateStateMachineRequest
{
Name = stateMachineName,
Definition = definition,
RoleArn = roleArn
};
var response =
await _amazonStepFunctions.CreateStateMachineAsync(request);
return response.StateMachineArn;
}