Commit 1ca66ee2 authored by Zelda Hessler's avatar Zelda Hessler
Browse files

Merge branch 'main' into zhessler/request-compression

parents a8c500ba f0ddc666
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -36,6 +36,24 @@ references = ["aws-sdk-rust#1079"]
meta = { "breaking" = false, "bug" = true, "tada" = false }
author = "rcoh"

[[aws-sdk-rust]]
message = "Fixes stalled upload stream protection to not apply to empty request bodies and to stop checking for violations once the request body has been read."
references = ["aws-sdk-rust#1141", "aws-sdk-rust#1146", "aws-sdk-rust#1148"]
meta = { "breaking" = false, "tada" = false, "bug" = true }
authors = ["aajtodd", "Velfi"]

[[smithy-rs]]
message = "Fixes stalled upload stream protection to not apply to empty request bodies and to stop checking for violations once the request body has been read."
references = ["aws-sdk-rust#1141", "aws-sdk-rust#1146", "aws-sdk-rust#1148"]
meta = { "breaking" = false, "tada" = false, "bug" = true }
authors = ["aajtodd", "Velfi"]

[[aws-sdk-rust]]
message = "Updating the documentation for the `app_name` method on `ConfigLoader` to indicate the order of precedence for the sources of the `AppName`."
references = ["smithy-rs#3645"]
meta = { "breaking" = false, "bug" = false, "tada" = false }
author = "landonxjames"

[[smithy-rs]]
message = """
Compression is now supported for operations modeled with the `@requestCompression` trait.
+8 −1
Original line number Diff line number Diff line
@@ -535,9 +535,16 @@ mod loader {

        /// Override the name of the app used to build [`SdkConfig`].
        ///
        /// This _optional_ name is used to identify the application in the user agent that
        /// This _optional_ name is used to identify the application in the user agent header that
        /// gets sent along with requests.
        ///
        /// The app name is selected from an ordered list of sources:
        /// 1. This override.
        /// 2. The value of the `AWS_SDK_UA_APP_ID` environment variable.
        /// 3. Profile files from the key `sdk_ua_app_id`
        ///
        /// If none of those sources are set the value is `None` and it is not added to the user agent header.
        ///
        /// # Examples
        /// ```no_run
        /// # async fn create_config() {
+8 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.OperationCus
import software.amazon.smithy.rust.codegen.client.smithy.generators.OperationGenerator
import software.amazon.smithy.rust.codegen.client.smithy.generators.OperationSection
import software.amazon.smithy.rust.codegen.client.smithy.protocols.ClientRestXmlFactory
import software.amazon.smithy.rust.codegen.client.smithy.traits.IncompatibleWithStalledStreamProtectionTrait
import software.amazon.smithy.rust.codegen.core.rustlang.Writable
import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate
import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate
@@ -59,6 +60,10 @@ class S3Decorator : ClientCodegenDecorator {
            // API returns ListAllMyDirectoryBucketsResult instead of ListDirectoryBucketsOutput
            ShapeId.from("com.amazonaws.s3#ListDirectoryBucketsOutput"),
        )
    private val operationsIncompatibleWithStalledStreamProtection =
        setOf(
            ShapeId.from("com.amazonaws.s3#CopyObject"),
        )

    override fun protocols(
        serviceId: ShapeId,
@@ -81,6 +86,9 @@ class S3Decorator : ClientCodegenDecorator {
            shape.letIf(isInInvalidXmlRootAllowList(shape)) {
                logger.info("Adding AllowInvalidXmlRoot trait to $it")
                (it as StructureShape).toBuilder().addTrait(AllowInvalidXmlRoot()).build()
            }.letIf(operationsIncompatibleWithStalledStreamProtection.contains(shape.id)) {
                logger.info("Adding IncompatibleWithStalledStreamProtection trait to $it")
                (it as OperationShape).toBuilder().addTrait(IncompatibleWithStalledStreamProtectionTrait()).build()
            }
        }
            // the model has the bucket in the path
+8 −1
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.configReexport
import software.amazon.smithy.rust.codegen.client.smithy.customize.ClientCodegenDecorator
import software.amazon.smithy.rust.codegen.client.smithy.generators.OperationCustomization
import software.amazon.smithy.rust.codegen.client.smithy.generators.OperationSection
import software.amazon.smithy.rust.codegen.client.smithy.traits.IncompatibleWithStalledStreamProtectionTrait
import software.amazon.smithy.rust.codegen.core.rustlang.Writable
import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate
import software.amazon.smithy.rust.codegen.core.rustlang.writable
@@ -34,7 +35,7 @@ class StalledStreamProtectionDecorator : ClientCodegenDecorator {
        operation: OperationShape,
        baseCustomizations: List<OperationCustomization>,
    ): List<OperationCustomization> {
        return baseCustomizations + StalledStreamProtectionOperationCustomization(codegenContext)
        return baseCustomizations + StalledStreamProtectionOperationCustomization(codegenContext, operation)
    }
}

@@ -111,11 +112,17 @@ class StalledStreamProtectionConfigCustomization(codegenContext: ClientCodegenCo

class StalledStreamProtectionOperationCustomization(
    codegenContext: ClientCodegenContext,
    private val operationShape: OperationShape,
) : OperationCustomization() {
    private val rc = codegenContext.runtimeConfig

    override fun section(section: OperationSection): Writable =
        writable {
            // Don't add the stalled stream protection interceptor if the operation is incompatible with it
            if (operationShape.hasTrait(IncompatibleWithStalledStreamProtectionTrait.ID)) {
                return@writable
            }

            when (section) {
                is OperationSection.AdditionalInterceptors -> {
                    val stalledStreamProtectionModule = RuntimeType.smithyRuntime(rc).resolve("client::stalled_stream_protection")
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

package software.amazon.smithy.rust.codegen.client.smithy.traits

import software.amazon.smithy.model.node.Node
import software.amazon.smithy.model.shapes.ShapeId
import software.amazon.smithy.model.traits.AnnotationTrait

/**
 * Indicates that an operation shape is incompatible with stalled stream protection.
 */
class IncompatibleWithStalledStreamProtectionTrait : AnnotationTrait(ID, Node.objectNode()) {
    companion object {
        val ID: ShapeId = ShapeId.from("software.amazon.smithy.rust.codegen.client.smithy.traits#incompatibleWithStalledStreamProtectionTrait")
    }
}
Loading