Unverified Commit 6b21e46e authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Orchestrator `ResponseDeserializer` codegen and auth (#2494)



* Convert interceptor fns to macro invocations

Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>

* Add unmodeled error to ServiceError and bring in EventLog

Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>

* Simplify and test `EventLog`

* Attempt to integrate the event log with the orchestrator

* fix: error type in integration test
update: retry handling in orchestrator

* update: set the runtime plugins to do nothing instead of panic when called on

* Introduce a construct for type erasure

* Eliminate several generics and add phased error handling

* Code generate the `ResponseDeserializer` trait impls

* CI fixes

* Reorganize the new runtime crates

* Create the `Identity` type

* Reorganize orchestrator traits and accessors

* Set up code generated test environment for the new runtime

* Add initial auth orchestration implementation

* Fix clippy lint

* Incorporate feedback

* Fix external types lint

---------

Co-authored-by: default avatarZelda Hessler <zhessler@amazon.com>
parent b65a645c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -58,6 +58,12 @@ impl<B> RequestId for http::Response<B> {
    }
}

impl RequestId for HeaderMap {
    fn request_id(&self) -> Option<&str> {
        extract_request_id(self)
    }
}

impl<O, E> RequestId for Result<O, E>
where
    O: RequestId,
+6 −0
Original line number Diff line number Diff line
@@ -59,6 +59,12 @@ impl<B> RequestIdExt for http::Response<B> {
    }
}

impl RequestIdExt for HeaderMap {
    fn extended_request_id(&self) -> Option<&str> {
        extract_extended_request_id(self)
    }
}

impl<O, E> RequestIdExt for Result<O, E>
where
    O: RequestIdExt,
+2 −2
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@
 * SPDX-License-Identifier: Apache-2.0
 */

extra["displayName"] = "Smithy :: Rust :: Codegen :: Test"
extra["moduleName"] = "software.amazon.smithy.kotlin.codegen.test"
extra["displayName"] = "Smithy :: Rust :: AWS-SDK :: Ad-hoc Test"
extra["moduleName"] = "software.amazon.smithy.rust.awssdk.adhoc.test"

tasks["jar"].enabled = false

+2 −2
Original line number Diff line number Diff line
@@ -83,13 +83,13 @@ abstract class BaseRequestIdDecorator : ClientCodegenDecorator {
            when (section) {
                is OperationSection.PopulateErrorMetadataExtras -> {
                    rustTemplate(
                        "${section.builderName} = #{apply_to_error}(${section.builderName}, ${section.responseName}.headers());",
                        "${section.builderName} = #{apply_to_error}(${section.builderName}, ${section.responseHeadersName});",
                        "apply_to_error" to applyToError(codegenContext),
                    )
                }
                is OperationSection.MutateOutput -> {
                    rust(
                        "output._set_$fieldName(#T::$accessorFunctionName(response).map(str::to_string));",
                        "output._set_$fieldName(#T::$accessorFunctionName(${section.responseHeadersName}).map(str::to_string));",
                        accessorTrait(codegenContext),
                    )
                }
+7 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import software.amazon.smithy.rust.codegen.core.smithy.generators.operationBuild
import software.amazon.smithy.rust.codegen.core.util.expectMember
import software.amazon.smithy.rust.codegen.core.util.getTrait
import software.amazon.smithy.rust.codegen.core.util.inputShape
import software.amazon.smithy.rust.codegen.core.util.letIf
import software.amazon.smithy.rust.codegen.core.util.orNull

fun RuntimeConfig.awsInlineableBodyWithChecksum() = RuntimeType.forInlineDependency(
@@ -41,12 +42,16 @@ class HttpRequestChecksumDecorator : ClientCodegenDecorator {
    override val name: String = "HttpRequestChecksum"
    override val order: Byte = 0

    // TODO(enableNewSmithyRuntime): Implement checksumming via interceptor and delete this decorator
    private fun applies(codegenContext: ClientCodegenContext): Boolean =
        !codegenContext.settings.codegenConfig.enableNewSmithyRuntime

    override fun operationCustomizations(
        codegenContext: ClientCodegenContext,
        operation: OperationShape,
        baseCustomizations: List<OperationCustomization>,
    ): List<OperationCustomization> {
        return baseCustomizations + HttpRequestChecksumCustomization(codegenContext, operation)
    ): List<OperationCustomization> = baseCustomizations.letIf(applies(codegenContext)) {
        it + HttpRequestChecksumCustomization(codegenContext, operation)
    }
}

Loading