# Path: netman/core/objects/bond.py
# class Bond(BaseInterface):
#     def __init__(self, number=None, link_speed=None, members=None, **interface):
#         super(Bond, self).__init__(**interface)
#         self.number = number
#         self.link_speed = link_speed
#         self.members = members or []
# 
#     @property
#     def interface(self):
#         warnings.warn('Deprecated: Use directly the members of Bond instead.', DeprecationWarning)
#         return Interface(
#             shutdown=self.shutdown,
#             port_mode=self.port_mode,
#             access_vlan=self.access_vlan,
#             trunk_native_vlan=self.trunk_native_vlan,
#             trunk_vlans=self.trunk_vlans,
#         )


from netman.api.objects import base_interface, interface, Serializer, \
    Serializers
from netman.api.objects import sub_dict
from netman.core.objects.bond import Bond
from netman.core.objects.interface import Interface
            **base_interface.to_api(bond)
        )

    def to_core(self, api_bond):
        params = dict(vars(base_interface.to_core(api_bond)))
        params.update(sub_dict(api_bond, 'number', 'link_speed', 'members'))
        return Bond(**params)


class V1(Serializer):
    since_version = 1

    def to_api(self, bond):
        return dict(
            number=bond.number,
            link_speed=bond.link_speed,
            members=bond.members,
            interface=interface.to_api(Interface(
                shutdown=bond.shutdown,
                port_mode=bond.port_mode,
                access_vlan=bond.access_vlan,
                trunk_native_vlan=bond.trunk_native_vlan,
                trunk_vlans=bond.trunk_vlans,
                mtu=bond.mtu
            ))
        )

    def to_core(self, api_bond):
        params = dict(vars(base_interface.to_core(api_bond['interface'])))
        params.update(sub_dict(api_bond, 'number', 'link_speed', 'members'))

# Path: netman/core/objects/bond.py
# class Bond(BaseInterface):
#     def __init__(self, number=None, link_speed=None, members=None, **interface):
#         super(Bond, self).__init__(**interface)
#         self.number = number
#         self.link_speed = link_speed
#         self.members = members or []
# 
#     @property
#     def interface(self):
#         warnings.warn('Deprecated: Use directly the members of Bond instead.', DeprecationWarning)
#         return Interface(
#             shutdown=self.shutdown,
#             port_mode=self.port_mode,
#             access_vlan=self.access_vlan,
#             trunk_native_vlan=self.trunk_native_vlan,
#             trunk_vlans=self.trunk_vlans,
#         )


# Path: netman/api/objects/bond.py
from netman.api.objects import base_interface, interface, Serializer, \
    Serializers
from netman.api.objects import sub_dict
from netman.core.objects.bond import Bond
from netman.core.objects.interface import Interface

            **base_interface.to_api(bond)
        )

    def to_core(self, api_bond):
        params = dict(vars(base_interface.to_core(api_bond)))
        params.update(sub_dict(api_bond, 'number', 'link_speed', 'members'))
        return Bond(**params)


class V1(Serializer):
    since_version = 1

    def to_api(self, bond):
        return dict(
            number=bond.number,
            link_speed=bond.link_speed,
            members=bond.members,
            interface=interface.to_api(Interface(
                shutdown=bond.shutdown,
                port_mode=bond.port_mode,
                access_vlan=bond.access_vlan,
                trunk_native_vlan=bond.trunk_native_vlan,
                trunk_vlans=bond.trunk_vlans,
                mtu=bond.mtu
            ))
        )

    def to_core(self, api_bond):
        params = dict(vars(base_interface.to_core(api_bond['interface'])))
        params.update(sub_dict(api_bond, 'number', 'link_speed', 'members'))

        return Bond(**params)