Esempio n. 1
0
    def _get_root(self, root_path):
        """
        Returns an APi Root object, given a Server and an API Root path
        Args:
            Server (taxii2.v2*.Server): The TAXII Server to search for
            root_path (str): the path of the API root in the URL
        Returns:
            The taxii2.v2*.Collection object with the name `coll_title`

        """
        for root in self.server.api_roots:
            if root.url.split("/")[-2] == root_path:
                return root
        msg = f"Api Root {root_path} does not exist in the TAXII server"
        raise TAXIIServiceException(msg)
Esempio n. 2
0
    def _get_collection(self, root, coll_title):
        """
        Returns a Collection object, given an API Root and a collection name
        Args:
            root (taxii2.v2*.ApiRoot): The API Root to search through
            coll_title (str): The Name of the target Collections
        Returns:
            The taxii2.v2*.Collection object with the name `coll_title`

        """
        for coll in root.collections:
            if coll.title == coll_title:
                return coll
        msg = f"Collection {coll_title} does not exist in API root {root.title}"
        raise TAXIIServiceException(msg)