# Path: bgpvpn_dashboard/api/bgpvpn.py
# LOG = logging.getLogger(__name__)
# class Bgpvpn(neutron.NeutronAPIDictWrapper):
# class NetworkAssociation(neutron.NeutronAPIDictWrapper):
# class RouterAssociation(neutron.NeutronAPIDictWrapper):
# def bgpvpns_list(request, **kwargs):
# def bgpvpn_get(request, bgpvpn_id, **kwargs):
# def bgpvpn_create(request, **kwargs):
# def bgpvpn_update(request, bgpvpn_id, **kwargs):
# def bgpvpn_delete(request, bgpvpn_id):
# def network_association_get(request, bgpvpn_id, network_assoc_id, **kwargs):
# def network_association_list(request, bgpvpn_id, **kwargs):
# def network_association_create(request, bgpvpn_id, **kwargs):
# def network_association_delete(request, resource_id, bgpvpn_id):
# def router_association_get(request, bgpvpn_id, router_assoc_id, **kwargs):
# def router_association_list(request, bgpvpn_id, **kwargs):
# def router_association_create(request, bgpvpn_id, **kwargs):
# def router_association_update(request, bgpvpn_id, router_association_id,
#                               **kwargs):
# def router_association_delete(request, resource_id, bgpvpn_id):


import logging
from django.urls import reverse
from django.urls import reverse_lazy
from django.utils import safestring
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
from horizon import exceptions
from horizon import tables
from bgpvpn_dashboard.api import bgpvpn as bgpvpn_api

class IDColumn(tables.Column):
    url = "horizon:project:bgpvpn:network_assos:detail"

    def get_link_url(self, asso):
        bgpvpn_id = self.table.kwargs['bgpvpn_id']
        return reverse(self.url, args=(bgpvpn_id, asso.id))


class NetworkColumn(tables.Column):
    def get_raw_data(self, asso):
        url = reverse('horizon:project:networks:detail',
                      args=[asso.network_id])
        instance = '<a href=%s>%s</a>' % (url,
                                          asso.network_name or asso.network_id)
        return safestring.mark_safe(instance)


class NetworkAssociationsTable(tables.DataTable):
    id = IDColumn("id", verbose_name=_("Association ID"),
                  link='horizon:project:bgpvpn:network_assos:detail')
    network = NetworkColumn("network_id", verbose_name=_("Network"))

    failure_url = reverse_lazy('horizon:project:bgpvpn:detail')

    class Meta(object):
        name = "network_associations"
        verbose_name = _("Network Associations")
        table_actions = (CreateNetworkAssociation,)
        row_actions = (DeleteNetworkAssociation,)

# Path: bgpvpn_dashboard/api/bgpvpn.py
# LOG = logging.getLogger(__name__)
# class Bgpvpn(neutron.NeutronAPIDictWrapper):
# class NetworkAssociation(neutron.NeutronAPIDictWrapper):
# class RouterAssociation(neutron.NeutronAPIDictWrapper):
# def bgpvpns_list(request, **kwargs):
# def bgpvpn_get(request, bgpvpn_id, **kwargs):
# def bgpvpn_create(request, **kwargs):
# def bgpvpn_update(request, bgpvpn_id, **kwargs):
# def bgpvpn_delete(request, bgpvpn_id):
# def network_association_get(request, bgpvpn_id, network_assoc_id, **kwargs):
# def network_association_list(request, bgpvpn_id, **kwargs):
# def network_association_create(request, bgpvpn_id, **kwargs):
# def network_association_delete(request, resource_id, bgpvpn_id):
# def router_association_get(request, bgpvpn_id, router_assoc_id, **kwargs):
# def router_association_list(request, bgpvpn_id, **kwargs):
# def router_association_create(request, bgpvpn_id, **kwargs):
# def router_association_update(request, bgpvpn_id, router_association_id,
#                               **kwargs):
# def router_association_delete(request, resource_id, bgpvpn_id):


# Path: bgpvpn_dashboard/dashboards/project/bgpvpn/network_associations/tables.py
import logging
from django.urls import reverse
from django.urls import reverse_lazy
from django.utils import safestring
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
from horizon import exceptions
from horizon import tables
from bgpvpn_dashboard.api import bgpvpn as bgpvpn_api


class IDColumn(tables.Column):
    url = "horizon:project:bgpvpn:network_assos:detail"

    def get_link_url(self, asso):
        bgpvpn_id = self.table.kwargs['bgpvpn_id']
        return reverse(self.url, args=(bgpvpn_id, asso.id))


class NetworkColumn(tables.Column):
    def get_raw_data(self, asso):
        url = reverse('horizon:project:networks:detail',
                      args=[asso.network_id])
        instance = '<a href=%s>%s</a>' % (url,
                                          asso.network_name or asso.network_id)
        return safestring.mark_safe(instance)


class NetworkAssociationsTable(tables.DataTable):
    id = IDColumn("id", verbose_name=_("Association ID"),
                  link='horizon:project:bgpvpn:network_assos:detail')
    network = NetworkColumn("network_id", verbose_name=_("Network"))

    failure_url = reverse_lazy('horizon:project:bgpvpn:detail')

    class Meta(object):
        name = "network_associations"
        verbose_name = _("Network Associations")
        table_actions = (CreateNetworkAssociation,)
        row_actions = (DeleteNetworkAssociation,)

        hidden_title = False