Skip to content

Commit 9ed0108

Browse files
Add Glue scenario example for Swift (#7487)
Add Glue scenario example for Swift -------- Co-authored-by: Jason Q <81179619+beqqrry-aws@users.noreply.github.com>
1 parent 95d6ac1 commit 9ed0108

File tree

8 files changed

+1509
-0
lines changed

8 files changed

+1509
-0
lines changed

.doc_gen/metadata/glue_metadata.yaml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@ glue_GetCrawler:
153153
- description:
154154
snippet_tags:
155155
- rust.glue.get_crawler
156+
Swift:
157+
versions:
158+
- sdk_version: 1
159+
github: swift/example_code/glue
160+
excerpts:
161+
- description:
162+
snippet_tags:
163+
- swift.glue.import
164+
- swift.glue.GetCrawler
156165
services:
157166
glue: {GetCrawler}
158167
glue_CreateCrawler:
@@ -241,6 +250,15 @@ glue_CreateCrawler:
241250
- description:
242251
snippet_tags:
243252
- rust.glue.create_crawler
253+
Swift:
254+
versions:
255+
- sdk_version: 1
256+
github: swift/example_code/glue
257+
excerpts:
258+
- description:
259+
snippet_tags:
260+
- swift.glue.import
261+
- swift.glue.CreateCrawler
244262
services:
245263
glue: {CreateCrawler}
246264
glue_StartCrawler:
@@ -329,6 +347,15 @@ glue_StartCrawler:
329347
- description:
330348
snippet_tags:
331349
- rust.glue.start_crawler
350+
Swift:
351+
versions:
352+
- sdk_version: 1
353+
github: swift/example_code/glue
354+
excerpts:
355+
- description:
356+
snippet_tags:
357+
- swift.glue.import
358+
- swift.glue.StartCrawler
332359
services:
333360
glue: {StartCrawler}
334361
glue_GetDatabase:
@@ -416,6 +443,15 @@ glue_GetDatabase:
416443
- description:
417444
snippet_tags:
418445
- rust.glue.get_database
446+
Swift:
447+
versions:
448+
- sdk_version: 1
449+
github: swift/example_code/glue
450+
excerpts:
451+
- description:
452+
snippet_tags:
453+
- swift.glue.import
454+
- swift.glue.GetDatabase
419455
services:
420456
glue: {GetDatabase}
421457
glue_GetTables:
@@ -494,6 +530,15 @@ glue_GetTables:
494530
- description:
495531
snippet_tags:
496532
- rust.glue.get_tables
533+
Swift:
534+
versions:
535+
- sdk_version: 1
536+
github: swift/example_code/glue
537+
excerpts:
538+
- description:
539+
snippet_tags:
540+
- swift.glue.import
541+
- swift.glue.GetTables
497542
services:
498543
glue: {GetTables}
499544
glue_CreateJob:
@@ -573,6 +618,15 @@ glue_CreateJob:
573618
- description:
574619
snippet_tags:
575620
- rust.glue.create_job
621+
Swift:
622+
versions:
623+
- sdk_version: 1
624+
github: swift/example_code/glue
625+
excerpts:
626+
- description:
627+
snippet_tags:
628+
- swift.glue.import
629+
- swift.glue.CreateJob
576630
services:
577631
glue: {CreateJob}
578632
glue_StartJobRun:
@@ -653,6 +707,15 @@ glue_StartJobRun:
653707
- description:
654708
snippet_tags:
655709
- rust.glue.start_job_run
710+
Swift:
711+
versions:
712+
- sdk_version: 1
713+
github: swift/example_code/glue
714+
excerpts:
715+
- description:
716+
snippet_tags:
717+
- swift.glue.import
718+
- swift.glue.StartJobRun
656719
services:
657720
glue: {StartJobRun}
658721
glue_ListJobs:
@@ -720,6 +783,15 @@ glue_ListJobs:
720783
- description:
721784
snippet_tags:
722785
- rust.glue.list_jobs
786+
Swift:
787+
versions:
788+
- sdk_version: 1
789+
github: swift/example_code/glue
790+
excerpts:
791+
- description:
792+
snippet_tags:
793+
- swift.glue.import
794+
- swift.glue.ListJobs
723795
services:
724796
glue: {ListJobs}
725797
glue_GetJobRuns:
@@ -859,6 +931,15 @@ glue_GetJobRun:
859931
- description:
860932
snippet_tags:
861933
- rust.glue.get_job_run
934+
Swift:
935+
versions:
936+
- sdk_version: 1
937+
github: swift/example_code/glue
938+
excerpts:
939+
- description:
940+
snippet_tags:
941+
- swift.glue.import
942+
- swift.glue.GetJobRun
862943
services:
863944
glue: {GetJobRun}
864945
glue_DeleteJob:
@@ -936,6 +1017,15 @@ glue_DeleteJob:
9361017
- description:
9371018
snippet_tags:
9381019
- rust.glue.delete_job
1020+
Swift:
1021+
versions:
1022+
- sdk_version: 1
1023+
github: swift/example_code/glue
1024+
excerpts:
1025+
- description:
1026+
snippet_tags:
1027+
- swift.glue.import
1028+
- swift.glue.DeleteJob
9391029
services:
9401030
glue: {DeleteJob}
9411031
glue_DeleteTable:
@@ -1070,6 +1160,15 @@ glue_DeleteDatabase:
10701160
- description:
10711161
snippet_tags:
10721162
- rust.glue.delete_database
1163+
Swift:
1164+
versions:
1165+
- sdk_version: 1
1166+
github: swift/example_code/glue
1167+
excerpts:
1168+
- description:
1169+
snippet_tags:
1170+
- swift.glue.import
1171+
- swift.glue.DeleteDatabase
10731172
services:
10741173
glue: {DeleteDatabase}
10751174
glue_DeleteCrawler:
@@ -1147,6 +1246,15 @@ glue_DeleteCrawler:
11471246
- description:
11481247
snippet_tags:
11491248
- rust.glue.delete_crawler
1249+
Swift:
1250+
versions:
1251+
- sdk_version: 1
1252+
github: swift/example_code/glue
1253+
excerpts:
1254+
- description:
1255+
snippet_tags:
1256+
- swift.glue.import
1257+
- swift.glue.DeleteCrawler
11501258
services:
11511259
glue: {DeleteCrawler}
11521260
glue_GetDatabases:
@@ -1333,6 +1441,17 @@ glue_Scenario_GetStartedCrawlersJobs:
13331441
- rust.glue.delete_table
13341442
- rust.glue.delete_database
13351443
- rust.glue.delete_crawler
1444+
Swift:
1445+
versions:
1446+
- sdk_version: 1
1447+
github: swift/example_code/glue
1448+
excerpts:
1449+
- description: The <code>Package.swift</code> file.
1450+
snippet_tags:
1451+
- swift.glue.scenario.package
1452+
- description: The Swift code file, <code>entry.swift</code>.
1453+
snippet_tags:
1454+
- swift.glue.scenario
13361455
services:
13371456
glue: {GetCrawler, CreateCrawler, StartCrawler, GetDatabase, GetDatabases, GetTables, CreateJob, StartJobRun, ListJobs,
13381457
GetJob, GetJobRuns, GetJobRun, DeleteJob, DeleteTable, DeleteDatabase, DeleteCrawler}

swift/example_code/glue/README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# AWS Glue 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 Glue.
6+
7+
<!--custom.overview.start-->
8+
<!--custom.overview.end-->
9+
10+
_AWS Glue is a scalable, serverless data integration service that makes it easy to discover, prepare, and combine data for analytics, machine learning, and application development._
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/Package.swift)
37+
38+
39+
### Single actions
40+
41+
Code excerpts that show you how to call individual service functions.
42+
43+
- [CreateCrawler](scenario/Sources/entry.swift#L134)
44+
- [CreateJob](scenario/Sources/entry.swift#L275)
45+
- [DeleteCrawler](scenario/Sources/entry.swift#L178)
46+
- [DeleteDatabase](scenario/Sources/entry.swift#L463)
47+
- [DeleteJob](scenario/Sources/entry.swift#L349)
48+
- [GetCrawler](scenario/Sources/entry.swift#L220)
49+
- [GetDatabase](scenario/Sources/entry.swift#L399)
50+
- [GetJobRun](scenario/Sources/entry.swift#L557)
51+
- [GetTables](scenario/Sources/entry.swift#L422)
52+
- [ListJobs](scenario/Sources/entry.swift#L312)
53+
- [StartCrawler](scenario/Sources/entry.swift#L198)
54+
- [StartJobRun](scenario/Sources/entry.swift#L518)
55+
56+
57+
<!--custom.examples.start-->
58+
<!--custom.examples.end-->
59+
60+
## Run the examples
61+
62+
### Instructions
63+
64+
To build any of these examples from a terminal window, navigate into its
65+
directory, then use the following command:
66+
67+
```
68+
$ swift build
69+
```
70+
71+
To build one of these examples in Xcode, navigate to the example's directory
72+
(such as the `ListUsers` directory, to build that example). Then type `xed.`
73+
to open the example directory in Xcode. You can then use standard Xcode build
74+
and run commands.
75+
76+
<!--custom.instructions.start-->
77+
<!--custom.instructions.end-->
78+
79+
80+
#### Learn the basics
81+
82+
This example shows you how to do the following:
83+
84+
- Create a crawler that crawls a public Amazon S3 bucket and generates a database of CSV-formatted metadata.
85+
- List information about databases and tables in your AWS Glue Data Catalog.
86+
- Create a job to extract CSV data from the S3 bucket, transform the data, and load JSON-formatted output into another S3 bucket.
87+
- List information about job runs, view transformed data, and clean up resources.
88+
89+
<!--custom.basic_prereqs.glue_Scenario_GetStartedCrawlersJobs.start-->
90+
<!--custom.basic_prereqs.glue_Scenario_GetStartedCrawlersJobs.end-->
91+
92+
93+
<!--custom.basics.glue_Scenario_GetStartedCrawlersJobs.start-->
94+
<!--custom.basics.glue_Scenario_GetStartedCrawlersJobs.end-->
95+
96+
97+
### Tests
98+
99+
⚠ Running tests might result in charges to your AWS account.
100+
101+
102+
To find instructions for running these tests, see the [README](../../README.md#Tests)
103+
in the `swift` folder.
104+
105+
106+
107+
<!--custom.tests.start-->
108+
<!--custom.tests.end-->
109+
110+
## Additional resources
111+
112+
- [AWS Glue Developer Guide](https://docs.aws.amazon.com/glue/latest/dg/what-is-glue.html)
113+
- [AWS Glue API Reference](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api.html)
114+
- [SDK for Swift AWS Glue reference](https://sdk.amazonaws.com/swift/api/awsglue/latest/documentation/awsglue)
115+
116+
<!--custom.resources.start-->
117+
<!--custom.resources.end-->
118+
119+
---
120+
121+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
122+
123+
SPDX-License-Identifier: Apache-2.0
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// swift-tools-version: 5.9
2+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
// (swift-tools-version has two lines here because it needs to be the first
6+
// line in the file, but it should also appear in the snippet below)
7+
//
8+
// snippet-start:[swift.glue.scenario.package]
9+
// swift-tools-version: 5.9
10+
//
11+
// The swift-tools-version declares the minimum version of Swift required to
12+
// build this package.
13+
14+
import PackageDescription
15+
16+
let package = Package(
17+
name: "glue-scenario",
18+
// Let Xcode know the minimum Apple platforms supported.
19+
platforms: [
20+
.macOS(.v13),
21+
.iOS(.v15)
22+
],
23+
dependencies: [
24+
// Dependencies declare other packages that this package depends on.
25+
.package(
26+
url: "https://github.com/awslabs/aws-sdk-swift",
27+
from: "1.0.0"),
28+
.package(
29+
url: "https://github.com/apple/swift-argument-parser.git",
30+
branch: "main"
31+
)
32+
],
33+
targets: [
34+
// Targets are the basic building blocks of a package, defining a module or a test suite.
35+
// Targets can depend on other targets in this package and products
36+
// from dependencies.
37+
.executableTarget(
38+
name: "glue-scenario",
39+
dependencies: [
40+
.product(name: "AWSGlue", package: "aws-sdk-swift"),
41+
.product(name: "AWSS3", package: "aws-sdk-swift"),
42+
.product(name: "ArgumentParser", package: "swift-argument-parser")
43+
],
44+
path: "Sources")
45+
46+
]
47+
)
48+
// snippet-end:[swift.glue.scenario.package]

0 commit comments

Comments
 (0)