Files
floci/tools/aws/regen_sesv2_shapes.py
T
Kenshin Okinaka 6aac097c82 chore(tools): generate the request shapes from one shared script (#5816)
regen_dynamodb_shapes.py and regen_sesv2_shapes.py carried the same
build() and main(); the SES v2 one only added the filter that drops
members bound to the URI, query string or headers, which leaves
DynamoDB's model unchanged since it has none. request_shapes.py now
holds load_model(), a build() that takes the generator's name, render()
and main(), and each script names its model and output. Both vendored
files regenerate unchanged.
2026-10-16 17:54:54 -05:00

40 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Regenerate src/main/resources/aws/sesv2-request-shapes.json from botocore's SES v2 model.
SES v2 rejects a request body member of the wrong JSON type with a SerializationException before
it validates anything. The Java side (`SesV2RequestShapes`) needs each operation's body shapes to
do the same, so this script keeps only what that check reads: the input shape of every
operation, reduced to the members carried in the JSON body, and for every shape reachable from
one, its type and the shapes of its members, list elements or map values.
Members bound to the URI, the query string or a header are left out: they never reach the body,
and an operation whose binding moved (ListEmailIdentities went from a GET with a query string
to a POST with a body) keeps its old route served by hand.
The model is botocore's `sesv2/2019-09-27/service-2.json` (Apache-2.0,
https://github.com/boto/botocore). It is located, in order, at `--botocore-data`, the
`local/aws/botocore` checkout, then the installed `botocore` package, which `requirements.txt`
pins so CI regenerates the same bytes.
Run from anywhere in the repo:
python3 tools/aws/regen_sesv2_shapes.py # rewrite the vendored file in place
python3 tools/aws/regen_sesv2_shapes.py --check # exit 1 when the vendored file is stale
"""
from __future__ import annotations
import sys
from pathlib import Path
import request_shapes
OUTPUT = request_shapes.REPO_ROOT / "src/main/resources/aws/sesv2-request-shapes.json"
MODEL = Path("sesv2/2019-09-27")
def main(argv: list[str] | None = None) -> int:
return request_shapes.main(argv, script=__file__, model=MODEL, output=OUTPUT, description=__doc__)
if __name__ == "__main__":
sys.exit(main())