clear-skies-aws 1.9.0__py3-none-any.whl → 1.9.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clear-skies-aws
3
- Version: 1.9.0
3
+ Version: 1.9.2
4
4
  Summary: clearskies bindings for working in AWS
5
5
  Home-page: https://github.com/cmancone/clearskies-aws
6
6
  License: MIT
@@ -3,8 +3,8 @@ clearskies_aws/actions/__init__.py,sha256=QEKR3TKEp7NWqhfz0g19Dv2v8KTTVewKi_3zeX
3
3
  clearskies_aws/actions/action_aws.py,sha256=hWYnYA0QNegWp2LDMYILs0Dk1TOsFykW5JgSEMwfDE8,3877
4
4
  clearskies_aws/actions/assume_role.py,sha256=tZHKMTQaImj_EAWormFZdIPkR_db7yBwOJxYaUyuGdA,4085
5
5
  clearskies_aws/actions/assume_role_test.py,sha256=MDMGePZLVyDNTjdAlGBDJzBlfMpGIpA3Q1Ur0qEPl1w,2450
6
- clearskies_aws/actions/ses.py,sha256=Lc554msF20ZDUBu43CfdA6bu2-xeOW6d2daOHAn1x5g,6933
7
- clearskies_aws/actions/ses_test.py,sha256=6XydNRXmniViOHkWcRCZNCEuGi3K2tp2w7Fkyg6JEBk,1739
6
+ clearskies_aws/actions/ses.py,sha256=iSo-dtQoreqOCveGpDAKWkbaa0gZx1xTymHYqlvL7hk,7886
7
+ clearskies_aws/actions/ses_test.py,sha256=lyNbqI46Ld_ZUKtWLgSwwfSOFksQ39H4hzPS3eTx7nk,3076
8
8
  clearskies_aws/actions/sns.py,sha256=m9LEoogTGGPr-u8oj39PIiOd9rkoF340nFbWefXJREA,2197
9
9
  clearskies_aws/actions/sns_test.py,sha256=iqlaZOA-0YHPOu52-XqpCIAgAv1JZodDdlm4YYYhj8U,2306
10
10
  clearskies_aws/actions/sqs.py,sha256=UZykBoi83EzzlqaPVdobZ8D_JRYqPFCwrCjWqg0ACzk,2340
@@ -58,7 +58,7 @@ clearskies_aws/secrets/parameter_store_test.py,sha256=UyqKE4AZYlldj9ww5f0fR15qsV
58
58
  clearskies_aws/secrets/secrets_manager.py,sha256=jlpfAFC23EeSpm50L8B-yrXg4IROQq-M_90zzXDp_ak,3056
59
59
  clearskies_aws/secrets/secrets_manager_test.py,sha256=mlNWtDm1wWS5C8aV0vJAzZVZB82KFR6NGRAPEkLtTyk,786
60
60
  clearskies_aws/web_socket_connection_model.py,sha256=d_Au_Pu7YXBfc7_lbuI7zz4MZ8ZOOwGM0oooppEofcI,1776
61
- clear_skies_aws-1.9.0.dist-info/LICENSE,sha256=3Ehd0g3YOpCj8sqj0Xjq5qbOtjjgk9qzhhD9YjRQgOA,1053
62
- clear_skies_aws-1.9.0.dist-info/METADATA,sha256=0Zz6vD7_Bxpn4DboubwY3M5_LP9BOVGicUbNUeOmHCQ,8579
63
- clear_skies_aws-1.9.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
64
- clear_skies_aws-1.9.0.dist-info/RECORD,,
61
+ clear_skies_aws-1.9.2.dist-info/LICENSE,sha256=3Ehd0g3YOpCj8sqj0Xjq5qbOtjjgk9qzhhD9YjRQgOA,1053
62
+ clear_skies_aws-1.9.2.dist-info/METADATA,sha256=EioQguPZ53N-grHN-60sHrXLGCRSuR5kLfUsjEe5yVE,8579
63
+ clear_skies_aws-1.9.2.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
64
+ clear_skies_aws-1.9.2.dist-info/RECORD,,
@@ -22,9 +22,9 @@ class SES(ActionAws):
22
22
  def configure(
23
23
  self,
24
24
  sender,
25
- to: Optional[Union[list, str]] = None,
26
- cc: Optional[Union[list, str]] = None,
27
- bcc: Optional[Union[list, str]] = None,
25
+ to: Optional[Union[list, str, Callable]] = None,
26
+ cc: Optional[Union[list, str, Callable]] = None,
27
+ bcc: Optional[Union[list, str, Callable]] = None,
28
28
  subject: Optional[str] = None,
29
29
  message: Optional[str] = None,
30
30
  subject_template: Optional[str] = None,
@@ -48,7 +48,7 @@ class SES(ActionAws):
48
48
  destination_values = locals()[key]
49
49
  if not destination_values:
50
50
  continue
51
- if type(destination_values) == str:
51
+ if type(destination_values) == str or callable(destination_values):
52
52
  self.destinations[key] = [destination_values]
53
53
  else:
54
54
  self.destinations[key] = destination_values
@@ -136,6 +136,17 @@ class SES(ActionAws):
136
136
  resolved = []
137
137
  destinations = self.destinations[name]
138
138
  for destination in destinations:
139
+ if callable(destination):
140
+ more = self.di.call_function(destination, model=model)
141
+ if not isinstance(more, list):
142
+ more = [more]
143
+ for entry in more:
144
+ if not isinstance(entry, str):
145
+ raise ValueError(f"I invoked a callable to fetch the '{name}' addresses for model '{model.__class__.__name__}' but it returned something other than a string. Callables must return a valid email address or a list of email addresses.")
146
+ if "@" not in entry:
147
+ raise ValueError(f"I invoked a callable to fetch the '{name}' addresses for model '{model.__class__.__name__}' but it returned a non-email address. Callables must return a valid email address or a list of email addresses.")
148
+ resolved.extend(more)
149
+ continue
139
150
  if "@" in destination:
140
151
  resolved.append(destination)
141
152
  continue
@@ -48,3 +48,42 @@ class SESTest(unittest.TestCase):
48
48
  Source='test@example.com'
49
49
  ),
50
50
  ])
51
+
52
+ def test_send_callable(self):
53
+ ses = SES(self.environment, self.boto3, self.di)
54
+ ses.configure(
55
+ 'test@example.com',
56
+ to=lambda model: 'jane@example.com',
57
+ bcc=lambda model: ['bob@example.com', 'greg@example.com'],
58
+ subject='welcome!',
59
+ message_template='hi {{ model.id }}!'
60
+ )
61
+ model = MagicMock()
62
+ model.id = 'asdf'
63
+ ses(model)
64
+ self.ses.send_email.assert_has_calls([
65
+ call(
66
+ Destination={
67
+ 'ToAddresses': ['jane@example.com'],
68
+ 'CcAddresses': [],
69
+ 'BccAddresses': ['bob@example.com', 'greg@example.com']
70
+ },
71
+ Message={
72
+ 'Body': {
73
+ 'Html': {
74
+ 'Charset': 'utf-8',
75
+ 'Data': 'hi asdf!'
76
+ },
77
+ 'Text': {
78
+ 'Charset': 'utf-8',
79
+ 'Data': 'hi asdf!'
80
+ }
81
+ },
82
+ 'Subject': {
83
+ 'Charset': 'utf-8',
84
+ 'Data': 'welcome!'
85
+ }
86
+ },
87
+ Source='test@example.com'
88
+ ),
89
+ ])