Skip to content

Commit c1f8aff

Browse files
authored
Swift: RDS scenario example (#7545)
1 parent 33a648b commit c1f8aff

File tree

5 files changed

+1121
-2
lines changed

5 files changed

+1121
-2
lines changed

.doc_gen/metadata/rds_metadata.yaml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ rds_CreateDBInstance:
126126
- description:
127127
snippet_tags:
128128
- php.example_code.rds.createDBInstance.complete
129+
Swift:
130+
versions:
131+
- sdk_version: 1
132+
github: swift/example_code/rds
133+
excerpts:
134+
- description:
135+
snippet_tags:
136+
- swift.rds.import
137+
- swift.rds.CreateDBInstance
129138
services:
130139
rds: {CreateDBInstance}
131140
rds_DeleteDBInstance:
@@ -194,6 +203,15 @@ rds_DeleteDBInstance:
194203
- description:
195204
snippet_tags:
196205
- php.example_code.rds.deleteDBInstance.complete
206+
Swift:
207+
versions:
208+
- sdk_version: 1
209+
github: swift/example_code/rds
210+
excerpts:
211+
- description:
212+
snippet_tags:
213+
- swift.rds.import
214+
- swift.rds.DeleteDBInstance
197215
services:
198216
rds: {DeleteDBInstance}
199217
rds_DescribeAccountAttributes:
@@ -292,6 +310,15 @@ rds_DescribeDBInstances:
292310
- description:
293311
snippet_tags:
294312
- php.example_code.rds.describeDBInstances.complete
313+
Swift:
314+
versions:
315+
- sdk_version: 1
316+
github: swift/example_code/rds
317+
excerpts:
318+
- description:
319+
snippet_tags:
320+
- swift.rds.import
321+
- swift.rds.DescribeDBInstances
295322
services:
296323
rds: {DescribeDBInstances}
297324
rds_ModifyDBInstance:
@@ -389,6 +416,15 @@ rds_DescribeDBParameterGroups:
389416
- cpp.example_code.rds.client
390417
- cpp.example_code.rds.DescribeDBParameterGroups1
391418
- cpp.example_code.rds.DescribeDBParameterGroups2
419+
Swift:
420+
versions:
421+
- sdk_version: 1
422+
github: swift/example_code/rds
423+
excerpts:
424+
- description:
425+
snippet_tags:
426+
- swift.rds.import
427+
- swift.rds.DescribeDBParameterGroups
392428
services:
393429
rds: {DescribeDBParameterGroups}
394430
rds_CreateDBParameterGroup:
@@ -441,6 +477,15 @@ rds_CreateDBParameterGroup:
441477
- cpp.example_code.rds.client_configuration
442478
- cpp.example_code.rds.client
443479
- cpp.example_code.rds.CreateDBParameterGroup
480+
Swift:
481+
versions:
482+
- sdk_version: 1
483+
github: swift/example_code/rds
484+
excerpts:
485+
- description:
486+
snippet_tags:
487+
- swift.rds.import
488+
- swift.rds.CreateDBParameterGroup
444489
services:
445490
rds: {CreateDBParameterGroup}
446491
rds_DeleteDBParameterGroup:
@@ -493,6 +538,15 @@ rds_DeleteDBParameterGroup:
493538
- cpp.example_code.rds.client_configuration
494539
- cpp.example_code.rds.client
495540
- cpp.example_code.rds.DeleteDBParameterGroup
541+
Swift:
542+
versions:
543+
- sdk_version: 1
544+
github: swift/example_code/rds
545+
excerpts:
546+
- description:
547+
snippet_tags:
548+
- swift.rds.import
549+
- swift.rds.DeleteDBParameterGroup
496550
services:
497551
rds: {DeleteDBParameterGroup}
498552
rds_DescribeDBParameters:
@@ -554,6 +608,15 @@ rds_DescribeDBParameters:
554608
- cpp.example_code.rds.client_configuration
555609
- cpp.example_code.rds.client
556610
- cpp.example_code.rds.DescribeDBParameters
611+
Swift:
612+
versions:
613+
- sdk_version: 1
614+
github: swift/example_code/rds
615+
excerpts:
616+
- description:
617+
snippet_tags:
618+
- swift.rds.import
619+
- swift.rds.DescribeDBParameters
557620
services:
558621
rds: {DescribeDBParameters}
559622
rds_ModifyDBParameterGroup:
@@ -606,6 +669,15 @@ rds_ModifyDBParameterGroup:
606669
- cpp.example_code.rds.client_configuration
607670
- cpp.example_code.rds.client
608671
- cpp.example_code.rds.ModifyDBParameterGroup
672+
Swift:
673+
versions:
674+
- sdk_version: 1
675+
github: swift/example_code/rds
676+
excerpts:
677+
- description:
678+
snippet_tags:
679+
- swift.rds.import
680+
- swift.rds.ModifyDBParameterGroup
609681
services:
610682
rds: {ModifyDBParameterGroup}
611683
rds_CreateDBSnapshot:
@@ -675,6 +747,15 @@ rds_CreateDBSnapshot:
675747
- description:
676748
snippet_tags:
677749
- php.example_code.rds.createDBSnapshot.complete
750+
Swift:
751+
versions:
752+
- sdk_version: 1
753+
github: swift/example_code/rds
754+
excerpts:
755+
- description:
756+
snippet_tags:
757+
- swift.rds.import
758+
- swift.rds.CreateDBSnapshot
678759
services:
679760
rds: {CreateDBSnapshot}
680761
rds_DescribeDBSnapshots:
@@ -727,6 +808,15 @@ rds_DescribeDBSnapshots:
727808
- cpp.example_code.rds.client_configuration
728809
- cpp.example_code.rds.client
729810
- cpp.example_code.rds.DescribeDBSnapshots
811+
Swift:
812+
versions:
813+
- sdk_version: 1
814+
github: swift/example_code/rds
815+
excerpts:
816+
- description:
817+
snippet_tags:
818+
- swift.rds.import
819+
- swift.rds.DescribeDBSnapshots
730820
services:
731821
rds: {DescribeDBSnapshots}
732822
rds_DescribeDBEngineVersions:
@@ -779,6 +869,15 @@ rds_DescribeDBEngineVersions:
779869
- cpp.example_code.rds.client_configuration
780870
- cpp.example_code.rds.client
781871
- cpp.example_code.rds.DescribeDBEngineVersions
872+
Swift:
873+
versions:
874+
- sdk_version: 1
875+
github: swift/example_code/rds
876+
excerpts:
877+
- description:
878+
snippet_tags:
879+
- swift.rds.import
880+
- swift.rds.DescribeDBEngineVersions
782881
services:
783882
rds: {DescribeDBEngineVersions}
784883
rds_DescribeOrderableDBInstanceOptions:
@@ -822,6 +921,15 @@ rds_DescribeOrderableDBInstanceOptions:
822921
- cpp.example_code.rds.client_configuration
823922
- cpp.example_code.rds.client
824923
- cpp.example_code.rds.DescribeOrderableDBInstanceOptions
924+
Swift:
925+
versions:
926+
- sdk_version: 1
927+
github: swift/example_code/rds
928+
excerpts:
929+
- description:
930+
snippet_tags:
931+
- swift.rds.import
932+
- swift.rds.DescribeOrderableDBInstanceOptions
825933
services:
826934
rds: {DescribeOrderableDBInstanceOptions}
827935
rds_GenerateRDSAuthToken:
@@ -916,6 +1024,17 @@ rds_Scenario_GetStartedInstances:
9161024
snippet_tags:
9171025
- cpp.example_code.rds.client_configuration
9181026
- cpp.example_code.rds.get_started_instances
1027+
Swift:
1028+
versions:
1029+
- sdk_version: 1
1030+
github: swift/example_code/rds
1031+
excerpts:
1032+
- description: The <code>Package.swift</code> file.
1033+
snippet_tags:
1034+
- swift.rds.scenario.package
1035+
- description: The Swift code file, <code>entry.swift</code>.
1036+
snippet_tags:
1037+
- swift.rds.scenario
9191038
services:
9201039
rds: {CreateDBInstance, CreateDBParameterGroup, CreateDBSnapshot, DeleteDBInstance, DeleteDBParameterGroup, DescribeDBInstances,
9211040
DescribeDBEngineVersions, DescribeDBParameterGroups, DescribeDBParameters, DescribeDBSnapshots, DescribeOrderableDBInstanceOptions,

swift/example_code/rds/README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Amazon RDS code examples for the SDK for Swift
2+
3+
## Overview
4+
5+
Shows how to use the AWS SDK for Swift to work with Amazon Relational Database Service (Amazon RDS).
6+
7+
<!--custom.overview.start-->
8+
<!--custom.overview.end-->
9+
10+
_Amazon RDS is a web service that makes it easier to set up, operate, and scale a relational database in the cloud._
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+
- [CreateDBInstance](scenario/Sources/entry.swift#L529)
44+
- [CreateDBParameterGroup](scenario/Sources/entry.swift#L326)
45+
- [CreateDBSnapshot](scenario/Sources/entry.swift#L627)
46+
- [DeleteDBInstance](scenario/Sources/entry.swift#L705)
47+
- [DeleteDBParameterGroup](scenario/Sources/entry.swift#L770)
48+
- [DescribeDBEngineVersions](scenario/Sources/entry.swift#L303)
49+
- [DescribeDBInstances](scenario/Sources/entry.swift#L581)
50+
- [DescribeDBParameterGroups](scenario/Sources/entry.swift#L350)
51+
- [DescribeDBParameters](scenario/Sources/entry.swift#L374)
52+
- [DescribeDBSnapshots](scenario/Sources/entry.swift#L656)
53+
- [DescribeOrderableDBInstanceOptions](scenario/Sources/entry.swift#L478)
54+
- [ModifyDBParameterGroup](scenario/Sources/entry.swift#L413)
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 custom DB parameter group and set parameter values.
85+
- Create a DB instance that's configured to use the parameter group. The DB instance also contains a database.
86+
- Take a snapshot of the instance.
87+
- Delete the instance and parameter group.
88+
89+
<!--custom.basic_prereqs.rds_Scenario_GetStartedInstances.start-->
90+
<!--custom.basic_prereqs.rds_Scenario_GetStartedInstances.end-->
91+
92+
93+
<!--custom.basics.rds_Scenario_GetStartedInstances.start-->
94+
<!--custom.basics.rds_Scenario_GetStartedInstances.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+
- [Amazon RDS User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Welcome.html)
113+
- [Amazon RDS API Reference](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/Welcome.html)
114+
- [SDK for Swift Amazon RDS reference](https://sdk.amazonaws.com/swift/api/awsrds/latest/documentation/awsrds)
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: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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.rds.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: "rds-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.4.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: "rds-scenario",
39+
dependencies: [
40+
.product(name: "AWSRDS", package: "aws-sdk-swift"),
41+
.product(name: "ArgumentParser", package: "swift-argument-parser")
42+
],
43+
path: "Sources")
44+
45+
]
46+
)
47+
// snippet-end:[swift.rds.scenario.package]

0 commit comments

Comments
 (0)