Skip to content

Commit

Permalink
Polishing: visibility modifiers and legibility
Browse files Browse the repository at this point in the history
  • Loading branch information
0marperez committed Jun 29, 2023
1 parent f3ee41e commit bc422b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import software.amazon.smithy.model.transform.ModelTransformer
class ChangeResourceRecordSetsUnmarshallingIntegration : KotlinIntegration {
override val sectionWriters: List<SectionWriterBinding> = listOf(
SectionWriterBinding(AwsHttpBindingProtocolGenerator.ProtocolErrorDeserialization) { writer, originalValue ->
val lines = originalValue?.split("\n")
writer.write("#L\naws.sdk.kotlin.services.route53.internal.parseCustomXmlErrorResponse(payload) ?: #L", lines?.get(0) ?: "", lines?.get(1) ?: "")
requireNotNull(originalValue) { "Unexpectedly empty original value" }
val (nullCheckLine, parseLine) = originalValue.split("\n", limit = 2)
writer.write("#L", nullCheckLine)
writer.write("aws.sdk.kotlin.services.route53.internal.parseCustomXmlErrorResponse(payload) ?: #L", parseLine)
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public suspend fun parseCustomXmlErrorResponse(payload: ByteArray): ErrorDetails
return ErrorDetails(details.code, details.message, details.requestId)
}

internal object InvalidChangeBatchDeserializer {
private object InvalidChangeBatchDeserializer {
private val MESSAGES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, XmlSerialName("Messages"))
private val REQUESTID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, XmlSerialName("RequestId"))
private val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
Expand Down Expand Up @@ -49,7 +49,7 @@ internal object InvalidChangeBatchDeserializer {
}
}

internal object InvalidChangeBatchMessageDeserializer {
private object InvalidChangeBatchMessageDeserializer {
private val MESSAGE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, XmlSerialName("Message"))
private val CODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, XmlSerialName("Code"))
private val REQUESTID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, XmlSerialName("RequestId"))
Expand Down Expand Up @@ -83,26 +83,3 @@ internal object InvalidChangeBatchMessageDeserializer {
}
}
}

// XML Error response parser from RestXMLErrorDeserializer
internal interface RestXmlErrorDetails {
val requestId: String?
val code: String?
val message: String?
}

// Models "ErrorResponse" type in https://awslabs.github.io/smithy/1.0/spec/aws/aws-restxml-protocol.html#operation-error-serialization
internal data class XmlErrorResponse(
val error: XmlError?,
override val requestId: String? = error?.requestId,
) : RestXmlErrorDetails {
override val code: String? = error?.code
override val message: String? = error?.message
}

// Models "Error" type in https://awslabs.github.io/smithy/1.0/spec/aws/aws-restxml-protocol.html#operation-error-serialization
internal data class XmlError(
override val requestId: String?,
override val code: String?,
override val message: String?,
) : RestXmlErrorDetails

0 comments on commit bc422b3

Please sign in to comment.