Skip to content

Commit

Permalink
fix header argument for list arguemnts
Browse files Browse the repository at this point in the history
  • Loading branch information
sbiscigl committed Feb 21, 2024
1 parent 375778b commit 7342500
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <aws/core/utils/memory/stl/AWSStringStream.h>

#include <utility>
#include <numeric>

using namespace Aws::S3Crt::Model;
using namespace Aws::Utils::Xml;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <aws/core/utils/memory/stl/AWSStringStream.h>

#include <utility>
#include <numeric>

using namespace Aws::S3Crt::Model;
using namespace Aws::Utils::Xml;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <aws/core/utils/memory/stl/AWSStringStream.h>

#include <utility>
#include <numeric>

using namespace Aws::S3Crt::Model;
using namespace Aws::Utils::Xml;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <aws/core/utils/memory/stl/AWSStringStream.h>

#include <utility>
#include <numeric>

using namespace Aws::S3Crt::Model;
using namespace Aws::Utils::Xml;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <aws/core/utils/memory/stl/AWSStringStream.h>

#include <utility>
#include <numeric>

using namespace Aws::S3::Model;
using namespace Aws::Utils::Xml;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <aws/core/utils/memory/stl/AWSStringStream.h>

#include <utility>
#include <numeric>

using namespace Aws::S3::Model;
using namespace Aws::Utils::Xml;
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 8 additions & 6 deletions generated/src/aws-cpp-sdk-s3/source/model/ListObjectsRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <aws/core/utils/memory/stl/AWSStringStream.h>

#include <utility>
#include <numeric>

using namespace Aws::S3::Model;
using namespace Aws::Utils::Xml;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <aws/core/utils/memory/stl/AWSStringStream.h>

#include <utility>
#include <numeric>

using namespace Aws::S3::Model;
using namespace Aws::Utils::Xml;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#end

\#include <utility>
#if(${CppViewHelper.hasListMemberUsedForHeader($shape)})
\#include <numeric>
#end

using namespace ${rootNamespace}::${serviceNamespace}::Model;
using namespace Aws::Utils::Stream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#end

\#include <utility>
#if(${CppViewHelper.hasListMemberUsedForHeader($shape)})
\#include <numeric>
#end

using namespace ${rootNamespace}::${serviceNamespace}::Model;
using namespace Aws::Utils::Json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#end

\#include <utility>
#if(${CppViewHelper.hasListMemberUsedForHeader($shape)})
\#include <numeric>
#end

using namespace ${rootNamespace}::${serviceNamespace}::Model;
using namespace Aws::Utils::Xml;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#end

\#include <utility>
#if(${CppViewHelper.hasListMemberUsedForHeader($shape)})
\#include <numeric>
#end

using namespace ${rootNamespace}::${serviceNamespace}::Model;
using namespace Aws::Utils::Xml;
Expand Down

0 comments on commit 7342500

Please sign in to comment.