aws-clj-sdk icon indicating copy to clipboard operation
aws-clj-sdk copied to clipboard

"json" protocol v1.0

Open milt opened this issue 6 years ago • 3 comments

This PR begins to address #4 by adding support for "json" protocol apis, version 1.0 only. Confirmed working with DynamoDB and DDBStreams.

Other notable changes:

  • Gen:
    • portkey.awsgen/gen-api dispatches on protocol, then version
    • portkey.awsgen/gen-operation is a multimethod, dispatch fn looks at protocol and version if present.
    • portkey.awsgen/gen-api reports on unsupported versions.
    • portkey.awsgen/generate-files! now looks for endpoints with both the munged and unmunged name, and does not attempt to generate if they are absent, preventing a runtime NPE.
  • Client:
    • portkey.aws/*endpoint-override* is a dynamic var that can be used to override the endpoint uri for local testing, etc.
    • portkey.aws/params-toquerystring no longer puts a ? on URIs if there are no query params.
    • portkey.aws/-json-call provides request processing for json v1.0 apis with the "X-AMZ-Target" header.
    • portkey.aws/-json-call finds exceptions that only exist in the body of the response
    • POSSIBLY_BREAKING - both request functions now wrap errors going into the ex-info map in an additional map, wherein the :type key contains the spec keyword of the exception, and the body key contains the exception map (with message) itself.

Smells:

  • There's a lot of duplicated code in the method forportkey.awsgen/gen-operation for json protocol, and the -json-call request fn. This should be refactored away as we add more protocols.
  • Generation logging with versions is a little noisy, maybe some better spacing/formatting can be applied
  • Many "rest-json" protocol ns's have a jsonVersion, so it may be wise to further dispatch on those for services that don't generate or fail at runtime.

milt avatar Jun 22 '18 17:06 milt

Fantastic work Milton! @dupuchba do you have time to review it since there’s overlap with your current work?

cgrand avatar Jun 22 '18 21:06 cgrand

@cgrand thanks, I love where this project is going! One last review note , I added two additional commits to produce slightly more useable errors (that have the spec keyword, in addition to the shape as a message), but might break downstream projects that rely on the exception map being the root of the ex-info map.

milt avatar Jun 22 '18 22:06 milt

@milt Thanks a lot for your work !!!

I won't be able to review it today but I'll take some time tomorrow !

dupuchba avatar Jun 23 '18 09:06 dupuchba