Skip to content

Commit 7dc1992

Browse files
authored
chore: remove @deprecated APIs in preparation for v1.5 (#1636)
1 parent 76083fa commit 7dc1992

File tree

11 files changed

+37
-194
lines changed

11 files changed

+37
-194
lines changed

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public class EcsCredentialsProvider(
8787
}
8888

8989
val op = SdkHttpOperation.build<Unit, Credentials> {
90-
serializer = EcsCredentialsSerializer(authToken)
91-
deserializer = EcsCredentialsDeserializer()
90+
serializeWith = EcsCredentialsSerializer(authToken)
91+
deserializeWith = EcsCredentialsDeserializer()
9292
operationName = "EcsCredentialsProvider"
9393
serviceName = "EcsContainerMetadata"
9494
execution.endpointResolver = EndpointResolver { Endpoint(url) }
@@ -196,14 +196,14 @@ public class EcsCredentialsProvider(
196196
override fun toString(): String = this.simpleClassName
197197
}
198198

199-
private class EcsCredentialsDeserializer : HttpDeserialize<Credentials> {
200-
override suspend fun deserialize(context: ExecutionContext, call: HttpCall): Credentials {
199+
private class EcsCredentialsDeserializer : HttpDeserializer.NonStreaming<Credentials> {
200+
override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): Credentials {
201201
val response = call.response
202202
if (!response.status.isSuccess()) {
203-
throwCredentialsResponseException(response)
203+
throwCredentialsResponseException(response, payload)
204204
}
205205

206-
val payload = response.body.readAll() ?: throw CredentialsProviderException("HTTP credentials response did not contain a payload")
206+
if (payload == null) throw CredentialsProviderException("HTTP credentials response did not contain a payload")
207207
val deserializer = JsonDeserializer(payload)
208208
val resp = deserializeJsonCredentials(deserializer)
209209
if (resp !is JsonCredentialsResponse.SessionCredentials) {
@@ -221,8 +221,8 @@ private class EcsCredentialsDeserializer : HttpDeserialize<Credentials> {
221221
}
222222
}
223223

224-
private suspend fun throwCredentialsResponseException(response: HttpResponse): Nothing {
225-
val errorResp = tryParseErrorResponse(response)
224+
private fun throwCredentialsResponseException(response: HttpResponse, payload: ByteArray?): Nothing {
225+
val errorResp = tryParseErrorResponse(response, payload)
226226
val messageDetails = errorResp?.run { "code=$code; message=$message" } ?: "HTTP ${response.status}"
227227

228228
throw CredentialsProviderException("Error retrieving credentials from container service: $messageDetails").apply {
@@ -233,17 +233,15 @@ private suspend fun throwCredentialsResponseException(response: HttpResponse): N
233233
}
234234
}
235235

236-
private suspend fun tryParseErrorResponse(response: HttpResponse): JsonCredentialsResponse.Error? {
237-
if (response.headers["Content-Type"] != "application/json") return null
238-
val payload = response.body.readAll() ?: return null
239-
236+
private fun tryParseErrorResponse(response: HttpResponse, payload: ByteArray?): JsonCredentialsResponse.Error? {
237+
if (response.headers["Content-Type"] != "application/json" || payload == null) return null
240238
return deserializeJsonCredentials(JsonDeserializer(payload)) as? JsonCredentialsResponse.Error
241239
}
242240

243241
private class EcsCredentialsSerializer(
244242
private val authToken: String? = null,
245-
) : HttpSerialize<Unit> {
246-
override suspend fun serialize(context: ExecutionContext, input: Unit): HttpRequestBuilder {
243+
) : HttpSerializer.NonStreaming<Unit> {
244+
override fun serialize(context: ExecutionContext, input: Unit): HttpRequestBuilder {
247245
val builder = HttpRequestBuilder()
248246
builder.url.path
249247
builder.header("Accept", "application/json")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ internal sealed class JsonCredentialsResponse {
7474
* ```
7575
*/
7676
@Suppress("ktlint:standard:property-naming")
77-
internal suspend fun deserializeJsonCredentials(deserializer: Deserializer): JsonCredentialsResponse {
77+
internal fun deserializeJsonCredentials(deserializer: Deserializer): JsonCredentialsResponse {
7878
val CODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Code"))
7979
val ACCESS_KEY_ID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("AccessKeyId"))
8080
val SECRET_ACCESS_KEY_ID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("SecretAccessKey"))

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ import aws.sdk.kotlin.runtime.http.middleware.UserAgent
1212
import aws.smithy.kotlin.runtime.client.LogMode
1313
import aws.smithy.kotlin.runtime.client.SdkClientOption
1414
import aws.smithy.kotlin.runtime.client.endpoints.Endpoint
15-
import aws.smithy.kotlin.runtime.http.*
15+
import aws.smithy.kotlin.runtime.http.HttpCall
16+
import aws.smithy.kotlin.runtime.http.HttpStatusCode
17+
import aws.smithy.kotlin.runtime.http.SdkHttpClient
1618
import aws.smithy.kotlin.runtime.http.engine.DefaultHttpEngine
1719
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngine
1820
import aws.smithy.kotlin.runtime.http.engine.ProxySelector
21+
import aws.smithy.kotlin.runtime.http.isSuccess
1922
import aws.smithy.kotlin.runtime.http.operation.*
2023
import aws.smithy.kotlin.runtime.io.Closeable
2124
import aws.smithy.kotlin.runtime.io.closeIfCloseable
@@ -109,15 +112,14 @@ public class ImdsClient private constructor(builder: Builder) : InstanceMetadata
109112
*/
110113
public override suspend fun get(path: String): String {
111114
val op = SdkHttpOperation.build<Unit, String> {
112-
serializer = UnitSerializer
113-
deserializer = object : HttpDeserialize<String> {
114-
override suspend fun deserialize(context: ExecutionContext, call: HttpCall): String {
115+
serializeWith = HttpSerializer.Unit
116+
deserializeWith = object : HttpDeserializer.NonStreaming<String> {
117+
override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): String {
115118
val response = call.response
116119
if (response.status.isSuccess()) {
117-
val payload = response.body.readAll() ?: throw EC2MetadataError(response.status.value, "no metadata payload")
118-
return payload.decodeToString()
120+
return payload!!.decodeToString()
119121
} else {
120-
throw EC2MetadataError(response.status.value, "error retrieving instance metadata: ${response.status.description}")
122+
throw EC2MetadataError(response.status, "error retrieving instance metadata: ${response.status.description}")
121123
}
122124
}
123125
}
@@ -232,9 +234,9 @@ public enum class EndpointMode(internal val defaultEndpoint: Endpoint) {
232234
* @param message The error message
233235
*/
234236
public class EC2MetadataError(public val status: HttpStatusCode, message: String) : AwsServiceException(message) {
235-
@Deprecated("This constructor passes HTTP status as an Int instead of as HttpStatusCode")
237+
@Deprecated("This constructor passes HTTP status as an Int instead of as HttpStatusCode. This declaration will be removed in version 1.6.x.")
236238
public constructor(statusCode: Int, message: String) : this(HttpStatusCode.fromValue(statusCode), message)
237239

238-
@Deprecated("This property is now deprecated and should be fetched from status.value")
240+
@Deprecated("This property is now deprecated and should be fetched from status.value. This declaration will be removed in version 1.6.x.")
239241
public val statusCode: Int = status.value
240242
}

aws-runtime/aws-endpoint/api/aws-endpoint.api

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ public final class aws/sdk/kotlin/runtime/endpoint/functions/Partition {
4242

4343
public final class aws/sdk/kotlin/runtime/endpoint/functions/PartitionConfig {
4444
public fun <init> ()V
45-
public fun <init> (Ljava/lang/String;)V
46-
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
47-
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
48-
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;)V
49-
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;)V
50-
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
5145
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;)V
5246
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
5347
public final fun component1 ()Ljava/lang/String;

aws-runtime/aws-endpoint/common/src/aws/sdk/kotlin/runtime/endpoint/functions/Functions.kt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import aws.sdk.kotlin.runtime.InternalSdkApi
99
import aws.smithy.kotlin.runtime.client.endpoints.functions.isValidHostLabel
1010
import aws.smithy.kotlin.runtime.net.isIpv4
1111
import aws.smithy.kotlin.runtime.net.isIpv6
12-
import kotlin.jvm.JvmOverloads
1312

1413
// the number of top-level components an arn contains (separated by colons)
1514
private const val ARN_COMPONENT_COUNT = 6
@@ -70,23 +69,6 @@ public data class PartitionConfig(
7069
public val supportsDualStack: Boolean? = null,
7170
public val implicitGlobalRegion: String? = null,
7271
) {
73-
@Deprecated("This constructor does not support implicitGlobalRegion") // but is added for backwards compatibility
74-
@JvmOverloads
75-
public constructor (
76-
name: String? = null,
77-
dnsSuffix: String? = null,
78-
dualStackDnsSuffix: String? = null,
79-
supportsFIPS: Boolean? = null,
80-
supportsDualStack: Boolean? = null,
81-
) : this(
82-
name,
83-
dnsSuffix,
84-
dualStackDnsSuffix,
85-
supportsFIPS,
86-
supportsDualStack,
87-
null,
88-
)
89-
9072
public fun mergeWith(other: PartitionConfig): PartitionConfig =
9173
PartitionConfig(
9274
other.name ?: name,

aws-runtime/aws-http/api/aws-http.api

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -168,29 +168,6 @@ public final class aws/sdk/kotlin/runtime/http/interceptors/IgnoreCompositeFlexi
168168
public fun ignoreChecksum (Ljava/lang/String;Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;)Z
169169
}
170170

171-
public final class aws/sdk/kotlin/runtime/http/interceptors/UnsupportedSigningAlgorithmInterceptor : aws/smithy/kotlin/runtime/client/Interceptor {
172-
public fun <init> ()V
173-
public fun modifyBeforeAttemptCompletion-gIAlu-s (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
174-
public fun modifyBeforeCompletion-gIAlu-s (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
175-
public fun modifyBeforeDeserialization (Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
176-
public fun modifyBeforeRetryLoop (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
177-
public fun modifyBeforeSerialization (Laws/smithy/kotlin/runtime/client/RequestInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
178-
public fun modifyBeforeSigning (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
179-
public fun modifyBeforeTransmit (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
180-
public fun readAfterAttempt (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;)V
181-
public fun readAfterDeserialization (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;)V
182-
public fun readAfterExecution (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;)V
183-
public fun readAfterSerialization (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
184-
public fun readAfterSigning (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
185-
public fun readAfterTransmit (Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;)V
186-
public fun readBeforeAttempt (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
187-
public fun readBeforeDeserialization (Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;)V
188-
public fun readBeforeExecution (Laws/smithy/kotlin/runtime/client/RequestInterceptorContext;)V
189-
public fun readBeforeSerialization (Laws/smithy/kotlin/runtime/client/RequestInterceptorContext;)V
190-
public fun readBeforeSigning (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
191-
public fun readBeforeTransmit (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
192-
}
193-
194171
public final class aws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric : java/lang/Enum, aws/smithy/kotlin/runtime/businessmetrics/BusinessMetric {
195172
public static final field DDB_MAPPER Laws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric;
196173
public static final field S3_EXPRESS_BUCKET Laws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric;

aws-runtime/aws-http/common/src/aws/sdk/kotlin/runtime/http/interceptors/UnsupportedSigningAlgorithmInterceptor.kt

Lines changed: 0 additions & 37 deletions
This file was deleted.

aws-runtime/aws-http/common/test/aws/sdk/kotlin/runtime/http/interceptors/UnsupportedSigningAlgorithmInterceptorTest.kt

Lines changed: 0 additions & 78 deletions
This file was deleted.

aws-runtime/aws-http/common/test/aws/sdk/kotlin/runtime/http/middleware/AwsRetryHeaderMiddlewareTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class AwsRetryHeaderMiddlewareTest {
2121
fun testItSetsRetryHeaders() = runTest {
2222
// see retry-header SEP
2323
val op = SdkHttpOperation.build<Unit, Unit> {
24-
serializer = UnitSerializer
25-
deserializer = UnitDeserializer
24+
serializeWith = HttpSerializer.Unit
25+
deserializeWith = HttpDeserializer.Unit
2626
operationName = "TestOperation"
2727
serviceName = "TestService"
2828
}

aws-runtime/aws-http/common/test/aws/sdk/kotlin/runtime/http/middleware/RecursionDetectionTest.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import kotlin.test.assertFalse
2121
class RecursionDetectionTest {
2222
private class TraceHeaderSerializer(
2323
private val traceHeader: String,
24-
) : HttpSerialize<Unit> {
25-
override suspend fun serialize(context: ExecutionContext, input: Unit): HttpRequestBuilder {
24+
) : HttpSerializer.NonStreaming<Unit> {
25+
override fun serialize(context: ExecutionContext, input: Unit): HttpRequestBuilder {
2626
val builder = HttpRequestBuilder()
2727
builder.headers[HEADER_TRACE_ID] = traceHeader
2828
return builder
@@ -37,8 +37,13 @@ class RecursionDetectionTest {
3737
expectedTraceHeader: String?,
3838
) {
3939
val op = SdkHttpOperation.build<Unit, HttpResponse> {
40-
serializer = if (existingTraceHeader != null) TraceHeaderSerializer(existingTraceHeader) else UnitSerializer
41-
deserializer = IdentityDeserializer
40+
serializeWith = if (existingTraceHeader != null) {
41+
TraceHeaderSerializer(existingTraceHeader)
42+
} else {
43+
HttpSerializer.Unit
44+
}
45+
46+
deserializeWith = HttpDeserializer.Identity
4247
operationName = "testOperation"
4348
serviceName = "TestService"
4449
}

0 commit comments

Comments
 (0)