@@ -9,12 +9,19 @@ import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
99import software.amazon.smithy.kotlin.codegen.integration.SectionWriterBinding
1010import software.amazon.smithy.kotlin.codegen.model.hasTrait
1111import software.amazon.smithy.kotlin.codegen.rendering.smoketests.*
12+ import software.amazon.smithy.kotlin.codegen.rendering.smoketests.Param.ParamName
13+ import software.amazon.smithy.kotlin.codegen.rendering.smoketests.Param.ParamShape
14+ import software.amazon.smithy.kotlin.codegen.rendering.smoketests.Param.Parameter
15+ import software.amazon.smithy.kotlin.codegen.rendering.util.format
16+ import software.amazon.smithy.kotlin.codegen.utils.dq
1217import software.amazon.smithy.kotlin.codegen.utils.topDownOperations
1318import software.amazon.smithy.model.Model
19+ import software.amazon.smithy.model.node.*
20+ import software.amazon.smithy.model.shapes.*
1421import software.amazon.smithy.smoketests.traits.SmokeTestsTrait
1522
1623/* *
17- * Adds support for AWS specific client config during smoke tests code generation.
24+ * Adds support for AWS specific client config and custom code generation to smoke tests .
1825 */
1926class SmokeTestAwsVendorParamsIntegration : KotlinIntegration {
2027 override fun enabledForService (model : Model , settings : KotlinSettings ): Boolean =
@@ -29,9 +36,80 @@ class SmokeTestAwsVendorParamsIntegration : KotlinIntegration {
2936 regionSectionWriters +
3037 useAccelerateSectionWriters +
3138 useMultiRegionAccessPointsSectionWriters +
32- useGlobalEndpointSectionWriters
39+ useGlobalEndpointSectionWriters +
40+ listOf (parameterGenerator) // TODO: Convert this so that all can be placed here in this list
3341}
3442
43+ /* *
44+ * TODO: Write
45+ */
46+ private val parameterGenerator =
47+ SectionWriterBinding (Param ) { writer, _ ->
48+ val paramName = writer.getContextValue(ParamName )
49+ val parameter = writer.getContextValue(Parameter )
50+ val shape = writer.getContextValue(ParamShape )
51+
52+ writer.write(" #L" , coerceParameterToModeledShape(parameter, shape, paramName))
53+ }
54+
55+ fun coerceParameterToModeledShape (param : Node , customShape : Shape ? , name : String ): String {
56+ if (customShape == null ) return param.format()
57+
58+ // TODO: Fill this out
59+
60+ // TODO: Which ones need customization and which ones can I delegate down to `format` ?
61+ when (customShape) {
62+ is BigDecimalShape -> {
63+ if (param !is NumberNode )
64+ }
65+ is BigIntegerShape -> {}
66+ is BlobShape -> {}
67+ is BooleanShape -> {}
68+ is ByteShape -> {}
69+ is ListShape -> {}
70+ is CollectionShape -> {}
71+ is DocumentShape -> {}
72+ is DoubleShape -> {}
73+ is EntityShape -> {} // ??
74+ is EnumShape -> {}
75+ is FloatShape -> {}
76+ is IntEnumShape -> {}
77+ is IntegerShape -> {}
78+ is LongShape -> {}
79+ is MapShape -> {}
80+ is MemberShape -> {}
81+ is NumberShape -> {}
82+ is SetShape -> {}
83+ is ShortShape -> {}
84+ is StringShape -> {}
85+ is TimestampShape -> {}
86+ is UnionShape -> {}
87+ else -> throw Exception (" Code generation unsupported for smoke test operation parameter '$name ' of type '$customShape '." )
88+ }
89+
90+ // TODO: Remove. This is here for reference only.
91+ when (param) {
92+ is NullNode -> " null"
93+ is StringNode -> value.dq()
94+ is BooleanNode -> value.toString()
95+ is NumberNode -> value.toString()
96+ is ArrayNode -> elements.joinToString(" ," , " listOf(" , " )" ) { element ->
97+ element.format()
98+ }
99+ is ObjectNode -> stringMap.entries.joinToString(" , " , " mapOf(" , " )" ) { (key, value) ->
100+ " ${key.dq()} to ${value.format()} "
101+ }
102+ else -> throw Exception (" Unexpected node type: $this " )
103+ }
104+
105+ return " "
106+ }
107+
108+
109+
110+
111+
112+
35113/* *
36114 * Uses the AWS Kotlin SDK specific name for the dual stack config option i.e. `useDualstack` -> `useDualStack`
37115 */
0 commit comments