From 734250011ee4e41325f1166f98d8200bc493f968 Mon Sep 17 00:00:00 2001 From: sbiscigl Date: Wed, 21 Feb 2024 13:16:53 -0500 Subject: [PATCH] fix header argument for list arguemnts --- .../source/model/GetObjectAttributesRequest.cpp | 14 ++++++++------ .../source/model/ListObjectVersionsRequest.cpp | 14 ++++++++------ .../source/model/ListObjectsRequest.cpp | 14 ++++++++------ .../source/model/ListObjectsV2Request.cpp | 14 ++++++++------ .../source/model/GetObjectAttributesRequest.cpp | 14 ++++++++------ .../source/model/ListObjectVersionsRequest.cpp | 14 ++++++++------ .../source/model/ListObjectsRequest.cpp | 14 ++++++++------ .../source/model/ListObjectsV2Request.cpp | 14 ++++++++------ .../codegeneration/cpp/CppViewHelper.java | 5 +++++ .../velocity/cpp/ModelClassHeaderMembersSource.vm | 15 ++++++++------- .../velocity/cpp/StreamRequestSource.vm | 3 +++ .../velocity/cpp/json/JsonRequestSource.vm | 3 +++ .../PutBucketNotificationConfigurationRequest.vm | 3 +++ .../velocity/cpp/xml/XmlRequestSource.vm | 3 +++ 14 files changed, 89 insertions(+), 55 deletions(-) diff --git a/generated/src/aws-cpp-sdk-s3-crt/source/model/GetObjectAttributesRequest.cpp b/generated/src/aws-cpp-sdk-s3-crt/source/model/GetObjectAttributesRequest.cpp index 88fcc1fa0a6..cba908d1834 100644 --- a/generated/src/aws-cpp-sdk-s3-crt/source/model/GetObjectAttributesRequest.cpp +++ b/generated/src/aws-cpp-sdk-s3-crt/source/model/GetObjectAttributesRequest.cpp @@ -10,6 +10,7 @@ #include #include +#include using namespace Aws::S3Crt::Model; using namespace Aws::Utils::Xml; @@ -122,12 +123,13 @@ Aws::Http::HeaderValueCollection GetObjectAttributesRequest::GetRequestSpecificH if(m_objectAttributesHasBeenSet) { - for(const auto& item : m_objectAttributes) - { - ss << ObjectAttributesMapper::GetNameForObjectAttributes(item); - headers.emplace("x-amz-object-attributes", ss.str()); - ss.str(""); - } + headers.emplace("x-amz-object-attributes", std::accumulate(std::begin(m_objectAttributes), + std::end(m_objectAttributes), + Aws::String{}, + [](const Aws::String &acc, const ObjectAttributes &item) -> Aws::String { + const auto headerValue = ObjectAttributesMapper::GetNameForObjectAttributes(item); + return acc.empty() ? headerValue : acc + "," + headerValue; + })); } return headers; diff --git a/generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectVersionsRequest.cpp b/generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectVersionsRequest.cpp index 2e73b21ba4a..f9ba9cfb4ba 100644 --- a/generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectVersionsRequest.cpp +++ b/generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectVersionsRequest.cpp @@ -10,6 +10,7 @@ #include #include +#include using namespace Aws::S3Crt::Model; using namespace Aws::Utils::Xml; @@ -121,12 +122,13 @@ Aws::Http::HeaderValueCollection ListObjectVersionsRequest::GetRequestSpecificHe if(m_optionalObjectAttributesHasBeenSet) { - for(const auto& item : m_optionalObjectAttributes) - { - ss << OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item); - headers.emplace("x-amz-optional-object-attributes", ss.str()); - ss.str(""); - } + headers.emplace("x-amz-optional-object-attributes", std::accumulate(std::begin(m_optionalObjectAttributes), + std::end(m_optionalObjectAttributes), + Aws::String{}, + [](const Aws::String &acc, const OptionalObjectAttributes &item) -> Aws::String { + const auto headerValue = OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item); + return acc.empty() ? headerValue : acc + "," + headerValue; + })); } return headers; diff --git a/generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectsRequest.cpp b/generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectsRequest.cpp index fb86b3d6d4f..78dd1a545bc 100644 --- a/generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectsRequest.cpp +++ b/generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectsRequest.cpp @@ -10,6 +10,7 @@ #include #include +#include using namespace Aws::S3Crt::Model; using namespace Aws::Utils::Xml; @@ -113,12 +114,13 @@ Aws::Http::HeaderValueCollection ListObjectsRequest::GetRequestSpecificHeaders() if(m_optionalObjectAttributesHasBeenSet) { - for(const auto& item : m_optionalObjectAttributes) - { - ss << OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item); - headers.emplace("x-amz-optional-object-attributes", ss.str()); - ss.str(""); - } + headers.emplace("x-amz-optional-object-attributes", std::accumulate(std::begin(m_optionalObjectAttributes), + std::end(m_optionalObjectAttributes), + Aws::String{}, + [](const Aws::String &acc, const OptionalObjectAttributes &item) -> Aws::String { + const auto headerValue = OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item); + return acc.empty() ? headerValue : acc + "," + headerValue; + })); } return headers; diff --git a/generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectsV2Request.cpp b/generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectsV2Request.cpp index e174fa257b9..c563b658da5 100644 --- a/generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectsV2Request.cpp +++ b/generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectsV2Request.cpp @@ -10,6 +10,7 @@ #include #include +#include using namespace Aws::S3Crt::Model; using namespace Aws::Utils::Xml; @@ -130,12 +131,13 @@ Aws::Http::HeaderValueCollection ListObjectsV2Request::GetRequestSpecificHeaders if(m_optionalObjectAttributesHasBeenSet) { - for(const auto& item : m_optionalObjectAttributes) - { - ss << OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item); - headers.emplace("x-amz-optional-object-attributes", ss.str()); - ss.str(""); - } + headers.emplace("x-amz-optional-object-attributes", std::accumulate(std::begin(m_optionalObjectAttributes), + std::end(m_optionalObjectAttributes), + Aws::String{}, + [](const Aws::String &acc, const OptionalObjectAttributes &item) -> Aws::String { + const auto headerValue = OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item); + return acc.empty() ? headerValue : acc + "," + headerValue; + })); } return headers; diff --git a/generated/src/aws-cpp-sdk-s3/source/model/GetObjectAttributesRequest.cpp b/generated/src/aws-cpp-sdk-s3/source/model/GetObjectAttributesRequest.cpp index 919060c379d..0a53d0ff655 100644 --- a/generated/src/aws-cpp-sdk-s3/source/model/GetObjectAttributesRequest.cpp +++ b/generated/src/aws-cpp-sdk-s3/source/model/GetObjectAttributesRequest.cpp @@ -10,6 +10,7 @@ #include #include +#include using namespace Aws::S3::Model; using namespace Aws::Utils::Xml; @@ -122,12 +123,13 @@ Aws::Http::HeaderValueCollection GetObjectAttributesRequest::GetRequestSpecificH if(m_objectAttributesHasBeenSet) { - for(const auto& item : m_objectAttributes) - { - ss << ObjectAttributesMapper::GetNameForObjectAttributes(item); - headers.emplace("x-amz-object-attributes", ss.str()); - ss.str(""); - } + headers.emplace("x-amz-object-attributes", std::accumulate(std::begin(m_objectAttributes), + std::end(m_objectAttributes), + Aws::String{}, + [](const Aws::String &acc, const ObjectAttributes &item) -> Aws::String { + const auto headerValue = ObjectAttributesMapper::GetNameForObjectAttributes(item); + return acc.empty() ? headerValue : acc + "," + headerValue; + })); } return headers; diff --git a/generated/src/aws-cpp-sdk-s3/source/model/ListObjectVersionsRequest.cpp b/generated/src/aws-cpp-sdk-s3/source/model/ListObjectVersionsRequest.cpp index f84033583f2..2c05e0222ae 100644 --- a/generated/src/aws-cpp-sdk-s3/source/model/ListObjectVersionsRequest.cpp +++ b/generated/src/aws-cpp-sdk-s3/source/model/ListObjectVersionsRequest.cpp @@ -10,6 +10,7 @@ #include #include +#include using namespace Aws::S3::Model; using namespace Aws::Utils::Xml; @@ -121,12 +122,13 @@ Aws::Http::HeaderValueCollection ListObjectVersionsRequest::GetRequestSpecificHe if(m_optionalObjectAttributesHasBeenSet) { - for(const auto& item : m_optionalObjectAttributes) - { - ss << OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item); - headers.emplace("x-amz-optional-object-attributes", ss.str()); - ss.str(""); - } + headers.emplace("x-amz-optional-object-attributes", std::accumulate(std::begin(m_optionalObjectAttributes), + std::end(m_optionalObjectAttributes), + Aws::String{}, + [](const Aws::String &acc, const OptionalObjectAttributes &item) -> Aws::String { + const auto headerValue = OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item); + return acc.empty() ? headerValue : acc + "," + headerValue; + })); } return headers; diff --git a/generated/src/aws-cpp-sdk-s3/source/model/ListObjectsRequest.cpp b/generated/src/aws-cpp-sdk-s3/source/model/ListObjectsRequest.cpp index 9da68dbabc7..73597ba1ed4 100644 --- a/generated/src/aws-cpp-sdk-s3/source/model/ListObjectsRequest.cpp +++ b/generated/src/aws-cpp-sdk-s3/source/model/ListObjectsRequest.cpp @@ -10,6 +10,7 @@ #include #include +#include using namespace Aws::S3::Model; using namespace Aws::Utils::Xml; @@ -113,12 +114,13 @@ Aws::Http::HeaderValueCollection ListObjectsRequest::GetRequestSpecificHeaders() if(m_optionalObjectAttributesHasBeenSet) { - for(const auto& item : m_optionalObjectAttributes) - { - ss << OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item); - headers.emplace("x-amz-optional-object-attributes", ss.str()); - ss.str(""); - } + headers.emplace("x-amz-optional-object-attributes", std::accumulate(std::begin(m_optionalObjectAttributes), + std::end(m_optionalObjectAttributes), + Aws::String{}, + [](const Aws::String &acc, const OptionalObjectAttributes &item) -> Aws::String { + const auto headerValue = OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item); + return acc.empty() ? headerValue : acc + "," + headerValue; + })); } return headers; diff --git a/generated/src/aws-cpp-sdk-s3/source/model/ListObjectsV2Request.cpp b/generated/src/aws-cpp-sdk-s3/source/model/ListObjectsV2Request.cpp index 59af1632e62..7765ee72b13 100644 --- a/generated/src/aws-cpp-sdk-s3/source/model/ListObjectsV2Request.cpp +++ b/generated/src/aws-cpp-sdk-s3/source/model/ListObjectsV2Request.cpp @@ -10,6 +10,7 @@ #include #include +#include using namespace Aws::S3::Model; using namespace Aws::Utils::Xml; @@ -130,12 +131,13 @@ Aws::Http::HeaderValueCollection ListObjectsV2Request::GetRequestSpecificHeaders if(m_optionalObjectAttributesHasBeenSet) { - for(const auto& item : m_optionalObjectAttributes) - { - ss << OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item); - headers.emplace("x-amz-optional-object-attributes", ss.str()); - ss.str(""); - } + headers.emplace("x-amz-optional-object-attributes", std::accumulate(std::begin(m_optionalObjectAttributes), + std::end(m_optionalObjectAttributes), + Aws::String{}, + [](const Aws::String &acc, const OptionalObjectAttributes &item) -> Aws::String { + const auto headerValue = OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item); + return acc.empty() ? headerValue : acc + "," + headerValue; + })); } return headers; diff --git a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/cpp/CppViewHelper.java b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/cpp/CppViewHelper.java index 391b81c3e4c..6782607c6f3 100644 --- a/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/cpp/CppViewHelper.java +++ b/tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/cpp/CppViewHelper.java @@ -481,4 +481,9 @@ public static String checkForCollision( .map(__ -> prefix + cppType) .orElse(functionName); } + + public static boolean hasListMemberUsedForHeader(final Shape shape) { + return shape.getMembers().values().stream() + .anyMatch(shapeMember -> shapeMember.getShape().isList() && shapeMember.isUsedForHeader()); + } } diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ModelClassHeaderMembersSource.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ModelClassHeaderMembersSource.vm index f3090c96e2a..96a890434b3 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ModelClassHeaderMembersSource.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ModelClassHeaderMembersSource.vm @@ -38,16 +38,17 @@ ${spaces} ss.str(""); ${spaces}} #elseif($member.shape.list) - ${spaces}for(const auto& item : $memberVarName) - ${spaces}{ + ${spaces}headers.emplace("${locationName}", std::accumulate(std::begin($memberVarName), + ${spaces} std::end($memberVarName), + ${spaces} Aws::String{}, + ${spaces} [](const Aws::String &acc, const ${member.shape.listMember.shape.name} &item) -> Aws::String { #if($member.shape.listMember.shape.enum) - ${spaces} ss << ${member.shape.listMember.shape.name}Mapper::GetNameFor${member.shape.listMember.shape.name}(item); + ${spaces} const auto headerValue = ${member.shape.listMember.shape.name}Mapper::GetNameFor${member.shape.listMember.shape.name}(item); #else - ${spaces} ss << item; + ${spaces} const auto headerValue = item; #end - ${spaces} headers.emplace("${locationName}", ss.str()); - ${spaces} ss.str(""); - ${spaces}} + ${spaces} return acc.empty() ? headerValue : acc + "," + headerValue; + ${spaces} })); #else ${spaces}ss << m_${lowerCaseVarName}; ${spaces}headers.emplace("${locationName}", #if($member.requiresHeaderEncoding())URI::URLEncodePath(ss.str())#else ss.str()#end); diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/StreamRequestSource.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/StreamRequestSource.vm index 74df4ccabd6..03bbca7a8e4 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/StreamRequestSource.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/StreamRequestSource.vm @@ -13,6 +13,9 @@ #end \#include +#if(${CppViewHelper.hasListMemberUsedForHeader($shape)}) +\#include +#end using namespace ${rootNamespace}::${serviceNamespace}::Model; using namespace Aws::Utils::Stream; diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/JsonRequestSource.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/JsonRequestSource.vm index 5d3b964cadc..fa1a73bdc10 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/JsonRequestSource.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/JsonRequestSource.vm @@ -16,6 +16,9 @@ #end \#include +#if(${CppViewHelper.hasListMemberUsedForHeader($shape)}) +\#include +#end using namespace ${rootNamespace}::${serviceNamespace}::Model; using namespace Aws::Utils::Json; diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/s3/PutBucketNotificationConfigurationRequest.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/s3/PutBucketNotificationConfigurationRequest.vm index 1e4673e7c07..b5738d8c484 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/s3/PutBucketNotificationConfigurationRequest.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/s3/PutBucketNotificationConfigurationRequest.vm @@ -14,6 +14,9 @@ #end \#include +#if(${CppViewHelper.hasListMemberUsedForHeader($shape)}) +\#include +#end using namespace ${rootNamespace}::${serviceNamespace}::Model; using namespace Aws::Utils::Xml; diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/xml/XmlRequestSource.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/xml/XmlRequestSource.vm index 6cf1fac118c..618ef47133b 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/xml/XmlRequestSource.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/xml/XmlRequestSource.vm @@ -19,6 +19,9 @@ #end \#include +#if(${CppViewHelper.hasListMemberUsedForHeader($shape)}) +\#include +#end using namespace ${rootNamespace}::${serviceNamespace}::Model; using namespace Aws::Utils::Xml;