From 0b41278e035da33de7578f93d27bdb90e383ac8c Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Fri, 2 Aug 2024 00:21:41 +0000 Subject: [PATCH 1/2] fix(codegen): add TranscribeStreaming plugin only for operations with event stream --- .../codegen/AddTranscribeStreamingDependency.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java index f427d183de36..1c6a3fd819ac 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java @@ -22,6 +22,8 @@ import software.amazon.smithy.aws.traits.ServiceTrait; import software.amazon.smithy.codegen.core.SymbolProvider; import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.knowledge.EventStreamIndex; +import software.amazon.smithy.model.shapes.OperationShape; import software.amazon.smithy.model.shapes.ServiceShape; import software.amazon.smithy.typescript.codegen.LanguageTarget; import software.amazon.smithy.typescript.codegen.TypeScriptSettings; @@ -54,7 +56,7 @@ public List getClientPlugins() { RuntimeClientPlugin.builder() .withConventions(AwsDependency.TRANSCRIBE_STREAMING_MIDDLEWARE.dependency, "TranscribeStreaming", RuntimeClientPlugin.Convention.HAS_MIDDLEWARE) - .servicePredicate((m, s) -> isTranscribeStreaming(s)) + .operationPredicate((m, s, o) -> isTranscribeStreaming(s) && hasEventStreamInput(m, s, o)) .build() ); } @@ -92,6 +94,11 @@ private static boolean isTranscribeStreaming(ServiceShape service) { String serviceId = service.getTrait(ServiceTrait.class).map(ServiceTrait::getSdkId).orElse(""); return serviceId.equals("Transcribe Streaming"); } + + private static boolean hasEventStreamInput(Model model, ServiceShape service, OperationShape operation) { + EventStreamIndex eventStreamIndex = EventStreamIndex.of(model); + return eventStreamIndex.getInputInfo(operation).isPresent(); + } } From a260ece09bec7f898166567cdadd26fcde96186c Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Fri, 2 Aug 2024 00:26:40 +0000 Subject: [PATCH 2/2] fix(client-transcribe-streaming): add plugin only for operations with streaming trait --- .../src/TranscribeStreamingClient.ts | 2 -- .../commands/StartCallAnalyticsStreamTranscriptionCommand.ts | 2 ++ .../src/commands/StartMedicalStreamTranscriptionCommand.ts | 2 ++ .../src/commands/StartStreamTranscriptionCommand.ts | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/clients/client-transcribe-streaming/src/TranscribeStreamingClient.ts b/clients/client-transcribe-streaming/src/TranscribeStreamingClient.ts index 56755f50a477..f72b683dafa9 100644 --- a/clients/client-transcribe-streaming/src/TranscribeStreamingClient.ts +++ b/clients/client-transcribe-streaming/src/TranscribeStreamingClient.ts @@ -12,7 +12,6 @@ import { } from "@aws-sdk/middleware-host-header"; import { getLoggerPlugin } from "@aws-sdk/middleware-logger"; import { getRecursionDetectionPlugin } from "@aws-sdk/middleware-recursion-detection"; -import { getTranscribeStreamingPlugin } from "@aws-sdk/middleware-sdk-transcribe-streaming"; import { getUserAgentPlugin, resolveUserAgentConfig, @@ -361,7 +360,6 @@ export class TranscribeStreamingClient extends __Client< }), }) ); - this.middlewareStack.use(getTranscribeStreamingPlugin(this.config)); this.middlewareStack.use(getHttpSigningPlugin(this.config)); } diff --git a/clients/client-transcribe-streaming/src/commands/StartCallAnalyticsStreamTranscriptionCommand.ts b/clients/client-transcribe-streaming/src/commands/StartCallAnalyticsStreamTranscriptionCommand.ts index c86000954e9a..bde4511fd55f 100644 --- a/clients/client-transcribe-streaming/src/commands/StartCallAnalyticsStreamTranscriptionCommand.ts +++ b/clients/client-transcribe-streaming/src/commands/StartCallAnalyticsStreamTranscriptionCommand.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { getEventStreamPlugin } from "@aws-sdk/middleware-eventstream"; +import { getTranscribeStreamingPlugin } from "@aws-sdk/middleware-sdk-transcribe-streaming"; import { getWebSocketPlugin } from "@aws-sdk/middleware-websocket"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { getSerdePlugin } from "@smithy/middleware-serde"; @@ -248,6 +249,7 @@ export class StartCallAnalyticsStreamTranscriptionCommand extends $Command getWebSocketPlugin(config, { headerPrefix: "x-amzn-transcribe-", }), + getTranscribeStreamingPlugin(config), ]; }) .s("Transcribe", "StartCallAnalyticsStreamTranscription", { diff --git a/clients/client-transcribe-streaming/src/commands/StartMedicalStreamTranscriptionCommand.ts b/clients/client-transcribe-streaming/src/commands/StartMedicalStreamTranscriptionCommand.ts index 141cad5dc81a..b55896d637fa 100644 --- a/clients/client-transcribe-streaming/src/commands/StartMedicalStreamTranscriptionCommand.ts +++ b/clients/client-transcribe-streaming/src/commands/StartMedicalStreamTranscriptionCommand.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { getEventStreamPlugin } from "@aws-sdk/middleware-eventstream"; +import { getTranscribeStreamingPlugin } from "@aws-sdk/middleware-sdk-transcribe-streaming"; import { getWebSocketPlugin } from "@aws-sdk/middleware-websocket"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { getSerdePlugin } from "@smithy/middleware-serde"; @@ -229,6 +230,7 @@ export class StartMedicalStreamTranscriptionCommand extends $Command getWebSocketPlugin(config, { headerPrefix: "x-amzn-transcribe-", }), + getTranscribeStreamingPlugin(config), ]; }) .s("Transcribe", "StartMedicalStreamTranscription", { diff --git a/clients/client-transcribe-streaming/src/commands/StartStreamTranscriptionCommand.ts b/clients/client-transcribe-streaming/src/commands/StartStreamTranscriptionCommand.ts index e04efbdafb6f..3f2185eb96ae 100644 --- a/clients/client-transcribe-streaming/src/commands/StartStreamTranscriptionCommand.ts +++ b/clients/client-transcribe-streaming/src/commands/StartStreamTranscriptionCommand.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { getEventStreamPlugin } from "@aws-sdk/middleware-eventstream"; +import { getTranscribeStreamingPlugin } from "@aws-sdk/middleware-sdk-transcribe-streaming"; import { getWebSocketPlugin } from "@aws-sdk/middleware-websocket"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { getSerdePlugin } from "@smithy/middleware-serde"; @@ -253,6 +254,7 @@ export class StartStreamTranscriptionCommand extends $Command getWebSocketPlugin(config, { headerPrefix: "x-amzn-transcribe-", }), + getTranscribeStreamingPlugin(config), ]; }) .s("Transcribe", "StartStreamTranscription", {