Beispiel #1
0
 def __iter__(self):
     for node in self.data[self.typeof]:
         data = ElementCache(node)
         yield (self.__class__(href=data.get_link('self'),
                               type=self.__class__.__name__,
                               data=node,
                               parent=self))
Beispiel #2
0
 def _load(cls, engine):
     nodes = []
     for node in engine.data.get('nodes', []):
         for typeof, data in node.items():
             cache = ElementCache(data)
             node = Node(name=cache.get('name'),
                         href=cache.get_link('self'),
                         type=typeof)
             node.data = cache
             node._engine = engine
             nodes.append(node)
     return nodes
    def parameter_values(self):
        """
        Parameter values for this inspection situation. This correlate to
        the the situation_context.

        :rtype: list(SituationParameterValue)
        """
        for param in self.data.get("parameter_values", []):
            cache = ElementCache(data=self.make_request(href=param))
            name = "{}".format(cache.type.title()).replace("_", "")
            yield type(name, (SituationParameterValue,), {"data": cache})(
                name=cache.name, type=cache.type, href=param
            )
    def situation_parameters(self):
        """
        Situation parameters defining detection logic for the context.
        This will return a list of SituationParameter indicating how
        the detection is made, i.e. regular expression, integer value,
        etc.

        :rtype: list(SituationParameter)
        """
        for param in self.data.get("situation_parameters", []):
            cache = ElementCache(data=self.make_request(href=param))
            yield type("SituationParameter", (SituationParameter,), {"data": cache})(
                name=cache.name, type=cache.type, href=param
            )
 def parameters(self):
     """
     Protocol agent parameters are settings specific to the protocol agent
     type. Each protocol agent will have parameter settings that are
     configurable when a service uses a given protocol agent. Parameters
     on the protocol agent are templates that define settings exposed in
     the service. These are read-only attributes.
     
     :rtype: list(ProtocolParameter)
     """
     return [type('ProtocolParameter', (SubElement,), {
         'data': ElementCache(data=self._get_param_values(param.get('name')))}
         )(**param)
         for param in self.make_request(resource='pa_parameters')]
Beispiel #6
0
    def __init__(self, element=None, level='gateway', **kwargs):
        self.destinations = kwargs.pop('destinations', [])
        self.data = ElementCache(kwargs)
        self.data.update(level=level, routing_node=[])

        if element:
            self.data.update(href=element.href, name=element.name)
            #related_element_type=element.typeof)

        for destination in self.destinations:
            self.data['routing_node'].append({
                'href': destination.href,
                'name': destination.name,
                'level': 'any'
            })
Beispiel #7
0
    def __init__(self, element=None, level="gateway", **kwargs):
        self.destinations = kwargs.pop("destinations", [])
        self.data = ElementCache(kwargs)
        self.data.update(level=level, routing_node=[])

        if element:
            self.data.update(href=element.href, name=element.name)
            # related_element_type=element.typeof)

        for destination in self.destinations:
            self.data["routing_node"].append({
                "href": destination.href,
                "name": destination.name,
                "level": "any"
            })
Beispiel #8
0
 def __init__(self, kwargs):
     self.data = ElementCache(kwargs)
Beispiel #9
0
 def __init__(self, task):
     super(Task, self).__init__(href=task.get("follower", None),
                                name=task.get("type", None))
     self.data = ElementCache(task)
Beispiel #10
0
 def __init__(self, data=None):
     self.data = data if data else ElementCache()
Beispiel #11
0
 def __init__(self, data=None, **meta):
     super(RoutingTree, self).__init__(**meta)
     if data is not None:
         self.data = ElementCache(data)
Beispiel #12
0
 def __init__(self, task):
     super(Task, self).__init__(href=task.get('follower', None),
                                name=task.get('type', None))
     self.data = ElementCache(**task)
Beispiel #13
0
 def __iter__(self):
     for node in self.data['antispoofing_node']:
         data = ElementCache(**node)
         yield (Antispoofing(href=data.get_link('self'), data=node))
Beispiel #14
0
 def __init__(self, data=None, **meta):
     super(Antispoofing, self).__init__(**meta)
     if data is not None:
         self.data = ElementCache(**data)