britzl / aws-sdk-lua

Auto generated AWS SDK for Lua
Apache License 2.0
39 stars 10 forks source link

Add support for protocol type "query" #2

Open britzl opened 5 years ago

britzl commented 5 years ago

https://github.com/britzl/aws-sdk-lua/blob/master/aws-sdk/core/request_handlers/query.lua

SirLynix commented 5 years ago

I tried to implement this for SNS and managed to have it working (at least for the request part, handling the response require XML).

I had to remove the content type header (by returning nil in content_type.lua) and add the action to the query (the only way I managed to do that is by changing aws-sdk/sns.lua).

Do you have a better idea on how to fix this (without changing the generator)?

britzl commented 5 years ago

Hi! I'm happy to work with you on this. I've created a branch where I've started working on this:

https://github.com/britzl/aws-sdk-lua/tree/query_support

Two changes I've made:

Both of the above changes required a small change to the Mustache template.

I haven't tried any of this yet. Some questions:

SirLynix commented 5 years ago

I found this about query requests: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Query-Requests.html

It looks like some requests may be GET request as well, although it doesn't look very common in AWS.

It looks like it doesn't expect any POST data actually, in my tests I just didn't send anything. As for v4 signers, I guess it isn't much different from json protocol (as I did manage to make requests using a slightly modified version of the json protocol file for queries).

Your changes look pretty good in my opinion. It's really nice from you to still work on this.

britzl commented 5 years ago

I'll try to find some time to configure and test an AWS service that uses query requests. You're using SNS right?

For XML parsing I think xml2lua will do just fine: https://github.com/manoelcampos/xml2lua