Skip to content

Commit 7444468

Browse files
aws-sdk-cpp-automationkai-ion
authored andcommitted
init
1 parent 0ce806f commit 7444468

File tree

8 files changed

+75
-4
lines changed

8 files changed

+75
-4
lines changed

generated/src/aws-cpp-sdk-test-new-service-sdk-testing/include/aws/test-new-service-sdk-testing/model/PublishEvents.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
#pragma once
77
#include <aws/core/utils/event/EventStream.h>
8+
#include <aws/core/utils/event/EventStreamHandler.h>
89
#include <aws/test-new-service-sdk-testing/TestNewServiceSDKTesting_EXPORTS.h>
910
#include <aws/test-new-service-sdk-testing/model/LeaveEvent.h>
1011
#include <aws/test-new-service-sdk-testing/model/Message.h>
1112

13+
#include <functional>
1214
#include <utility>
1315

1416
namespace Aws {
@@ -34,6 +36,17 @@ class AWS_TESTNEWSERVICESDKTESTING_API PublishEvents : public Aws::Utils::Event:
3436
WriteEvent(msg);
3537
return *this;
3638
}
39+
40+
std::function<void(const Aws::Utils::Event::Message&, const Aws::Utils::Event::InitialResponseType&)>& GetInitialResponseCallbackEx() {
41+
return m_initialResponseCallback;
42+
}
43+
void SetInitialResponseCallbackEx(
44+
std::function<void(const Aws::Utils::Event::Message&, const Aws::Utils::Event::InitialResponseType&)> callback) {
45+
m_initialResponseCallback = std::move(callback);
46+
}
47+
48+
private:
49+
std::function<void(const Aws::Utils::Event::Message&, const Aws::Utils::Event::InitialResponseType&)> m_initialResponseCallback;
3750
};
3851

3952
} // namespace Model

generated/src/aws-cpp-sdk-test-new-service-sdk-testing/include/aws/test-new-service-sdk-testing/model/PublishFoosRequest.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#pragma once
7+
#include <aws/core/utils/event/EventStreamDecoder.h>
78
#include <aws/core/utils/memory/stl/AWSString.h>
89
#include <aws/test-new-service-sdk-testing/TestNewServiceSDKTestingRequest.h>
910
#include <aws/test-new-service-sdk-testing/TestNewServiceSDKTesting_EXPORTS.h>
@@ -20,7 +21,7 @@ namespace Model {
2021
*/
2122
class PublishFoosRequest : public TestNewServiceSDKTestingRequest {
2223
public:
23-
AWS_TESTNEWSERVICESDKTESTING_API PublishFoosRequest() = default;
24+
AWS_TESTNEWSERVICESDKTESTING_API PublishFoosRequest() : m_eventStreamDecoder(nullptr) {}
2425

2526
// Service request name is the Operation name which will send this request out,
2627
// each operation should has unique request name, so that we can get operation's name from this request.
@@ -35,6 +36,17 @@ class PublishFoosRequest : public TestNewServiceSDKTestingRequest {
3536
AWS_TESTNEWSERVICESDKTESTING_API std::shared_ptr<Aws::IOStream> GetBody() const override;
3637
AWS_TESTNEWSERVICESDKTESTING_API Aws::Http::HeaderValueCollection GetRequestSpecificHeaders() const override;
3738

39+
/**
40+
* Underlying Event Stream Handler which is used to define the handlers to process the underlying event-stream
41+
*/
42+
inline std::shared_ptr<PublishEvents> GetEventStreamHandler() const { return m_messages; }
43+
inline void SetEventStreamHandler(std::shared_ptr<PublishEvents> value) { m_messages = std::move(value); }
44+
45+
/**
46+
* Event Stream Decoder for processing incoming event stream messages
47+
*/
48+
inline Aws::Utils::Event::EventStreamDecoder& GetEventStreamDecoder() const { return m_eventStreamDecoder; }
49+
3850
///@{
3951

4052
inline const Aws::String& GetRoom() const { return m_room; }
@@ -68,6 +80,8 @@ class PublishFoosRequest : public TestNewServiceSDKTestingRequest {
6880
Aws::String m_room;
6981

7082
std::shared_ptr<PublishEvents> m_messages;
83+
mutable Aws::Utils::Event::EventStreamDecoder m_eventStreamDecoder{nullptr};
84+
7185
bool m_roomHasBeenSet = false;
7286
bool m_messagesHasBeenSet = false;
7387
};

generated/src/aws-cpp-sdk-test-new-service-sdk-testing/source/TestNewServiceSDKTestingClient.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <aws/core/auth/AWSAuthSigner.h>
77
#include <aws/core/auth/AWSCredentialsProviderChain.h>
8+
#include <aws/core/client/AWSClientEventStreamingAsyncTask.h>
89
#include <aws/core/client/CoreErrors.h>
910
#include <aws/core/client/RetryStrategy.h>
1011
#include <aws/core/http/HttpClient.h>

src/aws-cpp-sdk-core/include/aws/core/client/AWSClientEventStreamingAsyncTask.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@ class AWS_CORE_LOCAL BidirectionalEventStreamingTask final {
6161
AWS_CHECK_PTR(ClientT::GetAllocationTag(), request);
6262
AWS_CHECK_PTR(ClientT::GetAllocationTag(), response);
6363

64-
auto& initialResponseHandler = request->GetEventStreamHandler().GetInitialResponseCallbackEx();
64+
auto& initialResponseHandler = request->GetEventStreamHandler()->GetInitialResponseCallbackEx();
6565
if (initialResponseHandler) {
66-
initialResponseHandler({response->GetHeaders()}, Utils::Event::InitialResponseType::ON_RESPONSE);
66+
Utils::Event::Message msg;
67+
for (const auto& header : response->GetHeaders()) {
68+
msg.InsertEventHeader(header.first, header.second);
69+
}
70+
initialResponseHandler(msg, Utils::Event::InitialResponseType::ON_RESPONSE);
6771
}
6872
});
6973
}

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ModelClassMembersAndInlines.vm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@
153153
${operation.name}Handler m_handler;
154154
Aws::Utils::Event::EventStreamDecoder m_decoder{Utils::Event::EventStreamDecoder(&m_handler)};
155155

156+
#end
157+
#if($operation.request.shape.hasEventStreamMembers())
158+
mutable Aws::Utils::Event::EventStreamDecoder m_eventStreamDecoder{nullptr};
159+
156160
#end
157161
#end##if($shape.members.size() > 0)
158162
#foreach($member in $shape.members.entrySet())

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/RequestHeader.vm

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#end
1414
#if($operation.request.shape.hasEventStreamMembers())
1515
\#include <memory>
16+
\#include <aws/core/utils/event/EventStreamDecoder.h>
1617
#end
1718
#foreach($header in $typeInfo.headerIncludes)
1819
\#include $header
@@ -46,7 +47,11 @@ namespace Model
4647
class ${typeInfo.className} : public ${typeInfo.baseClass}
4748
{
4849
public:
50+
#if($operation.request.shape.hasEventStreamMembers())
51+
${exportMacro} ${typeInfo.className}() : m_eventStreamDecoder(nullptr) {}
52+
#else
4953
${exportMacro} ${typeInfo.className}() = default;
54+
#end
5055

5156
// Service request name is the Operation name which will send this request out,
5257
// each operation should has unique request name, so that we can get operation's name from this request.
@@ -140,6 +145,29 @@ namespace Model
140145
*/
141146
inline ${operation.request.shape.name}& WithEventStreamHandler(const ${operation.name}Handler& value) { SetEventStreamHandler(value); return *this; }
142147

148+
#end
149+
#if($operation.request.shape.hasEventStreamMembers())
150+
#set($streamMemberName = "")
151+
#set($streamMemberType = "")
152+
#foreach($memberEntry in $operation.request.shape.members.entrySet())
153+
#if($memberEntry.value.shape.isEventStream())
154+
#set($streamMemberName = $memberEntry.key)
155+
#set($streamMemberType = $memberEntry.value.shape.name)
156+
#break
157+
#end
158+
#end
159+
#set($streamMemberNameCap = $CppViewHelper.capitalizeFirstChar($streamMemberName))
160+
/**
161+
* Underlying Event Stream Handler which is used to define the handlers to process the underlying event-stream
162+
*/
163+
inline std::shared_ptr<${streamMemberType}> GetEventStreamHandler() const { return m_${streamMemberName}; }
164+
inline void SetEventStreamHandler(std::shared_ptr<${streamMemberType}> value) { m_${streamMemberName} = std::move(value); }
165+
166+
/**
167+
* Event Stream Decoder for processing incoming event stream messages
168+
*/
169+
inline Aws::Utils::Event::EventStreamDecoder& GetEventStreamDecoder() const { return m_eventStreamDecoder; }
170+
143171
#end
144172
#if($operation.requestCompressionRequired)
145173
#if($operation.requestCompressionRequiredGzip)

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceClientSourceHeaders.vm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
#set($hasEventStreamRequest = true)
99
#end
1010
#end
11-
#if($hasEventStreamResult)
1211
#if($hasEventStreamRequest)
1312
\#include <aws/core/client/AWSClientEventStreamingAsyncTask.h>
1413
#end
14+
#if($hasEventStreamResult)
1515
\#include <aws/core/utils/event/EventStream.h>
1616
#end
1717
#if($arnEndpointSupported || $metadata.hasEndpointDiscoveryTrait)

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/EventStreamHeader.vm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
\#include $header
1010
#end
1111
\#include <aws/core/utils/event/EventStream.h>
12+
\#include <aws/core/utils/event/EventStreamHandler.h>
13+
\#include <functional>
1214
#foreach($entry in $shape.members.entrySet())
1315
#if($entry.value.shape.isEvent())
1416
#foreach($eventMemberEntry in $entry.value.shape.members.entrySet())
@@ -75,6 +77,11 @@ namespace Model
7577
#end
7678
#end
7779

80+
std::function<void(const Aws::Utils::Event::Message&, const Aws::Utils::Event::InitialResponseType&)>& GetInitialResponseCallbackEx() { return m_initialResponseCallback; }
81+
void SetInitialResponseCallbackEx(std::function<void(const Aws::Utils::Event::Message&, const Aws::Utils::Event::InitialResponseType&)> callback) { m_initialResponseCallback = std::move(callback); }
82+
83+
private:
84+
std::function<void(const Aws::Utils::Event::Message&, const Aws::Utils::Event::InitialResponseType&)> m_initialResponseCallback;
7885
};
7986

8087
} // namespace Model

0 commit comments

Comments
 (0)