Skip to content

Commit

Permalink
Merge pull request #111 from aws-beam/add-hostname-to-elixir-metadata…
Browse files Browse the repository at this point in the history
…-to-support-global-endpoints

Add hostname from aws-global for global endpoints to Elixir metadata Structs in order to support global endpoints
  • Loading branch information
onno-vos-dev committed May 17, 2024
2 parents e19270c + b5a9541 commit e04adcf
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/aws_codegen.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ defmodule AWS.CodeGen do
encode: nil,
endpoint_prefix: nil,
is_global: false,
hostname: nil,
json_version: nil,
language: nil,
module_name: nil,
Expand Down
6 changes: 6 additions & 0 deletions lib/aws_codegen/post_service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ defmodule AWS.CodeGen.PostService do
endpoint_info["endpoints"]["aws-global"]["credentialScope"]["region"]
end

hostname =
if is_global do
endpoint_info["endpoints"]["aws-global"]["hostname"]
end

json_version = AWS.CodeGen.Util.get_json_version(service)
protocol = spec.protocol |> to_string()
content_type = @configuration[protocol][:content_type]
Expand All @@ -96,6 +101,7 @@ defmodule AWS.CodeGen.PostService do
encode: Map.fetch!(@configuration[protocol][language], :encode),
endpoint_prefix: endpoint_prefix,
is_global: is_global,
hostname: hostname,
json_version: json_version,
language: language,
module_name: spec.module_name,
Expand Down
6 changes: 6 additions & 0 deletions lib/aws_codegen/rest_service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ defmodule AWS.CodeGen.RestService do
endpoint_info["endpoints"]["aws-global"]["credentialScope"]["region"]
end

hostname =
if is_global do
endpoint_info["endpoints"]["aws-global"]["hostname"]
end

signing_name = traits["aws.auth#sigv4"]["name"] || endpoint_prefix

%Service{
Expand All @@ -144,6 +149,7 @@ defmodule AWS.CodeGen.RestService do
encode: Map.fetch!(@configuration[protocol][language], :encode),
endpoint_prefix: endpoint_prefix,
is_global: is_global,
hostname: hostname,
json_version: AWS.CodeGen.Util.get_json_version(service),
language: language,
module_name: spec.module_name,
Expand Down
1 change: 1 addition & 0 deletions priv/post.ex.eex
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ defmodule <%= context.module_name %> do
credential_scope: <%= inspect(context.credential_scope) %>,
endpoint_prefix: <%= inspect(context.endpoint_prefix) %>,
global?: <%= inspect(context.is_global) %>,
hostname: <%= inspect(context.hostname) %>,
protocol: <%= inspect(context.protocol) %>,
service_id: <%= inspect(context.service_id) %>,
signature_version: <%= inspect(context.signature_version) %>,
Expand Down
1 change: 1 addition & 0 deletions priv/rest.ex.eex
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ defmodule <%= context.module_name %> do
credential_scope: <%= inspect(context.credential_scope) %>,
endpoint_prefix: <%= inspect(context.endpoint_prefix) %>,
global?: <%= inspect(context.is_global) %>,
hostname: <%= inspect(context.hostname) %>,
protocol: <%= inspect(context.protocol) %>,
service_id: <%= inspect(context.service_id) %>,
signature_version: <%= inspect(context.signature_version) %>,
Expand Down
3 changes: 3 additions & 0 deletions test/aws_codegen_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ defmodule AWS.CodeGenTest do
credential_scope: nil,
endpoint_prefix: \"cloudtrail-data\",
global?: false,
hostname: nil,
protocol: \"rest-json\",
service_id: \"CloudTrail Data\",
signature_version: \"v4\",
Expand Down Expand Up @@ -448,6 +449,7 @@ defmodule AWS.CodeGenTest do
credential_scope: nil,
endpoint_prefix: \"cloudtrail-data\",
global?: false,
hostname: nil,
protocol: \"rest-json\",
service_id: \"CloudTrail Data\",
signature_version: \"v4\",
Expand Down Expand Up @@ -690,6 +692,7 @@ defmodule AWS.CodeGenTest do
credential_scope: nil,
endpoint_prefix: \"cloudtrail-data\",
global?: false,
hostname: nil,
protocol: \"rest-json\",
service_id: \"CloudTrail Data\",
signature_version: \"v4\",
Expand Down

0 comments on commit e04adcf

Please sign in to comment.