Skip to content

Commit ce35bde

Browse files
committed
Add SoS metadata
1 parent e253084 commit ce35bde

File tree

5 files changed

+258
-3
lines changed

5 files changed

+258
-3
lines changed

.doc_gen/metadata/sfn_metadata.yaml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ sfn_CreateStateMachine:
8181
snippet_tags:
8282
- python.example_code.sfn.StateMachine_decl
8383
- python.example_code.sfn.CreateStateMachine
84+
Swift:
85+
versions:
86+
- sdk_version: 1
87+
github: swift/example_code/sfn/scenario
88+
excerpts:
89+
- snippet_tags:
90+
- swift.sfn.import
91+
- swift.sfn.CreateStateMachine
8492
services:
8593
sfn: {CreateStateMachine}
8694
sfn_DeleteStateMachine:
@@ -122,6 +130,14 @@ sfn_DeleteStateMachine:
122130
snippet_tags:
123131
- python.example_code.sfn.StateMachine_decl
124132
- python.example_code.sfn.DeleteStateMachine
133+
Swift:
134+
versions:
135+
- sdk_version: 1
136+
github: swift/example_code/sfn/scenario
137+
excerpts:
138+
- snippet_tags:
139+
- swift.sfn.import
140+
- swift.sfn.DeleteStateMachine
125141
services:
126142
sfn: {DeleteStateMachine}
127143
sfn_ListStateMachines:
@@ -163,6 +179,14 @@ sfn_ListStateMachines:
163179
snippet_tags:
164180
- python.example_code.sfn.StateMachine_decl
165181
- python.example_code.sfn.ListStateMachines
182+
Swift:
183+
versions:
184+
- sdk_version: 1
185+
github: swift/example_code/sfn/scenario
186+
excerpts:
187+
- snippet_tags:
188+
- swift.sfn.import
189+
- swift.sfn.ListStateMachines
166190
services:
167191
sfn: {ListStateMachines}
168192
sfn_DescribeStateMachine:
@@ -204,6 +228,14 @@ sfn_DescribeStateMachine:
204228
snippet_tags:
205229
- python.example_code.sfn.StateMachine_decl
206230
- python.example_code.sfn.DescribeStateMachine
231+
Swift:
232+
versions:
233+
- sdk_version: 1
234+
github: swift/example_code/sfn/scenario
235+
excerpts:
236+
- snippet_tags:
237+
- swift.sfn.import
238+
- swift.sfn.DescribeStateMachine
207239
services:
208240
sfn: {DescribeStateMachine}
209241
sfn_StartExecution:
@@ -254,6 +286,14 @@ sfn_StartExecution:
254286
- description:
255287
snippet_files:
256288
- javascriptv3/example_code/sfn/actions/start-execution.js
289+
Swift:
290+
versions:
291+
- sdk_version: 1
292+
github: swift/example_code/sfn/scenario
293+
excerpts:
294+
- snippet_tags:
295+
- swift.sfn.import
296+
- swift.sfn.StartExecution
257297
services:
258298
sfn: {StartExecution}
259299
sfn_ListExecutions:
@@ -325,6 +365,14 @@ sfn_DescribeExecution:
325365
- description:
326366
snippet_tags:
327367
- python.example_code.sfn.DescribeExecution
368+
Swift:
369+
versions:
370+
- sdk_version: 1
371+
github: swift/example_code/sfn/scenario
372+
excerpts:
373+
- snippet_tags:
374+
- swift.sfn.import
375+
- swift.sfn.DescribeExecution
328376
services:
329377
sfn: {DescribeExecution}
330378
sfn_CreateActivity:
@@ -366,6 +414,14 @@ sfn_CreateActivity:
366414
snippet_tags:
367415
- python.example_code.sfn.Activity_decl
368416
- python.example_code.sfn.CreateActivity
417+
Swift:
418+
versions:
419+
- sdk_version: 1
420+
github: swift/example_code/sfn/scenario
421+
excerpts:
422+
- snippet_tags:
423+
- swift.sfn.import
424+
- swift.sfn.CreateActivity
369425
services:
370426
sfn: {CreateActivity}
371427
sfn_ListActivities:
@@ -407,6 +463,14 @@ sfn_ListActivities:
407463
snippet_tags:
408464
- python.example_code.sfn.Activity_decl
409465
- python.example_code.sfn.ListActivities
466+
Swift:
467+
versions:
468+
- sdk_version: 1
469+
github: swift/example_code/sfn/scenario
470+
excerpts:
471+
- snippet_tags:
472+
- swift.sfn.import
473+
- swift.sfn.CreateActivity
410474
services:
411475
sfn: {ListActivities}
412476
sfn_GetActivityTask:
@@ -447,6 +511,14 @@ sfn_GetActivityTask:
447511
snippet_tags:
448512
- python.example_code.sfn.Activity_decl
449513
- python.example_code.sfn.GetActivityTask
514+
Swift:
515+
versions:
516+
- sdk_version: 1
517+
github: swift/example_code/sfn/scenario
518+
excerpts:
519+
- snippet_tags:
520+
- swift.sfn.import
521+
- swift.sfn.GetActivityTask
450522
services:
451523
sfn: {GetActivityTask}
452524
sfn_SendTaskSuccess:
@@ -488,6 +560,14 @@ sfn_SendTaskSuccess:
488560
snippet_tags:
489561
- python.example_code.sfn.Activity_decl
490562
- python.example_code.sfn.SendTaskSuccess
563+
Swift:
564+
versions:
565+
- sdk_version: 1
566+
github: swift/example_code/sfn/scenario
567+
excerpts:
568+
- snippet_tags:
569+
- swift.sfn.import
570+
- swift.sfn.SendTaskSuccess
491571
services:
492572
sfn: {SendTaskSuccess}
493573
sfn_DeleteActivity:
@@ -529,6 +609,14 @@ sfn_DeleteActivity:
529609
snippet_tags:
530610
- python.example_code.sfn.Activity_decl
531611
- python.example_code.sfn.DeleteActivity
612+
Swift:
613+
versions:
614+
- sdk_version: 1
615+
github: swift/example_code/sfn/scenario
616+
excerpts:
617+
- snippet_tags:
618+
- swift.sfn.import
619+
- swift.sfn.DeleteActivity
532620
services:
533621
sfn: {DeleteActivity}
534622
sfn_Scenario_GetStartedStateMachines:
@@ -586,6 +674,21 @@ sfn_Scenario_GetStartedStateMachines:
586674
- description: Define a class that wraps activity actions.
587675
snippet_tags:
588676
- python.example_code.sfn.Activity_full
677+
Swift:
678+
versions:
679+
- sdk_version: 1
680+
github: swift/example_code/sfn/scenario
681+
excerpts:
682+
- description: The main program, <filename>entry.swift</filename>.
683+
snippet_tags:
684+
- swift.sfn.scenario
685+
- description: The activity manager, <filename>Activity.swift</filename>
686+
snippet_tags:
687+
- swift.sfn.scenario.activity
688+
- description: The state machine manager, <filename>StateMachine.swift</filename>
689+
snippet_tags:
690+
- swift.sfn.scenario.statemachine
691+
589692
services:
590693
sfn: {CreateActivity, CreateStateMachine, DeleteActivity, DeleteStateMachine, DescribeExecution, DescribeStateMachine,
591694
GetActivityTask, ListActivities, ListStateMachines, SendTaskSuccess, StartExecution, StopExecution}

swift/example_code/sfn/README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Step Functions code examples for the SDK for Swift
2+
3+
## Overview
4+
5+
Shows how to use the AWS SDK for Swift to work with AWS Step Functions.
6+
7+
<!--custom.overview.start-->
8+
<!--custom.overview.end-->
9+
10+
_Step Functions makes it easy to coordinate the components of distributed applications as a series of steps in a visual workflow._
11+
12+
## ⚠ Important
13+
14+
* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/).
15+
* Running the tests might result in charges to your AWS account.
16+
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
17+
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).
18+
19+
<!--custom.important.start-->
20+
<!--custom.important.end-->
21+
22+
## Code examples
23+
24+
### Prerequisites
25+
26+
For prerequisites, see the [README](../../README.md#Prerequisites) in the `swift` folder.
27+
28+
29+
<!--custom.prerequisites.start-->
30+
<!--custom.prerequisites.end-->
31+
32+
### Basics
33+
34+
Code examples that show you how to perform the essential operations within a service.
35+
36+
- [Learn the basics](scenario/Sources/entry.swift)
37+
38+
39+
### Single actions
40+
41+
Code excerpts that show you how to call individual service functions.
42+
43+
- [CreateActivity](scenario/Sources/Activity.swift#L42)
44+
- [CreateStateMachine](scenario/Sources/StateMachine.swift#L133)
45+
- [DeleteActivity](scenario/Sources/Activity.swift#L102)
46+
- [DeleteStateMachine](scenario/Sources/StateMachine.swift#L308)
47+
- [DescribeExecution](scenario/Sources/StateMachine.swift#L263)
48+
- [DescribeStateMachine](scenario/Sources/StateMachine.swift#L180)
49+
- [GetActivityTask](scenario/Sources/StateMachine.swift#L228)
50+
- [ListActivities](scenario/Sources/Activity.swift#L42)
51+
- [ListStateMachines](scenario/Sources/StateMachine.swift#L105)
52+
- [SendTaskSuccess](scenario/Sources/Activity.swift#L115)
53+
- [StartExecution](scenario/Sources/StateMachine.swift#L205)
54+
55+
56+
<!--custom.examples.start-->
57+
<!--custom.examples.end-->
58+
59+
## Run the examples
60+
61+
### Instructions
62+
63+
To build any of these examples from a terminal window, navigate into its
64+
directory, then use the following command:
65+
66+
```
67+
$ swift build
68+
```
69+
70+
To build one of these examples in Xcode, navigate to the example's directory
71+
(such as the `ListUsers` directory, to build that example). Then type `xed.`
72+
to open the example directory in Xcode. You can then use standard Xcode build
73+
and run commands.
74+
75+
<!--custom.instructions.start-->
76+
<!--custom.instructions.end-->
77+
78+
79+
#### Learn the basics
80+
81+
This example shows you how to do the following:
82+
83+
- Create an activity.
84+
- Create a state machine from an Amazon States Language definition that contains the previously created activity as a step.
85+
- Run the state machine and respond to the activity with user input.
86+
- Get the final status and output after the run completes, then clean up resources.
87+
88+
<!--custom.basic_prereqs.sfn_Scenario_GetStartedStateMachines.start-->
89+
<!--custom.basic_prereqs.sfn_Scenario_GetStartedStateMachines.end-->
90+
91+
92+
<!--custom.basics.sfn_Scenario_GetStartedStateMachines.start-->
93+
<!--custom.basics.sfn_Scenario_GetStartedStateMachines.end-->
94+
95+
96+
### Tests
97+
98+
⚠ Running tests might result in charges to your AWS account.
99+
100+
101+
To find instructions for running these tests, see the [README](../../README.md#Tests)
102+
in the `swift` folder.
103+
104+
105+
106+
<!--custom.tests.start-->
107+
<!--custom.tests.end-->
108+
109+
## Additional resources
110+
111+
- [Step Functions Developer Guide](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html)
112+
- [Step Functions API Reference](https://docs.aws.amazon.com/step-functions/latest/apireference/Welcome.html)
113+
- [SDK for Swift Step Functions reference](https://sdk.amazonaws.com/swift/api/awssfn/latest/documentation/awssfn)
114+
115+
<!--custom.resources.start-->
116+
<!--custom.resources.end-->
117+
118+
---
119+
120+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
121+
122+
SPDX-License-Identifier: Apache-2.0

swift/example_code/sfn/scenario/Sources/Activity.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
// snippet-start:[swift.sfn.scenario.activity]
45
import Foundation
56
import AWSSFN
67

@@ -38,6 +39,7 @@ class Activity {
3839
try await self.findOrCreateActivity()
3940
}
4041

42+
// snippet-start:[swift.sfn.CreateActivity]
4143
/// Create a new Step Functions activity.
4244
///
4345
/// - Throws: `ActivityError` and appropriate AWS errors.
@@ -52,7 +54,10 @@ class Activity {
5254

5355
activityArn = arn
5456
}
57+
// snippet-end:[swift.sfn.CreateActivity]
5558

59+
// snippet-start:[swift.sfn.ListActivitiesPaginated]
60+
// snippet-start:[swift.sfn.ListActivities]
5661
/// Find an activity with the name specified when initializing the
5762
/// `Activity` object.
5863
///
@@ -79,6 +84,8 @@ class Activity {
7984

8085
throw ActivityError.activityNotFoundError
8186
}
87+
// snippet-end:[swift.sfn.ListActivities]
88+
// snippet-end:[swift.sfn.ListActivitiesPaginated]
8289

8390
/// Finds an existing activity with the name given when initializing
8491
/// the `Activity`. If one isn't found, a new one is created.
@@ -92,6 +99,7 @@ class Activity {
9299
}
93100
}
94101

102+
// snippet-start:[swift.sfn.DeleteActivity]
95103
/// Delete the activity described by this object.
96104
public func delete() async {
97105
do {
@@ -102,7 +110,9 @@ class Activity {
102110
print("*** Error deleting the activity: \(error.localizedDescription)")
103111
}
104112
}
113+
// snippet-end:[swift.sfn.DeleteActivity]
105114

115+
// snippet-start:[swift.sfn.SendTaskSuccess]
106116
/// Sends a task success notification to the activity.
107117
///
108118
/// - Parameters:
@@ -122,4 +132,6 @@ class Activity {
122132
return false
123133
}
124134
}
125-
}
135+
// snippet-end:[swift.sfn.SendTaskSuccess]
136+
}
137+
// snippet-end:[swift.sfn.scenario.activity]

0 commit comments

Comments
 (0)