def _flatten_task(obj):
    """Flatten the structure of the task into a single dict
    """

    data = {
        'id': obj.id,
        'checkpoint_id': obj.checkpoint_id,
        'policy_id': obj.policy_id,
        'provider_id': obj.provider_id,
        'vault_id': obj.vault_id,
        'vault_name': obj.vault_name,
        'operation_type': obj.operation_type,
        'error_mesage': obj.error_info.message,
        'error_code': obj.error_info.code,
        'created_at': obj.created_at,
        'ended_at': obj.ended_at,
        'started_at': obj.started_at,
        'updated_at': obj.updated_at,
    }

    return data