Exemplo n.º 1
0
def ListClients(query=None, context=None):
    """List clients conforming to a givent query."""

    args = api_pb2.ApiListClientsArgs(query=query)

    items = context.SendIteratorRequest("ListClients", args)
    return utils.MapItemsIterator(
        lambda data: Client(data=data, context=context), items)
Exemplo n.º 2
0
  def ListFiles(self):
    args = api_pb2.ApiListFilesArgs(
        client_id=self.client_id, file_path=self.path)
    items = self._context.SendIteratorRequest("ListFiles", args)

    def MapDataToFile(data):
      return File(client_id=self.client_id, data=data, context=self._context)

    return utils.MapItemsIterator(MapDataToFile, items)
Exemplo n.º 3
0
def ListHuntApprovals(context=None):
  """List all hunt approvals belonging to requesting user."""
  items = context.SendIteratorRequest("ListHuntApprovals",
                                      api_pb2.ApiListHuntApprovalsArgs())

  def MapHuntApproval(data):
    return HuntApproval(data=data, username=context.username, context=context)

  return utils.MapItemsIterator(MapHuntApproval, items)
Exemplo n.º 4
0
    def ListFlows(self, offset=0, count=0):
        """List flows that ran on this client."""

        args = api_pb2.ApiListFlowsArgs(client_id=self.client_id,
                                        offset=offset,
                                        count=count)

        items = self._context.SendIteratorRequest("ListFlows", args)
        return utils.MapItemsIterator(
            lambda data: flow.Flow(data=data, context=self._context), items)
Exemplo n.º 5
0
    def ListApprovals(self, state=api_pb2.ApiListClientApprovalsArgs.ANY):
        args = api_pb2.ApiListClientApprovalsArgs(client_id=self.client_id,
                                                  state=state)
        items = self._context.SendIteratorRequest("ListClientApprovals", args)

        def MapClientApproval(data):
            return ClientApproval(data=data,
                                  username=self._context.username,
                                  context=self._context)

        return utils.MapItemsIterator(MapClientApproval, items)
Exemplo n.º 6
0
 def ListResults(self):
   args = api_pb2.ApiListFlowResultsArgs(
       client_id=self.client_id, flow_id=self.flow_id)
   items = self._context.SendIteratorRequest("ListFlowResults", args)
   return utils.MapItemsIterator(lambda data: FlowResult(data=data), items)
Exemplo n.º 7
0
 def ListResults(self):
   args = api_pb2.ApiListHuntResultsArgs(hunt_id=self.hunt_id)
   items = self._context.SendIteratorRequest("ListHuntResults", args)
   return utils.MapItemsIterator(
       lambda data: HuntResult(data=data, context=self._context), items)