-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate from ExAws to aws-elixir (#2167)
- Loading branch information
1 parent
9842843
commit acd4d50
Showing
27 changed files
with
571 additions
and
729 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,6 @@ config :dotcom, | |
if config_env() == :test do | ||
config :dotcom, | ||
time_fetcher: Feedback.FakeDateTime, | ||
exaws_config_fn: &Feedback.Test.mock_config/1, | ||
exaws_perform_fn: &Feedback.Test.mock_perform/2, | ||
feedback_rate_limit: 1_000, | ||
support_ticket_to_email: "[email protected]", | ||
support_ticket_from_email: "[email protected]", | ||
|
@@ -17,6 +15,5 @@ end | |
|
||
if config_env() == :dev do | ||
config :dotcom, | ||
exaws_config_fn: &Feedback.MockAws.config/1, | ||
exaws_perform_fn: &Feedback.MockAws.perform/2 | ||
send_email_fn: &Feedback.MockAws.send_email/1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
defmodule AwsClient.Behaviour do | ||
@moduledoc """ | ||
The behaviour for interacting with the AWS client | ||
""" | ||
@callback client() :: AWS.Client.t() | ||
@callback search_place_index_for_position( | ||
String.t(), | ||
AWS.Location.search_place_index_for_position_request() | ||
) :: | ||
{:ok, AWS.Location.search_place_index_for_position_response(), any()} | ||
| {:error, {:unexpected_response, any()}} | ||
| {:error, AWS.Location.search_place_index_for_position_errors()} | ||
|
||
@callback search_place_index_for_suggestions( | ||
String.t(), | ||
AWS.Location.search_place_index_for_suggestions_request() | ||
) :: | ||
{:ok, AWS.Location.search_place_index_for_suggestions_response(), any()} | ||
| {:error, {:unexpected_response, any()}} | ||
| {:error, AWS.Location.search_place_index_for_suggestions_errors()} | ||
|
||
@callback search_place_index_for_text( | ||
String.t(), | ||
AWS.Location.search_place_index_for_text_request() | ||
) :: | ||
{:ok, AWS.Location.search_place_index_for_text_response(), any()} | ||
| {:error, {:unexpected_response, any()}} | ||
| {:error, AWS.Location.search_place_index_for_text_errors()} | ||
|
||
@type bucket_name :: String.t() | ||
@type bucket_prefix :: String.t() | ||
@type bucket_object_key :: String.t() | ||
@callback get_object(bucket_name(), bucket_prefix()) :: | ||
{:ok, AWS.S3.get_object_output(), any()} | ||
| {:error, {:unexpected_response, any()}} | ||
| {:error, AWS.S3.get_object_errors()} | ||
@callback put_object(bucket_name(), bucket_object_key(), AWS.S3.put_object_request()) :: | ||
{:ok, AWS.S3.put_object_output(), any()} | ||
| {:error, {:unexpected_response, any()}} | ||
@callback list_objects(bucket_name(), bucket_object_key()) :: | ||
{:ok, AWS.S3.list_objects_output(), any()} | ||
| {:error, {:unexpected_response, any()}} | ||
| {:error, AWS.S3.list_objects_errors()} | ||
|
||
@callback send_raw_email(AWS.SES.send_raw_email_request()) :: | ||
{:ok, AWS.SES.send_raw_email_response(), any()} | ||
| {:error, {:unexpected_response, any()}} | ||
| {:error, AWS.SES.send_raw_email_errors()} | ||
|
||
@behaviour __MODULE__ | ||
|
||
@impl __MODULE__ | ||
def search_place_index_for_position(index_name, input) do | ||
AWS.Location.search_place_index_for_position(client(), index_name, input) | ||
end | ||
|
||
@impl __MODULE__ | ||
def search_place_index_for_suggestions(index_name, input) do | ||
AWS.Location.search_place_index_for_suggestions(client(), index_name, input) | ||
end | ||
|
||
@impl __MODULE__ | ||
def search_place_index_for_text(index_name, input) do | ||
AWS.Location.search_place_index_for_text(client(), index_name, input) | ||
end | ||
|
||
@impl __MODULE__ | ||
def list_objects(bucket, prefix), | ||
do: AWS.S3.list_objects(client(), bucket, nil, nil, nil, nil, prefix, nil, nil, nil) | ||
|
||
@impl __MODULE__ | ||
def get_object(bucket, object_key), | ||
do: AWS.S3.get_object(client(), bucket, object_key) | ||
|
||
@impl __MODULE__ | ||
def put_object(bucket, object_key, contents), | ||
do: AWS.S3.put_object(client(), bucket, object_key, contents) | ||
|
||
@impl __MODULE__ | ||
def send_raw_email(message), do: AWS.SES.send_raw_email(client(), message) | ||
|
||
@impl __MODULE__ | ||
def client do | ||
case :aws_credentials.get_credentials() do | ||
%{ | ||
access_key_id: access_key_id, | ||
secret_access_key: secret_access_key, | ||
token: token | ||
} -> | ||
AWS.Client.create(access_key_id, secret_access_key, token, "us-east-1") | ||
|
||
_ -> | ||
AWS.Client.create("us-east-1") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.