def create_from_previous_version(cls, previous_shadow, payload):
        """
        set None to payload when you want to delete shadow
        """
        version, previous_payload = (previous_shadow.version + 1, previous_shadow.to_dict(include_delta=False)) if previous_shadow else (1, {})

        if payload is None:
            # if given payload is None, delete existing payload
            # this means the request was delete_thing_shadow
            shadow = FakeShadow(None, None, None, version, deleted=True)
            return shadow

        # we can make sure that payload has 'state' key
        desired = payload['state'].get(
            'desired',
            previous_payload.get('state', {}).get('desired', None)
        )
        reported = payload['state'].get(
            'reported',
            previous_payload.get('state', {}).get('reported', None)
        )
        shadow = FakeShadow(desired, reported, payload, version)
        return shadow
def create_from_previous_version ( cls , previous_shadow , payload ) : version , previous_payload = ( previous_shadow . version + 1 , previous_shadow . to_dict ( include_delta = False ) ) if previous_shadow else ( 1 , { } ) if payload is None : shadow = FakeShadow ( None , None , None , version , deleted = True ) return shadow desired = payload [ 'state' ] . get ( 'desired' , previous_payload . get ( 'state' , { } ) . get ( 'desired' , None ) ) reported = payload [ 'state' ] . get ( 'reported' , previous_payload . get ( 'state' , { } ) . get ( 'reported' , None ) ) shadow = FakeShadow ( desired , reported , payload , version ) return shadow
set None to payload when you want to delete shadow