Skip to content

Commit

Permalink
feat: add runtime plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewFossAWS committed Jan 22, 2024
1 parent 36821c2 commit d514404
Show file tree
Hide file tree
Showing 384 changed files with 11,052 additions and 63 deletions.
2 changes: 1 addition & 1 deletion Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import ClientRuntime
/// ```
/// public typealias S3Client.S3ClientConfiguration = AWSClientConfiguration<S3Client.ServiceSpecificConfiguration>
/// ```
public class AWSClientConfiguration<ServiceSpecificConfiguration: AWSServiceSpecificConfiguration> {
public class AWSClientConfiguration<ServiceSpecificConfiguration: AWSServiceSpecificConfiguration>: ClientConfiguration {

Check warning on line 21 in Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift

View workflow job for this annotation

GitHub Actions / swiftlint

Line should be 120 characters or less; currently it has 121 characters (line_length)

/// The custom encoder to be used for encoding models for transmission.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

public protocol AwsDefaultClientConfiguration {
/// The credentials provider to be used for AWS credentials.
///
/// If no credentials provider is supplied, the SDK will look for credentials in the environment, then in the `~/.aws/credentials` file.
var credentialsProvider: CredentialsProviding { get set }

/// Specifies whether FIPS endpoints should be used.
var useFIPS: Bool? { get set }

/// Specifies whether dual-stack endpoints should be used.
var useDualStack: Bool? { get set }

/// An identifying string for the application being used with this SDK.
///
/// This value is set after resolving app ID from the standard progression of potential sources.
///
/// The application ID is submitted as part of the `user-agent` and allows for better tracking and troubleshooting.
/// The application ID may also be retrieved from the environment variable `AWS_SDK_UA_APP_ID` or from the
/// configuration file field `sdk_ua_app_id` if it is not set here.
var appID: String? { get set }

/// The AWS retry mode to be used.
///
/// This value is set after resolving retry mode from the standard progression of potential sources.
///
/// May be one of `legacy`, `standard`, or `adaptive`. `standard` and `adaptive` retry strategies are as defined in
/// Smithy Reference Architecture. For the Swift SDK, `legacy` is the same behavior as `standard`.
var awsRetryMode: AWSRetryMode { get set }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

public protocol AwsRegionClientConfiguration {

/// The AWS region to use, i.e. `us-east-1` or `us-west-2`, etc.
///
/// If no region is specified here, one must be specified in the `~/.aws/configuration` file.
var region: String? { get set }

/// The signing region to be used for signing AWS requests.
///
/// If none is specified, it is supplied by the SDK.
var signingRegion: String? { get set }
}
29 changes: 29 additions & 0 deletions Sources/Services/AWSACM/ACMClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,35 @@ extension ACMClient {
self.endpointResolver = try endpointResolver ?? DefaultEndpointResolver()
}
}

static func resolve(plugins: [any Plugin]) async throws -> ACMClient.ACMClientConfiguration {
let clientConfiguration = try await ACMClient.ACMClientConfiguration()
for plugin in plugins {
try await plugin.configureClient(clientConfiguration: clientConfiguration)
}
return clientConfiguration
}

public class Builder {
private var plugins: [Plugin]
public init(defaultPlugins: [Plugin] = []) {
self.plugins = defaultPlugins
}
public func withPlugin(plugin: any Plugin) {
self.plugins.append(plugin)
}
public func build() async throws -> ACMClient {
let configuration = try await resolve(plugins: self.plugins)
return ACMClient(config: configuration)
}
}

public static func builder() -> Builder {
return Builder(defaultPlugins: [DefaultClientPlugin()])
}
}

extension ACMClient.ACMClientConfiguration: AwsDefaultClientConfiguration & AwsRegionClientConfiguration & DefaultClientConfiguration & DefaultHttpClientConfiguration {
}

public struct ACMClientLogHandlerFactory: ClientRuntime.SDKLogHandlerFactory {
Expand Down
29 changes: 29 additions & 0 deletions Sources/Services/AWSACMPCA/ACMPCAClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,35 @@ extension ACMPCAClient {
self.endpointResolver = try endpointResolver ?? DefaultEndpointResolver()
}
}

static func resolve(plugins: [any Plugin]) async throws -> ACMPCAClient.ACMPCAClientConfiguration {
let clientConfiguration = try await ACMPCAClient.ACMPCAClientConfiguration()
for plugin in plugins {
try await plugin.configureClient(clientConfiguration: clientConfiguration)
}
return clientConfiguration
}

public class Builder {
private var plugins: [Plugin]
public init(defaultPlugins: [Plugin] = []) {
self.plugins = defaultPlugins
}
public func withPlugin(plugin: any Plugin) {
self.plugins.append(plugin)
}
public func build() async throws -> ACMPCAClient {
let configuration = try await resolve(plugins: self.plugins)
return ACMPCAClient(config: configuration)
}
}

public static func builder() -> Builder {
return Builder(defaultPlugins: [DefaultClientPlugin()])
}
}

extension ACMPCAClient.ACMPCAClientConfiguration: AwsDefaultClientConfiguration & AwsRegionClientConfiguration & DefaultClientConfiguration & DefaultHttpClientConfiguration {
}

public struct ACMPCAClientLogHandlerFactory: ClientRuntime.SDKLogHandlerFactory {
Expand Down
29 changes: 29 additions & 0 deletions Sources/Services/AWSAPIGateway/APIGatewayClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,35 @@ extension APIGatewayClient {
self.endpointResolver = try endpointResolver ?? DefaultEndpointResolver()
}
}

static func resolve(plugins: [any Plugin]) async throws -> APIGatewayClient.APIGatewayClientConfiguration {
let clientConfiguration = try await APIGatewayClient.APIGatewayClientConfiguration()
for plugin in plugins {
try await plugin.configureClient(clientConfiguration: clientConfiguration)
}
return clientConfiguration
}

public class Builder {
private var plugins: [Plugin]
public init(defaultPlugins: [Plugin] = []) {
self.plugins = defaultPlugins
}
public func withPlugin(plugin: any Plugin) {
self.plugins.append(plugin)
}
public func build() async throws -> APIGatewayClient {
let configuration = try await resolve(plugins: self.plugins)
return APIGatewayClient(config: configuration)
}
}

public static func builder() -> Builder {
return Builder(defaultPlugins: [DefaultClientPlugin()])
}
}

extension APIGatewayClient.APIGatewayClientConfiguration: AwsDefaultClientConfiguration & AwsRegionClientConfiguration & DefaultClientConfiguration & DefaultHttpClientConfiguration {
}

public struct APIGatewayClientLogHandlerFactory: ClientRuntime.SDKLogHandlerFactory {
Expand Down
29 changes: 29 additions & 0 deletions Sources/Services/AWSARCZonalShift/ARCZonalShiftClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,35 @@ extension ARCZonalShiftClient {
self.endpointResolver = try endpointResolver ?? DefaultEndpointResolver()
}
}

static func resolve(plugins: [any Plugin]) async throws -> ARCZonalShiftClient.ARCZonalShiftClientConfiguration {
let clientConfiguration = try await ARCZonalShiftClient.ARCZonalShiftClientConfiguration()
for plugin in plugins {
try await plugin.configureClient(clientConfiguration: clientConfiguration)
}
return clientConfiguration
}

public class Builder {
private var plugins: [Plugin]
public init(defaultPlugins: [Plugin] = []) {
self.plugins = defaultPlugins
}
public func withPlugin(plugin: any Plugin) {
self.plugins.append(plugin)
}
public func build() async throws -> ARCZonalShiftClient {
let configuration = try await resolve(plugins: self.plugins)
return ARCZonalShiftClient(config: configuration)
}
}

public static func builder() -> Builder {
return Builder(defaultPlugins: [DefaultClientPlugin()])
}
}

extension ARCZonalShiftClient.ARCZonalShiftClientConfiguration: AwsDefaultClientConfiguration & AwsRegionClientConfiguration & DefaultClientConfiguration & DefaultHttpClientConfiguration {
}

public struct ARCZonalShiftClientLogHandlerFactory: ClientRuntime.SDKLogHandlerFactory {
Expand Down
29 changes: 29 additions & 0 deletions Sources/Services/AWSAccessAnalyzer/AccessAnalyzerClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,35 @@ extension AccessAnalyzerClient {
self.endpointResolver = try endpointResolver ?? DefaultEndpointResolver()
}
}

static func resolve(plugins: [any Plugin]) async throws -> AccessAnalyzerClient.AccessAnalyzerClientConfiguration {
let clientConfiguration = try await AccessAnalyzerClient.AccessAnalyzerClientConfiguration()
for plugin in plugins {
try await plugin.configureClient(clientConfiguration: clientConfiguration)
}
return clientConfiguration
}

public class Builder {
private var plugins: [Plugin]
public init(defaultPlugins: [Plugin] = []) {
self.plugins = defaultPlugins
}
public func withPlugin(plugin: any Plugin) {
self.plugins.append(plugin)
}
public func build() async throws -> AccessAnalyzerClient {
let configuration = try await resolve(plugins: self.plugins)
return AccessAnalyzerClient(config: configuration)
}
}

public static func builder() -> Builder {
return Builder(defaultPlugins: [DefaultClientPlugin()])
}
}

extension AccessAnalyzerClient.AccessAnalyzerClientConfiguration: AwsDefaultClientConfiguration & AwsRegionClientConfiguration & DefaultClientConfiguration & DefaultHttpClientConfiguration {
}

public struct AccessAnalyzerClientLogHandlerFactory: ClientRuntime.SDKLogHandlerFactory {
Expand Down
29 changes: 29 additions & 0 deletions Sources/Services/AWSAccount/AccountClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,35 @@ extension AccountClient {
self.endpointResolver = try endpointResolver ?? DefaultEndpointResolver()
}
}

static func resolve(plugins: [any Plugin]) async throws -> AccountClient.AccountClientConfiguration {
let clientConfiguration = try await AccountClient.AccountClientConfiguration()
for plugin in plugins {
try await plugin.configureClient(clientConfiguration: clientConfiguration)
}
return clientConfiguration
}

public class Builder {
private var plugins: [Plugin]
public init(defaultPlugins: [Plugin] = []) {
self.plugins = defaultPlugins
}
public func withPlugin(plugin: any Plugin) {
self.plugins.append(plugin)
}
public func build() async throws -> AccountClient {
let configuration = try await resolve(plugins: self.plugins)
return AccountClient(config: configuration)
}
}

public static func builder() -> Builder {
return Builder(defaultPlugins: [DefaultClientPlugin()])
}
}

extension AccountClient.AccountClientConfiguration: AwsDefaultClientConfiguration & AwsRegionClientConfiguration & DefaultClientConfiguration & DefaultHttpClientConfiguration {
}

public struct AccountClientLogHandlerFactory: ClientRuntime.SDKLogHandlerFactory {
Expand Down
29 changes: 29 additions & 0 deletions Sources/Services/AWSAlexaForBusiness/AlexaForBusinessClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,35 @@ extension AlexaForBusinessClient {
self.endpointResolver = try endpointResolver ?? DefaultEndpointResolver()
}
}

static func resolve(plugins: [any Plugin]) async throws -> AlexaForBusinessClient.AlexaForBusinessClientConfiguration {
let clientConfiguration = try await AlexaForBusinessClient.AlexaForBusinessClientConfiguration()
for plugin in plugins {
try await plugin.configureClient(clientConfiguration: clientConfiguration)
}
return clientConfiguration
}

public class Builder {
private var plugins: [Plugin]
public init(defaultPlugins: [Plugin] = []) {
self.plugins = defaultPlugins
}
public func withPlugin(plugin: any Plugin) {
self.plugins.append(plugin)
}
public func build() async throws -> AlexaForBusinessClient {
let configuration = try await resolve(plugins: self.plugins)
return AlexaForBusinessClient(config: configuration)
}
}

public static func builder() -> Builder {
return Builder(defaultPlugins: [DefaultClientPlugin()])
}
}

extension AlexaForBusinessClient.AlexaForBusinessClientConfiguration: AwsDefaultClientConfiguration & AwsRegionClientConfiguration & DefaultClientConfiguration & DefaultHttpClientConfiguration {
}

public struct AlexaForBusinessClientLogHandlerFactory: ClientRuntime.SDKLogHandlerFactory {
Expand Down
29 changes: 29 additions & 0 deletions Sources/Services/AWSAmp/AmpClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,35 @@ extension AmpClient {
self.endpointResolver = try endpointResolver ?? DefaultEndpointResolver()
}
}

static func resolve(plugins: [any Plugin]) async throws -> AmpClient.AmpClientConfiguration {
let clientConfiguration = try await AmpClient.AmpClientConfiguration()
for plugin in plugins {
try await plugin.configureClient(clientConfiguration: clientConfiguration)
}
return clientConfiguration
}

public class Builder {
private var plugins: [Plugin]
public init(defaultPlugins: [Plugin] = []) {
self.plugins = defaultPlugins
}
public func withPlugin(plugin: any Plugin) {
self.plugins.append(plugin)
}
public func build() async throws -> AmpClient {
let configuration = try await resolve(plugins: self.plugins)
return AmpClient(config: configuration)
}
}

public static func builder() -> Builder {
return Builder(defaultPlugins: [DefaultClientPlugin()])
}
}

extension AmpClient.AmpClientConfiguration: AwsDefaultClientConfiguration & AwsRegionClientConfiguration & DefaultClientConfiguration & DefaultHttpClientConfiguration {
}

public struct AmpClientLogHandlerFactory: ClientRuntime.SDKLogHandlerFactory {
Expand Down
29 changes: 29 additions & 0 deletions Sources/Services/AWSAmplify/AmplifyClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,35 @@ extension AmplifyClient {
self.endpointResolver = try endpointResolver ?? DefaultEndpointResolver()
}
}

static func resolve(plugins: [any Plugin]) async throws -> AmplifyClient.AmplifyClientConfiguration {
let clientConfiguration = try await AmplifyClient.AmplifyClientConfiguration()
for plugin in plugins {
try await plugin.configureClient(clientConfiguration: clientConfiguration)
}
return clientConfiguration
}

public class Builder {
private var plugins: [Plugin]
public init(defaultPlugins: [Plugin] = []) {
self.plugins = defaultPlugins
}
public func withPlugin(plugin: any Plugin) {
self.plugins.append(plugin)
}
public func build() async throws -> AmplifyClient {
let configuration = try await resolve(plugins: self.plugins)
return AmplifyClient(config: configuration)
}
}

public static func builder() -> Builder {
return Builder(defaultPlugins: [DefaultClientPlugin()])
}
}

extension AmplifyClient.AmplifyClientConfiguration: AwsDefaultClientConfiguration & AwsRegionClientConfiguration & DefaultClientConfiguration & DefaultHttpClientConfiguration {
}

public struct AmplifyClientLogHandlerFactory: ClientRuntime.SDKLogHandlerFactory {
Expand Down
Loading

0 comments on commit d514404

Please sign in to comment.