-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storage) Parity: AWS SDK S3 accelerate via useAccelerateEndpoint…
… pluginOptions.
- Loading branch information
Showing
23 changed files
with
502 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
AmplifyPlugins/Storage/Sources/AWSS3StoragePlugin/Configuration/AWSS3PluginOptions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import Amplify | ||
import Foundation | ||
|
||
/// - Tag: AWSS3PluginOptions | ||
struct AWSS3PluginOptions { | ||
|
||
/// - Tag: AWSS3PluginOptionsCodingKeys | ||
enum CodingKeys: String, CodingKey { | ||
|
||
/// See: https://docs.amplify.aws/lib/storage/transfer-acceleration/q/platform/js/ | ||
/// - Tag: AWSS3PluginOptionsCodingKeys.useAccelerateEndpoint | ||
case useAccelerateEndpoint | ||
} | ||
|
||
/// Attempts to extract the boolean under the | ||
/// [useAccelerateEndpoint](x-source-tag://AWSS3PluginOptionsCodingKeys.useAccelerateEndpoint) | ||
/// contained in the given dictionary. | ||
/// | ||
/// In other words, a non-nil boolean is returned if: | ||
/// | ||
/// * The `pluginOptions` parameter is a dictionary ([String: Any]) | ||
/// * The `pluginOptions` dictionary contains a boolean key under the [useAccelerateEndpoint](x-source-tag://AWSS3PluginOptionsCodingKeys.useAccelerateEndpoint) key. | ||
/// | ||
/// - Tag: AWSS3PluginOptions.accelerateValue | ||
static func accelerateValue(pluginOptions: Any?) throws -> Bool? { | ||
guard let pluginOptions = pluginOptions as? [String:Any] else { | ||
return nil | ||
} | ||
guard let value = pluginOptions[CodingKeys.useAccelerateEndpoint.rawValue] else { | ||
return nil | ||
} | ||
guard let boolValue = value as? Bool else { | ||
throw StorageError.validation(CodingKeys.useAccelerateEndpoint.rawValue, | ||
"Expecting boolean value for key \(CodingKeys.useAccelerateEndpoint.rawValue)", | ||
"Ensure the value associated with \(CodingKeys.useAccelerateEndpoint.rawValue) is a boolean", | ||
nil) | ||
} | ||
return boolValue | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
...ifyPlugins/Storage/Sources/AWSS3StoragePlugin/Dependency/S3ClientConfigurationProxy.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import AWSS3 | ||
import AWSClientRuntime | ||
import ClientRuntime | ||
import Foundation | ||
|
||
/// Convenience proxy class around a | ||
/// [S3ClientConfigurationProtocol](x-source-tag://S3ClientConfigurationProtocol) | ||
/// implementaitons that allows Amplify to change configuration values JIT. | ||
/// | ||
/// - Tag: S3ClientConfigurationProxy | ||
struct S3ClientConfigurationProxy { | ||
|
||
/// - Tag: S3ClientConfigurationProxy.target | ||
var target: S3ClientConfigurationProtocol | ||
|
||
/// - Tag: S3ClientConfigurationProxy.accelerateOverride | ||
var accelerateOverride: Bool? | ||
} | ||
|
||
extension S3ClientConfigurationProxy: S3ClientConfigurationProtocol { | ||
|
||
var accelerate: Bool? { | ||
if let accelerateOverride = accelerateOverride { | ||
return accelerateOverride | ||
} | ||
return target.accelerate | ||
} | ||
|
||
var disableMultiRegionAccessPoints: Bool? { | ||
return target.disableMultiRegionAccessPoints | ||
} | ||
|
||
var endpointResolver: EndpointResolver { | ||
return target.endpointResolver | ||
} | ||
|
||
var forcePathStyle: Bool? { | ||
return target.forcePathStyle | ||
} | ||
|
||
var useArnRegion: Bool? { | ||
return target.useArnRegion | ||
} | ||
|
||
var useGlobalEndpoint: Bool? { | ||
return target.useGlobalEndpoint | ||
} | ||
|
||
var credentialsProvider: AWSClientRuntime.CredentialsProvider { | ||
get { | ||
return target.credentialsProvider | ||
} | ||
set(newValue) { | ||
target.credentialsProvider = newValue | ||
} | ||
} | ||
|
||
var region: String? { | ||
get { | ||
return target.region | ||
} | ||
set(newValue) { | ||
target.region = newValue | ||
} | ||
} | ||
|
||
var signingRegion: String? { | ||
get { | ||
return target.signingRegion | ||
} | ||
set(newValue) { | ||
target.signingRegion = newValue | ||
} | ||
} | ||
|
||
var regionResolver: RegionResolver? { | ||
get { | ||
return target.regionResolver | ||
} | ||
set(newValue) { | ||
target.regionResolver = newValue | ||
} | ||
} | ||
|
||
var frameworkMetadata: FrameworkMetadata? { | ||
get { | ||
return target.frameworkMetadata | ||
} | ||
set(newValue) { | ||
target.frameworkMetadata = newValue | ||
} | ||
} | ||
|
||
var useFIPS: Bool? { | ||
get { | ||
return target.useFIPS | ||
} | ||
set(newValue) { | ||
target.useFIPS = newValue | ||
} | ||
} | ||
|
||
var useDualStack: Bool? { | ||
get { | ||
return target.useDualStack | ||
} | ||
set(newValue) { | ||
target.useDualStack = newValue | ||
} | ||
} | ||
|
||
var logger: LogAgent { | ||
return target.logger | ||
} | ||
|
||
var retryer: ClientRuntime.SDKRetryer { | ||
return target.retryer | ||
} | ||
|
||
var endpoint: String? { | ||
get { | ||
return target.endpoint | ||
} | ||
set(newValue) { | ||
target.endpoint = newValue | ||
} | ||
} | ||
|
||
var encoder: ClientRuntime.RequestEncoder? { | ||
return target.encoder | ||
} | ||
|
||
var decoder: ClientRuntime.ResponseDecoder? { | ||
return target.decoder | ||
} | ||
|
||
var httpClientEngine: ClientRuntime.HttpClientEngine { | ||
return target.httpClientEngine | ||
} | ||
|
||
var httpClientConfiguration: ClientRuntime.HttpClientConfiguration { | ||
return target.httpClientConfiguration | ||
} | ||
|
||
var idempotencyTokenGenerator: ClientRuntime.IdempotencyTokenGenerator { | ||
return target.idempotencyTokenGenerator | ||
} | ||
|
||
var clientLogMode: ClientRuntime.ClientLogMode { | ||
return target.clientLogMode | ||
} | ||
|
||
var partitionID: String? { | ||
return target.partitionID | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.