Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public class EcsCredentialsProvider(
}

val op = SdkHttpOperation.build<Unit, Credentials> {
serializer = EcsCredentialsSerializer(authToken)
deserializer = EcsCredentialsDeserializer()
serializeWith = EcsCredentialsSerializer(authToken)
deserializeWith = EcsCredentialsDeserializer()
operationName = "EcsCredentialsProvider"
serviceName = "EcsContainerMetadata"
execution.endpointResolver = EndpointResolver { Endpoint(url) }
Expand Down Expand Up @@ -196,14 +196,14 @@ public class EcsCredentialsProvider(
override fun toString(): String = this.simpleClassName
}

private class EcsCredentialsDeserializer : HttpDeserialize<Credentials> {
override suspend fun deserialize(context: ExecutionContext, call: HttpCall): Credentials {
private class EcsCredentialsDeserializer : HttpDeserializer.NonStreaming<Credentials> {
override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): Credentials {
val response = call.response
if (!response.status.isSuccess()) {
throwCredentialsResponseException(response)
throwCredentialsResponseException(response, payload)
}

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

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

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

private suspend fun tryParseErrorResponse(response: HttpResponse): JsonCredentialsResponse.Error? {
if (response.headers["Content-Type"] != "application/json") return null
val payload = response.body.readAll() ?: return null

private fun tryParseErrorResponse(response: HttpResponse, payload: ByteArray?): JsonCredentialsResponse.Error? {
if (response.headers["Content-Type"] != "application/json" || payload == null) return null
return deserializeJsonCredentials(JsonDeserializer(payload)) as? JsonCredentialsResponse.Error
}

private class EcsCredentialsSerializer(
private val authToken: String? = null,
) : HttpSerialize<Unit> {
override suspend fun serialize(context: ExecutionContext, input: Unit): HttpRequestBuilder {
) : HttpSerializer.NonStreaming<Unit> {
override fun serialize(context: ExecutionContext, input: Unit): HttpRequestBuilder {
val builder = HttpRequestBuilder()
builder.url.path
builder.header("Accept", "application/json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ internal sealed class JsonCredentialsResponse {
* ```
*/
@Suppress("ktlint:standard:property-naming")
internal suspend fun deserializeJsonCredentials(deserializer: Deserializer): JsonCredentialsResponse {
internal fun deserializeJsonCredentials(deserializer: Deserializer): JsonCredentialsResponse {
val CODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Code"))
val ACCESS_KEY_ID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("AccessKeyId"))
val SECRET_ACCESS_KEY_ID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("SecretAccessKey"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import aws.sdk.kotlin.runtime.http.middleware.UserAgent
import aws.smithy.kotlin.runtime.client.LogMode
import aws.smithy.kotlin.runtime.client.SdkClientOption
import aws.smithy.kotlin.runtime.client.endpoints.Endpoint
import aws.smithy.kotlin.runtime.http.*
import aws.smithy.kotlin.runtime.http.HttpCall
import aws.smithy.kotlin.runtime.http.HttpStatusCode
import aws.smithy.kotlin.runtime.http.SdkHttpClient
import aws.smithy.kotlin.runtime.http.engine.DefaultHttpEngine
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngine
import aws.smithy.kotlin.runtime.http.engine.ProxySelector
import aws.smithy.kotlin.runtime.http.isSuccess
import aws.smithy.kotlin.runtime.http.operation.*
import aws.smithy.kotlin.runtime.io.Closeable
import aws.smithy.kotlin.runtime.io.closeIfCloseable
Expand Down Expand Up @@ -109,15 +112,14 @@ public class ImdsClient private constructor(builder: Builder) : InstanceMetadata
*/
public override suspend fun get(path: String): String {
val op = SdkHttpOperation.build<Unit, String> {
serializer = UnitSerializer
deserializer = object : HttpDeserialize<String> {
override suspend fun deserialize(context: ExecutionContext, call: HttpCall): String {
serializeWith = HttpSerializer.Unit
deserializeWith = object : HttpDeserializer.NonStreaming<String> {
override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): String {
val response = call.response
if (response.status.isSuccess()) {
val payload = response.body.readAll() ?: throw EC2MetadataError(response.status.value, "no metadata payload")
return payload.decodeToString()
return payload!!.decodeToString()
} else {
throw EC2MetadataError(response.status.value, "error retrieving instance metadata: ${response.status.description}")
throw EC2MetadataError(response.status, "error retrieving instance metadata: ${response.status.description}")
}
}
}
Expand Down Expand Up @@ -232,9 +234,9 @@ public enum class EndpointMode(internal val defaultEndpoint: Endpoint) {
* @param message The error message
*/
public class EC2MetadataError(public val status: HttpStatusCode, message: String) : AwsServiceException(message) {
@Deprecated("This constructor passes HTTP status as an Int instead of as HttpStatusCode")
@Deprecated("This constructor passes HTTP status as an Int instead of as HttpStatusCode. This declaration will be removed in version 1.6.x.")
public constructor(statusCode: Int, message: String) : this(HttpStatusCode.fromValue(statusCode), message)

@Deprecated("This property is now deprecated and should be fetched from status.value")
@Deprecated("This property is now deprecated and should be fetched from status.value. This declaration will be removed in version 1.6.x.")
Comment on lines +237 to +240
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we kept these? We've removed other APIs in this PR which were only @Deprecated with no version referenced

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I feel these deprecations were added too close to the v1.5 launch and it'd be unfair to remove them too quickly.

public val statusCode: Int = status.value
}
6 changes: 0 additions & 6 deletions aws-runtime/aws-endpoint/api/aws-endpoint.api
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ public final class aws/sdk/kotlin/runtime/endpoint/functions/Partition {

public final class aws/sdk/kotlin/runtime/endpoint/functions/PartitionConfig {
public fun <init> ()V
public fun <init> (Ljava/lang/String;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;)V
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
public final fun component1 ()Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import aws.sdk.kotlin.runtime.InternalSdkApi
import aws.smithy.kotlin.runtime.client.endpoints.functions.isValidHostLabel
import aws.smithy.kotlin.runtime.net.isIpv4
import aws.smithy.kotlin.runtime.net.isIpv6
import kotlin.jvm.JvmOverloads

// the number of top-level components an arn contains (separated by colons)
private const val ARN_COMPONENT_COUNT = 6
Expand Down Expand Up @@ -70,23 +69,6 @@ public data class PartitionConfig(
public val supportsDualStack: Boolean? = null,
public val implicitGlobalRegion: String? = null,
) {
@Deprecated("This constructor does not support implicitGlobalRegion") // but is added for backwards compatibility
@JvmOverloads
public constructor (
name: String? = null,
dnsSuffix: String? = null,
dualStackDnsSuffix: String? = null,
supportsFIPS: Boolean? = null,
supportsDualStack: Boolean? = null,
) : this(
name,
dnsSuffix,
dualStackDnsSuffix,
supportsFIPS,
supportsDualStack,
null,
)

public fun mergeWith(other: PartitionConfig): PartitionConfig =
PartitionConfig(
other.name ?: name,
Expand Down
23 changes: 0 additions & 23 deletions aws-runtime/aws-http/api/aws-http.api
Original file line number Diff line number Diff line change
Expand Up @@ -168,29 +168,6 @@ public final class aws/sdk/kotlin/runtime/http/interceptors/IgnoreCompositeFlexi
public fun ignoreChecksum (Ljava/lang/String;Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;)Z
}

public final class aws/sdk/kotlin/runtime/http/interceptors/UnsupportedSigningAlgorithmInterceptor : aws/smithy/kotlin/runtime/client/Interceptor {
public fun <init> ()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;
public fun modifyBeforeDeserialization (Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun modifyBeforeRetryLoop (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun modifyBeforeSerialization (Laws/smithy/kotlin/runtime/client/RequestInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun modifyBeforeSigning (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun modifyBeforeTransmit (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun readAfterAttempt (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;)V
public fun readAfterDeserialization (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;)V
public fun readAfterExecution (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;)V
public fun readAfterSerialization (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
public fun readAfterSigning (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
public fun readAfterTransmit (Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;)V
public fun readBeforeAttempt (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
public fun readBeforeDeserialization (Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;)V
public fun readBeforeExecution (Laws/smithy/kotlin/runtime/client/RequestInterceptorContext;)V
public fun readBeforeSerialization (Laws/smithy/kotlin/runtime/client/RequestInterceptorContext;)V
public fun readBeforeSigning (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
public fun readBeforeTransmit (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
}

public final class aws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric : java/lang/Enum, aws/smithy/kotlin/runtime/businessmetrics/BusinessMetric {
public static final field DDB_MAPPER Laws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric;
public static final field S3_EXPRESS_BUCKET Laws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class AwsRetryHeaderMiddlewareTest {
fun testItSetsRetryHeaders() = runTest {
// see retry-header SEP
val op = SdkHttpOperation.build<Unit, Unit> {
serializer = UnitSerializer
deserializer = UnitDeserializer
serializeWith = HttpSerializer.Unit
deserializeWith = HttpDeserializer.Unit
operationName = "TestOperation"
serviceName = "TestService"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import kotlin.test.assertFalse
class RecursionDetectionTest {
private class TraceHeaderSerializer(
private val traceHeader: String,
) : HttpSerialize<Unit> {
override suspend fun serialize(context: ExecutionContext, input: Unit): HttpRequestBuilder {
) : HttpSerializer.NonStreaming<Unit> {
override fun serialize(context: ExecutionContext, input: Unit): HttpRequestBuilder {
val builder = HttpRequestBuilder()
builder.headers[HEADER_TRACE_ID] = traceHeader
return builder
Expand All @@ -37,8 +37,13 @@ class RecursionDetectionTest {
expectedTraceHeader: String?,
) {
val op = SdkHttpOperation.build<Unit, HttpResponse> {
serializer = if (existingTraceHeader != null) TraceHeaderSerializer(existingTraceHeader) else UnitSerializer
deserializer = IdentityDeserializer
serializeWith = if (existingTraceHeader != null) {
TraceHeaderSerializer(existingTraceHeader)
} else {
HttpSerializer.Unit
}

deserializeWith = HttpDeserializer.Identity
operationName = "testOperation"
serviceName = "TestService"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class UserAgentTest {

private fun initializeOp(platformProvider: PlatformProvider = TestPlatformProvider()) =
SdkHttpOperation.build<Unit, HttpResponse> {
serializer = UnitSerializer
deserializer = IdentityDeserializer
serializeWith = HttpSerializer.Unit
deserializeWith = HttpDeserializer.Identity
operationName = "testOperation"
serviceName = "TestService"
}.apply {
Expand Down
Loading