Skip to content

Commit 2ac48c8

Browse files
authored
feat: Add Bedrock API key support (#951)
1 parent 8c2b682 commit 2ac48c8

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

Sources/SmithyIdentityAPI/Context/Context+AuthSchemePreference.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ extension Context {
1616
public func getAuthSchemePreference() -> [String]? {
1717
get(key: authSchemePreferenceKey)
1818
}
19+
20+
/// The auth scheme preferences for authenticating this request.
21+
public var authSchemePreference: [String]? {
22+
get { getAuthSchemePreference() }
23+
set { set(key: authSchemePreferenceKey, value: newValue) }
24+
}
1925
}
2026

2127
extension ContextBuilder {

Sources/SmithyIdentityAPI/Context/Context+IdentityResolver.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ extension Context {
1414
public func getIdentityResolvers() -> Attributes? {
1515
get(key: identityResolversKey)
1616
}
17+
18+
public func addIdentityResolver<T: IdentityResolver>(value: T, schemeID: String) {
19+
var identityResolvers: Attributes = get(key: identityResolversKey) ?? Attributes()
20+
identityResolvers.set(key: AttributeKey<any IdentityResolver>(name: schemeID), value: value)
21+
set(key: identityResolversKey, value: identityResolvers)
22+
}
1723
}
1824

1925
extension ContextBuilder {

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/HTTPBindingProtocolGenerator.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ abstract class HTTPBindingProtocolGenerator(
440440
operationMiddleware.appendMiddleware(operation, RetryMiddleware(ctx.model, ctx.symbolProvider, retryErrorInfoProviderSymbol))
441441
operationMiddleware.appendMiddleware(operation, SignerMiddleware(ctx.model, ctx.symbolProvider))
442442
addProtocolSpecificMiddleware(ctx, operation)
443+
addServiceSpecificMiddleware(ctx, operation)
443444
operationMiddleware.appendMiddleware(operation, AuthSchemeMiddleware(ctx.model, ctx.symbolProvider))
444445
for (integration in ctx.integrations) {
445446
integration.customizeMiddleware(ctx, operation, operationMiddleware)
@@ -482,6 +483,13 @@ abstract class HTTPBindingProtocolGenerator(
482483
operation: OperationShape,
483484
)
484485

486+
protected open fun addServiceSpecificMiddleware(
487+
ctx: ProtocolGenerator.GenerationContext,
488+
operation: OperationShape,
489+
) {
490+
// No operation. Override in subclasses to install per-service custom middleware/interceptors.
491+
}
492+
485493
protected abstract fun addUserAgentMiddleware(
486494
ctx: ProtocolGenerator.GenerationContext,
487495
operation: OperationShape,

0 commit comments

Comments
 (0)