# Path: orangengine/models/base/baseaddress.py
# class BaseAddress(BaseObject):
# 
#     AddressTypes = enum('IPv4', 'DNS', 'RANGE', 'ANY')
#     TypeMap = bidict({
#         AddressTypes.IPv4: 'ipv4',
#         AddressTypes.DNS: 'dns',
#         AddressTypes.RANGE: 'range',
#         AddressTypes.ANY: 'any',
#     })
# 
#     def __init__(self, name, value, a_type):
#         """init address object"""
# 
#         self.name = name
#         self.value = value
#         self.a_type = a_type
# 
#     def __getattr__(self, item):
# 
#         if item == 'value':
#             return self.value
#         else:
#             raise AttributeError
# 
#     def table_value(self, with_names):
#         if with_names:
#             return self.name + " - " + self.value
#         else:
#             return self.value
# 
#     @classmethod
#     def from_criteria(cls, criteria):
#         """Create an instance from the provided criteria
#         """
# 
#         return cls(criteria['name'], criteria['value'], cls.TypeMap[criteria['type']])
# 
#     def serialize(self):
#         """Searialize self to a json acceptable data structure
#         """
#         return {
#             'name': self.name,
#             'type': self.TypeMap[self.a_type],
#             'value': self.value,
#         }
# 
# Path: orangengine/utils.py
# def create_element(tag, text=None, parent=None):
#     # create an ambiguous xml element
#     if parent is not None:
#         e = letree.SubElement(parent, tag)
#     else:
#         e = letree.Element(tag)
#     if text:
#         e.text = text
#     return e


from orangengine.models.base import BaseAddress
from orangengine.utils import create_element
# -*- coding: utf-8 -*-


class JuniperSRXAddress(BaseAddress):

    def __init__(self, name, value, a_type):

        super(JuniperSRXAddress, self).__init__(name, value, a_type)

    def to_xml(self):
        """Map address objects to juniper SRX config tree elements
        """

        address_element = create_element('address')
        create_element('name', text=self.name, parent=address_element)
        if self.a_type == BaseAddress.AddressTypes.IPv4:
            # ipv4
            create_element('ip-prefix', text=self.value, parent=address_element)

# Path: orangengine/models/base/baseaddress.py
# class BaseAddress(BaseObject):
# 
#     AddressTypes = enum('IPv4', 'DNS', 'RANGE', 'ANY')
#     TypeMap = bidict({
#         AddressTypes.IPv4: 'ipv4',
#         AddressTypes.DNS: 'dns',
#         AddressTypes.RANGE: 'range',
#         AddressTypes.ANY: 'any',
#     })
# 
#     def __init__(self, name, value, a_type):
#         """init address object"""
# 
#         self.name = name
#         self.value = value
#         self.a_type = a_type
# 
#     def __getattr__(self, item):
# 
#         if item == 'value':
#             return self.value
#         else:
#             raise AttributeError
# 
#     def table_value(self, with_names):
#         if with_names:
#             return self.name + " - " + self.value
#         else:
#             return self.value
# 
#     @classmethod
#     def from_criteria(cls, criteria):
#         """Create an instance from the provided criteria
#         """
# 
#         return cls(criteria['name'], criteria['value'], cls.TypeMap[criteria['type']])
# 
#     def serialize(self):
#         """Searialize self to a json acceptable data structure
#         """
#         return {
#             'name': self.name,
#             'type': self.TypeMap[self.a_type],
#             'value': self.value,
#         }
# 
# Path: orangengine/utils.py
# def create_element(tag, text=None, parent=None):
#     # create an ambiguous xml element
#     if parent is not None:
#         e = letree.SubElement(parent, tag)
#     else:
#         e = letree.Element(tag)
#     if text:
#         e.text = text
#     return e


# Path: orangengine/models/juniper/address.py
from orangengine.models.base import BaseAddress
from orangengine.utils import create_element

# -*- coding: utf-8 -*-


class JuniperSRXAddress(BaseAddress):

    def __init__(self, name, value, a_type):

        super(JuniperSRXAddress, self).__init__(name, value, a_type)

    def to_xml(self):
        """Map address objects to juniper SRX config tree elements
        """

        address_element = create_element('address')
        create_element('name', text=self.name, parent=address_element)
        if self.a_type == BaseAddress.AddressTypes.IPv4:
            # ipv4
            create_element('ip-prefix', text=self.value, parent=address_element)

        elif self.a_type == BaseAddress.AddressTypes.DNS: