docs: def ReadAllClientActionRequests(self, client_id, cursor=None):
      """Reads all client messages available for a given client_id."""
  
      query = ("SELECT request, UNIX_TIMESTAMP(leased_until), leased_by, "
               "leased_count "
               "FROM client_action_requests "
               "WHERE client_id = %s")
  
      cursor.execute(query, [db_utils.ClientIDToInt(client_id)])
  
      ret = []
      for req, leased_until, leased_by, leased_count in cursor.fetchall():
        request = rdf_flows.ClientActionRequest.FromSerializedString(req)
        if leased_until is not None:
          request.leased_by = leased_by
          request.leased_until = mysql_utils.TimestampToRDFDatetime(leased_until)
        else:
          request.leased_by = None
          request.leased_until = None
        request.ttl = db.Database.CLIENT_MESSAGES_TTL - leased_count
        ret.append(request)
  
      return sorted(ret, key=lambda req: (req.flow_id, req.request_id))