Ejemplo n.º 1
0
    def browse(self):
        """
        Browse the elements nested below this Domain or Group.
        Results could be internal users or groups.

        :return: list of Element by type
        :rtype: list
        """
        return [Element.from_meta(**element) for element in self.make_request(resource="browse")]
Ejemplo n.º 2
0
 def browse(self):
     """
     Browse the elements nested below this Domain or Group.
     Results could be internal users or groups.
     
     :return: list of Element by type
     :rtype: list
     """
     return [Element.from_meta(**element)
         for element in self.make_request(resource='browse')]
Ejemplo n.º 3
0
    def used_on(self):
        """
        Return all NAT'd elements using this location. 

        .. note::
            Available only in SMC version 6.2

        :return: elements used by this location
        :rtype: list
        """
        return [Element.from_meta(**element)
                for element in
                self.make_request(resource='search_nated_elements_from_location')]
Ejemplo n.º 4
0
    def used_on(self):
        """
        Return all NAT'd elements using this location. 

        .. note::
            Available only in SMC version 6.2

        :return: elements used by this location
        :rtype: list
        """
        return [Element.from_meta(**element)
                for element in
                self.make_request(resource='search_nated_elements_from_location')]
Ejemplo n.º 5
0
    def search_elements(self):
        """
        Find all elements assigned to this category tag. You can also find
        category tags assigned directly to an element also::
        
            >>> host = Host('kali')
            >>> host.categories
            [Category(name=myelements), Category(name=foocategory)]

        :return: :py:class:`smc.base.model.Element`
        :rtype: list
        """
        return [Element.from_meta(**tag)
                for tag in
                self.make_request(resource='search_elements_from_category_tag')]
Ejemplo n.º 6
0
    def search_elements(self):
        """
        Find all elements assigned to this category tag. You can also find
        category tags assigned directly to an element also::
        
            >>> host = Host('kali')
            >>> host.categories
            [Category(name=myelements), Category(name=foocategory)]

        :return: :py:class:`smc.base.model.Element`
        :rtype: list
        """
        return [Element.from_meta(**tag)
                for tag in
                self.make_request(resource='search_elements_from_category_tag')]
Ejemplo n.º 7
0
def from_meta(node):
    """
    Helper method that reolves a routing node to element. Rather than doing
    a lookup and fetch, the routing node provides the information to
    build the element from meta alone.
    
    :rtype: Element
    """
    # Version SMC < 6.4
    if not node.related_element_type:
        return Element.from_href(node.data.get('href'))

    # SMC Version >= 6.4 - more efficient because it builds the
    # element by meta versus requiring a query
    return Element.from_meta(name=node.data.get('name'),
                             type=node.related_element_type,
                             href=node.data.get('href'))
Ejemplo n.º 8
0
def from_meta(node):
    """
    Helper method that reolves a routing node to element. Rather than doing
    a lookup and fetch, the routing node provides the information to
    build the element from meta alone.
    
    :rtype: Element
    """
    # Version SMC < 6.4
    if 'related_element_type' not in node.data:
        return Element.from_href(
            node.data.get('href'))
    
    # SMC Version >= 6.4 - more efficient because it builds the
    # element by meta versus requiring a query
    return Element.from_meta(
        name=node.data.get('name'),
        type=node.related_element_type,
        href=node.data.get('href'))