aws-beam / aws-codegen

Code generator for AWS clients in Erlang and Elixir.
Other
53 stars 49 forks source link

Add support for S3 metadata #76

Closed robertoaloi closed 3 years ago

robertoaloi commented 3 years ago

As part of the API specification, some input parameters can have the location set to headers (as opposed to the typical header). From what I can tell, this feature is currently used for the S3 service only.

The headers location type specifies a prefix that can be used by clients to pass custom headers. For example, in S3, given the parameter:

        "Metadata":{
          "shape":"Metadata",
          "location":"headers",
          "locationName":"x-amz-meta-"
        },

Users can specify metadata for uploaded files, as following:

aws_s3:put_object(Client, Bucket, Key, #{<<"Body">> => Body, <<"Metadata">> => #{<<"my-key">> => <<"1">>, <<"my_other_key">> => <<"2">>}}).

Which will then be translated into the headers:

x-amz-meta-my-key
x-amz-meta-my-other-key

Right now headers parameters are ignored, so users are not able to specify them. This PR adds support for headers input parameters and, therefore, for S3 metadata.

For now I only addressed the Erlang side. It would be good if some Elixir member could take that part, otherwise I will attempt it as a follow up.