'Returns the desired output of the API from an object.
From a MigrationsList\'s object this method returns a list of
primitive objects with the only necessary fields.'

def _output(self, req, migrations_obj, add_link=False):

    detail_keys = ['memory_total', 'memory_processed', 'memory_remaining', 'disk_total', 'disk_processed', 'disk_remaining']
    live_migration_in_progress = ['queued', 'preparing', 'running', 'post-migrating']
    objects = obj_base.obj_to_primitive(migrations_obj)
    objects = [x for x in objects if (not x['hidden'])]
    for obj in objects:
        del obj['deleted']
        del obj['deleted_at']
        del obj['hidden']
        if ('memory_total' in obj):
            for key in detail_keys:
                del obj[key]
        if (add_link and (obj['migration_type'] == 'live-migration') and (obj['status'] in live_migration_in_progress)):
            obj['links'] = self._view_builder._get_links(req, obj['id'], (self._collection_name % obj['instance_uuid']))
        elif (add_link is False):
            del obj['migration_type']
    return objects
