Skip to content

Commit 223d38b

Browse files
authored
refactor: track upstream HttpDeserialize changes (#1034)
1 parent d2ffbe6 commit 223d38b

File tree

17 files changed

+57
-31
lines changed

17 files changed

+57
-31
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"id": "55fc25d8-eb87-49fd-adfa-8b5a47b7713b",
3+
"type": "misc",
4+
"description": "**BREAKING**: Refactor HttpCall and HttpResponse types"
5+
}

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/EcsCredentialsProvider.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderExceptio
1515
import aws.smithy.kotlin.runtime.client.endpoints.Endpoint
1616
import aws.smithy.kotlin.runtime.config.resolve
1717
import aws.smithy.kotlin.runtime.http.*
18+
import aws.smithy.kotlin.runtime.http.HttpCall
1819
import aws.smithy.kotlin.runtime.http.engine.DefaultHttpEngine
1920
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngine
2021
import aws.smithy.kotlin.runtime.http.operation.*
@@ -156,7 +157,8 @@ public class EcsCredentialsProvider internal constructor(
156157
}
157158

158159
private class EcsCredentialsDeserializer : HttpDeserialize<Credentials> {
159-
override suspend fun deserialize(context: ExecutionContext, response: HttpResponse): Credentials {
160+
override suspend fun deserialize(context: ExecutionContext, call: HttpCall): Credentials {
161+
val response = call.response
160162
if (!response.status.isSuccess()) {
161163
throwCredentialsResponseException(response)
162164
}

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/imds/ImdsClient.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import aws.smithy.kotlin.runtime.client.LogMode
1313
import aws.smithy.kotlin.runtime.client.SdkClientOption
1414
import aws.smithy.kotlin.runtime.client.endpoints.Endpoint
1515
import aws.smithy.kotlin.runtime.http.*
16+
import aws.smithy.kotlin.runtime.http.HttpCall
1617
import aws.smithy.kotlin.runtime.http.engine.DefaultHttpEngine
1718
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngine
1819
import aws.smithy.kotlin.runtime.http.operation.*
19-
import aws.smithy.kotlin.runtime.http.response.HttpResponse
2020
import aws.smithy.kotlin.runtime.io.Closeable
2121
import aws.smithy.kotlin.runtime.io.closeIfCloseable
2222
import aws.smithy.kotlin.runtime.io.middleware.Phase
@@ -108,7 +108,8 @@ public class ImdsClient private constructor(builder: Builder) : InstanceMetadata
108108
val op = SdkHttpOperation.build<Unit, String> {
109109
serializer = UnitSerializer
110110
deserializer = object : HttpDeserialize<String> {
111-
override suspend fun deserialize(context: ExecutionContext, response: HttpResponse): String {
111+
override suspend fun deserialize(context: ExecutionContext, call: HttpCall): String {
112+
val response = call.response
112113
if (response.status.isSuccess()) {
113114
val payload = response.body.readAll() ?: throw EC2MetadataError(response.status.value, "no metadata payload")
114115
return payload.decodeToString()

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/imds/TokenMiddleware.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
package aws.sdk.kotlin.runtime.config.imds
77

88
import aws.smithy.kotlin.runtime.http.*
9+
import aws.smithy.kotlin.runtime.http.complete
910
import aws.smithy.kotlin.runtime.http.operation.ModifyRequestMiddleware
1011
import aws.smithy.kotlin.runtime.http.operation.SdkHttpOperation
1112
import aws.smithy.kotlin.runtime.http.operation.SdkHttpRequest
1213
import aws.smithy.kotlin.runtime.http.operation.setResolvedEndpoint
1314
import aws.smithy.kotlin.runtime.http.request.HttpRequestBuilder
1415
import aws.smithy.kotlin.runtime.http.request.url
15-
import aws.smithy.kotlin.runtime.http.response.complete
1616
import aws.smithy.kotlin.runtime.telemetry.logging.trace
1717
import aws.smithy.kotlin.runtime.time.Clock
1818
import aws.smithy.kotlin.runtime.util.CachedValue

aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProviderTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials
1111
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderException
1212
import aws.smithy.kotlin.runtime.http.Headers
1313
import aws.smithy.kotlin.runtime.http.HttpBody
14+
import aws.smithy.kotlin.runtime.http.HttpCall
1415
import aws.smithy.kotlin.runtime.http.HttpMethod
1516
import aws.smithy.kotlin.runtime.http.HttpStatusCode
1617
import aws.smithy.kotlin.runtime.http.content.ByteArrayContent
1718
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngineBase
1819
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngineConfig
1920
import aws.smithy.kotlin.runtime.http.request.HttpRequest
20-
import aws.smithy.kotlin.runtime.http.response.HttpCall
2121
import aws.smithy.kotlin.runtime.http.response.HttpResponse
2222
import aws.smithy.kotlin.runtime.httptest.TestEngine
2323
import aws.smithy.kotlin.runtime.httptest.buildTestConnection

codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/s3/S3Generator.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ class S3Generator : RestXml() {
6060
namespace = "${ctx.settings.pkg.name}.internal"
6161
}
6262

63-
writer.write("val payload = response.body.#T()", RuntimeTypes.Http.readAll)
64-
.write("val wrappedResponse = response.#T(payload)", RuntimeTypes.AwsProtocolCore.withPayload)
63+
writer.write("val payload = call.response.body.#T()", RuntimeTypes.Http.readAll)
64+
.write("val wrappedResponse = call.response.#T(payload)", RuntimeTypes.AwsProtocolCore.withPayload)
65+
.write("val wrappedCall = call.copy(response = wrappedResponse)")
6566
.write("")
6667
.write("val errorDetails = try {")
6768
.indent()
6869
.call {
6970
// customize error matching to handle HeadObject/HeadBucket error responses which have no payload
70-
writer.write("if (payload == null && response.status == #T.NotFound) {", RuntimeTypes.Http.StatusCode)
71+
writer.write("if (payload == null && call.response.status == #T.NotFound) {", RuntimeTypes.Http.StatusCode)
7172
.indent()
7273
.write("#T(code = #S)", s3ErrorDetails, "NotFound")
7374
.dedent()
@@ -93,7 +94,7 @@ class S3Generator : RestXml() {
9394
name = "${errSymbol.name}Deserializer"
9495
namespace = "${ctx.settings.pkg.name}.transform"
9596
}
96-
writer.write("#S -> #T().deserialize(context, wrappedResponse)", getErrorCode(ctx, err), errDeserializerSymbol)
97+
writer.write("#S -> #T().deserialize(context, wrappedCall)", getErrorCode(ctx, err), errDeserializerSymbol)
9798
}
9899
write("else -> #T(errorDetails.message)", exceptionBaseSymbol)
99100
}

codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/protocols/core/AwsHttpBindingProtocolGenerator.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ abstract class AwsHttpBindingProtocolGenerator : HttpBindingProtocolGenerator()
9292
override fun operationErrorHandler(ctx: ProtocolGenerator.GenerationContext, op: OperationShape): Symbol =
9393
op.errorHandler(ctx.settings) { writer ->
9494
writer.withBlock(
95-
"private suspend fun ${op.errorHandlerName()}(context: #T, response: #T): #Q {",
95+
"private suspend fun ${op.errorHandlerName()}(context: #T, call: #T): #Q {",
9696
"}",
9797
RuntimeTypes.Core.ExecutionContext,
98-
RuntimeTypes.Http.Response.HttpResponse,
98+
RuntimeTypes.Http.HttpCall,
9999
KotlinTypes.Nothing,
100100
) {
101101
renderThrowOperationError(ctx, op, writer)
@@ -110,8 +110,9 @@ abstract class AwsHttpBindingProtocolGenerator : HttpBindingProtocolGenerator()
110110
writer: KotlinWriter,
111111
) {
112112
val exceptionBaseSymbol = ExceptionBaseClassGenerator.baseExceptionSymbol(ctx.settings)
113-
writer.write("val payload = response.body.#T()", RuntimeTypes.Http.readAll)
114-
.write("val wrappedResponse = response.#T(payload)", RuntimeTypes.AwsProtocolCore.withPayload)
113+
writer.write("val payload = call.response.body.#T()", RuntimeTypes.Http.readAll)
114+
.write("val wrappedResponse = call.response.#T(payload)", RuntimeTypes.AwsProtocolCore.withPayload)
115+
.write("val wrappedCall = call.copy(response = wrappedResponse)")
115116
.write("")
116117
.declareSection(ProtocolErrorDeserialization)
117118
.write("val errorDetails = try {")
@@ -129,7 +130,7 @@ abstract class AwsHttpBindingProtocolGenerator : HttpBindingProtocolGenerator()
129130

130131
if (ctx.service.hasTrait<AwsQueryCompatibleTrait>()) {
131132
writer.write("var queryErrorDetails: #T? = null", RuntimeTypes.AwsProtocolCore.AwsQueryCompatibleErrorDetails)
132-
writer.withBlock("response.headers[#T]?.let {", "}", RuntimeTypes.AwsProtocolCore.XAmznQueryErrorHeader) {
133+
writer.withBlock("call.response.headers[#T]?.let {", "}", RuntimeTypes.AwsProtocolCore.XAmznQueryErrorHeader) {
133134
openBlock("queryErrorDetails = try {")
134135
write("#T.parse(it)", RuntimeTypes.AwsProtocolCore.AwsQueryCompatibleErrorDetails)
135136
closeAndOpenBlock("} catch (ex: Exception) {")
@@ -148,7 +149,7 @@ abstract class AwsHttpBindingProtocolGenerator : HttpBindingProtocolGenerator()
148149
name = "${errSymbol.name}Deserializer"
149150
namespace = "${ctx.settings.pkg.name}.transform"
150151
}
151-
writer.write("#S -> #T().deserialize(context, wrappedResponse)", getErrorCode(ctx, err), errDeserializerSymbol)
152+
writer.write("#S -> #T().deserialize(context, wrappedCall)", getErrorCode(ctx, err), errDeserializerSymbol)
152153
}
153154
write("else -> #T(errorDetails.message)", exceptionBaseSymbol)
154155
}

codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/protocols/json/JsonHttpBindingProtocolGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ abstract class JsonHttpBindingProtocolGenerator : AwsHttpBindingProtocolGenerato
3737
op: OperationShape,
3838
writer: KotlinWriter,
3939
) {
40-
writer.write("#T.deserialize(response.headers, payload)", RuntimeTypes.AwsJsonProtocols.RestJsonErrorDeserializer)
40+
writer.write("#T.deserialize(call.response.headers, payload)", RuntimeTypes.AwsJsonProtocols.RestJsonErrorDeserializer)
4141
}
4242
}

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ kotlin.native.ignoreDisabledTargets=true
66
org.gradle.jvmargs=-Xmx6g -XX:MaxMetaspaceSize=2G
77

88
# sdk
9-
sdkVersion=0.31.1-SNAPSHOT
9+
sdkVersion=0.32.0-SNAPSHOT
1010

1111
# codegen
1212
smithyVersion=1.29.0
1313
smithyGradleVersion=0.6.0
1414
# smithy-kotlin codegen and runtime are versioned together
15-
smithyKotlinVersion=0.26.0
15+
smithyKotlinVersion=0.27.0-SNAPSHOT
1616

1717
# kotlin
1818
kotlinVersion=1.8.22
@@ -37,4 +37,4 @@ mockkVersion=1.13.3
3737
slf4jVersion=2.0.6
3838

3939
# dokka config (values specified at build-time as needed)
40-
smithyKotlinDocBaseUrl=https://sdk.amazonaws.com/kotlin/api/smithy-kotlin/api/$smithyKotlinVersion/
40+
smithyKotlinDocBaseUrl=https://sdk.amazonaws.com/kotlin/api/smithy-kotlin/api/$smithyKotlinVersion/

services/polly/common/test/aws/sdk/kotlin/services/polly/PollyTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import aws.sdk.kotlin.services.polly.model.OutputFormat
99
import aws.sdk.kotlin.services.polly.model.SynthesizeSpeechRequest
1010
import aws.sdk.kotlin.services.polly.model.VoiceId
1111
import aws.sdk.kotlin.services.polly.presigners.presignSynthesizeSpeech
12+
import aws.smithy.kotlin.runtime.http.HttpCall
1213
import aws.smithy.kotlin.runtime.http.HttpMethod
1314
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngineBase
1415
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngineConfig
1516
import aws.smithy.kotlin.runtime.http.request.HttpRequest
16-
import aws.smithy.kotlin.runtime.http.response.HttpCall
1717
import aws.smithy.kotlin.runtime.operation.ExecutionContext
1818
import kotlinx.coroutines.ExperimentalCoroutinesApi
1919
import kotlinx.coroutines.test.runTest

0 commit comments

Comments
 (0)