55package aws.sdk.kotlin.codegen.customization.sqs
66
77import aws.sdk.kotlin.codegen.ServiceClientCompanionObjectWriter
8+ import aws.sdk.kotlin.codegen.sdkId
89import software.amazon.smithy.kotlin.codegen.KotlinSettings
910import software.amazon.smithy.kotlin.codegen.core.CodegenContext
1011import software.amazon.smithy.kotlin.codegen.core.KotlinWriter
@@ -17,6 +18,7 @@ import software.amazon.smithy.kotlin.codegen.model.expectShape
1718import software.amazon.smithy.kotlin.codegen.rendering.protocol.ProtocolGenerator
1819import software.amazon.smithy.kotlin.codegen.rendering.protocol.ProtocolMiddleware
1920import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigProperty
21+ import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigPropertyType
2022import software.amazon.smithy.model.Model
2123import software.amazon.smithy.model.shapes.OperationShape
2224import software.amazon.smithy.model.shapes.ServiceShape
@@ -26,38 +28,61 @@ import software.amazon.smithy.model.shapes.ServiceShape
2628 */
2729class SqsMd5ChecksumValidationIntegration : KotlinIntegration {
2830 override fun enabledForService (model : Model , settings : KotlinSettings ): Boolean =
29- model.expectShape<ServiceShape >(settings.service).isSqs
31+ model.expectShape<ServiceShape >(settings.service).sdkId.lowercase() == " sqs "
3032
3133 companion object {
3234 val ValidationEnabledProp : ConfigProperty = ConfigProperty {
3335 name = " checksumValidationEnabled"
3436 symbol = buildSymbol {
3537 name = " ValidationEnabled"
3638 namespace = " aws.sdk.kotlin.services.sqs.internal"
39+ nullable = false
3740 }
41+ propertyType = ConfigPropertyType .Custom (
42+ render = { prop, writer ->
43+ writer.write(" public val #1L: #2T = builder.#1L ?: #2T.NEVER" , prop.propertyName, prop.symbol)
44+ },
45+ renderBuilder = { prop, writer ->
46+ prop.documentation?.let (writer::dokka)
47+ writer.write(" public var #L: #T? = null" , prop.propertyName, prop.symbol)
48+ writer.write(" " )
49+ },
50+ )
3851 documentation = """
3952 Specifies when MD5 checksum validation should be performed for SQS messages. This controls the automatic
4053 calculation and validation of checksums during message operations.
4154
4255 Valid values:
43- - `ALWAYS` (default) - Checksums are calculated and validated for both sending and receiving operations
56+ - `ALWAYS` - Checksums are calculated and validated for both sending and receiving operations
4457 (SendMessage, SendMessageBatch, and ReceiveMessage)
4558 - `WHEN_SENDING` - Checksums are only calculated and validated during send operations
4659 (SendMessage and SendMessageBatch)
4760 - `WHEN_RECEIVING` - Checksums are only calculated and validated during receive operations
4861 (ReceiveMessage)
49- - `NEVER` - No checksum calculation or validation is performed
62+ - `NEVER` (default) - No checksum calculation or validation is performed
5063 """ .trimIndent()
64+ // TODO: MD5 checksum validation is temporarily disabled. Change default to ALWAYS in v1.5
5165 }
5266
5367 private val validationScope = buildSymbol {
5468 name = " ValidationScope"
5569 namespace = " aws.sdk.kotlin.services.sqs.internal"
70+ nullable = false
5671 }
5772
5873 val ValidationScopeProp : ConfigProperty = ConfigProperty {
5974 name = " checksumValidationScopes"
60- symbol = KotlinTypes .Collections .set(validationScope, default = " emptySet()" )
75+ symbol = KotlinTypes .Collections .set(validationScope)
76+ propertyType = ConfigPropertyType .Custom (
77+ render = { prop, writer ->
78+ writer.write(" public val #1L: #2T = builder.#1L ?: #3T.entries.toSet()" , prop.propertyName, prop.symbol, validationScope)
79+ },
80+ renderBuilder = { prop, writer ->
81+ prop.documentation?.let (writer::dokka)
82+ writer.write(" public var #L: #T? = null" , prop.propertyName, prop.symbol)
83+ writer.write(" " )
84+ },
85+ )
6186 documentation = """
6287 Specifies which parts of an SQS message should undergo MD5 checksum validation. This configuration
6388 accepts a set of validation scopes that determine which message components to validate.
@@ -69,7 +94,7 @@ class SqsMd5ChecksumValidationIntegration : KotlinIntegration {
6994 system attributes during message receipt)
7095 - `MESSAGE_BODY` - Validates checksums for the message body
7196
72- Default: All three scopes (MESSAGE_ATTRIBUTES, MESSAGE_SYSTEM_ATTRIBUTES, MESSAGE_BODY)
97+ Default: All three scopes (` MESSAGE_ATTRIBUTES`, ` MESSAGE_SYSTEM_ATTRIBUTES`, ` MESSAGE_BODY` )
7398 """ .trimIndent()
7499 }
75100 }
0 commit comments