From 63dfaa6ecf525e6171609b8ec792de09ac80cf86 Mon Sep 17 00:00:00 2001 From: kallu Date: Mon, 2 Nov 2020 07:53:25 +0200 Subject: [PATCH] Patch for "__init__() got an unexpected keyword argument 'snapshotRequested' (TypeError)" when creating a new resource. https://github.com/aws-cloudformation/cloudformation-cli-python-plugin/issues/130 --- src/cloudformation_cli_python_lib/interface.py | 1 + src/cloudformation_cli_python_lib/resource.py | 1 + src/cloudformation_cli_python_lib/utils.py | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/src/cloudformation_cli_python_lib/interface.py b/src/cloudformation_cli_python_lib/interface.py index 7dbd8aa8..bcdee427 100644 --- a/src/cloudformation_cli_python_lib/interface.py +++ b/src/cloudformation_cli_python_lib/interface.py @@ -139,3 +139,4 @@ class BaseResourceHandlerRequest: region: Optional[str] awsPartition: Optional[str] stackId: Optional[str] + snapshotRequested: Optional[bool] diff --git a/src/cloudformation_cli_python_lib/resource.py b/src/cloudformation_cli_python_lib/resource.py index 63363719..70ee2e38 100644 --- a/src/cloudformation_cli_python_lib/resource.py +++ b/src/cloudformation_cli_python_lib/resource.py @@ -165,6 +165,7 @@ def _cast_resource_request( logicalResourceIdentifier=request.requestData.logicalResourceId, stackId=request.stackId, region=request.region, + snapshotRequested=request.snapshotRequested, ).to_modelled(self._model_cls) except Exception as e: # pylint: disable=broad-except LOG.exception("Invalid request") diff --git a/src/cloudformation_cli_python_lib/utils.py b/src/cloudformation_cli_python_lib/utils.py index eb9a4a63..1b43ea94 100644 --- a/src/cloudformation_cli_python_lib/utils.py +++ b/src/cloudformation_cli_python_lib/utils.py @@ -58,6 +58,7 @@ class RequestData: providerCredentials: Optional[Credentials] = None previousResourceProperties: Optional[Mapping[str, Any]] = None previousStackTags: Optional[Mapping[str, Any]] = None + snapshotRequested: Optional[bool] = None @classmethod def deserialize(cls, json_data: MutableMapping[str, Any]) -> "RequestData": @@ -92,6 +93,7 @@ class HandlerRequest: resourceTypeVersion: Optional[str] = None callbackContext: Optional[MutableMapping[str, Any]] = None nextToken: Optional[str] = None + snapshotRequested: Optional[bool] = None def __init__(self, **kwargs: Any) -> None: dataclass_fields = {f.name for f in fields(self)} @@ -126,6 +128,7 @@ class UnmodelledRequest: nextToken: Optional[str] = None stackId: Optional[str] = None region: Optional[str] = None + snapshotRequested: Optional[bool] = None def to_modelled(self, model_cls: Type[BaseModel]) -> BaseResourceHandlerRequest: # pylint: disable=protected-access @@ -142,6 +145,7 @@ def to_modelled(self, model_cls: Type[BaseModel]) -> BaseResourceHandlerRequest: stackId=self.stackId, region=self.region, awsPartition=self.get_partition(self.region), + snapshotRequested=self.snapshotRequested, ) @staticmethod