Skip to content

Commit

Permalink
Merge pull request #100 from cheese-head/add-support-for-ec2-protocol
Browse files Browse the repository at this point in the history
adding support for the ec2 protocol
  • Loading branch information
onno-vos-dev committed Dec 15, 2023
2 parents db6561f + ed43d7c commit c6aec7c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/aws_codegen.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ defmodule AWS.CodeGen do
# Configuration map which determines what AWS API protocols have an
# implementation for what language.
@configuration %{
ec2: %{
module: AWS.CodeGen.PostService,
template: %{
elixir: "post.ex.eex",
erlang: "post.erl.eex"
}
},
json: %{
module: AWS.CodeGen.PostService,
template: %{
Expand Down
11 changes: 11 additions & 0 deletions lib/aws_codegen/post_service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ defmodule AWS.CodeGen.PostService do
end

@configuration %{
"ec2" => %{
content_type: "application/x-www-form-urlencoded",
elixir: %{
decode: "xml",
encode: "query"
},
erlang: %{
decode: "aws_util:decode_xml(Body)",
encode: "aws_util:encode_query(Input)"
}
},
"query" => %{
content_type: "application/x-www-form-urlencoded",
elixir: %{
Expand Down
5 changes: 3 additions & 2 deletions priv/post.erl.eex
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ request(Client, Action, Input, Options) ->
RequestFun = fun() -> do_request(Client, Action, Input, Options) end,
aws_request:request(RequestFun, Options).

do_request(Client, Action, Input0, Options) ->
Client1 = Client#{service => <<"<%= context.signing_name %>">><%= if context.is_global do %>,
<%= if context.protocol == "ec2" do %>do_request(Client, _Action, Input0, Options) ->
<% else %>do_request(Client, Action, Input0, Options) ->
<% end %> Client1 = Client#{service => <<"<%= context.signing_name %>">><%= if context.is_global do %>,
region => <<"<%= context.credential_scope %>">><% end %>},
Host = build_host(<<"<%= context.endpoint_prefix %>">>, Client1),
URL = build_url(Host, Client1),
Expand Down

0 comments on commit c6aec7c

Please sign in to comment.