cognitect-labs / aws-api

AWS, data driven
Apache License 2.0
724 stars 100 forks source link

apigateway client :embed ["methods"] doesn't work #206

Closed mtwomey closed 2 years ago

mtwomey commented 2 years ago

When making a basic apigateway request, the :embed keyword doesn't cause the client to return the embedded values:

(def apigateway (aws/client {:api :apigateway :credentials-provider (credentials/profile-credentials-provider)}))
(aws/invoke apigateway {:op :GetResources :request {:restApiId "el0mjiybr1" :embed ["methods"]}})

Adding this parameter is supposed to enrich the returned data with method detail on each resource. The request succeeds, but only the "un-enriched" data is returned (as if the embed parameter was not used).

By comparison, this works fine with the AWS command-line client:

aws apigateway get-resources --rest-api-id=el0mjiybr1 --embed methods

Note: I believe this issue makes it impossible to retrieve api-gateway method detail using this cognitect library as this is the only way to do it.

mtwomey commented 2 years ago

A little additional investigation and I see that the request being made actually looks correct. This URI matches the AWS spec for this call. So potentially the result is not being mapped correctly?

image

mtwomey commented 2 years ago

I'm a little unclear what to do here. I could try to fix it myself, but your README.md says you don't accept pull requests. Do you actively address bugs like these on your own or am I better off just forking and maintaining my own version?

mtwomey commented 2 years ago

Checking back if anyone has had a look?

dchelimsky commented 2 years ago

Hi @mtwomey. Haven't had a chance to look at this yet. We do maintain this library, but don't have enough bandwidth to keep on top of everything. We're working on that!

At quick glance, the content-type returned from AWS is "application/hal+json", and aws-api is parsing it accordingly, but I need to look closer at what's in the original body and what aws-api is doing with it. I'll follow up as I learn things.

dchelimsky commented 2 years ago

I started to look a little deeper and the json payload AWS sends back has keys like "resource:methods" as opposed to "resourceMethods", which is what is advertised in their docs. I'll keep looking, and it may be a while, but at least there's a hint.

dchelimsky commented 2 years ago

Found the issue.

The problem was that we interpreted https://github.com/cognitect-labs/aws-api/issues/30 incorrectly and tried to solve for parsing HAL instead of recognizing that we should not be receiving HAL at all. There are no instructions for processing HAL in the service descriptions and, as it turns out, AWS will send us json that parses correctly if we ask it to (accept header).

Release with fix forthcoming.

dchelimsky commented 2 years ago

Fixed in aws-api-0.5.561

mtwomey commented 1 year ago

Awesome! Thanks so much @dchelimsky !!!