diff --git a/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeAwsBearerTokenIdentityResolver.h b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeAwsBearerTokenIdentityResolver.h new file mode 100644 index 00000000000..54de0ca099e --- /dev/null +++ b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeAwsBearerTokenIdentityResolver.h @@ -0,0 +1,53 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Aws { +namespace BedrockAgentRuntime { + +class BedrockAgentRuntimeAwsBearerTokenIdentityResolver : public smithy::AwsBearerTokenIdentityResolver { + public: + using IdentityT = smithy::AwsBearerTokenIdentity; + virtual ~BedrockAgentRuntimeAwsBearerTokenIdentityResolver() = default; + + BedrockAgentRuntimeAwsBearerTokenIdentityResolver() { + m_providerChainLegacy.emplace_back(Aws::MakeShared("SSOBearerTokenProvider")); + const Aws::String bedrockToken = Aws::Environment::GetEnv("AWS_BEARER_TOKEN_BEDROCK"); + if (!bedrockToken.empty()) { + m_providerChainLegacy.emplace_back( + Aws::MakeShared("StaticAWSBearerTokenProvider", bedrockToken)); + } + }; + + BedrockAgentRuntimeAwsBearerTokenIdentityResolver(const Aws::Client::ClientConfiguration::CredentialProviderConfiguration &config) { + m_providerChainLegacy.emplace_back(Aws::MakeShared("SSOBearerTokenProvider", config.profile)); + const Aws::String bedrockToken = Aws::Environment::GetEnv("AWS_BEARER_TOKEN_BEDROCK"); + if (!bedrockToken.empty()) { + m_providerChainLegacy.emplace_back( + Aws::MakeShared("StaticAWSBearerTokenProvider", bedrockToken)); + } + } + + ResolveIdentityFutureOutcome virtual getIdentity(const IdentityProperties &identityProperties, + const AdditionalParameters &additionalParameters) override { + auto outcome = AwsBearerTokenIdentityResolver::getIdentity(identityProperties, additionalParameters); + outcome.GetResult()->AddUserAgentFeature(Aws::Client::UserAgentFeature::BEARER_SERVICE_ENV_VARS); + return outcome; + } +}; + +} // namespace BedrockAgentRuntime +} // namespace Aws \ No newline at end of file diff --git a/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeClientConfiguration.h b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeClientConfiguration.h new file mode 100644 index 00000000000..edcd366ca07 --- /dev/null +++ b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeClientConfiguration.h @@ -0,0 +1,43 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include +#include + +namespace Aws { +namespace BedrockAgentRuntime { +struct AWS_BEDROCKAGENTRUNTIME_API BedrockAgentRuntimeClientConfiguration : public Aws::Client::GenericClientConfiguration { + using BaseClientConfigClass = Aws::Client::GenericClientConfiguration; + + BedrockAgentRuntimeClientConfiguration(const Client::ClientConfigurationInitValues& configuration = {}); + + /** + * Create a configuration based on settings in the aws configuration file for the given profile name. + * The configuration file location can be set via the environment variable AWS_CONFIG_FILE + * @param profileName the aws profile name. + * @param shouldDisableIMDS whether or not to disable IMDS calls. + */ + BedrockAgentRuntimeClientConfiguration(const char* profileName, bool shouldDisableIMDS = false); + + /** + * Create a configuration with a predefined smart defaults + * @param useSmartDefaults, required to differentiate c-tors + * @param defaultMode, default mode to use + * @param shouldDisableIMDS whether or not to disable IMDS calls. + */ + BedrockAgentRuntimeClientConfiguration(bool useSmartDefaults, const char* defaultMode = "legacy", bool shouldDisableIMDS = false); + + /** + * Converting constructors for compatibility with a legacy code + */ + BedrockAgentRuntimeClientConfiguration(const Client::ClientConfiguration& config); + + private: + void LoadBedrockAgentRuntimeSpecificConfig(const Aws::String& profileName); +}; +} // namespace BedrockAgentRuntime +} // namespace Aws \ No newline at end of file diff --git a/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeEndpointProvider.h b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeEndpointProvider.h index df41a9d9d23..4d3d4eedac7 100644 --- a/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeEndpointProvider.h +++ b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeEndpointProvider.h @@ -4,9 +4,9 @@ */ #pragma once +#include #include #include -#include #include #include #include @@ -15,14 +15,19 @@ namespace Aws { namespace BedrockAgentRuntime { namespace Endpoint { +using BedrockAgentRuntimeClientConfiguration = Aws::BedrockAgentRuntime::BedrockAgentRuntimeClientConfiguration; using EndpointParameters = Aws::Endpoint::EndpointParameters; using Aws::Endpoint::DefaultEndpointProvider; using Aws::Endpoint::EndpointProviderBase; using BedrockAgentRuntimeClientContextParameters = Aws::Endpoint::ClientContextParameters; -using BedrockAgentRuntimeClientConfiguration = Aws::Client::GenericClientConfiguration; -using BedrockAgentRuntimeBuiltInParameters = Aws::Endpoint::BuiltInParameters; +class AWS_BEDROCKAGENTRUNTIME_API BedrockAgentRuntimeBuiltInParameters : public Aws::Endpoint::BuiltInParameters { + public: + virtual ~BedrockAgentRuntimeBuiltInParameters() {}; + using Aws::Endpoint::BuiltInParameters::SetFromClientConfiguration; + virtual void SetFromClientConfiguration(const BedrockAgentRuntimeClientConfiguration& config); +}; /** * The type for the BedrockAgentRuntime Client Endpoint Provider. @@ -37,6 +42,26 @@ using BedrockAgentRuntimeDefaultEpProviderBase = DefaultEndpointProvider; +} // namespace Endpoint +} // namespace BedrockAgentRuntime + +namespace Endpoint { +/** + * Export endpoint provider symbols for Windows DLL, otherwise declare as extern + */ +AWS_BEDROCKAGENTRUNTIME_EXTERN template class AWS_BEDROCKAGENTRUNTIME_API + Aws::Endpoint::EndpointProviderBase; + +AWS_BEDROCKAGENTRUNTIME_EXTERN template class AWS_BEDROCKAGENTRUNTIME_API + Aws::Endpoint::DefaultEndpointProvider; +} // namespace Endpoint + +namespace BedrockAgentRuntime { +namespace Endpoint { /** * Default endpoint provider used for this service */ diff --git a/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeServiceClientModel.h b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeServiceClientModel.h index 02266b8dfb4..80096ca2421 100644 --- a/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeServiceClientModel.h +++ b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/include/aws/bedrock-agent-runtime/BedrockAgentRuntimeServiceClientModel.h @@ -75,7 +75,6 @@ class RetryStrategy; } // namespace Client namespace BedrockAgentRuntime { -using BedrockAgentRuntimeClientConfiguration = Aws::Client::GenericClientConfiguration; using BedrockAgentRuntimeEndpointProviderBase = Aws::BedrockAgentRuntime::Endpoint::BedrockAgentRuntimeEndpointProviderBase; using BedrockAgentRuntimeEndpointProvider = Aws::BedrockAgentRuntime::Endpoint::BedrockAgentRuntimeEndpointProvider; diff --git a/generated/src/aws-cpp-sdk-bedrock-agent-runtime/source/BedrockAgentRuntimeClient.cpp b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/source/BedrockAgentRuntimeClient.cpp index 0cd3e4b6623..d349135762f 100644 --- a/generated/src/aws-cpp-sdk-bedrock-agent-runtime/source/BedrockAgentRuntimeClient.cpp +++ b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/source/BedrockAgentRuntimeClient.cpp @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0. */ +#include #include #include #include @@ -118,17 +119,16 @@ BedrockAgentRuntimeClient::BedrockAgentRuntimeClient(const std::shared_ptr(ALLOCATION_TAG), - Aws::MakeShared(ALLOCATION_TAG), - Aws::MakeShared>( - ALLOCATION_TAG, Aws::Vector({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption})), - { - {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, - smithy::SigV4AuthScheme{Aws::MakeShared( - ALLOCATION_TAG, clientConfiguration.credentialProviderConfig), - GetServiceName(), clientConfiguration.region}}, - }) {} + : AwsSmithyClientT( + clientConfiguration, GetServiceName(), "Bedrock Agent Runtime", Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared>( + ALLOCATION_TAG, Aws::Vector({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption})), + { + {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, + smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}}, + }) {} BedrockAgentRuntimeClient::BedrockAgentRuntimeClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) diff --git a/generated/src/aws-cpp-sdk-bedrock-agent-runtime/source/BedrockAgentRuntimeClientConfiguration.cpp b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/source/BedrockAgentRuntimeClientConfiguration.cpp new file mode 100644 index 00000000000..065c2faa0e3 --- /dev/null +++ b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/source/BedrockAgentRuntimeClientConfiguration.cpp @@ -0,0 +1,47 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#include + +namespace Aws { +namespace BedrockAgentRuntime { + +static const char AWS_BEARER_TOKEN_BEDROCK[] = "AWS_BEARER_TOKEN_BEDROCK"; + +void BedrockAgentRuntimeClientConfiguration::LoadBedrockAgentRuntimeSpecificConfig(const Aws::String& inputProfileName) { + const Aws::String& bedrockToken = + BaseClientConfigClass::LoadConfigFromEnvOrProfile(AWS_BEARER_TOKEN_BEDROCK, inputProfileName, AWS_BEARER_TOKEN_BEDROCK, {}, ""); + if (!bedrockToken.empty()) { + Aws::Vector::iterator position = std::find(authPreferences.begin(), authPreferences.end(), "bearer"); + if (position != authPreferences.end()) { + authPreferences.erase(position); + } + authPreferences.insert(authPreferences.begin(), "bearer"); + } +} + +BedrockAgentRuntimeClientConfiguration::BedrockAgentRuntimeClientConfiguration(const Client::ClientConfigurationInitValues& configuration) + : BaseClientConfigClass(configuration) { + LoadBedrockAgentRuntimeSpecificConfig(this->profileName); +} + +BedrockAgentRuntimeClientConfiguration::BedrockAgentRuntimeClientConfiguration(const char* inputProfileName, bool shouldDisableIMDS) + : BaseClientConfigClass(inputProfileName, shouldDisableIMDS) { + LoadBedrockAgentRuntimeSpecificConfig(Aws::String(inputProfileName)); +} + +BedrockAgentRuntimeClientConfiguration::BedrockAgentRuntimeClientConfiguration(bool useSmartDefaults, const char* defaultMode, + bool shouldDisableIMDS) + : BaseClientConfigClass(useSmartDefaults, defaultMode, shouldDisableIMDS) { + LoadBedrockAgentRuntimeSpecificConfig(this->profileName); +} + +BedrockAgentRuntimeClientConfiguration::BedrockAgentRuntimeClientConfiguration(const Client::ClientConfiguration& config) + : BaseClientConfigClass(config) { + LoadBedrockAgentRuntimeSpecificConfig(this->profileName); +} + +} // namespace BedrockAgentRuntime +} // namespace Aws diff --git a/generated/src/aws-cpp-sdk-bedrock-agent-runtime/source/BedrockAgentRuntimeEndpointProvider.cpp b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/source/BedrockAgentRuntimeEndpointProvider.cpp index 5481785fcca..f32d2c49171 100644 --- a/generated/src/aws-cpp-sdk-bedrock-agent-runtime/source/BedrockAgentRuntimeEndpointProvider.cpp +++ b/generated/src/aws-cpp-sdk-bedrock-agent-runtime/source/BedrockAgentRuntimeEndpointProvider.cpp @@ -6,7 +6,27 @@ #include namespace Aws { +#ifndef AWS_BEDROCKAGENTRUNTIME_EXPORTS // Except for Windows DLL +namespace Endpoint { +/** + * Instantiate endpoint providers + */ +template class Aws::Endpoint::EndpointProviderBase; + +template class Aws::Endpoint::DefaultEndpointProvider; +} // namespace Endpoint +#endif + namespace BedrockAgentRuntime { -namespace Endpoint {} // namespace Endpoint +namespace Endpoint { +void BedrockAgentRuntimeBuiltInParameters::SetFromClientConfiguration(const BedrockAgentRuntimeClientConfiguration& config) { + SetFromClientConfiguration(static_cast(config)); +} + +} // namespace Endpoint } // namespace BedrockAgentRuntime } // namespace Aws diff --git a/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentAwsBearerTokenIdentityResolver.h b/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentAwsBearerTokenIdentityResolver.h new file mode 100644 index 00000000000..6b962f7fc9e --- /dev/null +++ b/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentAwsBearerTokenIdentityResolver.h @@ -0,0 +1,53 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Aws { +namespace BedrockAgent { + +class BedrockAgentAwsBearerTokenIdentityResolver : public smithy::AwsBearerTokenIdentityResolver { + public: + using IdentityT = smithy::AwsBearerTokenIdentity; + virtual ~BedrockAgentAwsBearerTokenIdentityResolver() = default; + + BedrockAgentAwsBearerTokenIdentityResolver() { + m_providerChainLegacy.emplace_back(Aws::MakeShared("SSOBearerTokenProvider")); + const Aws::String bedrockToken = Aws::Environment::GetEnv("AWS_BEARER_TOKEN_BEDROCK"); + if (!bedrockToken.empty()) { + m_providerChainLegacy.emplace_back( + Aws::MakeShared("StaticAWSBearerTokenProvider", bedrockToken)); + } + }; + + BedrockAgentAwsBearerTokenIdentityResolver(const Aws::Client::ClientConfiguration::CredentialProviderConfiguration &config) { + m_providerChainLegacy.emplace_back(Aws::MakeShared("SSOBearerTokenProvider", config.profile)); + const Aws::String bedrockToken = Aws::Environment::GetEnv("AWS_BEARER_TOKEN_BEDROCK"); + if (!bedrockToken.empty()) { + m_providerChainLegacy.emplace_back( + Aws::MakeShared("StaticAWSBearerTokenProvider", bedrockToken)); + } + } + + ResolveIdentityFutureOutcome virtual getIdentity(const IdentityProperties &identityProperties, + const AdditionalParameters &additionalParameters) override { + auto outcome = AwsBearerTokenIdentityResolver::getIdentity(identityProperties, additionalParameters); + outcome.GetResult()->AddUserAgentFeature(Aws::Client::UserAgentFeature::BEARER_SERVICE_ENV_VARS); + return outcome; + } +}; + +} // namespace BedrockAgent +} // namespace Aws \ No newline at end of file diff --git a/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentClientConfiguration.h b/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentClientConfiguration.h new file mode 100644 index 00000000000..769fa780175 --- /dev/null +++ b/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentClientConfiguration.h @@ -0,0 +1,43 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include +#include + +namespace Aws { +namespace BedrockAgent { +struct AWS_BEDROCKAGENT_API BedrockAgentClientConfiguration : public Aws::Client::GenericClientConfiguration { + using BaseClientConfigClass = Aws::Client::GenericClientConfiguration; + + BedrockAgentClientConfiguration(const Client::ClientConfigurationInitValues& configuration = {}); + + /** + * Create a configuration based on settings in the aws configuration file for the given profile name. + * The configuration file location can be set via the environment variable AWS_CONFIG_FILE + * @param profileName the aws profile name. + * @param shouldDisableIMDS whether or not to disable IMDS calls. + */ + BedrockAgentClientConfiguration(const char* profileName, bool shouldDisableIMDS = false); + + /** + * Create a configuration with a predefined smart defaults + * @param useSmartDefaults, required to differentiate c-tors + * @param defaultMode, default mode to use + * @param shouldDisableIMDS whether or not to disable IMDS calls. + */ + BedrockAgentClientConfiguration(bool useSmartDefaults, const char* defaultMode = "legacy", bool shouldDisableIMDS = false); + + /** + * Converting constructors for compatibility with a legacy code + */ + BedrockAgentClientConfiguration(const Client::ClientConfiguration& config); + + private: + void LoadBedrockAgentSpecificConfig(const Aws::String& profileName); +}; +} // namespace BedrockAgent +} // namespace Aws \ No newline at end of file diff --git a/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentEndpointProvider.h b/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentEndpointProvider.h index b9a684abf4f..6040c7e683d 100644 --- a/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentEndpointProvider.h +++ b/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentEndpointProvider.h @@ -4,9 +4,9 @@ */ #pragma once +#include #include #include -#include #include #include #include @@ -15,14 +15,19 @@ namespace Aws { namespace BedrockAgent { namespace Endpoint { +using BedrockAgentClientConfiguration = Aws::BedrockAgent::BedrockAgentClientConfiguration; using EndpointParameters = Aws::Endpoint::EndpointParameters; using Aws::Endpoint::DefaultEndpointProvider; using Aws::Endpoint::EndpointProviderBase; using BedrockAgentClientContextParameters = Aws::Endpoint::ClientContextParameters; -using BedrockAgentClientConfiguration = Aws::Client::GenericClientConfiguration; -using BedrockAgentBuiltInParameters = Aws::Endpoint::BuiltInParameters; +class AWS_BEDROCKAGENT_API BedrockAgentBuiltInParameters : public Aws::Endpoint::BuiltInParameters { + public: + virtual ~BedrockAgentBuiltInParameters() {}; + using Aws::Endpoint::BuiltInParameters::SetFromClientConfiguration; + virtual void SetFromClientConfiguration(const BedrockAgentClientConfiguration& config); +}; /** * The type for the BedrockAgent Client Endpoint Provider. @@ -35,6 +40,24 @@ using BedrockAgentEndpointProviderBase = using BedrockAgentDefaultEpProviderBase = DefaultEndpointProvider; +} // namespace Endpoint +} // namespace BedrockAgent + +namespace Endpoint { +/** + * Export endpoint provider symbols for Windows DLL, otherwise declare as extern + */ +AWS_BEDROCKAGENT_EXTERN template class AWS_BEDROCKAGENT_API Aws::Endpoint::EndpointProviderBase< + BedrockAgent::Endpoint::BedrockAgentClientConfiguration, BedrockAgent::Endpoint::BedrockAgentBuiltInParameters, + BedrockAgent::Endpoint::BedrockAgentClientContextParameters>; + +AWS_BEDROCKAGENT_EXTERN template class AWS_BEDROCKAGENT_API Aws::Endpoint::DefaultEndpointProvider< + BedrockAgent::Endpoint::BedrockAgentClientConfiguration, BedrockAgent::Endpoint::BedrockAgentBuiltInParameters, + BedrockAgent::Endpoint::BedrockAgentClientContextParameters>; +} // namespace Endpoint + +namespace BedrockAgent { +namespace Endpoint { /** * Default endpoint provider used for this service */ diff --git a/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentServiceClientModel.h b/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentServiceClientModel.h index 6b7799dfed2..a36e64088f8 100644 --- a/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentServiceClientModel.h +++ b/generated/src/aws-cpp-sdk-bedrock-agent/include/aws/bedrock-agent/BedrockAgentServiceClientModel.h @@ -122,7 +122,6 @@ class RetryStrategy; } // namespace Client namespace BedrockAgent { -using BedrockAgentClientConfiguration = Aws::Client::GenericClientConfiguration; using BedrockAgentEndpointProviderBase = Aws::BedrockAgent::Endpoint::BedrockAgentEndpointProviderBase; using BedrockAgentEndpointProvider = Aws::BedrockAgent::Endpoint::BedrockAgentEndpointProvider; diff --git a/generated/src/aws-cpp-sdk-bedrock-agent/source/BedrockAgentClient.cpp b/generated/src/aws-cpp-sdk-bedrock-agent/source/BedrockAgentClient.cpp index 0b6eed4ed1a..37264028014 100644 --- a/generated/src/aws-cpp-sdk-bedrock-agent/source/BedrockAgentClient.cpp +++ b/generated/src/aws-cpp-sdk-bedrock-agent/source/BedrockAgentClient.cpp @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0. */ +#include #include #include #include @@ -158,17 +159,15 @@ BedrockAgentClient::BedrockAgentClient(const std::shared_ptr(ALLOCATION_TAG), - Aws::MakeShared(ALLOCATION_TAG), - Aws::MakeShared>( - ALLOCATION_TAG, Aws::Vector({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption})), - { - {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, - smithy::SigV4AuthScheme{Aws::MakeShared( - ALLOCATION_TAG, clientConfiguration.credentialProviderConfig), - GetServiceName(), clientConfiguration.region}}, - }) {} + : AwsSmithyClientT( + clientConfiguration, GetServiceName(), "Bedrock Agent", Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared(ALLOCATION_TAG), Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared>( + ALLOCATION_TAG, Aws::Vector({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption})), + { + {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, + smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}}, + }) {} BedrockAgentClient::BedrockAgentClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) : AwsSmithyClientT( diff --git a/generated/src/aws-cpp-sdk-bedrock-agent/source/BedrockAgentClientConfiguration.cpp b/generated/src/aws-cpp-sdk-bedrock-agent/source/BedrockAgentClientConfiguration.cpp new file mode 100644 index 00000000000..de0bdcdddd8 --- /dev/null +++ b/generated/src/aws-cpp-sdk-bedrock-agent/source/BedrockAgentClientConfiguration.cpp @@ -0,0 +1,46 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#include + +namespace Aws { +namespace BedrockAgent { + +static const char AWS_BEARER_TOKEN_BEDROCK[] = "AWS_BEARER_TOKEN_BEDROCK"; + +void BedrockAgentClientConfiguration::LoadBedrockAgentSpecificConfig(const Aws::String& inputProfileName) { + const Aws::String& bedrockToken = + BaseClientConfigClass::LoadConfigFromEnvOrProfile(AWS_BEARER_TOKEN_BEDROCK, inputProfileName, AWS_BEARER_TOKEN_BEDROCK, {}, ""); + if (!bedrockToken.empty()) { + Aws::Vector::iterator position = std::find(authPreferences.begin(), authPreferences.end(), "bearer"); + if (position != authPreferences.end()) { + authPreferences.erase(position); + } + authPreferences.insert(authPreferences.begin(), "bearer"); + } +} + +BedrockAgentClientConfiguration::BedrockAgentClientConfiguration(const Client::ClientConfigurationInitValues& configuration) + : BaseClientConfigClass(configuration) { + LoadBedrockAgentSpecificConfig(this->profileName); +} + +BedrockAgentClientConfiguration::BedrockAgentClientConfiguration(const char* inputProfileName, bool shouldDisableIMDS) + : BaseClientConfigClass(inputProfileName, shouldDisableIMDS) { + LoadBedrockAgentSpecificConfig(Aws::String(inputProfileName)); +} + +BedrockAgentClientConfiguration::BedrockAgentClientConfiguration(bool useSmartDefaults, const char* defaultMode, bool shouldDisableIMDS) + : BaseClientConfigClass(useSmartDefaults, defaultMode, shouldDisableIMDS) { + LoadBedrockAgentSpecificConfig(this->profileName); +} + +BedrockAgentClientConfiguration::BedrockAgentClientConfiguration(const Client::ClientConfiguration& config) + : BaseClientConfigClass(config) { + LoadBedrockAgentSpecificConfig(this->profileName); +} + +} // namespace BedrockAgent +} // namespace Aws diff --git a/generated/src/aws-cpp-sdk-bedrock-agent/source/BedrockAgentEndpointProvider.cpp b/generated/src/aws-cpp-sdk-bedrock-agent/source/BedrockAgentEndpointProvider.cpp index 66d911668da..43e1e8c141d 100644 --- a/generated/src/aws-cpp-sdk-bedrock-agent/source/BedrockAgentEndpointProvider.cpp +++ b/generated/src/aws-cpp-sdk-bedrock-agent/source/BedrockAgentEndpointProvider.cpp @@ -6,7 +6,27 @@ #include namespace Aws { +#ifndef AWS_BEDROCKAGENT_EXPORTS // Except for Windows DLL +namespace Endpoint { +/** + * Instantiate endpoint providers + */ +template class Aws::Endpoint::EndpointProviderBase; + +template class Aws::Endpoint::DefaultEndpointProvider; +} // namespace Endpoint +#endif + namespace BedrockAgent { -namespace Endpoint {} // namespace Endpoint +namespace Endpoint { +void BedrockAgentBuiltInParameters::SetFromClientConfiguration(const BedrockAgentClientConfiguration& config) { + SetFromClientConfiguration(static_cast(config)); +} + +} // namespace Endpoint } // namespace BedrockAgent } // namespace Aws diff --git a/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeAwsBearerTokenIdentityResolver.h b/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeAwsBearerTokenIdentityResolver.h new file mode 100644 index 00000000000..8cce220131a --- /dev/null +++ b/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeAwsBearerTokenIdentityResolver.h @@ -0,0 +1,53 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Aws { +namespace BedrockRuntime { + +class BedrockRuntimeAwsBearerTokenIdentityResolver : public smithy::AwsBearerTokenIdentityResolver { + public: + using IdentityT = smithy::AwsBearerTokenIdentity; + virtual ~BedrockRuntimeAwsBearerTokenIdentityResolver() = default; + + BedrockRuntimeAwsBearerTokenIdentityResolver() { + m_providerChainLegacy.emplace_back(Aws::MakeShared("SSOBearerTokenProvider")); + const Aws::String bedrockToken = Aws::Environment::GetEnv("AWS_BEARER_TOKEN_BEDROCK"); + if (!bedrockToken.empty()) { + m_providerChainLegacy.emplace_back( + Aws::MakeShared("StaticAWSBearerTokenProvider", bedrockToken)); + } + }; + + BedrockRuntimeAwsBearerTokenIdentityResolver(const Aws::Client::ClientConfiguration::CredentialProviderConfiguration &config) { + m_providerChainLegacy.emplace_back(Aws::MakeShared("SSOBearerTokenProvider", config.profile)); + const Aws::String bedrockToken = Aws::Environment::GetEnv("AWS_BEARER_TOKEN_BEDROCK"); + if (!bedrockToken.empty()) { + m_providerChainLegacy.emplace_back( + Aws::MakeShared("StaticAWSBearerTokenProvider", bedrockToken)); + } + } + + ResolveIdentityFutureOutcome virtual getIdentity(const IdentityProperties &identityProperties, + const AdditionalParameters &additionalParameters) override { + auto outcome = AwsBearerTokenIdentityResolver::getIdentity(identityProperties, additionalParameters); + outcome.GetResult()->AddUserAgentFeature(Aws::Client::UserAgentFeature::BEARER_SERVICE_ENV_VARS); + return outcome; + } +}; + +} // namespace BedrockRuntime +} // namespace Aws \ No newline at end of file diff --git a/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeClientConfiguration.h b/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeClientConfiguration.h new file mode 100644 index 00000000000..816cf4dad99 --- /dev/null +++ b/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeClientConfiguration.h @@ -0,0 +1,43 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include +#include + +namespace Aws { +namespace BedrockRuntime { +struct AWS_BEDROCKRUNTIME_API BedrockRuntimeClientConfiguration : public Aws::Client::GenericClientConfiguration { + using BaseClientConfigClass = Aws::Client::GenericClientConfiguration; + + BedrockRuntimeClientConfiguration(const Client::ClientConfigurationInitValues& configuration = {}); + + /** + * Create a configuration based on settings in the aws configuration file for the given profile name. + * The configuration file location can be set via the environment variable AWS_CONFIG_FILE + * @param profileName the aws profile name. + * @param shouldDisableIMDS whether or not to disable IMDS calls. + */ + BedrockRuntimeClientConfiguration(const char* profileName, bool shouldDisableIMDS = false); + + /** + * Create a configuration with a predefined smart defaults + * @param useSmartDefaults, required to differentiate c-tors + * @param defaultMode, default mode to use + * @param shouldDisableIMDS whether or not to disable IMDS calls. + */ + BedrockRuntimeClientConfiguration(bool useSmartDefaults, const char* defaultMode = "legacy", bool shouldDisableIMDS = false); + + /** + * Converting constructors for compatibility with a legacy code + */ + BedrockRuntimeClientConfiguration(const Client::ClientConfiguration& config); + + private: + void LoadBedrockRuntimeSpecificConfig(const Aws::String& profileName); +}; +} // namespace BedrockRuntime +} // namespace Aws \ No newline at end of file diff --git a/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeEndpointProvider.h b/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeEndpointProvider.h index 6f39b114bb9..54de77a268f 100644 --- a/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeEndpointProvider.h +++ b/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeEndpointProvider.h @@ -4,9 +4,9 @@ */ #pragma once +#include #include #include -#include #include #include #include @@ -15,14 +15,19 @@ namespace Aws { namespace BedrockRuntime { namespace Endpoint { +using BedrockRuntimeClientConfiguration = Aws::BedrockRuntime::BedrockRuntimeClientConfiguration; using EndpointParameters = Aws::Endpoint::EndpointParameters; using Aws::Endpoint::DefaultEndpointProvider; using Aws::Endpoint::EndpointProviderBase; using BedrockRuntimeClientContextParameters = Aws::Endpoint::ClientContextParameters; -using BedrockRuntimeClientConfiguration = Aws::Client::GenericClientConfiguration; -using BedrockRuntimeBuiltInParameters = Aws::Endpoint::BuiltInParameters; +class AWS_BEDROCKRUNTIME_API BedrockRuntimeBuiltInParameters : public Aws::Endpoint::BuiltInParameters { + public: + virtual ~BedrockRuntimeBuiltInParameters() {}; + using Aws::Endpoint::BuiltInParameters::SetFromClientConfiguration; + virtual void SetFromClientConfiguration(const BedrockRuntimeClientConfiguration& config); +}; /** * The type for the BedrockRuntime Client Endpoint Provider. @@ -35,6 +40,24 @@ using BedrockRuntimeEndpointProviderBase = using BedrockRuntimeDefaultEpProviderBase = DefaultEndpointProvider; +} // namespace Endpoint +} // namespace BedrockRuntime + +namespace Endpoint { +/** + * Export endpoint provider symbols for Windows DLL, otherwise declare as extern + */ +AWS_BEDROCKRUNTIME_EXTERN template class AWS_BEDROCKRUNTIME_API Aws::Endpoint::EndpointProviderBase< + BedrockRuntime::Endpoint::BedrockRuntimeClientConfiguration, BedrockRuntime::Endpoint::BedrockRuntimeBuiltInParameters, + BedrockRuntime::Endpoint::BedrockRuntimeClientContextParameters>; + +AWS_BEDROCKRUNTIME_EXTERN template class AWS_BEDROCKRUNTIME_API Aws::Endpoint::DefaultEndpointProvider< + BedrockRuntime::Endpoint::BedrockRuntimeClientConfiguration, BedrockRuntime::Endpoint::BedrockRuntimeBuiltInParameters, + BedrockRuntime::Endpoint::BedrockRuntimeClientContextParameters>; +} // namespace Endpoint + +namespace BedrockRuntime { +namespace Endpoint { /** * Default endpoint provider used for this service */ diff --git a/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeServiceClientModel.h b/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeServiceClientModel.h index d73e8657b3c..1dd84a98e4a 100644 --- a/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeServiceClientModel.h +++ b/generated/src/aws-cpp-sdk-bedrock-runtime/include/aws/bedrock-runtime/BedrockRuntimeServiceClientModel.h @@ -60,7 +60,6 @@ class RetryStrategy; } // namespace Client namespace BedrockRuntime { -using BedrockRuntimeClientConfiguration = Aws::Client::GenericClientConfiguration; using BedrockRuntimeEndpointProviderBase = Aws::BedrockRuntime::Endpoint::BedrockRuntimeEndpointProviderBase; using BedrockRuntimeEndpointProvider = Aws::BedrockRuntime::Endpoint::BedrockRuntimeEndpointProvider; diff --git a/generated/src/aws-cpp-sdk-bedrock-runtime/source/BedrockRuntimeClient.cpp b/generated/src/aws-cpp-sdk-bedrock-runtime/source/BedrockRuntimeClient.cpp index 96e23a5e495..c5b1f368ff8 100644 --- a/generated/src/aws-cpp-sdk-bedrock-runtime/source/BedrockRuntimeClient.cpp +++ b/generated/src/aws-cpp-sdk-bedrock-runtime/source/BedrockRuntimeClient.cpp @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0. */ +#include #include #include #include @@ -80,7 +81,9 @@ BedrockRuntimeClient::BedrockRuntimeClient(const BedrockRuntime::BedrockRuntimeC {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}}, {smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption.schemeId, - smithy::BearerTokenAuthScheme{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}}, + smithy::BearerTokenAuthScheme{Aws::MakeShared( + "BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), + GetServiceName(), clientConfiguration.region}}, }) {} BedrockRuntimeClient::BedrockRuntimeClient(const AWSCredentials& credentials, @@ -93,11 +96,13 @@ BedrockRuntimeClient::BedrockRuntimeClient(const AWSCredentials& credentials, Aws::MakeShared>( ALLOCATION_TAG, Aws::Vector({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption, smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption})), - { - {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, - smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentials), - GetServiceName(), clientConfiguration.region}}, - }) {} + {{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, + smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentials), + GetServiceName(), clientConfiguration.region}}, + {smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption.schemeId, + smithy::BearerTokenAuthScheme{Aws::MakeShared( + "BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), + GetServiceName(), clientConfiguration.region}}}) {} BedrockRuntimeClient::BedrockRuntimeClient(const std::shared_ptr& credentialsProvider, std::shared_ptr endpointProvider, @@ -125,12 +130,11 @@ BedrockRuntimeClient::BedrockRuntimeClient(const Client::ClientConfiguration& cl smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption})), { {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, - smithy::SigV4AuthScheme{Aws::MakeShared( - ALLOCATION_TAG, clientConfiguration.credentialProviderConfig), - GetServiceName(), clientConfiguration.region}}, + smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}}, {smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption.schemeId, - smithy::BearerTokenAuthScheme{Aws::MakeShared(ALLOCATION_TAG), GetServiceName(), - clientConfiguration.region}}, + smithy::BearerTokenAuthScheme{Aws::MakeShared( + "BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), + GetServiceName(), clientConfiguration.region}}, }) {} BedrockRuntimeClient::BedrockRuntimeClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) @@ -144,6 +148,11 @@ BedrockRuntimeClient::BedrockRuntimeClient(const AWSCredentials& credentials, co {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}}, + {smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption.schemeId, + smithy::BearerTokenAuthScheme{Aws::MakeShared( + "BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), + GetServiceName(), clientConfiguration.region}}, + }) {} BedrockRuntimeClient::BedrockRuntimeClient(const std::shared_ptr& credentialsProvider, @@ -154,11 +163,13 @@ BedrockRuntimeClient::BedrockRuntimeClient(const std::shared_ptr>( ALLOCATION_TAG, Aws::Vector({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption, smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption})), - { - {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, - smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentialsProvider), - GetServiceName(), clientConfiguration.region}}, - }) {} + {{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, + smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentialsProvider), + GetServiceName(), clientConfiguration.region}}, + {smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption.schemeId, + smithy::BearerTokenAuthScheme{Aws::MakeShared( + "BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), + GetServiceName(), clientConfiguration.region}}}) {} /* End of legacy constructors due deprecation */ BedrockRuntimeClient::~BedrockRuntimeClient() { ShutdownSdkClient(this, -1); } diff --git a/generated/src/aws-cpp-sdk-bedrock-runtime/source/BedrockRuntimeClientConfiguration.cpp b/generated/src/aws-cpp-sdk-bedrock-runtime/source/BedrockRuntimeClientConfiguration.cpp new file mode 100644 index 00000000000..4c559b73d6f --- /dev/null +++ b/generated/src/aws-cpp-sdk-bedrock-runtime/source/BedrockRuntimeClientConfiguration.cpp @@ -0,0 +1,46 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#include + +namespace Aws { +namespace BedrockRuntime { + +static const char AWS_BEARER_TOKEN_BEDROCK[] = "AWS_BEARER_TOKEN_BEDROCK"; + +void BedrockRuntimeClientConfiguration::LoadBedrockRuntimeSpecificConfig(const Aws::String& inputProfileName) { + const Aws::String& bedrockToken = + BaseClientConfigClass::LoadConfigFromEnvOrProfile(AWS_BEARER_TOKEN_BEDROCK, inputProfileName, AWS_BEARER_TOKEN_BEDROCK, {}, ""); + if (!bedrockToken.empty()) { + Aws::Vector::iterator position = std::find(authPreferences.begin(), authPreferences.end(), "bearer"); + if (position != authPreferences.end()) { + authPreferences.erase(position); + } + authPreferences.insert(authPreferences.begin(), "bearer"); + } +} + +BedrockRuntimeClientConfiguration::BedrockRuntimeClientConfiguration(const Client::ClientConfigurationInitValues& configuration) + : BaseClientConfigClass(configuration) { + LoadBedrockRuntimeSpecificConfig(this->profileName); +} + +BedrockRuntimeClientConfiguration::BedrockRuntimeClientConfiguration(const char* inputProfileName, bool shouldDisableIMDS) + : BaseClientConfigClass(inputProfileName, shouldDisableIMDS) { + LoadBedrockRuntimeSpecificConfig(Aws::String(inputProfileName)); +} + +BedrockRuntimeClientConfiguration::BedrockRuntimeClientConfiguration(bool useSmartDefaults, const char* defaultMode, bool shouldDisableIMDS) + : BaseClientConfigClass(useSmartDefaults, defaultMode, shouldDisableIMDS) { + LoadBedrockRuntimeSpecificConfig(this->profileName); +} + +BedrockRuntimeClientConfiguration::BedrockRuntimeClientConfiguration(const Client::ClientConfiguration& config) + : BaseClientConfigClass(config) { + LoadBedrockRuntimeSpecificConfig(this->profileName); +} + +} // namespace BedrockRuntime +} // namespace Aws diff --git a/generated/src/aws-cpp-sdk-bedrock-runtime/source/BedrockRuntimeEndpointProvider.cpp b/generated/src/aws-cpp-sdk-bedrock-runtime/source/BedrockRuntimeEndpointProvider.cpp index 4501701a5a4..51f47f42ee5 100644 --- a/generated/src/aws-cpp-sdk-bedrock-runtime/source/BedrockRuntimeEndpointProvider.cpp +++ b/generated/src/aws-cpp-sdk-bedrock-runtime/source/BedrockRuntimeEndpointProvider.cpp @@ -6,7 +6,27 @@ #include namespace Aws { +#ifndef AWS_BEDROCKRUNTIME_EXPORTS // Except for Windows DLL +namespace Endpoint { +/** + * Instantiate endpoint providers + */ +template class Aws::Endpoint::EndpointProviderBase; + +template class Aws::Endpoint::DefaultEndpointProvider; +} // namespace Endpoint +#endif + namespace BedrockRuntime { -namespace Endpoint {} // namespace Endpoint +namespace Endpoint { +void BedrockRuntimeBuiltInParameters::SetFromClientConfiguration(const BedrockRuntimeClientConfiguration& config) { + SetFromClientConfiguration(static_cast(config)); +} + +} // namespace Endpoint } // namespace BedrockRuntime } // namespace Aws diff --git a/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockAwsBearerTokenIdentityResolver.h b/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockAwsBearerTokenIdentityResolver.h new file mode 100644 index 00000000000..f999b2bfd5d --- /dev/null +++ b/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockAwsBearerTokenIdentityResolver.h @@ -0,0 +1,53 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Aws { +namespace Bedrock { + +class BedrockAwsBearerTokenIdentityResolver : public smithy::AwsBearerTokenIdentityResolver { + public: + using IdentityT = smithy::AwsBearerTokenIdentity; + virtual ~BedrockAwsBearerTokenIdentityResolver() = default; + + BedrockAwsBearerTokenIdentityResolver() { + m_providerChainLegacy.emplace_back(Aws::MakeShared("SSOBearerTokenProvider")); + const Aws::String bedrockToken = Aws::Environment::GetEnv("AWS_BEARER_TOKEN_BEDROCK"); + if (!bedrockToken.empty()) { + m_providerChainLegacy.emplace_back( + Aws::MakeShared("StaticAWSBearerTokenProvider", bedrockToken)); + } + }; + + BedrockAwsBearerTokenIdentityResolver(const Aws::Client::ClientConfiguration::CredentialProviderConfiguration &config) { + m_providerChainLegacy.emplace_back(Aws::MakeShared("SSOBearerTokenProvider", config.profile)); + const Aws::String bedrockToken = Aws::Environment::GetEnv("AWS_BEARER_TOKEN_BEDROCK"); + if (!bedrockToken.empty()) { + m_providerChainLegacy.emplace_back( + Aws::MakeShared("StaticAWSBearerTokenProvider", bedrockToken)); + } + } + + ResolveIdentityFutureOutcome virtual getIdentity(const IdentityProperties &identityProperties, + const AdditionalParameters &additionalParameters) override { + auto outcome = AwsBearerTokenIdentityResolver::getIdentity(identityProperties, additionalParameters); + outcome.GetResult()->AddUserAgentFeature(Aws::Client::UserAgentFeature::BEARER_SERVICE_ENV_VARS); + return outcome; + } +}; + +} // namespace Bedrock +} // namespace Aws \ No newline at end of file diff --git a/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockClientConfiguration.h b/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockClientConfiguration.h new file mode 100644 index 00000000000..49850aac56e --- /dev/null +++ b/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockClientConfiguration.h @@ -0,0 +1,43 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include +#include + +namespace Aws { +namespace Bedrock { +struct AWS_BEDROCK_API BedrockClientConfiguration : public Aws::Client::GenericClientConfiguration { + using BaseClientConfigClass = Aws::Client::GenericClientConfiguration; + + BedrockClientConfiguration(const Client::ClientConfigurationInitValues& configuration = {}); + + /** + * Create a configuration based on settings in the aws configuration file for the given profile name. + * The configuration file location can be set via the environment variable AWS_CONFIG_FILE + * @param profileName the aws profile name. + * @param shouldDisableIMDS whether or not to disable IMDS calls. + */ + BedrockClientConfiguration(const char* profileName, bool shouldDisableIMDS = false); + + /** + * Create a configuration with a predefined smart defaults + * @param useSmartDefaults, required to differentiate c-tors + * @param defaultMode, default mode to use + * @param shouldDisableIMDS whether or not to disable IMDS calls. + */ + BedrockClientConfiguration(bool useSmartDefaults, const char* defaultMode = "legacy", bool shouldDisableIMDS = false); + + /** + * Converting constructors for compatibility with a legacy code + */ + BedrockClientConfiguration(const Client::ClientConfiguration& config); + + private: + void LoadBedrockSpecificConfig(const Aws::String& profileName); +}; +} // namespace Bedrock +} // namespace Aws \ No newline at end of file diff --git a/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockEndpointProvider.h b/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockEndpointProvider.h index 504590bf66f..6d252cea38e 100644 --- a/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockEndpointProvider.h +++ b/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockEndpointProvider.h @@ -4,9 +4,9 @@ */ #pragma once +#include #include #include -#include #include #include #include @@ -15,14 +15,19 @@ namespace Aws { namespace Bedrock { namespace Endpoint { +using BedrockClientConfiguration = Aws::Bedrock::BedrockClientConfiguration; using EndpointParameters = Aws::Endpoint::EndpointParameters; using Aws::Endpoint::DefaultEndpointProvider; using Aws::Endpoint::EndpointProviderBase; using BedrockClientContextParameters = Aws::Endpoint::ClientContextParameters; -using BedrockClientConfiguration = Aws::Client::GenericClientConfiguration; -using BedrockBuiltInParameters = Aws::Endpoint::BuiltInParameters; +class AWS_BEDROCK_API BedrockBuiltInParameters : public Aws::Endpoint::BuiltInParameters { + public: + virtual ~BedrockBuiltInParameters() {}; + using Aws::Endpoint::BuiltInParameters::SetFromClientConfiguration; + virtual void SetFromClientConfiguration(const BedrockClientConfiguration& config); +}; /** * The type for the Bedrock Client Endpoint Provider. @@ -35,6 +40,24 @@ using BedrockEndpointProviderBase = using BedrockDefaultEpProviderBase = DefaultEndpointProvider; +} // namespace Endpoint +} // namespace Bedrock + +namespace Endpoint { +/** + * Export endpoint provider symbols for Windows DLL, otherwise declare as extern + */ +AWS_BEDROCK_EXTERN template class AWS_BEDROCK_API + Aws::Endpoint::EndpointProviderBase; + +AWS_BEDROCK_EXTERN template class AWS_BEDROCK_API + Aws::Endpoint::DefaultEndpointProvider; +} // namespace Endpoint + +namespace Bedrock { +namespace Endpoint { /** * Default endpoint provider used for this service */ diff --git a/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockServiceClientModel.h b/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockServiceClientModel.h index 298e0c594bf..54e12e629ea 100644 --- a/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockServiceClientModel.h +++ b/generated/src/aws-cpp-sdk-bedrock/include/aws/bedrock/BedrockServiceClientModel.h @@ -164,7 +164,6 @@ class RetryStrategy; } // namespace Client namespace Bedrock { -using BedrockClientConfiguration = Aws::Client::GenericClientConfiguration; using BedrockEndpointProviderBase = Aws::Bedrock::Endpoint::BedrockEndpointProviderBase; using BedrockEndpointProvider = Aws::Bedrock::Endpoint::BedrockEndpointProvider; diff --git a/generated/src/aws-cpp-sdk-bedrock/source/BedrockClient.cpp b/generated/src/aws-cpp-sdk-bedrock/source/BedrockClient.cpp index ec8e4f4a083..6c5d61c13dc 100644 --- a/generated/src/aws-cpp-sdk-bedrock/source/BedrockClient.cpp +++ b/generated/src/aws-cpp-sdk-bedrock/source/BedrockClient.cpp @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0. */ +#include #include #include #include @@ -165,7 +166,9 @@ BedrockClient::BedrockClient(const Bedrock::BedrockClientConfiguration& clientCo {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}}, {smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption.schemeId, - smithy::BearerTokenAuthScheme{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}}, + smithy::BearerTokenAuthScheme{Aws::MakeShared( + "BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), + GetServiceName(), clientConfiguration.region}}, }) {} BedrockClient::BedrockClient(const AWSCredentials& credentials, std::shared_ptr endpointProvider, @@ -177,11 +180,13 @@ BedrockClient::BedrockClient(const AWSCredentials& credentials, std::shared_ptr< Aws::MakeShared>( ALLOCATION_TAG, Aws::Vector({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption, smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption})), - { - {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, - smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentials), - GetServiceName(), clientConfiguration.region}}, - }) {} + {{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, + smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentials), + GetServiceName(), clientConfiguration.region}}, + {smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption.schemeId, + smithy::BearerTokenAuthScheme{Aws::MakeShared( + "BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), + GetServiceName(), clientConfiguration.region}}}) {} BedrockClient::BedrockClient(const std::shared_ptr& credentialsProvider, std::shared_ptr endpointProvider, @@ -209,12 +214,11 @@ BedrockClient::BedrockClient(const Client::ClientConfiguration& clientConfigurat smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption})), { {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, - smithy::SigV4AuthScheme{Aws::MakeShared( - ALLOCATION_TAG, clientConfiguration.credentialProviderConfig), - GetServiceName(), clientConfiguration.region}}, + smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}}, {smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption.schemeId, - smithy::BearerTokenAuthScheme{Aws::MakeShared(ALLOCATION_TAG), GetServiceName(), - clientConfiguration.region}}, + smithy::BearerTokenAuthScheme{Aws::MakeShared( + "BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), + GetServiceName(), clientConfiguration.region}}, }) {} BedrockClient::BedrockClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) @@ -228,6 +232,11 @@ BedrockClient::BedrockClient(const AWSCredentials& credentials, const Client::Cl {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}}, + {smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption.schemeId, + smithy::BearerTokenAuthScheme{Aws::MakeShared( + "BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), + GetServiceName(), clientConfiguration.region}}, + }) {} BedrockClient::BedrockClient(const std::shared_ptr& credentialsProvider, @@ -238,11 +247,13 @@ BedrockClient::BedrockClient(const std::shared_ptr& cred Aws::MakeShared>( ALLOCATION_TAG, Aws::Vector({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption, smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption})), - { - {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, - smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentialsProvider), - GetServiceName(), clientConfiguration.region}}, - }) {} + {{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, + smithy::SigV4AuthScheme{Aws::MakeShared(ALLOCATION_TAG, credentialsProvider), + GetServiceName(), clientConfiguration.region}}, + {smithy::BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption.schemeId, + smithy::BearerTokenAuthScheme{Aws::MakeShared( + "BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), + GetServiceName(), clientConfiguration.region}}}) {} /* End of legacy constructors due deprecation */ BedrockClient::~BedrockClient() { ShutdownSdkClient(this, -1); } diff --git a/generated/src/aws-cpp-sdk-bedrock/source/BedrockClientConfiguration.cpp b/generated/src/aws-cpp-sdk-bedrock/source/BedrockClientConfiguration.cpp new file mode 100644 index 00000000000..74351698394 --- /dev/null +++ b/generated/src/aws-cpp-sdk-bedrock/source/BedrockClientConfiguration.cpp @@ -0,0 +1,45 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#include + +namespace Aws { +namespace Bedrock { + +static const char AWS_BEARER_TOKEN_BEDROCK[] = "AWS_BEARER_TOKEN_BEDROCK"; + +void BedrockClientConfiguration::LoadBedrockSpecificConfig(const Aws::String& inputProfileName) { + const Aws::String& bedrockToken = + BaseClientConfigClass::LoadConfigFromEnvOrProfile(AWS_BEARER_TOKEN_BEDROCK, inputProfileName, AWS_BEARER_TOKEN_BEDROCK, {}, ""); + if (!bedrockToken.empty()) { + Aws::Vector::iterator position = std::find(authPreferences.begin(), authPreferences.end(), "bearer"); + if (position != authPreferences.end()) { + authPreferences.erase(position); + } + authPreferences.insert(authPreferences.begin(), "bearer"); + } +} + +BedrockClientConfiguration::BedrockClientConfiguration(const Client::ClientConfigurationInitValues& configuration) + : BaseClientConfigClass(configuration) { + LoadBedrockSpecificConfig(this->profileName); +} + +BedrockClientConfiguration::BedrockClientConfiguration(const char* inputProfileName, bool shouldDisableIMDS) + : BaseClientConfigClass(inputProfileName, shouldDisableIMDS) { + LoadBedrockSpecificConfig(Aws::String(inputProfileName)); +} + +BedrockClientConfiguration::BedrockClientConfiguration(bool useSmartDefaults, const char* defaultMode, bool shouldDisableIMDS) + : BaseClientConfigClass(useSmartDefaults, defaultMode, shouldDisableIMDS) { + LoadBedrockSpecificConfig(this->profileName); +} + +BedrockClientConfiguration::BedrockClientConfiguration(const Client::ClientConfiguration& config) : BaseClientConfigClass(config) { + LoadBedrockSpecificConfig(this->profileName); +} + +} // namespace Bedrock +} // namespace Aws diff --git a/generated/src/aws-cpp-sdk-bedrock/source/BedrockEndpointProvider.cpp b/generated/src/aws-cpp-sdk-bedrock/source/BedrockEndpointProvider.cpp index 72762d07dfb..0c992758cc8 100644 --- a/generated/src/aws-cpp-sdk-bedrock/source/BedrockEndpointProvider.cpp +++ b/generated/src/aws-cpp-sdk-bedrock/source/BedrockEndpointProvider.cpp @@ -6,7 +6,27 @@ #include namespace Aws { +#ifndef AWS_BEDROCK_EXPORTS // Except for Windows DLL +namespace Endpoint { +/** + * Instantiate endpoint providers + */ +template class Aws::Endpoint::EndpointProviderBase; + +template class Aws::Endpoint::DefaultEndpointProvider; +} // namespace Endpoint +#endif + namespace Bedrock { -namespace Endpoint {} // namespace Endpoint +namespace Endpoint { +void BedrockBuiltInParameters::SetFromClientConfiguration(const BedrockClientConfiguration& config) { + SetFromClientConfiguration(static_cast(config)); +} + +} // namespace Endpoint } // namespace Bedrock } // namespace Aws diff --git a/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp b/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp index 65eb589ab2c..b1ac749e20a 100644 --- a/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp +++ b/generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp @@ -143,16 +143,15 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr& cr /* Legacy constructors due deprecation */ DynamoDBClient::DynamoDBClient(const Client::ClientConfiguration& clientConfiguration) - : AwsSmithyClientT(clientConfiguration, GetServiceName(), "DynamoDB", Aws::Http::CreateHttpClient(clientConfiguration), - Aws::MakeShared(ALLOCATION_TAG), Aws::MakeShared(ALLOCATION_TAG), - Aws::MakeShared>( - ALLOCATION_TAG, Aws::Vector({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption})), - { - {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, - smithy::SigV4AuthScheme{Aws::MakeShared( - ALLOCATION_TAG, clientConfiguration.credentialProviderConfig), - GetServiceName(), clientConfiguration.region}}, - }) {} + : AwsSmithyClientT( + clientConfiguration, GetServiceName(), "DynamoDB", Aws::Http::CreateHttpClient(clientConfiguration), + Aws::MakeShared(ALLOCATION_TAG), Aws::MakeShared(ALLOCATION_TAG), + Aws::MakeShared>( + ALLOCATION_TAG, Aws::Vector({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption})), + { + {smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, + smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}}, + }) {} DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) : AwsSmithyClientT( diff --git a/generated/tests/bedrock-agent-gen-tests/BedrockAgentIncludeTests.cpp b/generated/tests/bedrock-agent-gen-tests/BedrockAgentIncludeTests.cpp index d8921304f85..035551e8244 100644 --- a/generated/tests/bedrock-agent-gen-tests/BedrockAgentIncludeTests.cpp +++ b/generated/tests/bedrock-agent-gen-tests/BedrockAgentIncludeTests.cpp @@ -6,7 +6,9 @@ #include #include +#include #include +#include #include #include #include diff --git a/generated/tests/bedrock-agent-runtime-gen-tests/BedrockAgentRuntimeIncludeTests.cpp b/generated/tests/bedrock-agent-runtime-gen-tests/BedrockAgentRuntimeIncludeTests.cpp index 65752b8a35e..538bef7649f 100644 --- a/generated/tests/bedrock-agent-runtime-gen-tests/BedrockAgentRuntimeIncludeTests.cpp +++ b/generated/tests/bedrock-agent-runtime-gen-tests/BedrockAgentRuntimeIncludeTests.cpp @@ -6,7 +6,9 @@ #include #include +#include #include +#include #include #include #include diff --git a/generated/tests/bedrock-gen-tests/BedrockIncludeTests.cpp b/generated/tests/bedrock-gen-tests/BedrockIncludeTests.cpp index a9c9eda1826..bf13898bd3b 100644 --- a/generated/tests/bedrock-gen-tests/BedrockIncludeTests.cpp +++ b/generated/tests/bedrock-gen-tests/BedrockIncludeTests.cpp @@ -6,7 +6,9 @@ #include #include +#include #include +#include #include #include #include diff --git a/generated/tests/bedrock-runtime-gen-tests/BedrockRuntimeIncludeTests.cpp b/generated/tests/bedrock-runtime-gen-tests/BedrockRuntimeIncludeTests.cpp index 6a22034b3ae..e28a0d6fa8b 100644 --- a/generated/tests/bedrock-runtime-gen-tests/BedrockRuntimeIncludeTests.cpp +++ b/generated/tests/bedrock-runtime-gen-tests/BedrockRuntimeIncludeTests.cpp @@ -6,7 +6,9 @@ #include #include +#include #include +#include #include #include #include diff --git a/src/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/DefaultBearerTokenProviderChain.h b/src/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/DefaultBearerTokenProviderChain.h index 8e8a4508a32..6c3bbf3e225 100644 --- a/src/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/DefaultBearerTokenProviderChain.h +++ b/src/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/DefaultBearerTokenProviderChain.h @@ -8,10 +8,16 @@ #include #include +#include #include namespace Aws { + namespace Client + { + struct ClientConfiguration; + } + namespace Auth { /** @@ -21,6 +27,7 @@ namespace Aws { public: DefaultBearerTokenProviderChain(); + DefaultBearerTokenProviderChain(const Aws::Client::ClientConfiguration::CredentialProviderConfiguration& config); virtual ~DefaultBearerTokenProviderChain() = default; /** diff --git a/src/aws-cpp-sdk-core/include/aws/core/client/UserAgent.h b/src/aws-cpp-sdk-core/include/aws/core/client/UserAgent.h index 59730dd00c7..dbfc6fd3ab4 100644 --- a/src/aws-cpp-sdk-core/include/aws/core/client/UserAgent.h +++ b/src/aws-cpp-sdk-core/include/aws/core/client/UserAgent.h @@ -44,6 +44,7 @@ enum class UserAgentFeature { CREDENTIALS_PROFILE_SOURCE_PROFILE, CREDENTIALS_LOGIN, PROTOCOL_RPC_V2_CBOR, + BEARER_SERVICE_ENV_VARS }; class AWS_CORE_API UserAgent { diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/BearerTokenAuthScheme.h b/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/BearerTokenAuthScheme.h index f1eac437cb7..19804562640 100644 --- a/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/BearerTokenAuthScheme.h +++ b/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/BearerTokenAuthScheme.h @@ -35,7 +35,7 @@ class BearerTokenAuthScheme : public AuthScheme explicit BearerTokenAuthScheme(const Aws::String &serviceName, const Aws::String ®ion, const Aws::Client::ClientConfiguration::CredentialProviderConfiguration& config) - : BearerTokenAuthScheme(Aws::MakeShared("BearerTokenAuthScheme"), serviceName, region) { + : BearerTokenAuthScheme(Aws::MakeShared("BearerTokenAuthScheme", config), serviceName, region) { AWS_UNREFERENCED_PARAM(config); assert(m_identityResolver); assert(m_signer); diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsBearerTokenIdentityBase.h b/src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsBearerTokenIdentityBase.h index f66586abd6c..503271561a1 100644 --- a/src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsBearerTokenIdentityBase.h +++ b/src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsBearerTokenIdentityBase.h @@ -13,5 +13,18 @@ namespace smithy { virtual Aws::Crt::Optional expiration() const override = 0; + + void AddUserAgentFeature(Aws::Client::UserAgentFeature feature) + { + m_features.insert(feature); + } + + Aws::Set GetUserAgentFeatures() const override + { + return m_features; + } + + protected: + Aws::Set m_features; }; } \ No newline at end of file diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsIdentity.h b/src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsIdentity.h index 5b8881ee1ed..cef896e2c0f 100644 --- a/src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsIdentity.h +++ b/src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsIdentity.h @@ -4,10 +4,16 @@ */ #pragma once +#include #include +#include -#include +namespace Aws { + namespace Client { + enum class UserAgentFeature; + } +} namespace smithy { class AwsIdentity { public: @@ -21,5 +27,9 @@ namespace smithy { virtual Aws::Crt::Optional accountId() const { return Aws::Crt::Optional{}; } + + virtual Aws::Set GetUserAgentFeatures() const { + return {}; + } }; } \ No newline at end of file diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/resolver/AwsBearerTokenIdentityResolver.h b/src/aws-cpp-sdk-core/include/smithy/identity/resolver/AwsBearerTokenIdentityResolver.h index d92e32cfa2a..2789dfdb29e 100644 --- a/src/aws-cpp-sdk-core/include/smithy/identity/resolver/AwsBearerTokenIdentityResolver.h +++ b/src/aws-cpp-sdk-core/include/smithy/identity/resolver/AwsBearerTokenIdentityResolver.h @@ -5,11 +5,15 @@ #pragma once #include +#include #include #include #include #include #include +#include +#include + namespace smithy { @@ -52,7 +56,7 @@ class AwsBearerTokenIdentityResolver } ResolveIdentityFutureOutcome - getIdentity(const IdentityProperties &identityProperties, + virtual getIdentity(const IdentityProperties &identityProperties, const AdditionalParameters &additionalParameters) override { AWS_UNREFERENCED_PARAM(identityProperties); @@ -107,7 +111,11 @@ class DefaultAwsBearerTokenIdentityResolver DefaultAwsBearerTokenIdentityResolver() : AwsBearerTokenIdentityResolver(Aws::Vector>{ - Aws::MakeShared("SSOBearerTokenProvider")}){}; + Aws::MakeShared("SSOBearerTokenProvider")}){}; + + DefaultAwsBearerTokenIdentityResolver(const Aws::Client::ClientConfiguration::CredentialProviderConfiguration& config) + : AwsBearerTokenIdentityResolver(Aws::Vector>{ + Aws::MakeShared("SSOBearerTokenProvider", config.profile)}){}; }; } // namespace smithy \ No newline at end of file diff --git a/src/aws-cpp-sdk-core/source/auth/bearer-token-provider/DefaultBearerTokenProviderChain.cpp b/src/aws-cpp-sdk-core/source/auth/bearer-token-provider/DefaultBearerTokenProviderChain.cpp index 16b301cd678..4dcdaae9f9f 100644 --- a/src/aws-cpp-sdk-core/source/auth/bearer-token-provider/DefaultBearerTokenProviderChain.cpp +++ b/src/aws-cpp-sdk-core/source/auth/bearer-token-provider/DefaultBearerTokenProviderChain.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include @@ -33,3 +34,8 @@ Aws::Auth::DefaultBearerTokenProviderChain::DefaultBearerTokenProviderChain() { AddProvider(Aws::MakeShared(SSO_DEFAULT_BEARER_TOKEN_PROVIDER_CHAIN_LOG_TAG)); } + +Aws::Auth::DefaultBearerTokenProviderChain::DefaultBearerTokenProviderChain(const Aws::Client::ClientConfiguration::CredentialProviderConfiguration& config) +{ + AddProvider(Aws::MakeShared(SSO_DEFAULT_BEARER_TOKEN_PROVIDER_CHAIN_LOG_TAG, config.profile)); +} diff --git a/src/aws-cpp-sdk-core/source/client/ClientConfiguration.cpp b/src/aws-cpp-sdk-core/source/client/ClientConfiguration.cpp index 3b38c3a2b33..132cc0fd7ec 100644 --- a/src/aws-cpp-sdk-core/source/client/ClientConfiguration.cpp +++ b/src/aws-cpp-sdk-core/source/client/ClientConfiguration.cpp @@ -55,6 +55,7 @@ static const char* AWS_WEB_IDENTITY_TOKEN_FILE_ENV_VAR = "AWS_WEB_IDENTITY_TOKEN static const char* AWS_WEB_IDENTITY_TOKEN_FILE_CONFIG_FILE_OPTION = "web_identity_token_file"; static const char* AWS_LOGIN_SESSION_FILE_OPTION = "login_session"; static const char* AWS_LOGIN_CACHE_DIRECTORY_ENV_VAR = "AWS_LOGIN_CACHE_DIRECTORY"; +static const char* AWS_AUTH_SCHEME_PREFERENCE = "AWS_AUTH_SCHEME_PREFERENCE"; using RequestChecksumConfigurationEnumMapping = std::pair; static const std::array REQUEST_CHECKSUM_CONFIG_MAPPING = {{ @@ -192,9 +193,9 @@ Aws::String calculateRegion() { Aws::Vector calculateAuthPreferences() { - // Automatically determine the AWS region from environment variables, configuration file and EC2 metadata. + // Automatically determine the auth scheme preferences, based on environment vars. Aws::Vector res; - auto prefs = Aws::Environment::GetEnv("AWS_AUTH_SCHEME_PREFERENCE"); + auto prefs = Aws::Environment::GetEnv(AWS_AUTH_SCHEME_PREFERENCE); Aws::Vector prefsList = Aws::Utils::StringUtils::Split(prefs, ','); res.reserve(prefsList.size()); // avoid repeated allocations for (auto& pref : prefsList) { diff --git a/src/aws-cpp-sdk-core/source/client/UserAgent.cpp b/src/aws-cpp-sdk-core/source/client/UserAgent.cpp index dd6fa87c3a7..f1d14510e11 100644 --- a/src/aws-cpp-sdk-core/source/client/UserAgent.cpp +++ b/src/aws-cpp-sdk-core/source/client/UserAgent.cpp @@ -54,6 +54,7 @@ const std::pair BUSINESS_METRIC_MAPPING[] = { {UserAgentFeature::CREDENTIALS_PROFILE_SOURCE_PROFILE, "p"}, {UserAgentFeature::CREDENTIALS_LOGIN, "AD"}, {UserAgentFeature::PROTOCOL_RPC_V2_CBOR, "M"}, + {UserAgentFeature::BEARER_SERVICE_ENV_VARS, "3"}, }; const std::pair RETRY_FEATURE_MAPPING[] = { diff --git a/src/aws-cpp-sdk-core/source/smithy/client/AwsSmithyClientBase.cpp b/src/aws-cpp-sdk-core/source/smithy/client/AwsSmithyClientBase.cpp index 117c8b42952..34f33336d36 100644 --- a/src/aws-cpp-sdk-core/source/smithy/client/AwsSmithyClientBase.cpp +++ b/src/aws-cpp-sdk-core/source/smithy/client/AwsSmithyClientBase.cpp @@ -207,6 +207,9 @@ bool AwsSmithyClientBase::ResolveIdentityAuth( responseHandler(std::move(identityOutcome)); return false; } + for (auto feature : identityOutcome.GetResult()->GetUserAgentFeatures()) { + pRequestCtx->m_pRequest->AddUserAgentFeature(feature); + } pRequestCtx->m_awsIdentity = std::move(identityOutcome.GetResultWithOwnership()); diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/config/ServiceGeneratorConfig.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/config/ServiceGeneratorConfig.java index c2a7acabada..a4ed55b0ab1 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/config/ServiceGeneratorConfig.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/config/ServiceGeneratorConfig.java @@ -14,6 +14,7 @@ import com.amazonaws.util.awsclientgenerator.generators.cpp.RestXmlCppClientGenerator; import com.amazonaws.util.awsclientgenerator.generators.cpp.apigateway.APIGatewayRestJsonCppClientGenerator; import com.amazonaws.util.awsclientgenerator.generators.cpp.apigatewayv2.APIGatewayV2RestJsonCppClientGenerator; +import com.amazonaws.util.awsclientgenerator.generators.cpp.bedrock.BedrockRestJsonCppClientGenerator; import com.amazonaws.util.awsclientgenerator.generators.cpp.docdb.DocDBCppClientGenerator; import com.amazonaws.util.awsclientgenerator.generators.cpp.dynamodb.DynamoDBJsonCppClientGenerator; import com.amazonaws.util.awsclientgenerator.generators.cpp.ec2.Ec2CppClientGenerator; @@ -75,6 +76,10 @@ public class ServiceGeneratorConfig { SPEC_OVERRIDE_MAPPING.put("cpp-dsql-rest-json", new DsqlCppClientGenerator()); SPEC_OVERRIDE_MAPPING.put("cpp-monitoring-json", new CloudwatchMonitoringJsonCppClientGenerator()); SPEC_OVERRIDE_MAPPING.put("cpp-monitoring-smithy-rpc-v2-cbor", new CloudwatchMonitoringCborCppClientGenerator()); + SPEC_OVERRIDE_MAPPING.put("cpp-bedrock-rest-json", new BedrockRestJsonCppClientGenerator()); + SPEC_OVERRIDE_MAPPING.put("cpp-bedrock-runtime-rest-json", new BedrockRestJsonCppClientGenerator()); + SPEC_OVERRIDE_MAPPING.put("cpp-bedrock-agent-rest-json", new BedrockRestJsonCppClientGenerator()); + SPEC_OVERRIDE_MAPPING.put("cpp-bedrock-agent-runtime-rest-json", new BedrockRestJsonCppClientGenerator()); // protocol tests clients SPEC_OVERRIDE_MAPPING.put("cpp-ec2-protocol-ec2", new Ec2CppClientGenerator()); diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java index feadd48bce3..635413e56dc 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java @@ -77,13 +77,20 @@ public boolean hasOnlyBearerAuth() { } public boolean shouldCreateLegacyBearerConstructor() { - return !metadata.getServiceFullName().toLowerCase().contains("bedrock"); + return !(metadata.getServiceId().equalsIgnoreCase("Bedrock") || + metadata.getServiceId().equalsIgnoreCase("Bedrock Runtime") || + metadata.getServiceId().equalsIgnoreCase("Bedrock Agent") || + metadata.getServiceId().equalsIgnoreCase("Bedrock Agent Runtime")); } public boolean hasServiceSpecificClientConfig() { return metadata.getServiceId().equalsIgnoreCase("S3") || metadata.getServiceId().equalsIgnoreCase("S3-CRT") || metadata.getServiceId().equalsIgnoreCase("S3 Control") || + metadata.getServiceId().equalsIgnoreCase("Bedrock") || + metadata.getServiceId().equalsIgnoreCase("Bedrock Runtime") || + metadata.getServiceId().equalsIgnoreCase("Bedrock Agent") || + metadata.getServiceId().equalsIgnoreCase("Bedrock Agent Runtime") || metadata.isHasEndpointDiscoveryTrait() || endpointRuleSetModel.getParameters().containsKey("AccountId") || endpointRuleSetModel.getParameters().containsKey("AccountIdEndpointMode"); } diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/bedrock/BedrockRestJsonCppClientGenerator.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/bedrock/BedrockRestJsonCppClientGenerator.java new file mode 100644 index 00000000000..707c37af482 --- /dev/null +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/bedrock/BedrockRestJsonCppClientGenerator.java @@ -0,0 +1,54 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +package com.amazonaws.util.awsclientgenerator.generators.cpp.bedrock; + +import com.amazonaws.util.awsclientgenerator.domainmodels.SdkFileEntry; +import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.ServiceModel; +import com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.cpp.CppViewHelper; +import com.amazonaws.util.awsclientgenerator.generators.cpp.JsonCppClientGenerator; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.velocity.VelocityContext; + +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class BedrockRestJsonCppClientGenerator extends JsonCppClientGenerator { + + public BedrockRestJsonCppClientGenerator() throws Exception { + super(); + } + + @Override + public SdkFileEntry[] generateSourceFiles(ServiceModel serviceModel) throws Exception { + return Stream.concat(generateBedrockIdentityResolverFiles(serviceModel).stream(), + Arrays.stream(super.generateSourceFiles(serviceModel))) + .toArray(SdkFileEntry[]::new); + } + + private List generateBedrockIdentityResolverFiles(final ServiceModel serviceModel) { + final String projectName = serviceModel.getMetadata().getProjectName(); + final String vmFilePrefixFormat = "/com/amazonaws/util/awsclientgenerator/velocity/cpp/bedrock/%s"; + final String includePath = String.format("include/aws/%s/", projectName); + final VelocityContext context = createContext(serviceModel); + context.put("CppViewHelper", CppViewHelper.class); + context.put("serviceModel", serviceModel); + context.put("metadata", serviceModel.getMetadata()); + + if (serviceModel.isUseSmithyClient()) + { + return Stream.of(Pair.of(includePath + serviceModel.getMetadata().getClassNamePrefix() + "AwsBearerTokenIdentityResolver.h", String.format(vmFilePrefixFormat, "BedrockAwsBearerTokenIdentityResolver.vm"))) + .map(codeGenPair -> makeFile(velocityEngine.getTemplate(codeGenPair.getValue()), + context, + codeGenPair.getKey(), + true)) + .collect(Collectors.toList()); + } + return Collections.emptyList(); + } +} diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientSourceHeaders.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientSourceHeaders.vm index ac56f332247..6a1117e6643 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientSourceHeaders.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientSourceHeaders.vm @@ -79,3 +79,6 @@ using namespace Aws::Utils; #end +#if($serviceModel.metadata.serviceId == "Bedrock" || $serviceModel.metadata.serviceId == "Bedrock Runtime" || $serviceModel.metadata.serviceId == "Bedrock Agent" || $serviceModel.metadata.serviceId == "Bedrock Agent Runtime") +\#include +#end diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/bedrock/BedrockAwsBearerTokenIdentityResolver.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/bedrock/BedrockAwsBearerTokenIdentityResolver.vm new file mode 100644 index 00000000000..ce15baaaca9 --- /dev/null +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/bedrock/BedrockAwsBearerTokenIdentityResolver.vm @@ -0,0 +1,63 @@ +#set($rootNamespace = $serviceModel.namespace) +#set($serviceNamespace = $metadata.namespace) +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +* SPDX-License-Identifier: Apache-2.0. +*/ +#pragma once + +\#include +\#include +\#include +\#include +\#include +\#include +\#include +\#include +\#include +\#include + +namespace ${rootNamespace} +{ +namespace ${serviceNamespace} +{ + +class ${metadata.classNamePrefix}AwsBearerTokenIdentityResolver +: public smithy::AwsBearerTokenIdentityResolver +{ + public: + using IdentityT = smithy::AwsBearerTokenIdentity; + virtual ~${metadata.classNamePrefix}AwsBearerTokenIdentityResolver() = default; + + ${metadata.classNamePrefix}AwsBearerTokenIdentityResolver() + { + m_providerChainLegacy.emplace_back(Aws::MakeShared("SSOBearerTokenProvider")); + const Aws::String bedrockToken = Aws::Environment::GetEnv("AWS_BEARER_TOKEN_BEDROCK"); + if (!bedrockToken.empty()) + { + m_providerChainLegacy.emplace_back(Aws::MakeShared("StaticAWSBearerTokenProvider", bedrockToken)); + } + }; + + ${metadata.classNamePrefix}AwsBearerTokenIdentityResolver(const Aws::Client::ClientConfiguration::CredentialProviderConfiguration& config) + { + m_providerChainLegacy.emplace_back(Aws::MakeShared("SSOBearerTokenProvider", config.profile)); + const Aws::String bedrockToken = Aws::Environment::GetEnv("AWS_BEARER_TOKEN_BEDROCK"); + if (!bedrockToken.empty()) + { + m_providerChainLegacy.emplace_back(Aws::MakeShared("StaticAWSBearerTokenProvider", bedrockToken)); + } + } + + ResolveIdentityFutureOutcome + virtual getIdentity(const IdentityProperties &identityProperties, + const AdditionalParameters &additionalParameters) override + { + auto outcome = AwsBearerTokenIdentityResolver::getIdentity(identityProperties, additionalParameters); + outcome.GetResult()->AddUserAgentFeature(Aws::Client::UserAgentFeature::BEARER_SERVICE_ENV_VARS); + return outcome; + } +}; + +} // namespace ${rootNamespace} +} // namespace ${serviceNameSpace} \ No newline at end of file diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationSource.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationSource.vm index 007b5900fc9..570c006823f 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationSource.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationSource.vm @@ -28,6 +28,9 @@ static const char S3_DISABLE_EXPRESS_SESSION_CONFIG_FILE_OPTION[] = "s3_disable_ static const char S3_USE_ARN_REGION_ENVIRONMENT_VARIABLE[] = "AWS_S3_USE_ARN_REGION"; static const char S3_USE_ARN_REGION_CONFIG_FILE_OPTION[] = "s3_use_arn_region"; #end +#if($serviceModel.metadata.serviceId == "Bedrock" || $serviceModel.metadata.serviceId == "Bedrock Runtime" || $serviceModel.metadata.serviceId == "Bedrock Agent" || $serviceModel.metadata.serviceId == "Bedrock Agent Runtime") +static const char AWS_BEARER_TOKEN_BEDROCK[] = "AWS_BEARER_TOKEN_BEDROCK"; +#end #if($metadata.hasEndpointDiscoveryTrait) bool IsEndpointDiscoveryEnabled(const Aws::String& endpointOverride, const Aws::String &profileName) @@ -132,6 +135,22 @@ void ${metadata.classNamePrefix}ClientConfiguration::Load${serviceNamespace}Spec return Client::InitRetryStrategy(); }; #end +## Bedrock API key auth +#if($serviceModel.metadata.serviceId == "Bedrock" || $serviceModel.metadata.serviceId == "Bedrock Runtime" || $serviceModel.metadata.serviceId == "Bedrock Agent" || $serviceModel.metadata.serviceId == "Bedrock Agent Runtime") + const Aws::String& bedrockToken = + BaseClientConfigClass::LoadConfigFromEnvOrProfile(AWS_BEARER_TOKEN_BEDROCK, + inputProfileName, + AWS_BEARER_TOKEN_BEDROCK, + {}, + ""); + if (!bedrockToken.empty()) { + Aws::Vector::iterator position = std::find(authPreferences.begin(), authPreferences.end(), "bearer"); + if (position != authPreferences.end()) { + authPreferences.erase(position); + } + authPreferences.insert(authPreferences.begin(), "bearer"); + } +#end } ${metadata.classNamePrefix}ClientConfiguration::${metadata.classNamePrefix}ClientConfiguration(const Client::ClientConfigurationInitValues &configuration) diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/model/ServiceClientModelHeaderInclude.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/model/ServiceClientModelHeaderInclude.vm index f4b64bdb975..fb3e9b1d4f0 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/model/ServiceClientModelHeaderInclude.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/model/ServiceClientModelHeaderInclude.vm @@ -83,7 +83,7 @@ namespace ${rootNamespace} namespace ${metadata.namespace} { -#if($serviceModel.metadata.serviceId != "S3" && $serviceModel.metadata.serviceId != "S3 Control" && !$serviceModel.metadata.hasEndpointDiscoveryTrait) +#if(!$serviceModel.hasServiceSpecificClientConfig()) using ${metadata.classNamePrefix}ClientConfiguration = Aws::Client::GenericClientConfiguration; #end using ${metadata.classNamePrefix}EndpointProviderBase = Aws::${metadata.namespace}::Endpoint::${metadata.classNamePrefix}EndpointProviderBase; diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSourceInit.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSourceInit.vm index 7b066f917f2..379e20e8103 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSourceInit.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyClientSourceInit.vm @@ -76,7 +76,11 @@ ${className}::${className}(const ${clientConfiguration}& clientConfiguration, }() #else #foreach($entry in $AuthSchemeMapEntries) - {${entry}{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}}, + #if($entry.contains("smithy::BearerTokenAuthScheme") && ($serviceModel.metadata.serviceId == "Bedrock" || $serviceModel.metadata.serviceId == "Bedrock Runtime" || $serviceModel.metadata.serviceId == "Bedrock Agent" || $serviceModel.metadata.serviceId == "Bedrock Agent Runtime")) + {${entry}{Aws::MakeShared<${metadata.classNamePrefix}AwsBearerTokenIdentityResolver>("BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), GetServiceName(), clientConfiguration.region}}, + #else + {${entry}{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}}, + #end #end #end }) @@ -118,6 +122,12 @@ ${className}::${className}(const AWSCredentials& credentials, #foreach($entry in $AuthSchemeMapEntries) #if(!$entry.contains("smithy::BearerTokenAuthScheme")) {${entry}{Aws::MakeShared(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}}, +#else + #if($serviceModel.metadata.serviceId == "Bedrock" || $serviceModel.metadata.serviceId == "Bedrock Runtime" || $serviceModel.metadata.serviceId == "Bedrock Agent" || $serviceModel.metadata.serviceId == "Bedrock Agent Runtime") + {${entry}{Aws::MakeShared<${metadata.classNamePrefix}AwsBearerTokenIdentityResolver>("BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), GetServiceName(), clientConfiguration.region}} + #else + {${entry}{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}} + #end #end #end #end @@ -295,11 +305,11 @@ ${className}::${className}(const Client::ClientConfiguration& clientConfiguratio #end { #foreach($entry in $AuthSchemeMapEntries) -#if($entry.contains("smithy::BearerTokenAuthScheme")) - {${entry}{Aws::MakeShared(ALLOCATION_TAG), GetServiceName(), clientConfiguration.region}}, -#else - {$entry{Aws::MakeShared(ALLOCATION_TAG, clientConfiguration.credentialProviderConfig), GetServiceName(), clientConfiguration.region}}, -#end + #if($entry.contains("smithy::BearerTokenAuthScheme") && ($serviceModel.metadata.serviceId == "Bedrock" || $serviceModel.metadata.serviceId == "Bedrock Runtime" || $serviceModel.metadata.serviceId == "Bedrock Agent" || $serviceModel.metadata.serviceId == "Bedrock Agent Runtime")) + {${entry}{Aws::MakeShared<${metadata.classNamePrefix}AwsBearerTokenIdentityResolver>("BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), GetServiceName(), clientConfiguration.region}}, + #else + {${entry}{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}}, + #end #end }) {} @@ -321,6 +331,13 @@ ${className}::${className}(const AWSCredentials& credentials, #foreach($entry in $AuthSchemeMapEntries) #if(!$entry.contains("smithy::BearerTokenAuthScheme")) {$entry{Aws::MakeShared(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}}, +#else + #if($entry.contains("smithy::BearerTokenAuthScheme") && ($serviceModel.metadata.serviceId == "Bedrock" || $serviceModel.metadata.serviceId == "Bedrock Runtime" || $serviceModel.metadata.serviceId == "Bedrock Agent" || $serviceModel.metadata.serviceId == "Bedrock Agent Runtime")) + {${entry}{Aws::MakeShared<${metadata.classNamePrefix}AwsBearerTokenIdentityResolver>("BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), GetServiceName(), clientConfiguration.region}}, + #else + {${entry}{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}} + #end + #end #end }) @@ -342,6 +359,12 @@ ${className}::${className}(const std::shared_ptr& creden #foreach($entry in $AuthSchemeMapEntries) #if(!$entry.contains("smithy::BearerTokenAuthScheme")) {$entry{Aws::MakeShared(ALLOCATION_TAG, credentialsProvider), GetServiceName(), clientConfiguration.region}}, +#else + #if($serviceModel.metadata.serviceId == "Bedrock" || $serviceModel.metadata.serviceId == "Bedrock Runtime" || $serviceModel.metadata.serviceId == "Bedrock Agent" || $serviceModel.metadata.serviceId == "Bedrock Agent Runtime") + {${entry}{Aws::MakeShared<${metadata.classNamePrefix}AwsBearerTokenIdentityResolver>("BearerTokenAuthScheme", clientConfiguration.credentialProviderConfig), GetServiceName(), clientConfiguration.region}} + #else + {${entry}{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}} + #end #end #end })