@@ -0,0 +1,1936 @@
+# Lint as: python3%0A%22%22%22Generic Google Cloud Platform multi-product generator.%0A%0ABase class for GCP firewalling products.%0A%22%22%22%0A%0Afrom __future__ import absolute_import%0Afrom __future__ import division%0Afrom __future__ import print_function%0Afrom __future__ import unicode_literals%0A%0Aimport json%0Afrom capirca.lib import aclgenerator%0A%0Aimport six%0A%0A%0Aclass Error(Exception):%0A  %22%22%22Generic error class.%22%22%22%0A%0A%0Aclass TermError(Error):%0A  %22%22%22Raised when a term is not valid.%22%22%22%0A%0A%0Aclass HeaderError(Error):%0A  %22%22%22Raised when a header is not valid.%22%22%22%0A%0A%0Aclass Term(aclgenerator.Term):%0A  %22%22%22A Term object.%22%22%22%0A%0A  def _TruncateComment(self, max_length):%0A    %22%22%22Truncate comment.%22%22%22%0A    raw_comment = ' '.join(self.term.comment)%0A    if len(raw_comment) %3E max_length:%0A      return raw_comment%5B:max_length%5D%0A    return raw_comment%0A%0A%0Aclass GCP(aclgenerator.ACLGenerator):%0A  %22%22%22A GCP object.%22%22%22%0A%0A  _GOOD_DIRECTION = %5B'INGRESS', 'EGRESS'%5D%0A%0A  def __str__(self):%0A    %22%22%22Return the JSON blob for a GCP object.%22%22%22%0A    out = '%25s%5Cn%5Cn' %25 (%0A        json.dumps(self.hf_policies, indent=2,%0A                   separators=(six.ensure_str(','), six.ensure_str(': ')),%0A                   sort_keys=True))%0A    return out%0A%0A%0Adef IsDefaultDeny(term):%0A  %22%22%22Return true if a term is a default deny without IPs, ports, etc.%22%22%22%0A  skip_attrs = %5B'flattened', 'flattened_addr', 'flattened_saddr',%0A                'flattened_daddr', 'action', 'comment', 'name'%5D%0A  if 'deny' not in term.action:%0A    return False%0A  # This lc will look through all methods and attributes of the object.%0A  # It returns only the attributes that need to be looked at to determine if%0A  # this is a default deny.%0A  for i in %5Ba for a in dir(term) if not a.startswith('__') and%0A            a.islower() and not callable(getattr(term, a))%5D:%0A    if i in skip_attrs:%0A      continue%0A    v = getattr(term, i)%0A    if isinstance(v, str) and v:%0A      return False%0A    if isinstance(v, list) and v:%0A      return False%0A%0A  return True%0A

Add generic GCP library.