Skip to content

Commit 42027b7

Browse files
committed
updated the SDK build number
1 parent 38cb73a commit 42027b7

File tree

1 file changed

+66
-62
lines changed

1 file changed

+66
-62
lines changed

javav2/example_code/stepfunctions/src/main/java/com/example/stepfunctions/StepFunctionsScenario.java

Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,24 @@
3939
import java.util.UUID;
4040

4141
// snippet-start:[stepfunctions.java2.scenario.main]
42+
4243
/**
4344
* You can obtain the JSON file to create a state machine in the following
4445
* GitHub location.
45-
*
46+
* <p>
4647
* https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/resources/sample_files
47-
*
48+
* <p>
4849
* To run this code example, place the chat_sfn_state_machine.json file into
4950
* your project's resources folder.
50-
*
51+
* <p>
5152
* Also, set up your development environment, including your credentials.
52-
*
53+
* <p>
5354
* For information, see this documentation topic:
54-
*
55+
* <p>
5556
* https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
56-
*
57+
* <p>
5758
* This Java code example performs the following tasks:
58-
*
59+
* <p>
5960
* 1. Creates an activity.
6061
* 2. Creates a state machine.
6162
* 3. Describes the state machine.
@@ -70,15 +71,15 @@ public class StepFunctionsScenario {
7071
public static void main(String[] args) throws Exception {
7172
final String usage = """
7273
73-
Usage:
74-
<roleARN> <activityName> <stateMachineName>
74+
Usage:
75+
<roleARN> <activityName> <stateMachineName>
7576
76-
Where:
77-
roleName - The name of the IAM role to create for this state machine.
78-
activityName - The name of an activity to create.
79-
stateMachineName - The name of the state machine to create.
80-
jsonFile - The location of the chat_sfn_state_machine.json file. You can located it in resources/sample_files.
81-
""";
77+
Where:
78+
roleName - The name of the IAM role to create for this state machine.
79+
activityName - The name of an activity to create.
80+
stateMachineName - The name of the state machine to create.
81+
jsonFile - The location of the chat_sfn_state_machine.json file. You can located it in resources/sample_files.
82+
""";
8283

8384
if (args.length != 4) {
8485
System.out.println(usage);
@@ -89,32 +90,35 @@ public static void main(String[] args) throws Exception {
8990
String activityName = args[1];
9091
String stateMachineName = args[2];
9192
String jsonFile = args[3];
92-
String polJSON = "{\n" +
93-
" \"Version\": \"2012-10-17\",\n" +
94-
" \"Statement\": [\n" +
95-
" {\n" +
96-
" \"Sid\": \"\",\n" +
97-
" \"Effect\": \"Allow\",\n" +
98-
" \"Principal\": {\n" +
99-
" \"Service\": \"states.amazonaws.com\"\n" +
100-
" },\n" +
101-
" \"Action\": \"sts:AssumeRole\"\n" +
102-
" }\n" +
103-
" ]\n" +
104-
"}";
93+
String polJSON = """
94+
{
95+
"Version": "2012-10-17",
96+
"Statement": [
97+
{
98+
"Sid": "",
99+
"Effect": "Allow",
100+
"Principal": {
101+
"Service": "states.amazonaws.com"
102+
},
103+
"Action": "sts:AssumeRole"
104+
}
105+
]
106+
}
107+
""";
108+
105109

106110
Scanner sc = new Scanner(System.in);
107111
boolean action = false;
108112

109113
Region region = Region.US_EAST_1;
110114
SfnClient sfnClient = SfnClient.builder()
111-
.region(region)
112-
.build();
115+
.region(region)
116+
.build();
113117

114118
Region regionGl = Region.AWS_GLOBAL;
115119
IamClient iam = IamClient.builder()
116-
.region(regionGl)
117-
.build();
120+
.region(regionGl)
121+
.build();
118122

119123
System.out.println(DASHES);
120124
System.out.println("Welcome to the AWS Step Functions example scenario.");
@@ -202,10 +206,10 @@ public static void main(String[] args) throws Exception {
202206
public static String createIAMRole(IamClient iam, String rolename, String polJSON) {
203207
try {
204208
CreateRoleRequest request = CreateRoleRequest.builder()
205-
.roleName(rolename)
206-
.assumeRolePolicyDocument(polJSON)
207-
.description("Created using the AWS SDK for Java")
208-
.build();
209+
.roleName(rolename)
210+
.assumeRolePolicyDocument(polJSON)
211+
.description("Created using the AWS SDK for Java")
212+
.build();
209213

210214
CreateRoleResponse response = iam.createRole(request);
211215
return response.role().arn();
@@ -221,8 +225,8 @@ public static String createIAMRole(IamClient iam, String rolename, String polJSO
221225
public static void describeExe(SfnClient sfnClient, String executionArn) {
222226
try {
223227
DescribeExecutionRequest executionRequest = DescribeExecutionRequest.builder()
224-
.executionArn(executionArn)
225-
.build();
228+
.executionArn(executionArn)
229+
.build();
226230

227231
String status = "";
228232
boolean hasSucceeded = false;
@@ -252,9 +256,9 @@ public static void describeExe(SfnClient sfnClient, String executionArn) {
252256
public static void sendTaskSuccess(SfnClient sfnClient, String token, String json) {
253257
try {
254258
SendTaskSuccessRequest successRequest = SendTaskSuccessRequest.builder()
255-
.taskToken(token)
256-
.output(json)
257-
.build();
259+
.taskToken(token)
260+
.output(json)
261+
.build();
258262

259263
sfnClient.sendTaskSuccess(successRequest);
260264

@@ -269,8 +273,8 @@ public static void sendTaskSuccess(SfnClient sfnClient, String token, String jso
269273
public static List<String> getActivityTask(SfnClient sfnClient, String actArn) {
270274
List<String> myList = new ArrayList<>();
271275
GetActivityTaskRequest getActivityTaskRequest = GetActivityTaskRequest.builder()
272-
.activityArn(actArn)
273-
.build();
276+
.activityArn(actArn)
277+
.build();
274278

275279
GetActivityTaskResponse response = sfnClient.getActivityTask(getActivityTaskRequest);
276280
myList.add(response.taskToken());
@@ -283,8 +287,8 @@ public static List<String> getActivityTask(SfnClient sfnClient, String actArn) {
283287
public static void deleteActivity(SfnClient sfnClient, String actArn) {
284288
try {
285289
DeleteActivityRequest activityRequest = DeleteActivityRequest.builder()
286-
.activityArn(actArn)
287-
.build();
290+
.activityArn(actArn)
291+
.build();
288292

289293
sfnClient.deleteActivity(activityRequest);
290294
System.out.println("You have deleted " + actArn);
@@ -300,8 +304,8 @@ public static void deleteActivity(SfnClient sfnClient, String actArn) {
300304
public static void describeStateMachine(SfnClient sfnClient, String stateMachineArn) {
301305
try {
302306
DescribeStateMachineRequest stateMachineRequest = DescribeStateMachineRequest.builder()
303-
.stateMachineArn(stateMachineArn)
304-
.build();
307+
.stateMachineArn(stateMachineArn)
308+
.build();
305309

306310
DescribeStateMachineResponse response = sfnClient.describeStateMachine(stateMachineRequest);
307311
System.out.println("The name of the State machine is " + response.name());
@@ -319,13 +323,13 @@ public static void describeStateMachine(SfnClient sfnClient, String stateMachine
319323
public static void deleteMachine(SfnClient sfnClient, String stateMachineArn) {
320324
try {
321325
DeleteStateMachineRequest deleteStateMachineRequest = DeleteStateMachineRequest.builder()
322-
.stateMachineArn(stateMachineArn)
323-
.build();
326+
.stateMachineArn(stateMachineArn)
327+
.build();
324328

325329
sfnClient.deleteStateMachine(deleteStateMachineRequest);
326330
DescribeStateMachineRequest describeStateMachine = DescribeStateMachineRequest.builder()
327-
.stateMachineArn(stateMachineArn)
328-
.build();
331+
.stateMachineArn(stateMachineArn)
332+
.build();
329333

330334
while (true) {
331335
DescribeStateMachineResponse response = sfnClient.describeStateMachine(describeStateMachine);
@@ -346,10 +350,10 @@ public static String startWorkflow(SfnClient sfnClient, String stateMachineArn,
346350
String uuidValue = uuid.toString();
347351
try {
348352
StartExecutionRequest executionRequest = StartExecutionRequest.builder()
349-
.input(jsonEx)
350-
.stateMachineArn(stateMachineArn)
351-
.name(uuidValue)
352-
.build();
353+
.input(jsonEx)
354+
.stateMachineArn(stateMachineArn)
355+
.name(uuidValue)
356+
.build();
353357

354358
StartExecutionResponse response = sfnClient.startExecution(executionRequest);
355359
return response.executionArn();
@@ -366,11 +370,11 @@ public static String startWorkflow(SfnClient sfnClient, String stateMachineArn,
366370
public static String createMachine(SfnClient sfnClient, String roleARN, String stateMachineName, String json) {
367371
try {
368372
CreateStateMachineRequest machineRequest = CreateStateMachineRequest.builder()
369-
.definition(json)
370-
.name(stateMachineName)
371-
.roleArn(roleARN)
372-
.type(StateMachineType.STANDARD)
373-
.build();
373+
.definition(json)
374+
.name(stateMachineName)
375+
.roleArn(roleARN)
376+
.type(StateMachineType.STANDARD)
377+
.build();
374378

375379
CreateStateMachineResponse response = sfnClient.createStateMachine(machineRequest);
376380
return response.stateMachineArn();
@@ -387,8 +391,8 @@ public static String createMachine(SfnClient sfnClient, String roleARN, String s
387391
public static String createActivity(SfnClient sfnClient, String activityName) {
388392
try {
389393
CreateActivityRequest activityRequest = CreateActivityRequest.builder()
390-
.name(activityName)
391-
.build();
394+
.name(activityName)
395+
.build();
392396

393397
CreateActivityResponse response = sfnClient.createActivity(activityRequest);
394398
return response.activityArn();

0 commit comments

Comments
 (0)