moto
moto copied to clipboard
SES v2 send_email
Amazon announced a new version of the SES API earlier this week.
I would like to use the new send_email
call with moto.
In boto3 this appears as boto3.client('sesv2').send_email()
, compared to the old boto3.client('ses').send_email()
and .send_raw_email()
.
I haven't yet looked into the details of the differences. The arguments have changed, and there's a few new ones.
In general, what does it take to add a new service to moto when it's an upgrade of an existing service? I expect that it should be relatively easy to just add a function that wraps around the old version in moto (or the other way around), compared to the complexity of implementing v2 from scratch separately to the existing v1. (In fact, the APIs should refer to the same underlying resources.)
Related to #5075
Hi @mdavis-xyz! As Moto intercepts the underlying HTTP request that boto3 sends to AWS, implementing any service consists of two things:
- Discover and decode the format of the HTTP request/response.
- Implement the actual mock-behaviour
The first part will always need to happen, for any service. Once that's done, the actual mock-behaviour can probably just call the SES backend instead, and reuse that logic, yes.
If you want to have a go at implementing this, the Contributing-section of our documentation might be useful. I haven't looked into the details of this particular service yet, so I can't be much more specific. Let me know if you get stuck though, happy to help out.
since sesv2 is a new service, it's defined in its own service-2.json file, here: https://github.com/boto/botocore/blob/develop/botocore/data/sesv2/2019-09-27/service-2.json.
This means that it needs to be treated as a new service within moto. You can look at past PRs for implementing new services as a guide.
I can take a look at this. Should I go ahead?
Sounds good to me @denny-sam - I'm not aware of anyone else working on this. Happy to help out if you run into any issues!
@denny-sam did you make a start on this?
In particular I don't understand how to write a new service such that it shares resources with an existing service.
e.g. Users should be able to create an SES domain identity with the v1 API, then send emails with that identity using the v2 api.
@mdavis-xyz Within a particular service, you can directly access the backend of other services. See this example, where ELB needs to access EC2 resources: https://github.com/getmoto/moto/blob/5d2f2bca8c3b3922127594835fad0c39345d6616/moto/elb/models.py#L282
@denny-sam Any chance this will be implemented? :)
Hey @denny-sam, I can take a look if you haven’t made much progress yet