Techdebt: Fix compatibility with botocore 1.32.1 (#7030)

This commit is contained in:
Bert Blommers 2023-11-16 07:09:54 -01:00 committed by GitHub
parent ed56ffd484
commit 1f841254b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,7 @@ from moto.core.utils import (
method_names_from_class, method_names_from_class,
params_sort_function, params_sort_function,
) )
from moto.utilities.utils import load_resource from moto.utilities.utils import load_resource, load_resource_as_bytes
from jinja2 import Environment, DictLoader, Template from jinja2 import Environment, DictLoader, Template
from typing import ( from typing import (
Dict, Dict,
@ -961,7 +961,12 @@ class AWSServiceSpec(object):
""" """
def __init__(self, path: str): def __init__(self, path: str):
try:
spec = load_resource("botocore", path) spec = load_resource("botocore", path)
except FileNotFoundError:
# botocore >= 1.32.1 sends compressed files
compressed = load_resource_as_bytes("botocore", f"{path}.gz")
spec = json.loads(gzip_decompress(compressed).decode("utf-8"))
self.metadata = spec["metadata"] self.metadata = spec["metadata"]
self.operations = spec["operations"] self.operations = spec["operations"]