Esempio n. 1
0
def MakeRule(predicate,
             default_status=None,
             default_owner_id=None,
             add_cc_ids=None,
             add_labels=None,
             add_notify=None):
    """Make a FilterRule PB with the supplied information.

  Args:
    predicate: string query that will trigger the rule if satisfied.
    default_status: optional default status to set if rule fires.
    default_owner_id: optional default owner_id to set if rule fires.
    add_cc_ids: optional cc ids to set if rule fires.
    add_labels: optional label strings to set if rule fires.
    add_notify: optional notify email addresses to set if rule fires.

  Returns:
    A new FilterRule PB.
  """
    rule_pb = tracker_pb2.FilterRule()
    rule_pb.predicate = predicate

    if add_labels:
        rule_pb.add_labels = add_labels
    if default_status:
        rule_pb.default_status = default_status
    if default_owner_id:
        rule_pb.default_owner_id = default_owner_id
    if add_cc_ids:
        rule_pb.add_cc_ids = add_cc_ids
    if add_notify:
        rule_pb.add_notify_addrs = add_notify

    return rule_pb
Esempio n. 2
0
def MakeRule(
    predicate, default_status=None, default_owner_id=None, add_cc_ids=None,
    add_labels=None, add_notify=None, warning=None, error=None):
  """Make a FilterRule PB with the supplied information.

  Args:
    predicate: string query that will trigger the rule if satisfied.
    default_status: optional default status to set if rule fires.
    default_owner_id: optional default owner_id to set if rule fires.
    add_cc_ids: optional cc ids to set if rule fires.
    add_labels: optional label strings to set if rule fires.
    add_notify: optional notify email addresses to set if rule fires.
    warning: optional string for a software development process warning.
    error: optional string for a software development process error.

  Returns:
    A new FilterRule PB.
  """
  rule_pb = tracker_pb2.FilterRule()
  rule_pb.predicate = predicate

  if add_labels:
    rule_pb.add_labels = add_labels
  if default_status:
    rule_pb.default_status = default_status
  if default_owner_id:
    rule_pb.default_owner_id = default_owner_id
  if add_cc_ids:
    rule_pb.add_cc_ids = add_cc_ids
  if add_notify:
    rule_pb.add_notify_addrs = add_notify
  if warning:
    rule_pb.warning = warning
  if error:
    rule_pb.error = error

  return rule_pb
Esempio n. 3
0
 def setUp(self):
     self.rule = tracker_pb2.FilterRule()
     self.rule.predicate = 'label:a label:b'