diff --git a/.changelog/removessptranscribestreaming.md b/.changelog/removessptranscribestreaming.md new file mode 100644 index 0000000000..2666b41fe1 --- /dev/null +++ b/.changelog/removessptranscribestreaming.md @@ -0,0 +1,12 @@ +--- +applies_to: + - aws-sdk-rust +authors: + - landonxjames +references: ["aws-sdk-rust#1181"] +breaking: false +new_feature: false +bug_fix: true +--- + +Remove stalled stream protection from transcribe-streaming operations. diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCodegenDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCodegenDecorator.kt index d665c5404b..f27ca2c45b 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCodegenDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsCodegenDecorator.kt @@ -28,6 +28,7 @@ import software.amazon.smithy.rustsdk.customize.s3control.S3ControlDecorator import software.amazon.smithy.rustsdk.customize.sso.SSODecorator import software.amazon.smithy.rustsdk.customize.sts.STSDecorator import software.amazon.smithy.rustsdk.customize.timestream.TimestreamDecorator +import software.amazon.smithy.rustsdk.customize.transcribestreaming.TranscribeStreamingDecorator import software.amazon.smithy.rustsdk.endpoints.AwsEndpointsStdLib import software.amazon.smithy.rustsdk.endpoints.OperationInputTestDecorator import software.amazon.smithy.rustsdk.endpoints.RequireEndpointRules @@ -88,6 +89,7 @@ val DECORATORS: List = SSODecorator().onlyApplyTo("com.amazonaws.sso#SWBPortalService"), TimestreamDecorator().onlyApplyTo("com.amazonaws.timestreamwrite#Timestream_20181101"), TimestreamDecorator().onlyApplyTo("com.amazonaws.timestreamquery#Timestream_20181101"), + TranscribeStreamingDecorator().onlyApplyTo("com.amazonaws.transcribestreaming#Transcribe"), // Only build docs-rs for linux to reduce load on docs.rs listOf( DocsRsMetadataDecorator( diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/transcribestreaming/TranscribeStreamingDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/transcribestreaming/TranscribeStreamingDecorator.kt new file mode 100644 index 0000000000..2f301e15ce --- /dev/null +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/transcribestreaming/TranscribeStreamingDecorator.kt @@ -0,0 +1,45 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.rustsdk.customize.transcribestreaming + +import software.amazon.smithy.model.Model +import software.amazon.smithy.model.shapes.OperationShape +import software.amazon.smithy.model.shapes.ServiceShape +import software.amazon.smithy.model.shapes.ShapeId +import software.amazon.smithy.model.transform.ModelTransformer +import software.amazon.smithy.rust.codegen.client.smithy.ClientRustSettings +import software.amazon.smithy.rust.codegen.client.smithy.customize.ClientCodegenDecorator +import software.amazon.smithy.rust.codegen.client.smithy.traits.IncompatibleWithStalledStreamProtectionTrait +import software.amazon.smithy.rust.codegen.core.util.letIf +import java.util.logging.Logger + +/** + * Top level decorator for TranscribeStreaming + */ +class TranscribeStreamingDecorator : ClientCodegenDecorator { + private val operationsIncompatibleWithStalledStreamProtection = + setOf( + ShapeId.from("com.amazonaws.transcribestreaming#StartCallAnalyticsStreamTranscription"), + ShapeId.from("com.amazonaws.transcribestreaming#StartMedicalStreamTranscription"), + ShapeId.from("com.amazonaws.transcribestreaming#StartStreamTranscription"), + ) + + override val name: String = "TranscribeStreamingDecorator" + override val order: Byte = 0 + private val logger = Logger.getLogger(javaClass.name) + + override fun transformModel( + service: ServiceShape, + model: Model, + settings: ClientRustSettings, + ): Model = + ModelTransformer.create().mapShapes(model) { shape -> + shape.letIf(shape.id in operationsIncompatibleWithStalledStreamProtection) { + logger.info("Adding IncompatibleWithStalledStreamProtection trait to $it") + (it as OperationShape).toBuilder().addTrait(IncompatibleWithStalledStreamProtectionTrait()).build() + } + } +}