cognitect-labs / aws-api

AWS, data driven

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mtwomey opened this issue · comments

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.

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

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?

Checking back if anyone has had a look?

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.

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.

Found the issue.

The problem was that we interpreted #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.

Fixed in aws-api-0.5.561

Awesome! Thanks so much @dchelimsky !!!