Honor AWS_ENDPOINT_URL_<SERVICE> env vars in generated Erlang clients#129
Honor AWS_ENDPOINT_URL_<SERVICE> env vars in generated Erlang clients#129vulkoingim wants to merge 1 commit into
AWS_ENDPOINT_URL_<SERVICE> env vars in generated Erlang clients#129Conversation
Depends on aws_beam_core:apply_endpoint_url_override
There was a problem hiding this comment.
Not a huge fan of the resulting indentation but I won't stop it 😄
DefaultHost = build_host(<<"chatbot">>, Client1),
URL0 = build_url(DefaultHost, Path, Client1),
PathBin = erlang:iolist_to_binary(Path),
{URL1, Host} = aws_util:apply_endpoint_url_override(
URL0, DefaultHost, PathBin,
<<"AWS_ENDPOINT_URL_CHATBOT">>),
URL = aws_request:add_query(URL1, Query),I would have personally preferred:
DefaultHost = build_host(<<"chatbot">>, Client1),
URL0 = build_url(DefaultHost, Path, Client1),
PathBin = erlang:iolist_to_binary(Path),
{URL1, Host} = aws_util:apply_endpoint_url_override(URL0, DefaultHost, PathBin, <<"AWS_ENDPOINT_URL_CHATBOT">>),
URL = aws_request:add_query(URL1, Query),Then again, I know some folks are incredibly picky about their line-length 😆
| signing_name: signing_name, | ||
| signature_version: AWS.CodeGen.Util.get_signature_version(service), | ||
| service_id: AWS.CodeGen.Util.get_service_id(service), | ||
| endpoint_url_env_var: AWS.CodeGen.Util.endpoint_url_env_var(service), |
There was a problem hiding this comment.
You could use below instead and save yourself adding something to the util.ex that essentially does the same thing.
| endpoint_url_env_var: AWS.CodeGen.Util.endpoint_url_env_var(service), | |
| endpoint_url_env_var: "AWS_ENDPOINT_URL_" <> spec.module_name |> String.upcase(), |
| signing_name: signing_name, | ||
| signature_version: AWS.CodeGen.Util.get_signature_version(service), | ||
| service_id: AWS.CodeGen.Util.get_service_id(service), | ||
| endpoint_url_env_var: AWS.CodeGen.Util.endpoint_url_env_var(service), |
There was a problem hiding this comment.
You could use below instead and save yourself adding something to the util.ex that essentially does the same thing.
| endpoint_url_env_var: AWS.CodeGen.Util.endpoint_url_env_var(service), | |
| endpoint_url_env_var: "AWS_ENDPOINT_URL_" <> spec.module_name |> String.upcase(), |
|
@vulkoingim I'll leave it up to you if you wanna address my comments. If I don't hear back from you by tomorrow, I'll merge it anyway but I think my comments would be cleaner. At least the obsolete |
Depends on
aws_beam_core:apply_endpoint_url_overrideAs a disclosure I have used a LLM to generate the code, but I have tested and verified that the generated erlang lib compiles and works against:
AWS_ENDPOINT_URL_DYNAMODBAWS_ENDPOINT_URL_S3Generates
do_requestin the form:do_request(Client, Action, Input0, Options) -> Client1 = Client#{service => <<"dynamodb">>}, - Host = build_host(<<"dynamodb">>, Client1), - URL = build_url(Host, Client1), + DefaultHost = build_host(<<"dynamodb">>, Client1), + {URL, Host} = aws_util:apply_endpoint_url_override( + build_url(DefaultHost, Client1), DefaultHost, <<"/">>, + <<"AWS_ENDPOINT_URL_DYNAMODB">>), Headers = [ {<<"Host">>, Host}, {<<"Content-Type">>, <<"application/x-amz-json-1.0">>},Tested after generating the code, and patching the
aws_utilin aws-erlang.