From 1d989f31b0248f4d800d6b07bdab20bde40b59c5 Mon Sep 17 00:00:00 2001 From: Luc Talatinian <102624213+lucix-aws@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:40:33 -0500 Subject: [PATCH] send opt-in query-compatible header where applicable (#2891) --- .../ccc0add5b568413fb8cf09c94a4c7fa7.json | 8 +++++++ .../smithy/aws/go/codegen/AwsJsonRpc1_0.java | 8 +++++++ service/sqs/serializers.go | 23 +++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 .changelog/ccc0add5b568413fb8cf09c94a4c7fa7.json diff --git a/.changelog/ccc0add5b568413fb8cf09c94a4c7fa7.json b/.changelog/ccc0add5b568413fb8cf09c94a4c7fa7.json new file mode 100644 index 00000000000..36717232614 --- /dev/null +++ b/.changelog/ccc0add5b568413fb8cf09c94a4c7fa7.json @@ -0,0 +1,8 @@ +{ + "id": "ccc0add5-b568-413f-b8cf-09c94a4c7fa7", + "type": "feature", + "description": "Send opt-in query-compatible header for applicable services.", + "modules": [ + "service/sqs" + ] +} \ No newline at end of file diff --git a/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/AwsJsonRpc1_0.java b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/AwsJsonRpc1_0.java index a2386b35ebc..a7839074561 100644 --- a/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/AwsJsonRpc1_0.java +++ b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/AwsJsonRpc1_0.java @@ -61,6 +61,14 @@ protected Set generateErrorShapes( } } + @Override + protected void writeDefaultHeaders(GenerationContext context, OperationShape operation, GoWriter writer) { + super.writeDefaultHeaders(context, operation, writer); + if (isAwsQueryCompatibleTraitFound(context)) { + writer.write("httpBindingEncoder.SetHeader(\"X-Amzn-Query-Mode\").Boolean(true)"); + } + } + @Override protected void deserializeError(GenerationContext context, StructureShape shape) { GoWriter writer = context.getWriter().get(); diff --git a/service/sqs/serializers.go b/service/sqs/serializers.go index 14dd99c39da..db8bbee96bb 100644 --- a/service/sqs/serializers.go +++ b/service/sqs/serializers.go @@ -57,6 +57,7 @@ func (m *awsAwsjson10_serializeOpAddPermission) HandleSerialize(ctx context.Cont } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.AddPermission") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentAddPermissionInput(input, jsonEncoder.Value); err != nil { @@ -118,6 +119,7 @@ func (m *awsAwsjson10_serializeOpCancelMessageMoveTask) HandleSerialize(ctx cont } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.CancelMessageMoveTask") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentCancelMessageMoveTaskInput(input, jsonEncoder.Value); err != nil { @@ -179,6 +181,7 @@ func (m *awsAwsjson10_serializeOpChangeMessageVisibility) HandleSerialize(ctx co } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.ChangeMessageVisibility") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentChangeMessageVisibilityInput(input, jsonEncoder.Value); err != nil { @@ -240,6 +243,7 @@ func (m *awsAwsjson10_serializeOpChangeMessageVisibilityBatch) HandleSerialize(c } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.ChangeMessageVisibilityBatch") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentChangeMessageVisibilityBatchInput(input, jsonEncoder.Value); err != nil { @@ -301,6 +305,7 @@ func (m *awsAwsjson10_serializeOpCreateQueue) HandleSerialize(ctx context.Contex } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.CreateQueue") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentCreateQueueInput(input, jsonEncoder.Value); err != nil { @@ -362,6 +367,7 @@ func (m *awsAwsjson10_serializeOpDeleteMessage) HandleSerialize(ctx context.Cont } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.DeleteMessage") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentDeleteMessageInput(input, jsonEncoder.Value); err != nil { @@ -423,6 +429,7 @@ func (m *awsAwsjson10_serializeOpDeleteMessageBatch) HandleSerialize(ctx context } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.DeleteMessageBatch") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentDeleteMessageBatchInput(input, jsonEncoder.Value); err != nil { @@ -484,6 +491,7 @@ func (m *awsAwsjson10_serializeOpDeleteQueue) HandleSerialize(ctx context.Contex } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.DeleteQueue") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentDeleteQueueInput(input, jsonEncoder.Value); err != nil { @@ -545,6 +553,7 @@ func (m *awsAwsjson10_serializeOpGetQueueAttributes) HandleSerialize(ctx context } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.GetQueueAttributes") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentGetQueueAttributesInput(input, jsonEncoder.Value); err != nil { @@ -606,6 +615,7 @@ func (m *awsAwsjson10_serializeOpGetQueueUrl) HandleSerialize(ctx context.Contex } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.GetQueueUrl") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentGetQueueUrlInput(input, jsonEncoder.Value); err != nil { @@ -667,6 +677,7 @@ func (m *awsAwsjson10_serializeOpListDeadLetterSourceQueues) HandleSerialize(ctx } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.ListDeadLetterSourceQueues") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentListDeadLetterSourceQueuesInput(input, jsonEncoder.Value); err != nil { @@ -728,6 +739,7 @@ func (m *awsAwsjson10_serializeOpListMessageMoveTasks) HandleSerialize(ctx conte } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.ListMessageMoveTasks") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentListMessageMoveTasksInput(input, jsonEncoder.Value); err != nil { @@ -789,6 +801,7 @@ func (m *awsAwsjson10_serializeOpListQueues) HandleSerialize(ctx context.Context } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.ListQueues") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentListQueuesInput(input, jsonEncoder.Value); err != nil { @@ -850,6 +863,7 @@ func (m *awsAwsjson10_serializeOpListQueueTags) HandleSerialize(ctx context.Cont } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.ListQueueTags") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentListQueueTagsInput(input, jsonEncoder.Value); err != nil { @@ -911,6 +925,7 @@ func (m *awsAwsjson10_serializeOpPurgeQueue) HandleSerialize(ctx context.Context } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.PurgeQueue") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentPurgeQueueInput(input, jsonEncoder.Value); err != nil { @@ -972,6 +987,7 @@ func (m *awsAwsjson10_serializeOpReceiveMessage) HandleSerialize(ctx context.Con } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.ReceiveMessage") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentReceiveMessageInput(input, jsonEncoder.Value); err != nil { @@ -1033,6 +1049,7 @@ func (m *awsAwsjson10_serializeOpRemovePermission) HandleSerialize(ctx context.C } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.RemovePermission") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentRemovePermissionInput(input, jsonEncoder.Value); err != nil { @@ -1094,6 +1111,7 @@ func (m *awsAwsjson10_serializeOpSendMessage) HandleSerialize(ctx context.Contex } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.SendMessage") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentSendMessageInput(input, jsonEncoder.Value); err != nil { @@ -1155,6 +1173,7 @@ func (m *awsAwsjson10_serializeOpSendMessageBatch) HandleSerialize(ctx context.C } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.SendMessageBatch") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentSendMessageBatchInput(input, jsonEncoder.Value); err != nil { @@ -1216,6 +1235,7 @@ func (m *awsAwsjson10_serializeOpSetQueueAttributes) HandleSerialize(ctx context } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.SetQueueAttributes") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentSetQueueAttributesInput(input, jsonEncoder.Value); err != nil { @@ -1277,6 +1297,7 @@ func (m *awsAwsjson10_serializeOpStartMessageMoveTask) HandleSerialize(ctx conte } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.StartMessageMoveTask") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentStartMessageMoveTaskInput(input, jsonEncoder.Value); err != nil { @@ -1338,6 +1359,7 @@ func (m *awsAwsjson10_serializeOpTagQueue) HandleSerialize(ctx context.Context, } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.TagQueue") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentTagQueueInput(input, jsonEncoder.Value); err != nil { @@ -1399,6 +1421,7 @@ func (m *awsAwsjson10_serializeOpUntagQueue) HandleSerialize(ctx context.Context } httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") httpBindingEncoder.SetHeader("X-Amz-Target").String("AmazonSQS.UntagQueue") + httpBindingEncoder.SetHeader("X-Amzn-Query-Mode").Boolean(true) jsonEncoder := smithyjson.NewEncoder() if err := awsAwsjson10_serializeOpDocumentUntagQueueInput(input, jsonEncoder.Value); err != nil {