Skip to content

Commit 98f2df5

Browse files
authored
Python: SESv2 Email Attachments Scenario (#7846)
* Initial commit of codeloom code * Initial commit of codeloom code * Updates to README and tools requirements. * Initial commit of codeloom code * Updates to README and tools requirements. * Updates for project structure. * Initial commit of codeloom code * Updates to README and tools requirements. * Updates for project structure. * Update to metadata order. * Update to README. * Update to metadata * Updates to metadata. * Update sesv2_metadata.yaml * Updates to metadata. * Update sesv2_wrapper.py * Undo requirements changes. * Update scenario_sesv2_email_attachments.py * Clean up messages and hello example. * Adding the spec and readme. * Updates to spec and readme. * Metadata fixes * Metadata cleanup. * Updates from feedback. * Update README.md
1 parent ac9d32f commit 98f2df5

12 files changed

Lines changed: 1307 additions & 22 deletions

File tree

.doc_gen/metadata/sesv2_metadata.yaml

Lines changed: 109 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ sesv2_CreateContactList:
3939
Python:
4040
versions:
4141
- sdk_version: 3
42-
github: python/example_code/sesv2
42+
github: python/example_code/sesv2/newsletter_scenario
4343
excerpts:
4444
- description:
4545
genai: most
@@ -89,7 +89,7 @@ sesv2_CreateContact:
8989
Python:
9090
versions:
9191
- sdk_version: 3
92-
github: python/example_code/sesv2
92+
github: python/example_code/sesv2/newsletter_scenario
9393
excerpts:
9494
- description:
9595
genai: most
@@ -101,6 +101,15 @@ sesv2_CreateContact:
101101
sesv2: {CreateContact}
102102
sesv2_GetEmailIdentity:
103103
languages:
104+
Python:
105+
versions:
106+
- sdk_version: 3
107+
github: python/example_code/sesv2/attachments_scenario
108+
excerpts:
109+
- description:
110+
snippet_tags:
111+
- python.example_code.sesv2.SESv2Wrapper.decl
112+
- python.example_code.sesv2.GetEmailIdentityAttachment
104113
Rust:
105114
versions:
106115
- sdk_version: 1
@@ -163,7 +172,7 @@ sesv2_ListContacts:
163172
Python:
164173
versions:
165174
- sdk_version: 3
166-
github: python/example_code/sesv2
175+
github: python/example_code/sesv2/newsletter_scenario
167176
excerpts:
168177
- description:
169178
genai: most
@@ -234,7 +243,14 @@ sesv2_SendEmail:
234243
Python:
235244
versions:
236245
- sdk_version: 3
237-
github: python/example_code/sesv2
246+
github: python/example_code/sesv2/attachments_scenario
247+
excerpts:
248+
- description: Sends a message with optional attachments.
249+
snippet_tags:
250+
- python.example_code.sesv2.SESv2Wrapper.decl
251+
- python.example_code.sesv2.SendEmailAttachment
252+
- sdk_version: 3
253+
github: python/example_code/sesv2/newsletter_scenario
238254
excerpts:
239255
- description: Sends a message to all members of the contact list.
240256
genai: most
@@ -282,7 +298,14 @@ sesv2_CreateEmailIdentity:
282298
Python:
283299
versions:
284300
- sdk_version: 3
285-
github: python/example_code/sesv2
301+
github: python/example_code/sesv2/attachments_scenario
302+
excerpts:
303+
- description:
304+
snippet_tags:
305+
- python.example_code.sesv2.SESv2Wrapper.decl
306+
- python.example_code.sesv2.CreateEmailIdentityAttachment
307+
- sdk_version: 3
308+
github: python/example_code/sesv2/newsletter_scenario
286309
excerpts:
287310
- description:
288311
genai: most
@@ -333,7 +356,14 @@ sesv2_CreateEmailTemplate:
333356
Python:
334357
versions:
335358
- sdk_version: 3
336-
github: python/example_code/sesv2
359+
github: python/example_code/sesv2/attachments_scenario
360+
excerpts:
361+
- description:
362+
snippet_tags:
363+
- python.example_code.sesv2.SESv2Wrapper.decl
364+
- python.example_code.sesv2.CreateEmailTemplateAttachment
365+
- sdk_version: 3
366+
github: python/example_code/sesv2/newsletter_scenario
337367
excerpts:
338368
- description:
339369
genai: most
@@ -384,7 +414,7 @@ sesv2_DeleteContactList:
384414
Python:
385415
versions:
386416
- sdk_version: 3
387-
github: python/example_code/sesv2
417+
github: python/example_code/sesv2/newsletter_scenario
388418
excerpts:
389419
- description:
390420
genai: most
@@ -435,7 +465,14 @@ sesv2_DeleteEmailIdentity:
435465
Python:
436466
versions:
437467
- sdk_version: 3
438-
github: python/example_code/sesv2
468+
github: python/example_code/sesv2/attachments_scenario
469+
excerpts:
470+
- description:
471+
snippet_tags:
472+
- python.example_code.sesv2.SESv2Wrapper.decl
473+
- python.example_code.sesv2.DeleteEmailIdentityAttachment
474+
- sdk_version: 3
475+
github: python/example_code/sesv2/newsletter_scenario
439476
excerpts:
440477
- description:
441478
genai: most
@@ -486,7 +523,14 @@ sesv2_DeleteEmailTemplate:
486523
Python:
487524
versions:
488525
- sdk_version: 3
489-
github: python/example_code/sesv2
526+
github: python/example_code/sesv2/attachments_scenario
527+
excerpts:
528+
- description:
529+
snippet_tags:
530+
- python.example_code.sesv2.SESv2Wrapper.decl
531+
- python.example_code.sesv2.DeleteEmailTemplateAttachment
532+
- sdk_version: 3
533+
github: python/example_code/sesv2/newsletter_scenario
490534
excerpts:
491535
- description:
492536
genai: most
@@ -544,7 +588,7 @@ sesv2_NewsletterWorkflow:
544588
Python:
545589
versions:
546590
- sdk_version: 3
547-
github: python/example_code/sesv2
591+
github: python/example_code/sesv2/newsletter_scenario
548592
excerpts:
549593
- description:
550594
genai: most
@@ -581,3 +625,58 @@ sesv2_NewsletterWorkflow:
581625
services:
582626
sesv2: {CreateContactList, CreateContact, ListContacts, SendEmail.simple, SendEmail.template, CreateEmailIdentity, CreateEmailTemplate,
583627
DeleteContactList, DeleteEmailIdentity, DeleteEmailTemplate}
628+
629+
sesv2_Hello:
630+
title: Hello &SESv2;
631+
title_abbrev: Hello &SESv2;
632+
synopsis: get started using &SESv2;.
633+
category: Hello
634+
languages:
635+
Python:
636+
versions:
637+
- sdk_version: 3
638+
github: python/example_code/sesv2/attachments_scenario
639+
excerpts:
640+
- description:
641+
snippet_tags:
642+
- python.example_code.sesv2.Hello
643+
services:
644+
sesv2: {ListEmailIdentities}
645+
sesv2_SendBulkEmail:
646+
languages:
647+
Python:
648+
versions:
649+
- sdk_version: 3
650+
github: python/example_code/sesv2/attachments_scenario
651+
excerpts:
652+
- description:
653+
snippet_tags:
654+
- python.example_code.sesv2.SESv2Wrapper.decl
655+
- python.example_code.sesv2.SendBulkEmail
656+
services:
657+
sesv2: {SendBulkEmail}
658+
sesv2_Scenario_EmailAttachments:
659+
title: Send emails with attachments using &SESv2;
660+
title_abbrev: Email Attachments Scenario
661+
synopsis: send emails with attachments using &SESv2;.
662+
synopsis_list:
663+
- Create an email template for bulk sends.
664+
- Send a simple email with a file attachment.
665+
- Send a simple email with an inline image.
666+
- Send bulk templated emails with attachments.
667+
- Clean up resources.
668+
category: Scenarios
669+
languages:
670+
Python:
671+
versions:
672+
- sdk_version: 3
673+
github: python/example_code/sesv2/attachments_scenario
674+
excerpts:
675+
- description: Run an interactive scenario demonstrating email attachments.
676+
snippet_tags:
677+
- python.example_code.sesv2.Scenario_EmailAttachments
678+
- description: Create an SESv2 wrapper class to manage operations.
679+
snippet_tags:
680+
- python.example_code.sesv2.SESv2Wrapper.class
681+
services:
682+
sesv2: {SendEmail, SendBulkEmail, CreateEmailIdentity, CreateEmailTemplate, GetEmailIdentity, DeleteEmailTemplate, DeleteEmailIdentity}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ kotlin/services/**/.kotlin/
4141
.kiro/settings/
4242
.kiro/steering/
4343

44+
/codeloom_outputs

python/example_code/sesv2/README.md

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,34 @@ python -m pip install -r requirements.txt
3434
<!--custom.prerequisites.start-->
3535
<!--custom.prerequisites.end-->
3636

37+
### Get started
38+
39+
- [Hello Amazon SES v2 API](attachments_scenario/sesv2_hello.py#L18) (`ListEmailIdentities`)
40+
41+
3742
### Single actions
3843

3944
Code excerpts that show you how to call individual service functions.
4045

41-
- [CreateContact](newsletter.py#L155)
42-
- [CreateContactList](newsletter.py#L105)
43-
- [CreateEmailIdentity](newsletter.py#L92)
44-
- [CreateEmailTemplate](newsletter.py#L118)
45-
- [DeleteContactList](newsletter.py#L258)
46-
- [DeleteEmailIdentity](newsletter.py#L286)
47-
- [DeleteEmailTemplate](newsletter.py#L271)
48-
- [ListContacts](newsletter.py#L198)
49-
- [SendEmail](newsletter.py#L164)
46+
- [CreateContact](newsletter_scenario/newsletter.py#L155)
47+
- [CreateContactList](newsletter_scenario/newsletter.py#L105)
48+
- [CreateEmailIdentity](attachments_scenario/sesv2_wrapper.py#L73)
49+
- [CreateEmailTemplate](attachments_scenario/sesv2_wrapper.py#L109)
50+
- [DeleteContactList](newsletter_scenario/newsletter.py#L258)
51+
- [DeleteEmailIdentity](attachments_scenario/sesv2_wrapper.py#L321)
52+
- [DeleteEmailTemplate](attachments_scenario/sesv2_wrapper.py#L291)
53+
- [GetEmailIdentity](attachments_scenario/sesv2_wrapper.py#L42)
54+
- [ListContacts](newsletter_scenario/newsletter.py#L198)
55+
- [SendBulkEmail](attachments_scenario/sesv2_wrapper.py#L227)
56+
- [SendEmail](attachments_scenario/sesv2_wrapper.py#L155)
5057

5158
### Scenarios
5259

5360
Code examples that show you how to accomplish a specific task by calling multiple
5461
functions within the same service.
5562

56-
- [Newsletter scenario](newsletter.py)
63+
- [Email Attachments Scenario](attachments_scenario/scenario_sesv2_email_attachments.py)
64+
- [Newsletter scenario](newsletter_scenario/newsletter.py)
5765

5866

5967
<!--custom.examples.start-->
@@ -74,7 +82,37 @@ To run the Newsletter example, copy the files from workflows/sesv2_weekly_mailer
7482

7583
<!--custom.instructions.end-->
7684

85+
#### Hello Amazon SES v2 API
86+
87+
This example shows you how to get started using Amazon SES v2 API.
88+
89+
```
90+
python attachments_scenario/sesv2_hello.py
91+
```
92+
93+
94+
#### Email Attachments Scenario
95+
96+
This example shows you how to send emails with attachments using Amazon SES v2 API.
97+
98+
- Create an email template for bulk sends.
99+
- Send a simple email with a file attachment.
100+
- Send a simple email with an inline image.
101+
- Send bulk templated emails with attachments.
102+
- Clean up resources.
103+
104+
<!--custom.scenario_prereqs.sesv2_Scenario_EmailAttachments.start-->
105+
<!--custom.scenario_prereqs.sesv2_Scenario_EmailAttachments.end-->
106+
107+
Start the example by running the following at a command prompt:
108+
109+
```
110+
python attachments_scenario/scenario_sesv2_email_attachments.py
111+
```
112+
77113

114+
<!--custom.scenarios.sesv2_Scenario_EmailAttachments.start-->
115+
<!--custom.scenarios.sesv2_Scenario_EmailAttachments.end-->
78116

79117
#### Newsletter scenario
80118

@@ -87,7 +125,7 @@ This example shows you how to run the Amazon SES v2 API newsletter scenario.
87125
Start the example by running the following at a command prompt:
88126

89127
```
90-
python newsletter.py
128+
python newsletter_scenario/newsletter.py
91129
```
92130

93131

0 commit comments

Comments
 (0)