Exemplo n.º 1
0
 def _deserialize(
     cls: Type["_User"],
     json_data: Optional[Mapping[str, Any]],
 ) -> Optional["_User"]:
     if not json_data:
         return None
     return cls(
         Name=json_data.get("Name"),
         SecretId=json_data.get("SecretId"),
         SuperUser=json_data.get("SuperUser"),
         Grants=deserialize_list(json_data.get("Grants"), Grant),
     )
Exemplo n.º 2
0
 def _deserialize(
     cls: Type["_EntityType"],
     json_data: Optional[Mapping[str, Any]],
 ) -> Optional["_EntityType"]:
     if not json_data:
         return None
     return cls(
         Arn=json_data.get("Arn"),
         Inline=json_data.get("Inline"),
         Name=json_data.get("Name"),
         Description=json_data.get("Description"),
         Tags=deserialize_list(json_data.get("Tags"), Tag),
         CreatedTime=json_data.get("CreatedTime"),
         LastUpdatedTime=json_data.get("LastUpdatedTime"),
     )
Exemplo n.º 3
0
 def _deserialize(
     cls: Type["_ResourceModel"],
     json_data: Optional[Mapping[str, Any]],
 ) -> Optional["_ResourceModel"]:
     if not json_data:
         return None
     dataclasses = {
         n: o
         for n, o in getmembers(sys.modules[__name__]) if isclass(o)
     }
     recast_object(cls, json_data, dataclasses)
     return cls(
         Name=json_data.get("Name"),
         Tags=deserialize_list(json_data.get("Tags"), Tag),
         Description=json_data.get("Description"),
         EventVariables=deserialize_list(json_data.get("EventVariables"),
                                         EventVariable),
         Labels=deserialize_list(json_data.get("Labels"), Label),
         EntityTypes=deserialize_list(json_data.get("EntityTypes"),
                                      EntityType),
         Arn=json_data.get("Arn"),
         CreatedTime=json_data.get("CreatedTime"),
         LastUpdatedTime=json_data.get("LastUpdatedTime"),
     )
Exemplo n.º 4
0
 def _deserialize(
     cls: Type["_ResourceModel"],
     json_data: Optional[Mapping[str, Any]],
 ) -> Optional["_ResourceModel"]:
     if not json_data:
         return None
     dataclasses = {
         n: o
         for n, o in getmembers(sys.modules[__name__]) if isclass(o)
     }
     recast_object(cls, json_data, dataclasses)
     return cls(
         Arn=json_data.get("Arn"),
         Id=json_data.get("Id"),
         RootId=json_data.get("RootId"),
         MasterAccountArn=json_data.get("MasterAccountArn"),
         MasterAccountId=json_data.get("MasterAccountId"),
         MasterAccountEmail=json_data.get("MasterAccountEmail"),
         EnabledPolicyTypes=deserialize_list(
             json_data.get("EnabledPolicyTypes"), EnabledPolicyTypes),
         EnabledServices=deserialize_list(json_data.get("EnabledServices"),
                                          EnabledServices),
         FeatureSet=json_data.get("FeatureSet"),
     )
Exemplo n.º 5
0
 def _deserialize(
     cls: Type["_EventVariable"],
     json_data: Optional[Mapping[str, Any]],
 ) -> Optional["_EventVariable"]:
     if not json_data:
         return None
     return cls(
         Arn=json_data.get("Arn"),
         Inline=json_data.get("Inline"),
         Name=json_data.get("Name"),
         DataSource=json_data.get("DataSource"),
         DataType=json_data.get("DataType"),
         DefaultValue=json_data.get("DefaultValue"),
         VariableType=json_data.get("VariableType"),
         Description=json_data.get("Description"),
         Tags=deserialize_list(json_data.get("Tags"), Tag),
         CreatedTime=json_data.get("CreatedTime"),
         LastUpdatedTime=json_data.get("LastUpdatedTime"),
     )
 def _deserialize(
     cls: Type["_ResourceModel"],
     json_data: Optional[Mapping[str, Any]],
 ) -> Optional["_ResourceModel"]:
     if not json_data:
         return None
     dataclasses = {
         n: o
         for n, o in getmembers(sys.modules[__name__]) if isclass(o)
     }
     recast_object(cls, json_data, dataclasses)
     return cls(
         KeyPairId=json_data.get("KeyPairId"),
         KeyFingerprint=json_data.get("KeyFingerprint"),
         KeyName=json_data.get("KeyName"),
         KeyType=json_data.get("KeyType"),
         PublicKeyMaterial=json_data.get("PublicKeyMaterial"),
         Tags=deserialize_list(json_data.get("Tags"), Tag),
     )
def test_deserialize_list_invalid():
    with pytest.raises(InvalidRequest):
        deserialize_list([(1, 2)], BaseModel)
def test_deserialize_list_empty():
    assert deserialize_list(None, BaseModel) is None
    assert deserialize_list([], BaseModel) is None