JuliaCloud / AWS.jl

Julia interface to AWS
MIT License
160 stars 62 forks source link

get_thing_shadow appears to discard the shadow name #672

Open Octogonapus opened 6 months ago

Octogonapus commented 6 months ago

My code:

@service IOT_Data_Plane
IOT_Data_Plane.get_thing_shadow("thingName", Dict("name" => "shadowName"))

Throws this error:

HTTP.Exceptions.StatusError(404, "GET", "/things/thingName/shadow", ...

According to the AWS documentation and the AWS.jl documentation the ?name=shadowName parameter should be included, but is not as we can see in that HTTP error.

AWS.jl v1.90.4

I can work on fixing this but I am not sure where to look in the parameter handling code.

ericphanson commented 6 months ago

I believe it is here that the request is built: https://github.com/JuliaCloud/AWS.jl/blob/5ebf8caa636dc8f2d051aea70a69adc7d146cad4/src/AWS.jl#L402. For a json service I think all the args are passed in the body as opposed to as a queryparam.

IIUC AWS.jl autogenerates the definitions from XML files so maybe we need to add support for some JSON services having some arguments as query parameters.

maybe @mattBrzezinski could say more

mattBrzezinski commented 6 months ago

We generate based off of aws-sdk-js JSON definitions, here's where we look at the GetThingShadowRequest, it looks like this does specify the queryparam so it should be going into the correct position?

To quickly unblock yourself, I think you could do something like...

function getShadowThing(thingName, shadowName; awsConfig=global_aws_config())
  return AWS.iot_data_plane("GET", "things/${thingName}/shadow?name=${shadowName}"; aws_config=aws_config)
end

Basically just write the "low-level" request yourself and send that over

ericphanson commented 6 months ago

That's a helpful pointer. What I'm getting at though is we don't have querystring location in the generation code, AFIACT. E.g. if I search for querystring I don't find anything, location just finds these two:

https://github.com/JuliaCloud/AWS.jl/blob/5ebf8caa636dc8f2d051aea70a69adc7d146cad4/src/api_generation/high_level.jl#L127-L128

So I think the generation code has be updated to handle the querystring location, as well as the RestJSONService code to actually use it.

Does that seem accurate?

mattBrzezinski commented 6 months ago

That's a helpful pointer. What I'm getting at though is we don't have querystring location in the generation code, AFIACT. E.g. if I search for querystring I don't find anything, location just finds these two:

https://github.com/JuliaCloud/AWS.jl/blob/5ebf8caa636dc8f2d051aea70a69adc7d146cad4/src/api_generation/high_level.jl#L127-L128

So I think the generation code has be updated to handle the querystring location, as well as the RestJSONService code to actually use it.

Does that seem accurate?

Aha! I thought we already had this, but I guess not. This is how we would fix it in that case, do a similar filter() call on locations for querystring and do something like,

querystring_params = "?" * join(params, "&")

And append that to the URL