def find_by_host(self, host: Host) -> List[Instance]: """ :param host: host instance filter :return: list of instances """ return [Instance.from_dict(data) for data in self._database.search(self._instances.host == host.get_name())]
def find_one_by_name(self, name: str) -> Instance: search_results = self._database.search(self._instances.name == name) if not search_results: raise NotFound('No instance with name "{0}"'.format(name)) return Instance.from_dict(search_results.pop())
def get_all(self) -> list: return [Instance.from_dict(instance_data) for instance_data in self._database.all()]