From 50ee25da569b4138fa88d17a21c4cfa1a2454d9d Mon Sep 17 00:00:00 2001 From: Matas Lauzadis Date: Thu, 8 Feb 2024 12:39:51 -0500 Subject: [PATCH] cleanup --- aws-runtime/aws-http/api/aws-http.api | 96 +++++++++---------- .../s3/ClientConfigIntegration.kt | 2 - .../SigV4S3ExpressAuthSchemeIntegration.kt | 19 +--- 3 files changed, 51 insertions(+), 66 deletions(-) diff --git a/aws-runtime/aws-http/api/aws-http.api b/aws-runtime/aws-http/api/aws-http.api index b716520c2a4..88a9dfd857f 100644 --- a/aws-runtime/aws-http/api/aws-http.api +++ b/aws-runtime/aws-http/api/aws-http.api @@ -103,6 +103,12 @@ public final class aws/sdk/kotlin/runtime/http/OsMetadata { public fun toString ()Ljava/lang/String; } +public final class aws/sdk/kotlin/runtime/http/S3ExpressHttpSigner : aws/smithy/kotlin/runtime/http/auth/HttpSigner { + public fun (Laws/smithy/kotlin/runtime/http/auth/AwsHttpSigner;)V + public final fun getAwsHttpSigner ()Laws/smithy/kotlin/runtime/http/auth/AwsHttpSigner; + public fun sign (Laws/smithy/kotlin/runtime/http/auth/SignHttpRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + public final class aws/sdk/kotlin/runtime/http/SdkMetadata { public fun (Ljava/lang/String;Ljava/lang/String;)V public final fun component1 ()Ljava/lang/String; @@ -162,8 +168,11 @@ public final class aws/sdk/kotlin/runtime/http/interceptors/AwsSpanInterceptor : public fun readBeforeTransmit (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V } -public final class aws/sdk/kotlin/runtime/http/interceptors/UnsupportedSigningAlgorithmInterceptor : aws/smithy/kotlin/runtime/client/Interceptor { +public final class aws/sdk/kotlin/runtime/http/interceptors/S3ExpressCrc32ChecksumInterceptor : aws/smithy/kotlin/runtime/client/Interceptor { public fun ()V + public fun (Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getChecksumAlgorithmHeaderName ()Ljava/lang/String; public fun modifyBeforeAttemptCompletion-gIAlu-s (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun modifyBeforeCompletion-gIAlu-s (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun modifyBeforeDeserialization (Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -185,53 +194,8 @@ public final class aws/sdk/kotlin/runtime/http/interceptors/UnsupportedSigningAl public fun readBeforeTransmit (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V } -public final class aws/sdk/kotlin/runtime/http/middleware/AwsRetryHeaderMiddleware : aws/smithy/kotlin/runtime/http/operation/MutateMiddleware { - public fun ()V - public fun handle (Laws/smithy/kotlin/runtime/http/operation/OperationRequest;Laws/smithy/kotlin/runtime/io/Handler;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public synthetic fun handle (Ljava/lang/Object;Laws/smithy/kotlin/runtime/io/Handler;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public fun install (Laws/smithy/kotlin/runtime/http/operation/SdkHttpOperation;)V -} - -public final class aws/sdk/kotlin/runtime/http/middleware/RecursionDetection : aws/smithy/kotlin/runtime/http/operation/ModifyRequestMiddleware { - public fun ()V - public fun (Laws/smithy/kotlin/runtime/util/EnvironmentProvider;)V - public synthetic fun (Laws/smithy/kotlin/runtime/util/EnvironmentProvider;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun install (Laws/smithy/kotlin/runtime/http/operation/SdkHttpOperation;)V - public fun modifyRequest (Laws/smithy/kotlin/runtime/http/operation/OperationRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public synthetic fun modifyRequest (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class aws/sdk/kotlin/runtime/http/middleware/UserAgent : aws/smithy/kotlin/runtime/http/operation/ModifyRequestMiddleware { - public fun (Laws/sdk/kotlin/runtime/http/AwsUserAgentMetadata;)V - public fun install (Laws/smithy/kotlin/runtime/http/operation/SdkHttpOperation;)V - public fun modifyRequest (Laws/smithy/kotlin/runtime/http/operation/OperationRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public synthetic fun modifyRequest (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class aws/sdk/kotlin/runtime/http/operation/ConfigMetadata : aws/sdk/kotlin/runtime/http/operation/TypedUserAgentMetadata { - public fun (Ljava/lang/String;Ljava/lang/String;)V - public final fun component1 ()Ljava/lang/String; - public final fun component2 ()Ljava/lang/String; - public final fun copy (Ljava/lang/String;Ljava/lang/String;)Laws/sdk/kotlin/runtime/http/operation/ConfigMetadata; - public static synthetic fun copy$default (Laws/sdk/kotlin/runtime/http/operation/ConfigMetadata;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Laws/sdk/kotlin/runtime/http/operation/ConfigMetadata; - public fun equals (Ljava/lang/Object;)Z - public final fun getName ()Ljava/lang/String; - public final fun getValue ()Ljava/lang/String; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class aws/sdk/kotlin/runtime/http/S3ExpressHttpSigner : aws/smithy/kotlin/runtime/http/auth/HttpSigner { - public fun (Laws/smithy/kotlin/runtime/http/auth/AwsHttpSigner;)V - public final fun getAwsHttpSigner ()Laws/smithy/kotlin/runtime/http/auth/AwsHttpSigner; - public fun sign (Laws/smithy/kotlin/runtime/http/auth/SignHttpRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class aws/sdk/kotlin/runtime/http/interceptors/S3ExpressCrc32ChecksumInterceptor : aws/smithy/kotlin/runtime/client/Interceptor { +public final class aws/sdk/kotlin/runtime/http/interceptors/S3ExpressDisableChecksumInterceptor : aws/smithy/kotlin/runtime/client/Interceptor { public fun ()V - public fun (Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getChecksumAlgorithmHeaderName ()Ljava/lang/String; public fun modifyBeforeAttemptCompletion-gIAlu-s (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun modifyBeforeCompletion-gIAlu-s (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun modifyBeforeDeserialization (Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -253,7 +217,7 @@ public final class aws/sdk/kotlin/runtime/http/interceptors/S3ExpressCrc32Checks public fun readBeforeTransmit (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V } -public final class aws/sdk/kotlin/runtime/http/interceptors/S3ExpressDisableChecksumInterceptor : aws/smithy/kotlin/runtime/client/Interceptor { +public final class aws/sdk/kotlin/runtime/http/interceptors/UnsupportedSigningAlgorithmInterceptor : aws/smithy/kotlin/runtime/client/Interceptor { public fun ()V public fun modifyBeforeAttemptCompletion-gIAlu-s (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun modifyBeforeCompletion-gIAlu-s (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -276,6 +240,42 @@ public final class aws/sdk/kotlin/runtime/http/interceptors/S3ExpressDisableChec public fun readBeforeTransmit (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V } +public final class aws/sdk/kotlin/runtime/http/middleware/AwsRetryHeaderMiddleware : aws/smithy/kotlin/runtime/http/operation/MutateMiddleware { + public fun ()V + public fun handle (Laws/smithy/kotlin/runtime/http/operation/OperationRequest;Laws/smithy/kotlin/runtime/io/Handler;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public synthetic fun handle (Ljava/lang/Object;Laws/smithy/kotlin/runtime/io/Handler;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun install (Laws/smithy/kotlin/runtime/http/operation/SdkHttpOperation;)V +} + +public final class aws/sdk/kotlin/runtime/http/middleware/RecursionDetection : aws/smithy/kotlin/runtime/http/operation/ModifyRequestMiddleware { + public fun ()V + public fun (Laws/smithy/kotlin/runtime/util/EnvironmentProvider;)V + public synthetic fun (Laws/smithy/kotlin/runtime/util/EnvironmentProvider;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun install (Laws/smithy/kotlin/runtime/http/operation/SdkHttpOperation;)V + public fun modifyRequest (Laws/smithy/kotlin/runtime/http/operation/OperationRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public synthetic fun modifyRequest (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class aws/sdk/kotlin/runtime/http/middleware/UserAgent : aws/smithy/kotlin/runtime/http/operation/ModifyRequestMiddleware { + public fun (Laws/sdk/kotlin/runtime/http/AwsUserAgentMetadata;)V + public fun install (Laws/smithy/kotlin/runtime/http/operation/SdkHttpOperation;)V + public fun modifyRequest (Laws/smithy/kotlin/runtime/http/operation/OperationRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public synthetic fun modifyRequest (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class aws/sdk/kotlin/runtime/http/operation/ConfigMetadata : aws/sdk/kotlin/runtime/http/operation/TypedUserAgentMetadata { + public fun (Ljava/lang/String;Ljava/lang/String;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Ljava/lang/String; + public final fun copy (Ljava/lang/String;Ljava/lang/String;)Laws/sdk/kotlin/runtime/http/operation/ConfigMetadata; + public static synthetic fun copy$default (Laws/sdk/kotlin/runtime/http/operation/ConfigMetadata;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Laws/sdk/kotlin/runtime/http/operation/ConfigMetadata; + public fun equals (Ljava/lang/Object;)Z + public final fun getName ()Ljava/lang/String; + public final fun getValue ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + public final class aws/sdk/kotlin/runtime/http/operation/CustomUserAgentMetadata { public fun ()V public fun (Ljava/util/Map;Ljava/util/List;)V diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/s3/ClientConfigIntegration.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/s3/ClientConfigIntegration.kt index 7f829b7ec63..8b9b0334118 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/s3/ClientConfigIntegration.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/s3/ClientConfigIntegration.kt @@ -90,8 +90,6 @@ class ClientConfigIntegration : KotlinIntegration { }, ) - // FIXME Figure out why the default value is not being used properly. -// propertyType = ConfigPropertyType.RequiredWithDefault("S3ExpressCredentialsProvider(this.credentialsProvider)") propertyType = ConfigPropertyType.Custom( render = { _, writer -> writer.write("public val $name: S3ExpressCredentialsProvider = builder.$name ?: SdkS3ExpressCredentialsProvider(this.credentialsProvider)") diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/s3/express/SigV4S3ExpressAuthSchemeIntegration.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/s3/express/SigV4S3ExpressAuthSchemeIntegration.kt index 7d42a9d70ca..d91ba06e626 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/s3/express/SigV4S3ExpressAuthSchemeIntegration.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/s3/express/SigV4S3ExpressAuthSchemeIntegration.kt @@ -27,7 +27,6 @@ import software.amazon.smithy.kotlin.codegen.rendering.protocol.* import software.amazon.smithy.kotlin.codegen.utils.getOrNull import software.amazon.smithy.model.Model import software.amazon.smithy.model.node.Node -import software.amazon.smithy.model.node.ObjectNode import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.ShapeId @@ -93,19 +92,13 @@ open class SigV4S3ExpressAuthSchemeHandler : AuthSchemeHandler { } } -private fun String.toAuthOptionFactoryFn(): Symbol? = - when (this) { - "sigv4-s3express" -> AwsRuntimeTypes.Config.Auth.sigV4S3Express - else -> null - } - private fun renderAuthSchemes(writer: KotlinWriter, authSchemes: Expression, expressionRenderer: ExpressionRenderer) { writer.writeInline("#T to ", RuntimeTypes.SmithyClient.Endpoints.SigningContextAttributeKey) writer.withBlock("listOf(", ")") { authSchemes.toNode().expectArrayNode().forEach { val scheme = it.expectObjectNode() val schemeName = scheme.expectStringMember("name").value - val authFactoryFn = schemeName.toAuthOptionFactoryFn() ?: return@forEach + val authFactoryFn = if (schemeName == "sigv4-s3express") AwsRuntimeTypes.Config.Auth.sigV4S3Express else return@forEach withBlock("#T(", "),", authFactoryFn) { // we delegate back to the expression visitor for each of these fields because it's possible to @@ -117,9 +110,8 @@ private fun renderAuthSchemes(writer: KotlinWriter, authSchemes: Expression, exp writeInline("disableDoubleUriEncode = ") renderOrElse(expressionRenderer, scheme.getBooleanMember("disableDoubleEncoding"), "false") - when (schemeName) { - "sigv4-s3express" -> renderSigV4ExpressFields(writer, scheme, expressionRenderer) - } + writer.writeInline("signingRegion = ") + writer.renderOrElse(expressionRenderer, scheme.getStringMember("signingRegion"), "null") } } } @@ -137,8 +129,3 @@ private fun KotlinWriter.renderOrElse( } write(",") } - -private fun renderSigV4ExpressFields(writer: KotlinWriter, scheme: ObjectNode, expressionRenderer: ExpressionRenderer) { - writer.writeInline("signingRegion = ") - writer.renderOrElse(expressionRenderer, scheme.getStringMember("signingRegion"), "null") -}