Skip to content

Commit 852fe92

Browse files
authored
refactor: remove ByteArrayContent and rename transform package (#1062)
1 parent b65b9cb commit 852fe92

File tree

21 files changed

+38
-37
lines changed

21 files changed

+38
-37
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"id": "b0f89880-988f-46c1-87dc-f1741587860d",
3+
"type": "misc",
4+
"description": "Track upstream changes that make `ByteArrayContent` and friends internal. Users should only be using `ByteStream.fromBytes()`, `ByteStream.fromString()`, and `HttpBody.fromBytes()`."
5+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import aws.sdk.kotlin.runtime.config.AwsSdkSetting
99
import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials
1010
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderException
1111
import aws.smithy.kotlin.runtime.http.Headers
12+
import aws.smithy.kotlin.runtime.http.HttpBody
1213
import aws.smithy.kotlin.runtime.http.HttpMethod
1314
import aws.smithy.kotlin.runtime.http.HttpStatusCode
14-
import aws.smithy.kotlin.runtime.http.content.ByteArrayContent
1515
import aws.smithy.kotlin.runtime.http.request.HttpRequest
1616
import aws.smithy.kotlin.runtime.http.request.HttpRequestBuilder
1717
import aws.smithy.kotlin.runtime.http.request.header
@@ -54,15 +54,15 @@ class EcsCredentialsProviderTest {
5454
"Expiration" : "${expectedExpiration.format(TimestampFormat.ISO_8601)}"
5555
}
5656
""".encodeToByteArray()
57-
return HttpResponse(HttpStatusCode.OK, Headers.Empty, ByteArrayContent(payload))
57+
return HttpResponse(HttpStatusCode.OK, Headers.Empty, HttpBody.fromBytes(payload))
5858
}
5959

6060
private fun errorResponse(
6161
statusCode: HttpStatusCode = HttpStatusCode.BadRequest,
6262
headers: Headers = Headers.Empty,
6363
body: String = "",
6464
): HttpResponse =
65-
HttpResponse(statusCode, headers, ByteArrayContent(body.encodeToByteArray()))
65+
HttpResponse(statusCode, headers, HttpBody.fromBytes(body.encodeToByteArray()))
6666

6767
private fun ecsRequest(url: String, authToken: String? = null): HttpRequest {
6868
val resolvedUrl = Url.parse(url)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import aws.smithy.kotlin.runtime.http.HttpBody
1414
import aws.smithy.kotlin.runtime.http.HttpCall
1515
import aws.smithy.kotlin.runtime.http.HttpMethod
1616
import aws.smithy.kotlin.runtime.http.HttpStatusCode
17-
import aws.smithy.kotlin.runtime.http.content.ByteArrayContent
1817
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngineBase
1918
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngineConfig
2019
import aws.smithy.kotlin.runtime.http.request.HttpRequest
@@ -241,7 +240,7 @@ class ImdsCredentialsProviderTest {
241240
HttpResponse(
242241
HttpStatusCode.NotFound,
243242
Headers.Empty,
244-
ByteArrayContent(
243+
HttpBody.fromBytes(
245244
"""<?xml version="1.0" encoding="iso-8859-1"?>
246245
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
247246
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials
99
import aws.smithy.kotlin.runtime.http.Headers
1010
import aws.smithy.kotlin.runtime.http.HttpBody
1111
import aws.smithy.kotlin.runtime.http.HttpStatusCode
12-
import aws.smithy.kotlin.runtime.http.content.ByteArrayContent
1312
import aws.smithy.kotlin.runtime.http.response.HttpResponse
1413
import aws.smithy.kotlin.runtime.httptest.TestConnection
1514
import aws.smithy.kotlin.runtime.httptest.buildTestConnection
@@ -169,7 +168,7 @@ class SsoCredentialsProviderTest {
169168

170169
val engine = buildTestConnection {
171170
expect(
172-
HttpResponse(HttpStatusCode.OK, Headers.Empty, ByteArrayContent(serviceResp.encodeToByteArray())),
171+
HttpResponse(HttpStatusCode.OK, Headers.Empty, HttpBody.fromBytes(serviceResp.encodeToByteArray())),
173172
)
174173
}
175174

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ package aws.sdk.kotlin.runtime.auth.credentials
88
import aws.sdk.kotlin.runtime.auth.credentials.internal.sts.model.RegionDisabledException
99
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderException
1010
import aws.smithy.kotlin.runtime.http.Headers
11+
import aws.smithy.kotlin.runtime.http.HttpBody
1112
import aws.smithy.kotlin.runtime.http.HttpStatusCode
12-
import aws.smithy.kotlin.runtime.http.content.ByteArrayContent
1313
import aws.smithy.kotlin.runtime.http.response.HttpResponse
1414
import aws.smithy.kotlin.runtime.httptest.CallAsserter
1515
import aws.smithy.kotlin.runtime.httptest.buildTestConnection
@@ -105,7 +105,7 @@ class StsAssumeRoleCredentialsProviderTest {
105105
</ErrorResponse>
106106
"""
107107
val testEngine = buildTestConnection {
108-
expect(HttpResponse(HttpStatusCode.BadRequest, Headers.Empty, ByteArrayContent(errorResponseBody.encodeToByteArray())))
108+
expect(HttpResponse(HttpStatusCode.BadRequest, Headers.Empty, HttpBody.fromBytes(errorResponseBody.encodeToByteArray())))
109109
}
110110

111111
val provider = StsAssumeRoleCredentialsProvider(
@@ -132,7 +132,7 @@ class StsAssumeRoleCredentialsProviderTest {
132132
</ErrorResponse>
133133
"""
134134
val testEngine = buildTestConnection {
135-
expect(HttpResponse(HttpStatusCode.Forbidden, Headers.Empty, ByteArrayContent(errorResponseBody.encodeToByteArray())))
135+
expect(HttpResponse(HttpStatusCode.Forbidden, Headers.Empty, HttpBody.fromBytes(errorResponseBody.encodeToByteArray())))
136136
}
137137

138138
val provider = StsAssumeRoleCredentialsProvider(

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import aws.smithy.kotlin.runtime.http.Headers
1010
import aws.smithy.kotlin.runtime.http.HttpBody
1111
import aws.smithy.kotlin.runtime.http.HttpMethod
1212
import aws.smithy.kotlin.runtime.http.HttpStatusCode
13-
import aws.smithy.kotlin.runtime.http.content.ByteArrayContent
1413
import aws.smithy.kotlin.runtime.http.request.HttpRequestBuilder
1514
import aws.smithy.kotlin.runtime.http.request.url
1615
import aws.smithy.kotlin.runtime.http.response.HttpResponse
@@ -76,6 +75,6 @@ object StsTestUtils {
7675
</ResponseMetadata>
7776
</AssumeRoleResponse>
7877
""".trimIndent()
79-
return HttpResponse(HttpStatusCode.OK, Headers.Empty, ByteArrayContent(body.encodeToByteArray()))
78+
return HttpResponse(HttpStatusCode.OK, Headers.Empty, HttpBody.fromBytes(body.encodeToByteArray()))
8079
}
8180
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ package aws.sdk.kotlin.runtime.auth.credentials
88
import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials
99
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderException
1010
import aws.smithy.kotlin.runtime.http.Headers
11+
import aws.smithy.kotlin.runtime.http.HttpBody
1112
import aws.smithy.kotlin.runtime.http.HttpStatusCode
12-
import aws.smithy.kotlin.runtime.http.content.ByteArrayContent
1313
import aws.smithy.kotlin.runtime.http.response.HttpResponse
1414
import aws.smithy.kotlin.runtime.httptest.CallAsserter
1515
import aws.smithy.kotlin.runtime.httptest.TestConnection
@@ -67,7 +67,7 @@ class StsWebIdentityCredentialsProviderTest {
6767
</AssumeRoleWithWebIdentityResponse>
6868
""".trimIndent()
6969

70-
return HttpResponse(HttpStatusCode.OK, Headers.Empty, ByteArrayContent(body.encodeToByteArray()))
70+
return HttpResponse(HttpStatusCode.OK, Headers.Empty, HttpBody.fromBytes(body.encodeToByteArray()))
7171
}
7272

7373
@Test
@@ -160,7 +160,7 @@ class StsWebIdentityCredentialsProviderTest {
160160
"""
161161

162162
val testEngine = buildTestConnection {
163-
expect(HttpResponse(HttpStatusCode.BadRequest, Headers.Empty, ByteArrayContent(errorResponseBody.encodeToByteArray())))
163+
expect(HttpResponse(HttpStatusCode.BadRequest, Headers.Empty, HttpBody.fromBytes(errorResponseBody.encodeToByteArray())))
164164
}
165165

166166
val testPlatform = TestPlatformProvider(

aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/config/imds/ImdsTestUtils.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
package aws.sdk.kotlin.runtime.config.imds
77

88
import aws.smithy.kotlin.runtime.http.Headers
9+
import aws.smithy.kotlin.runtime.http.HttpBody
910
import aws.smithy.kotlin.runtime.http.HttpMethod
1011
import aws.smithy.kotlin.runtime.http.HttpStatusCode
11-
import aws.smithy.kotlin.runtime.http.content.ByteArrayContent
1212
import aws.smithy.kotlin.runtime.http.request.HttpRequest
1313
import aws.smithy.kotlin.runtime.http.request.url
1414
import aws.smithy.kotlin.runtime.http.response.HttpResponse
@@ -27,7 +27,7 @@ fun tokenResponse(ttl: Int, token: String): HttpResponse = HttpResponse(
2727
Headers {
2828
append(X_AWS_EC2_METADATA_TOKEN_TTL_SECONDS, ttl.toString())
2929
},
30-
ByteArrayContent(token.encodeToByteArray()),
30+
HttpBody.fromBytes(token.encodeToByteArray()),
3131
)
3232

3333
fun imdsRequest(url: String, token: String): HttpRequest = HttpRequest {
@@ -39,5 +39,5 @@ fun imdsRequest(url: String, token: String): HttpRequest = HttpRequest {
3939
fun imdsResponse(body: String): HttpResponse = HttpResponse(
4040
HttpStatusCode.OK,
4141
Headers.Empty,
42-
ByteArrayContent(body.encodeToByteArray()),
42+
HttpBody.fromBytes(body.encodeToByteArray()),
4343
)

codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/PresignerGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class PresignerGenerator : KotlinIntegration {
121121
val serializerSymbol = buildSymbol {
122122
definitionFile = "${op.serializerName()}.kt"
123123
name = op.serializerName()
124-
namespace = "${ctx.settings.pkg.name}.transform"
124+
namespace = ctx.settings.pkg.serde
125125
}
126126

127127
val contextMap: Map<SectionKey<*>, Any> = mapOf(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class S3Generator : RestXml() {
9292
val errSymbol = ctx.symbolProvider.toSymbol(ctx.model.expectShape(err))
9393
val errDeserializerSymbol = buildSymbol {
9494
name = "${errSymbol.name}Deserializer"
95-
namespace = "${ctx.settings.pkg.name}.transform"
95+
namespace = ctx.settings.pkg.serde
9696
}
9797
writer.write("#S -> #T().deserialize(context, wrappedCall)", getErrorCode(ctx, err), errDeserializerSymbol)
9898
}

0 commit comments

Comments
 (0)