Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <aws/bedrock-runtime/BedrockRuntime_EXPORTS.h>
#include <aws/bedrock-runtime/model/BidirectionalInputPayloadPart.h>
#include <aws/core/utils/event/EventStream.h>
#include <aws/core/utils/stream/HttpWriteDataStreamBuf.h>

#include <utility>

Expand All @@ -22,6 +23,9 @@ namespace Model {
*/
class AWS_BEDROCKRUNTIME_API InvokeModelWithBidirectionalStreamInput : public Aws::Utils::Event::EventEncoderStream {
public:
InvokeModelWithBidirectionalStreamInput() = default;
explicit InvokeModelWithBidirectionalStreamInput(std::shared_ptr<Aws::Utils::Stream::HttpWriteDataStreamBuf> streambuf)
: Aws::Utils::Event::EventEncoderStream(std::move(streambuf)) {}
InvokeModelWithBidirectionalStreamInput& WriteBidirectionalInputPayloadPart(const BidirectionalInputPayloadPart& value) {
Aws::Utils::Event::Message msg;
msg.InsertEventHeader(":message-type", Aws::String("event"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <aws/core/utils/logging/LogMacros.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/threading/Executor.h>
#include <smithy/client/SmithyBidirectionalStreamingWriteDataTask.h>
#include <smithy/client/SmithyEventStreamingAsyncTask.h>
#include <smithy/identity/resolver/built-in/AwsCredentialsProviderIdentityResolver.h>
#include <smithy/identity/resolver/built-in/DefaultAwsCredentialIdentityResolver.h>
Expand Down Expand Up @@ -387,6 +388,30 @@ void BedrockRuntimeClient::InvokeModelWithBidirectionalStreamAsync(
resolvedEndpoint.AddPathSegments("/invoke-with-bidirectional-stream");
};

#if AWS_SDK_USE_CRT_HTTP
// Push-based WriteData path (CRT HTTP client only)
auto writeDataStreamBuf = Aws::MakeShared<Aws::Utils::Stream::HttpWriteDataStreamBuf>(ALLOCATION_TAG, m_httpClient);
auto eventEncoderStream = Aws::MakeShared<Model::InvokeModelWithBidirectionalStreamInput>(ALLOCATION_TAG, writeDataStreamBuf);
request.SetBody(eventEncoderStream);

auto requestCopy = Aws::MakeShared<InvokeModelWithBidirectionalStreamRequest>(ALLOCATION_TAG, request);

auto authCallback = [&](std::shared_ptr<smithy::client::AwsSmithyClientAsyncRequestContext> ctx) -> void {
eventEncoderStream->SetSigningCallback([this, ctx, eventEncoderStream](Aws::Utils::Event::Message& message, Aws::String& seed) -> bool {
auto outcome = SignEventMessage(message, seed, ctx);
return outcome.IsSuccess();
});
};

auto asyncTask = smithy::client::CreateSmithyBidirectionalWriteDataTask<InvokeModelWithBidirectionalStreamOutcome>(
this, requestCopy, handler, handlerContext, eventEncoderStream, writeDataStreamBuf, std::move(endpointCallback),
std::move(authCallback));
auto sem = asyncTask.GetSemaphore();
m_clientConfiguration.executor->Submit(std::move(asyncTask));
sem->WaitOne();
streamReadyHandler(*eventEncoderStream);
#else
// Pull-based path
auto eventEncoderStream = Aws::MakeShared<Model::InvokeModelWithBidirectionalStreamInput>(ALLOCATION_TAG);
auto authCallback = [&](std::shared_ptr<smithy::client::AwsSmithyClientAsyncRequestContext> ctx) -> void {
eventEncoderStream->SetSigningCallback([this, ctx, eventEncoderStream](Aws::Utils::Event::Message& message, Aws::String& seed) -> bool {
Expand All @@ -395,15 +420,16 @@ void BedrockRuntimeClient::InvokeModelWithBidirectionalStreamAsync(
});
};
auto requestCopy = Aws::MakeShared<InvokeModelWithBidirectionalStreamRequest>("InvokeModelWithBidirectionalStream", request);
requestCopy->SetBody(eventEncoderStream); // this becomes the body of the request
request.SetBody(eventEncoderStream); // this becomes the body of the request
requestCopy->SetBody(eventEncoderStream);
request.SetBody(eventEncoderStream);

auto asyncTask = smithy::client::CreateSmithyBidirectionalEventStreamTask<InvokeModelWithBidirectionalStreamOutcome>(
this, requestCopy, handler, handlerContext, eventEncoderStream, endpointCallback, authCallback);
auto sem = asyncTask.GetSemaphore();
m_clientConfiguration.executor->Submit(std::move(asyncTask));
sem->WaitOne();
streamReadyHandler(*eventEncoderStream);
#endif
}
InvokeModelWithResponseStreamOutcome BedrockRuntimeClient::InvokeModelWithResponseStream(
InvokeModelWithResponseStreamRequest& request) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <aws/connecthealth/model/MedicalScribeConfigurationEvent.h>
#include <aws/connecthealth/model/MedicalScribeSessionControlEvent.h>
#include <aws/core/utils/event/EventStream.h>
#include <aws/core/utils/stream/HttpWriteDataStreamBuf.h>

#include <utility>

Expand All @@ -24,6 +25,9 @@ namespace Model {
*/
class AWS_CONNECTHEALTH_API MedicalScribeInputStream : public Aws::Utils::Event::EventEncoderStream {
public:
MedicalScribeInputStream() = default;
explicit MedicalScribeInputStream(std::shared_ptr<Aws::Utils::Stream::HttpWriteDataStreamBuf> streambuf)
: Aws::Utils::Event::EventEncoderStream(std::move(streambuf)) {}
MedicalScribeInputStream& WriteMedicalScribeAudioEvent(const MedicalScribeAudioEvent& value) {
Aws::Utils::Event::Message msg;
msg.InsertEventHeader(":message-type", Aws::String("event"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <aws/connecthealth/model/UntagResourceRequest.h>
#include <aws/core/auth/AWSAuthSigner.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/client/AWSClientBidirectionalStreaming.h>
#include <aws/core/client/AWSClientEventStreamingAsyncTask.h>
#include <aws/core/client/CoreErrors.h>
#include <aws/core/client/RetryStrategy.h>
Expand Down Expand Up @@ -517,10 +518,43 @@ void ConnectHealthClient::StartMedicalScribeListeningSessionAsync(
}
endpointResolutionOutcome.GetResult().AddPathSegments("/medical-scribe-stream/");

#if AWS_SDK_USE_CRT_HTTP
// Push-based WriteData path (CRT HTTP client only)
auto writeDataStreamBuf = Aws::MakeShared<Aws::Utils::Stream::HttpWriteDataStreamBuf>(ALLOCATION_TAG, GetHttpClient());
auto signer = GetSignerByName(Aws::Auth::EVENTSTREAM_SIGV4_SIGNER);

auto eventEncoderStream = Aws::MakeShared<Model::MedicalScribeInputStream>(ALLOCATION_TAG, writeDataStreamBuf);
eventEncoderStream->SetSigner(signer);

auto requestCopy = Aws::MakeShared<StartMedicalScribeListeningSessionRequest>(ALLOCATION_TAG, request);
request.SetInputStream(eventEncoderStream);

auto& endpoint = endpointResolutionOutcome.GetResult();
auto httpRequest =
CreateHttpRequest(endpoint.GetURI(), Aws::Http::HttpMethod::HTTP_POST, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
httpRequest->SetEventStreamRequest(true);
httpRequest->SetHasEventStreamResponse(true);
BuildHttpRequest(*requestCopy, httpRequest);

if (!signer->SignRequest(*httpRequest, nullptr, nullptr, true)) {
handler(this, request,
StartMedicalScribeListeningSessionOutcome(
Aws::Client::AWSError<CoreErrors>(CoreErrors::CLIENT_SIGNING_FAILURE, "", "Failed to sign request", false)),
handlerContext);
return;
}
eventEncoderStream->SetSignatureSeed(Aws::Client::GetAuthorizationHeader(*httpRequest));

Aws::Client::SubmitBidirectionalStreamingRequest<ConnectHealthClient, StartMedicalScribeListeningSessionOutcome,
StartMedicalScribeListeningSessionRequest, Model::MedicalScribeInputStream>(
this, request, requestCopy, eventEncoderStream, writeDataStreamBuf, httpRequest, m_clientConfiguration.executor.get(),
streamReadyHandler, handler, handlerContext);
#else
// Pull-based path (curl/WinHTTP)
auto eventEncoderStream = Aws::MakeShared<Model::MedicalScribeInputStream>(ALLOCATION_TAG);
eventEncoderStream->SetSigner(GetSignerByName(Aws::Auth::EVENTSTREAM_SIGV4_SIGNER));
auto requestCopy = Aws::MakeShared<StartMedicalScribeListeningSessionRequest>("StartMedicalScribeListeningSession", request);
requestCopy->SetInputStream(eventEncoderStream); // this becomes the body of the request
requestCopy->SetInputStream(eventEncoderStream);
request.SetInputStream(eventEncoderStream);

auto asyncTask = CreateBidirectionalEventStreamTask<StartMedicalScribeListeningSessionOutcome>(
Expand All @@ -529,6 +563,7 @@ void ConnectHealthClient::StartMedicalScribeListeningSessionAsync(
m_clientConfiguration.executor->Submit(std::move(asyncTask));
sem->WaitOne();
streamReadyHandler(*eventEncoderStream);
#endif
}
StartPatientInsightsJobOutcome ConnectHealthClient::StartPatientInsightsJob(const StartPatientInsightsJobRequest& request) const {
if (!request.DomainIdHasBeenSet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#pragma once
#include <aws/core/utils/event/EventStream.h>
#include <aws/core/utils/stream/HttpWriteDataStreamBuf.h>
#include <aws/lexv2-runtime/LexRuntimeV2_EXPORTS.h>
#include <aws/lexv2-runtime/model/AudioInputEvent.h>
#include <aws/lexv2-runtime/model/ConfigurationEvent.h>
Expand All @@ -27,6 +28,9 @@ namespace Model {
*/
class AWS_LEXRUNTIMEV2_API StartConversationRequestEventStream : public Aws::Utils::Event::EventEncoderStream {
public:
StartConversationRequestEventStream() = default;
explicit StartConversationRequestEventStream(std::shared_ptr<Aws::Utils::Stream::HttpWriteDataStreamBuf> streambuf)
: Aws::Utils::Event::EventEncoderStream(std::move(streambuf)) {}
StartConversationRequestEventStream& WriteConfigurationEvent(const ConfigurationEvent& value) {
Aws::Utils::Event::Message msg;
msg.InsertEventHeader(":message-type", Aws::String("event"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <aws/core/auth/AWSAuthSigner.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/client/AWSClientBidirectionalStreaming.h>
#include <aws/core/client/AWSClientEventStreamingAsyncTask.h>
#include <aws/core/client/CoreErrors.h>
#include <aws/core/client/RetryStrategy.h>
Expand Down Expand Up @@ -489,10 +490,43 @@ void LexRuntimeV2Client::StartConversationAsync(Model::StartConversationRequest&
endpointResolutionOutcome.GetResult().AddPathSegment(request.GetSessionId());
endpointResolutionOutcome.GetResult().AddPathSegments("/conversation");

#if AWS_SDK_USE_CRT_HTTP
// Push-based WriteData path (CRT HTTP client only)
auto writeDataStreamBuf = Aws::MakeShared<Aws::Utils::Stream::HttpWriteDataStreamBuf>(ALLOCATION_TAG, GetHttpClient());
auto signer = GetSignerByName(Aws::Auth::EVENTSTREAM_SIGV4_SIGNER);

auto eventEncoderStream = Aws::MakeShared<Model::StartConversationRequestEventStream>(ALLOCATION_TAG, writeDataStreamBuf);
eventEncoderStream->SetSigner(signer);

auto requestCopy = Aws::MakeShared<StartConversationRequest>(ALLOCATION_TAG, request);
request.SetRequestEventStream(eventEncoderStream);

auto& endpoint = endpointResolutionOutcome.GetResult();
auto httpRequest =
CreateHttpRequest(endpoint.GetURI(), Aws::Http::HttpMethod::HTTP_POST, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
httpRequest->SetEventStreamRequest(true);
httpRequest->SetHasEventStreamResponse(true);
BuildHttpRequest(*requestCopy, httpRequest);

if (!signer->SignRequest(*httpRequest, nullptr, nullptr, true)) {
handler(this, request,
StartConversationOutcome(
Aws::Client::AWSError<CoreErrors>(CoreErrors::CLIENT_SIGNING_FAILURE, "", "Failed to sign request", false)),
handlerContext);
return;
}
eventEncoderStream->SetSignatureSeed(Aws::Client::GetAuthorizationHeader(*httpRequest));

Aws::Client::SubmitBidirectionalStreamingRequest<LexRuntimeV2Client, StartConversationOutcome, StartConversationRequest,
Model::StartConversationRequestEventStream>(
this, request, requestCopy, eventEncoderStream, writeDataStreamBuf, httpRequest, m_clientConfiguration.executor.get(),
streamReadyHandler, handler, handlerContext);
#else
// Pull-based path (curl/WinHTTP)
auto eventEncoderStream = Aws::MakeShared<Model::StartConversationRequestEventStream>(ALLOCATION_TAG);
eventEncoderStream->SetSigner(GetSignerByName(Aws::Auth::EVENTSTREAM_SIGV4_SIGNER));
auto requestCopy = Aws::MakeShared<StartConversationRequest>("StartConversation", request);
requestCopy->SetRequestEventStream(eventEncoderStream); // this becomes the body of the request
requestCopy->SetRequestEventStream(eventEncoderStream);
request.SetRequestEventStream(eventEncoderStream);

auto asyncTask = CreateBidirectionalEventStreamTask<StartConversationOutcome>(this, endpointResolutionOutcome.GetResultWithOwnership(),
Expand All @@ -501,4 +535,5 @@ void LexRuntimeV2Client::StartConversationAsync(Model::StartConversationRequest&
m_clientConfiguration.executor->Submit(std::move(asyncTask));
sem->WaitOne();
streamReadyHandler(*eventEncoderStream);
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#pragma once
#include <aws/core/utils/event/EventStream.h>
#include <aws/core/utils/stream/HttpWriteDataStreamBuf.h>
#include <aws/polly/Polly_EXPORTS.h>
#include <aws/polly/model/CloseStreamEvent.h>
#include <aws/polly/model/TextEvent.h>
Expand All @@ -23,6 +24,9 @@ namespace Model {
*/
class AWS_POLLY_API StartSpeechSynthesisStreamActionStream : public Aws::Utils::Event::EventEncoderStream {
public:
StartSpeechSynthesisStreamActionStream() = default;
explicit StartSpeechSynthesisStreamActionStream(std::shared_ptr<Aws::Utils::Stream::HttpWriteDataStreamBuf> streambuf)
: Aws::Utils::Event::EventEncoderStream(std::move(streambuf)) {}
StartSpeechSynthesisStreamActionStream& WriteTextEvent(const TextEvent& value) {
Aws::Utils::Event::Message msg;
msg.InsertEventHeader(":message-type", Aws::String("event"));
Expand Down
37 changes: 36 additions & 1 deletion generated/src/aws-cpp-sdk-polly/source/PollyClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <aws/core/auth/AWSAuthSigner.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/client/AWSClientBidirectionalStreaming.h>
#include <aws/core/client/AWSClientEventStreamingAsyncTask.h>
#include <aws/core/client/CoreErrors.h>
#include <aws/core/client/RetryStrategy.h>
Expand Down Expand Up @@ -340,10 +341,43 @@ void PollyClient::StartSpeechSynthesisStreamAsync(Model::StartSpeechSynthesisStr
}
endpointResolutionOutcome.GetResult().AddPathSegments("/v1/synthesisStream");

#if AWS_SDK_USE_CRT_HTTP
// Push-based WriteData path (CRT HTTP client only)
auto writeDataStreamBuf = Aws::MakeShared<Aws::Utils::Stream::HttpWriteDataStreamBuf>(ALLOCATION_TAG, GetHttpClient());
auto signer = GetSignerByName(Aws::Auth::EVENTSTREAM_SIGV4_SIGNER);

auto eventEncoderStream = Aws::MakeShared<Model::StartSpeechSynthesisStreamActionStream>(ALLOCATION_TAG, writeDataStreamBuf);
eventEncoderStream->SetSigner(signer);

auto requestCopy = Aws::MakeShared<StartSpeechSynthesisStreamRequest>(ALLOCATION_TAG, request);
request.SetActionStream(eventEncoderStream);

auto& endpoint = endpointResolutionOutcome.GetResult();
auto httpRequest =
CreateHttpRequest(endpoint.GetURI(), Aws::Http::HttpMethod::HTTP_POST, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
httpRequest->SetEventStreamRequest(true);
httpRequest->SetHasEventStreamResponse(true);
BuildHttpRequest(*requestCopy, httpRequest);

if (!signer->SignRequest(*httpRequest, nullptr, nullptr, true)) {
handler(this, request,
StartSpeechSynthesisStreamOutcome(
Aws::Client::AWSError<CoreErrors>(CoreErrors::CLIENT_SIGNING_FAILURE, "", "Failed to sign request", false)),
handlerContext);
return;
}
eventEncoderStream->SetSignatureSeed(Aws::Client::GetAuthorizationHeader(*httpRequest));

Aws::Client::SubmitBidirectionalStreamingRequest<PollyClient, StartSpeechSynthesisStreamOutcome, StartSpeechSynthesisStreamRequest,
Model::StartSpeechSynthesisStreamActionStream>(
this, request, requestCopy, eventEncoderStream, writeDataStreamBuf, httpRequest, m_clientConfiguration.executor.get(),
streamReadyHandler, handler, handlerContext);
#else
// Pull-based path (curl/WinHTTP)
auto eventEncoderStream = Aws::MakeShared<Model::StartSpeechSynthesisStreamActionStream>(ALLOCATION_TAG);
eventEncoderStream->SetSigner(GetSignerByName(Aws::Auth::EVENTSTREAM_SIGV4_SIGNER));
auto requestCopy = Aws::MakeShared<StartSpeechSynthesisStreamRequest>("StartSpeechSynthesisStream", request);
requestCopy->SetActionStream(eventEncoderStream); // this becomes the body of the request
requestCopy->SetActionStream(eventEncoderStream);
request.SetActionStream(eventEncoderStream);

auto asyncTask = CreateBidirectionalEventStreamTask<StartSpeechSynthesisStreamOutcome>(
Expand All @@ -352,6 +386,7 @@ void PollyClient::StartSpeechSynthesisStreamAsync(Model::StartSpeechSynthesisStr
m_clientConfiguration.executor->Submit(std::move(asyncTask));
sem->WaitOne();
streamReadyHandler(*eventEncoderStream);
#endif
}
StartSpeechSynthesisTaskOutcome PollyClient::StartSpeechSynthesisTask(const StartSpeechSynthesisTaskRequest& request) const {
auto uriResolver = [&](Aws::Endpoint::ResolveEndpointOutcome& endpointResolutionOutcome) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma once
#include <aws/core/utils/event/EventStream.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/utils/stream/HttpWriteDataStreamBuf.h>
#include <aws/qbusiness/QBusiness_EXPORTS.h>
#include <aws/qbusiness/model/ActionExecutionEvent.h>
#include <aws/qbusiness/model/AttachmentInputEvent.h>
Expand All @@ -28,6 +29,9 @@ namespace Model {
*/
class AWS_QBUSINESS_API ChatInputStream : public Aws::Utils::Event::EventEncoderStream {
public:
ChatInputStream() = default;
explicit ChatInputStream(std::shared_ptr<Aws::Utils::Stream::HttpWriteDataStreamBuf> streambuf)
: Aws::Utils::Event::EventEncoderStream(std::move(streambuf)) {}
ChatInputStream& WriteConfigurationEvent(const ConfigurationEvent& value) {
Aws::Utils::Event::Message msg;
msg.InsertEventHeader(":message-type", Aws::String("event"));
Expand Down
Loading
Loading