Loading codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/AwsQuery.kt +18 −9 Original line number Diff line number Diff line Loading @@ -5,9 +5,11 @@ package software.amazon.smithy.rust.codegen.smithy.protocols import software.amazon.smithy.aws.traits.protocols.AwsQueryErrorTrait import software.amazon.smithy.model.Model import software.amazon.smithy.model.pattern.UriPattern import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ToShapeId import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.traits.TimestampFormatTrait import software.amazon.smithy.rust.codegen.rustlang.CargoDependency Loading @@ -24,6 +26,7 @@ import software.amazon.smithy.rust.codegen.smithy.protocols.serialize.AwsQuerySe import software.amazon.smithy.rust.codegen.smithy.protocols.serialize.StructuredDataSerializerGenerator import software.amazon.smithy.rust.codegen.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.smithy.transformers.RemoveEventStreamOperations import software.amazon.smithy.rust.codegen.util.getTrait class AwsQueryFactory : ProtocolGeneratorFactory<HttpBoundProtocolGenerator> { override fun buildProtocolGenerator(protocolConfig: ProtocolConfig): HttpBoundProtocolGenerator = Loading @@ -43,18 +46,24 @@ class AwsQueryFactory : ProtocolGeneratorFactory<HttpBoundProtocolGenerator> { } } class AwsQueryProtocol(private val protocolConfig: ProtocolConfig) : Protocol { private val runtimeConfig = protocolConfig.runtimeConfig private val awsQueryErrors: RuntimeType = RuntimeType.wrappedXmlErrors(runtimeConfig) override val httpBindingResolver: HttpBindingResolver = StaticHttpBindingResolver( protocolConfig.model, HttpTrait.builder() private val awsQueryHttpTrait = HttpTrait.builder() .code(200) .method("POST") .uri(UriPattern.parse("/")) .build(), "application/x-www-form-urlencoded" ) .build() class AwsQueryBindingResolver(private val model: Model) : StaticHttpBindingResolver(model, awsQueryHttpTrait, "application/x-www-form-urlencoded") { override fun errorCode(errorShape: ToShapeId): String { val error = model.expectShape(errorShape.toShapeId()) return error.getTrait<AwsQueryErrorTrait>()?.code ?: errorShape.toShapeId().name } } class AwsQueryProtocol(private val protocolConfig: ProtocolConfig) : Protocol { private val runtimeConfig = protocolConfig.runtimeConfig private val awsQueryErrors: RuntimeType = RuntimeType.wrappedXmlErrors(runtimeConfig) override val httpBindingResolver: HttpBindingResolver = AwsQueryBindingResolver(protocolConfig.model) override val defaultTimestampFormat: TimestampFormatTrait.Format = TimestampFormatTrait.Format.DATE_TIME Loading codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/HttpBindingResolver.kt +3 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ interface HttpBindingResolver { */ fun errorResponseBindings(errorShape: ToShapeId): List<HttpBindingDescriptor> fun errorCode(errorShape: ToShapeId): String = errorShape.toShapeId().name /** * Returns a list of member shapes bound to a given request [location] for a given [operationShape] */ Loading Loading @@ -122,7 +124,7 @@ class HttpTraitHttpBindingResolver( * Takes an [HttpTrait] value and content type, and provides bindings based on those. * All members will end up being document members. */ class StaticHttpBindingResolver( open class StaticHttpBindingResolver( private val model: Model, private val httpTrait: HttpTrait, private val requestContentType: String, Loading codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/HttpBoundProtocolGenerator.kt +1 −1 Original line number Diff line number Diff line Loading @@ -296,7 +296,7 @@ class HttpBoundProtocolGenerator( val errorShape = model.expectShape(error, StructureShape::class.java) val variantName = symbolProvider.toSymbol(model.expectShape(error)).name withBlock( "${error.name.dq()} => #1T { meta: generic, kind: #1TKind::$variantName({", "${httpBindingResolver.errorCode(errorShape).dq()} => #1T { meta: generic, kind: #1TKind::$variantName({", "})},", errorSymbol ) { Loading gradle.properties +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ kotlin.code.style=official # codegen smithyVersion=1.7.2 smithyVersion=1.8.0 # kotlin kotlinVersion=1.4.21 Loading Loading
codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/AwsQuery.kt +18 −9 Original line number Diff line number Diff line Loading @@ -5,9 +5,11 @@ package software.amazon.smithy.rust.codegen.smithy.protocols import software.amazon.smithy.aws.traits.protocols.AwsQueryErrorTrait import software.amazon.smithy.model.Model import software.amazon.smithy.model.pattern.UriPattern import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ToShapeId import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.traits.TimestampFormatTrait import software.amazon.smithy.rust.codegen.rustlang.CargoDependency Loading @@ -24,6 +26,7 @@ import software.amazon.smithy.rust.codegen.smithy.protocols.serialize.AwsQuerySe import software.amazon.smithy.rust.codegen.smithy.protocols.serialize.StructuredDataSerializerGenerator import software.amazon.smithy.rust.codegen.smithy.transformers.OperationNormalizer import software.amazon.smithy.rust.codegen.smithy.transformers.RemoveEventStreamOperations import software.amazon.smithy.rust.codegen.util.getTrait class AwsQueryFactory : ProtocolGeneratorFactory<HttpBoundProtocolGenerator> { override fun buildProtocolGenerator(protocolConfig: ProtocolConfig): HttpBoundProtocolGenerator = Loading @@ -43,18 +46,24 @@ class AwsQueryFactory : ProtocolGeneratorFactory<HttpBoundProtocolGenerator> { } } class AwsQueryProtocol(private val protocolConfig: ProtocolConfig) : Protocol { private val runtimeConfig = protocolConfig.runtimeConfig private val awsQueryErrors: RuntimeType = RuntimeType.wrappedXmlErrors(runtimeConfig) override val httpBindingResolver: HttpBindingResolver = StaticHttpBindingResolver( protocolConfig.model, HttpTrait.builder() private val awsQueryHttpTrait = HttpTrait.builder() .code(200) .method("POST") .uri(UriPattern.parse("/")) .build(), "application/x-www-form-urlencoded" ) .build() class AwsQueryBindingResolver(private val model: Model) : StaticHttpBindingResolver(model, awsQueryHttpTrait, "application/x-www-form-urlencoded") { override fun errorCode(errorShape: ToShapeId): String { val error = model.expectShape(errorShape.toShapeId()) return error.getTrait<AwsQueryErrorTrait>()?.code ?: errorShape.toShapeId().name } } class AwsQueryProtocol(private val protocolConfig: ProtocolConfig) : Protocol { private val runtimeConfig = protocolConfig.runtimeConfig private val awsQueryErrors: RuntimeType = RuntimeType.wrappedXmlErrors(runtimeConfig) override val httpBindingResolver: HttpBindingResolver = AwsQueryBindingResolver(protocolConfig.model) override val defaultTimestampFormat: TimestampFormatTrait.Format = TimestampFormatTrait.Format.DATE_TIME Loading
codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/HttpBindingResolver.kt +3 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ interface HttpBindingResolver { */ fun errorResponseBindings(errorShape: ToShapeId): List<HttpBindingDescriptor> fun errorCode(errorShape: ToShapeId): String = errorShape.toShapeId().name /** * Returns a list of member shapes bound to a given request [location] for a given [operationShape] */ Loading Loading @@ -122,7 +124,7 @@ class HttpTraitHttpBindingResolver( * Takes an [HttpTrait] value and content type, and provides bindings based on those. * All members will end up being document members. */ class StaticHttpBindingResolver( open class StaticHttpBindingResolver( private val model: Model, private val httpTrait: HttpTrait, private val requestContentType: String, Loading
codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/HttpBoundProtocolGenerator.kt +1 −1 Original line number Diff line number Diff line Loading @@ -296,7 +296,7 @@ class HttpBoundProtocolGenerator( val errorShape = model.expectShape(error, StructureShape::class.java) val variantName = symbolProvider.toSymbol(model.expectShape(error)).name withBlock( "${error.name.dq()} => #1T { meta: generic, kind: #1TKind::$variantName({", "${httpBindingResolver.errorCode(errorShape).dq()} => #1T { meta: generic, kind: #1TKind::$variantName({", "})},", errorSymbol ) { Loading
gradle.properties +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ kotlin.code.style=official # codegen smithyVersion=1.7.2 smithyVersion=1.8.0 # kotlin kotlinVersion=1.4.21 Loading