diff --git a/src/aws-cpp-sdk-core/include/aws/core/utils/event/EventEncoderStream.h b/src/aws-cpp-sdk-core/include/aws/core/utils/event/EventEncoderStream.h index 1e2140d50f7..8779a507898 100644 --- a/src/aws-cpp-sdk-core/include/aws/core/utils/event/EventEncoderStream.h +++ b/src/aws-cpp-sdk-core/include/aws/core/utils/event/EventEncoderStream.h @@ -91,6 +91,6 @@ namespace Aws } SmithyEventStreamEncoder m_evtEncoder; }; - } // namespace Event + } // namespace Event } } diff --git a/src/aws-cpp-sdk-core/include/smithy/client/common/AwsSmithyRequestSigning.h b/src/aws-cpp-sdk-core/include/smithy/client/common/AwsSmithyRequestSigning.h index 4045db8da14..0a9b12470fc 100644 --- a/src/aws-cpp-sdk-core/include/smithy/client/common/AwsSmithyRequestSigning.h +++ b/src/aws-cpp-sdk-core/include/smithy/client/common/AwsSmithyRequestSigning.h @@ -21,11 +21,57 @@ namespace smithy { - static const char AWS_SMITHY_CLIENT_SIGNING_TAG[] = "AwsClientRequestSigning"; - //4 Minutes - static const std::chrono::milliseconds TIME_DIFF_MAX = std::chrono::minutes(4); - //-4 Minutes - static const std::chrono::milliseconds TIME_DIFF_MIN = std::chrono::minutes(-4); + static const char AWS_SMITHY_CLIENT_SIGNING_TAG[] = "AwsClientRequestSigning"; + //4 Minutes + static const std::chrono::milliseconds TIME_DIFF_MAX = std::chrono::minutes(4); + //-4 Minutes + static const std::chrono::milliseconds TIME_DIFF_MIN = std::chrono::minutes(-4); + + + struct EventStreamSignerVisitor + { + explicit EventStreamSignerVisitor(std::shared_ptr evSp, + const AuthSchemeOption& targetAuthSchemeOption) + : m_eventEncoderStreamSp(evSp), m_targetAuthSchemeOption(targetAuthSchemeOption) {} + template + void operator()(AuthSchemeAlternativeT&) {} + std::shared_ptr m_eventEncoderStreamSp; + const AuthSchemeOption& m_targetAuthSchemeOption; + }; + + + + template <> + void EventStreamSignerVisitor::operator()(smithy::SigV4AuthScheme& authScheme) { + // Auth Scheme Variant alternative contains the requested auth option + assert(strcmp(authScheme.schemeId, m_targetAuthSchemeOption.schemeId) == 0); + using IdentityT = smithy::SigV4AuthScheme::IdentityT; + using IdentityResolver = IdentityResolverBase; + using Signer = AwsSignerBase; + std::shared_ptr signer = authScheme.signer(m_targetAuthSchemeOption.isEventStreaming); + if (!signer) { + AWS_LOGSTREAM_ERROR(AWS_SMITHY_CLIENT_SIGNING_TAG, "Failed to adjust signing clock skew. Signer is null."); + return; + } + + std::shared_ptr identityResolver = authScheme.identityResolver(); + if (!identityResolver) { + AWS_LOGSTREAM_ERROR(AWS_SMITHY_CLIENT_SIGNING_TAG, "Failed to find identityResolver."); + + return; + } + + auto identityResult = + identityResolver->getIdentity(m_targetAuthSchemeOption.identityProperties(), m_targetAuthSchemeOption.identityProperties()); + + if (!identityResult.IsSuccess()) { + AWS_LOGSTREAM_ERROR(AWS_SMITHY_CLIENT_SIGNING_TAG, "Failed to resolve identity"); + return; + } + + // typecast to streaming type as we know this visitor is for smithy types + m_eventEncoderStreamSp->SetSigner(signer, std::move(identityResult.GetResultWithOwnership())); + } template class AwsClientRequestSigning @@ -209,49 +255,5 @@ namespace smithy } } }; - - struct EventStreamSignerVisitor { - explicit EventStreamSignerVisitor(std::shared_ptr evSp, - const AuthSchemeOption& targetAuthSchemeOption) - : m_eventEncoderStreamSp(evSp), m_targetAuthSchemeOption(targetAuthSchemeOption) {} - - std::shared_ptr m_eventEncoderStreamSp; - const AuthSchemeOption& m_targetAuthSchemeOption; - - template - void operator()(AuthSchemeAlternativeT&) {} - - template <> - void operator()(smithy::SigV4AuthScheme& authScheme) { - // Auth Scheme Variant alternative contains the requested auth option - assert(strcmp(authScheme.schemeId, m_targetAuthSchemeOption.schemeId) == 0); - using IdentityT = smithy::SigV4AuthScheme::IdentityT; - using IdentityResolver = IdentityResolverBase; - using Signer = AwsSignerBase; - std::shared_ptr signer = authScheme.signer(m_targetAuthSchemeOption.isEventStreaming); - if (!signer) { - AWS_LOGSTREAM_ERROR(AWS_SMITHY_CLIENT_SIGNING_TAG, "Failed to adjust signing clock skew. Signer is null."); - return; - } - - std::shared_ptr identityResolver = authScheme.identityResolver(); - if (!identityResolver) { - AWS_LOGSTREAM_ERROR(AWS_SMITHY_CLIENT_SIGNING_TAG, "Failed to find identityResolver."); - - return; - } - - auto identityResult = - identityResolver->getIdentity(m_targetAuthSchemeOption.identityProperties(), m_targetAuthSchemeOption.identityProperties()); - - if (!identityResult.IsSuccess()) { - AWS_LOGSTREAM_ERROR(AWS_SMITHY_CLIENT_SIGNING_TAG, "Failed to resolve identity"); - return; - } - - // typecast to streaming type as we know this visitor is for smithy types - m_eventEncoderStreamSp->SetSigner(signer, std::move(identityResult.GetResultWithOwnership())); - } - }; }; - } // namespace smithy + } // namespace smithy diff --git a/tools/scripts/run_code_generation.py b/tools/scripts/run_code_generation.py index 12cc51034e2..14c4d9d438c 100644 --- a/tools/scripts/run_code_generation.py +++ b/tools/scripts/run_code_generation.py @@ -105,7 +105,7 @@ def _build_service_model_with_endpoints(models_dir: str, endpoint_rules_dir: str endpoint_tests=endpoint_tests_filename) -def collect_available_models(models_dir: str, endpoint_rules_dir: str, legacy_mapped_services: Set[str]) -> dict: +def collect_available_models(models_dir: str, endpoint_rules_dir: str, legacy_mapped_services: Set[str], smithy_supported_clients: Set[str]) -> dict: """Return a dict of with all available c2j models in a models_dir :param models_dir: path to the directory with c2j models @@ -156,7 +156,7 @@ def collect_available_models(models_dir: str, endpoint_rules_dir: str, legacy_ma if ("protocol" in model["metadata"] and (model["metadata"]["protocol"] == "json" or model["metadata"]["protocol"] == "rest-json")): if key not in SMITHY_EXCLUSION_CLIENTS: - SMITHY_SUPPORTED_CLIENTS.add(key) + smithy_supported_clients.add(key) else: print("service Id not found in model file:", model_file_date[0], " Skipping.") @@ -563,6 +563,9 @@ def main(): with open(os.path.abspath(SMITHY_TO_C2J_MAP_FILE), 'r') as file: smithy_c2j_data = json.load(file) c2j_smithy_data = {value: key for key, value in smithy_c2j_data.items()} + + + smithy_supported_clients = SMITHY_SUPPORTED_CLIENTS.copy() with ProcessPoolExecutor(max_workers=max_workers) as executor: build_generator_future = None @@ -575,7 +578,8 @@ def main(): available_models = collect_available_models(args["path_to_api_definitions"], args["path_to_endpoint_rules"], - set(c2j_smithy_data.keys())) + set(c2j_smithy_data.keys()), + smithy_supported_clients) if args.get("list_all"): model_list = available_models.keys() print(model_list) @@ -600,7 +604,7 @@ def main(): pending = set() done = set() if DEBUG: - print(f"Smithy supported clients: {SMITHY_SUPPORTED_CLIENTS}") + print(f"Smithy supported clients: {smithy_supported_clients}") print(f"Running code generator, up to {max_workers} processes in parallel") sys.stdout.flush() for core_component in ["defaults", "partitions"]: @@ -628,7 +632,7 @@ def main(): args["path_to_generator"], args["output_location"], None, - (service in SMITHY_SUPPORTED_CLIENTS), + (service in smithy_supported_clients), args["raw_generator_arguments"]) pending.add(task)