def _gc_rule_from_pb(gc_rule_pb):
 rule_name = gc_rule_pb.WhichOneof('rule')
 if (rule_name is None):
  return None
 if (rule_name == 'max_num_versions'):
  return MaxVersionsGCRule(gc_rule_pb.max_num_versions)
 elif (rule_name == 'max_age'):
  max_age = _helpers._duration_pb_to_timedelta(gc_rule_pb.max_age)
  return MaxAgeGCRule(max_age)
 elif (rule_name == 'union'):
  return GCRuleUnion([_gc_rule_from_pb(rule) for rule in gc_rule_pb.union.rules])
 elif (rule_name == 'intersection'):
  rules = [_gc_rule_from_pb(rule) for rule in gc_rule_pb.intersection.rules]
  return GCRuleIntersection(rules)
 else:
  raise ValueError('Unexpected rule name', rule_name)

def _gc_rule_from_pb ( gc_rule_pb ) : rule_name = gc_rule_pb . WhichOneof ( 'rule' ) if ( rule_name is None ) : return None if ( rule_name == 'max_num_versions' ) : return MaxVersionsGCRule ( gc_rule_pb . max_num_versions ) elif ( rule_name == 'max_age' ) : max_age = _helpers . _duration_pb_to_timedelta ( gc_rule_pb . max_age ) return MaxAgeGCRule ( max_age ) elif ( rule_name == 'union' ) : return GCRuleUnion ( [ _gc_rule_from_pb ( rule ) for rule in gc_rule_pb . union . rules ] ) elif ( rule_name == 'intersection' ) : rules = [ _gc_rule_from_pb ( rule ) for rule in gc_rule_pb . intersection . rules ] return GCRuleIntersection ( rules ) else : raise ValueError ( 'Unexpected rule name' , rule_name )
convert a protobuf gc rule to a native object .