Beispiel #1
0
 def list_instances(self, offset: int = 0, limit: Optional[int] = None,
                    with_info: bool = False) -> List[GraphInstanceInfo]:
     """List all known graph instances.
        If with_info is false, only instance_id will be received.
     :returns List[GraphInstanceInfo]: List of received graph instances
     """
     data = {offset: offset, with_info: '1' if with_info else '0'}
     if limit is not None:
         data['limit'] = limit
     return [GraphInstanceInfo.create(_)
             for _ in requests.get(self._url_prefix + 'instances', params=data).json()['payload']]
Beispiel #2
0
 def add_graph_instance(self, instance_id: str, graph_struct: GraphStruct) -> GraphInstanceInfo:
     instance = GraphInstanceInfo()
     instance.instance_id = instance_id
     instance.structure = graph_struct
     self.backend.write_graph_instance_info(instance_id, instance)
     return instance
Beispiel #3
0
 def list_graph_instance_info(self, with_info: bool = False) -> Iterator[Tuple[str, Optional[GraphInstanceInfo]]]:
     for instance_id, instance_info in self.instances.iterate_all(include_value=with_info):
         yield instance_id, GraphInstanceInfo.create(instance_info) if instance_info else None
Beispiel #4
0
 def write_graph_instance_info(self, instance_id: str, instance_info: GraphInstanceInfo):
     return self.instances.put(instance_id, instance_info.to_json())
Beispiel #5
0
 def read_graph_instance_info(self, instance_id: str) -> GraphInstanceInfo:
     return GraphInstanceInfo.create(self.instances.get(instance_id))
Beispiel #6
0
 def read_instance(self, instance_id: str) -> GraphInstanceInfo:
     """Read info about a specified graph's instance.
     :returns GraphInstanceInfo: info about a graph's instance
     """
     return GraphInstanceInfo.create(requests.get(self._get_instance_url(instance_id)).json()['payload'])