Skip to content

feat: Add Bedrock API key support #951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 29, 2025
Merged

feat: Add Bedrock API key support #951

merged 5 commits into from
Jul 29, 2025

Conversation

jbelkins
Copy link
Contributor

Description of changes

These changes support the addition of Bedrock API Key support in awslabs/aws-sdk-swift#1992

  • Add the ability to modify auth scheme preferences and identity resolvers on an existing Context.
  • Pass generation context into the Plugins generator, to allow the default plugins to vary based on the model being generated.

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

public var authSchemePreference: [String]? {
get { getAuthSchemePreference() }
set { set(key: authSchemePreferenceKey, value: newValue) }
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Bedrock API Key customization needs to alter the configured auth scheme preference order, hence a setter is provided

var identityResolvers: Attributes = get(key: identityResolversKey) ?? Attributes()
identityResolvers.set(key: AttributeKey<any IdentityResolver>(name: schemeID), value: value)
set(key: identityResolversKey, value: identityResolvers)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Bedrock API Key customization needs to add an identity resolver after they have been set, hence this method is provided

) {
// No operation. Override in subclasses to install per-service custom middleware/interceptors.
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This provides a customization point for aws-sdk-swift to add in custom middleware based on the service that is being generated.

@jbelkins jbelkins marked this pull request as ready for review July 25, 2025 18:29
@jbelkins jbelkins requested review from dayaffe and sichanyoo July 25, 2025 18:29
Copy link
Contributor

@sichanyoo sichanyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment on codegen funtion naming

@@ -482,6 +483,13 @@ abstract class HTTPBindingProtocolGenerator(
operation: OperationShape,
)

protected open fun addCustomizationMiddleware(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could rename this to something like addServiceSpecificMiddleware to make it more descriptive & follow same pattern as pre-existing addProtocolSpecificMiddleware function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed as suggested

@sichanyoo sichanyoo self-requested a review July 28, 2025 23:37
@jbelkins jbelkins merged commit 2ac48c8 into main Jul 29, 2025
33 checks passed
@jbelkins jbelkins deleted the jbe/bedrock_api_key branch July 29, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants