def METHOD_NAME():
    response = _fetch_software_updates()
    with transaction.atomic():
        seen_software_updates = []
        for kwargs, supported_devices in _iter_software_updates(response):
            su, _ = SoftwareUpdate.objects.update_or_create(**kwargs)
            seen_software_updates.append(su.pk)
            for device_id in supported_devices:
                sd, _ = SoftwareUpdateDeviceID.objects.get_or_create(software_update=su, device_id=device_id)
            (SoftwareUpdateDeviceID.objects.filter(software_update=su)
                                           .exclude(device_id__in=supported_devices).delete())
        SoftwareUpdate.objects.exclude(pk__in=seen_software_updates).delete()