From 7bae68091d91a9ed5381c9c6099487204627755b Mon Sep 17 00:00:00 2001 From: cheese-head Date: Mon, 27 Nov 2023 11:52:21 -0700 Subject: [PATCH 1/2] adding support for the ec2 protocol --- lib/aws_codegen.ex | 7 +++++++ lib/aws_codegen/post_service.ex | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/aws_codegen.ex b/lib/aws_codegen.ex index 54d3c41..f3c64e7 100644 --- a/lib/aws_codegen.ex +++ b/lib/aws_codegen.ex @@ -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: %{ diff --git a/lib/aws_codegen/post_service.ex b/lib/aws_codegen/post_service.ex index d73d68b..076f094 100644 --- a/lib/aws_codegen/post_service.ex +++ b/lib/aws_codegen/post_service.ex @@ -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: %{ From ed43d7c7bb2a1fccc63824a194d7a261a0826d07 Mon Sep 17 00:00:00 2001 From: Onno Vos Date: Fri, 15 Dec 2023 11:43:13 +0100 Subject: [PATCH 2/2] Fix Warning upon compilation in erlang generated aws_ec.erl by underscoring Action --- priv/post.erl.eex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/priv/post.erl.eex b/priv/post.erl.eex index 2109534..691b1f3 100644 --- a/priv/post.erl.eex +++ b/priv/post.erl.eex @@ -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),