# Path: capirca/lib/gcp.py
# class Error(Exception):
# class TermError(Error):
# class HeaderError(Error):
# class UnsupportedFilterTypeError(Error):
# class Term(aclgenerator.Term):
# class GCP(aclgenerator.ACLGenerator):
#   _ALLOW_PROTO_NAME = frozenset(
#       ['tcp', 'udp', 'icmp', 'esp', 'ah', 'ipip', 'sctp',
#        'all'
#       ])
#   _GOOD_DIRECTION = ['INGRESS', 'EGRESS']
#   def _GetPorts(self):
#   def _GetLoggingSetting(self):
#   def __str__(self):
# def IsDefaultDeny(term):
# def IsProjectIDValid(project):
# def IsVPCNameValid(vpc):
# def TruncateString(raw_string, max_length):
# def GetIpv6TermName(term_name):
# 
# Path: capirca/lib/nacaddr.py
# def IP(ip, comment='', token='', strict=True):
# def _is_subnet_of(a, b):  # pylint: disable=invalid-name
#   def __init__(self, ip_string, comment='', token='', strict=True):
#   def subnet_of(self, other):
#   def supernet_of(self, other):
#   def __deepcopy__(self, memo):
#   def AddComment(self, comment=''):
#   def supernet(self, prefixlen_diff=1):
#   def __init__(self, ip_string, comment='', token='', strict=True):
#   def subnet_of(self, other):
#   def supernet_of(self, other):
#   def __deepcopy__(self, memo):
#   def supernet(self, prefixlen_diff=1):
#   def AddComment(self, comment=''):
# def _InNetList(adders, ip):
# def IsSuperNet(supernets, subnets):
# def CollapseAddrListPreserveTokens(addresses):
# def _SafeToMerge(address, merge_target, check_addresses):
# def _CollapseAddrListInternal(addresses, complements_by_network):
# def CollapseAddrList(addresses, complement_addresses=None):
# def SortAddrList(addresses):
# def RemoveAddressFromList(superset, exclude):
# def AddressListExclude(superset, excludes, collapse_addrs=True):
# class IPv4(ipaddress.IPv4Network):
# class IPv6(ipaddress.IPv6Network):
# class PrefixlenDiffInvalidError(ipaddress.NetmaskValueError):


import copy
import datetime
import ipaddress
import json
import logging
import re
import six
from typing import Dict, Any
from capirca.lib import gcp
from capirca.lib import nacaddr


def IsDefaultDeny(term):
  """Returns true if a term is a default deny without IPs, ports, etc."""
  skip_attrs = ['flattened', 'flattened_addr', 'flattened_saddr',
                'flattened_daddr', 'action', 'comment', 'name', 'logging']
  if 'deny' not in term.action:
    return False
  # This lc will look through all methods and attributes of the object.
  # It returns only the attributes that need to be looked at to determine if
  # this is a default deny.
  for i in [a for a in dir(term) if not a.startswith('__') and
            a.islower() and not callable(getattr(term, a))]:
    if i in skip_attrs:
      continue
    v = getattr(term, i)
    if isinstance(v, str) and v:
      return False
    if isinstance(v, list) and v:
      return False

  return True



def GetNextPriority(priority):
  """Get the priority for the next rule."""
  return priority



# Path: capirca/lib/gcp.py
# class Error(Exception):
# class TermError(Error):
# class HeaderError(Error):
# class UnsupportedFilterTypeError(Error):
# class Term(aclgenerator.Term):
# class GCP(aclgenerator.ACLGenerator):
#   _ALLOW_PROTO_NAME = frozenset(
#       ['tcp', 'udp', 'icmp', 'esp', 'ah', 'ipip', 'sctp',
#        'all'
#       ])
#   _GOOD_DIRECTION = ['INGRESS', 'EGRESS']
#   def _GetPorts(self):
#   def _GetLoggingSetting(self):
#   def __str__(self):
# def IsDefaultDeny(term):
# def IsProjectIDValid(project):
# def IsVPCNameValid(vpc):
# def TruncateString(raw_string, max_length):
# def GetIpv6TermName(term_name):
# 
# Path: capirca/lib/nacaddr.py
# def IP(ip, comment='', token='', strict=True):
# def _is_subnet_of(a, b):  # pylint: disable=invalid-name
#   def __init__(self, ip_string, comment='', token='', strict=True):
#   def subnet_of(self, other):
#   def supernet_of(self, other):
#   def __deepcopy__(self, memo):
#   def AddComment(self, comment=''):
#   def supernet(self, prefixlen_diff=1):
#   def __init__(self, ip_string, comment='', token='', strict=True):
#   def subnet_of(self, other):
#   def supernet_of(self, other):
#   def __deepcopy__(self, memo):
#   def supernet(self, prefixlen_diff=1):
#   def AddComment(self, comment=''):
# def _InNetList(adders, ip):
# def IsSuperNet(supernets, subnets):
# def CollapseAddrListPreserveTokens(addresses):
# def _SafeToMerge(address, merge_target, check_addresses):
# def _CollapseAddrListInternal(addresses, complements_by_network):
# def CollapseAddrList(addresses, complement_addresses=None):
# def SortAddrList(addresses):
# def RemoveAddressFromList(superset, exclude):
# def AddressListExclude(superset, excludes, collapse_addrs=True):
# class IPv4(ipaddress.IPv4Network):
# class IPv6(ipaddress.IPv6Network):
# class PrefixlenDiffInvalidError(ipaddress.NetmaskValueError):


# Path: capirca/lib/gce.py
import copy
import datetime
import ipaddress
import json
import logging
import re
import six
from typing import Dict, Any
from capirca.lib import gcp
from capirca.lib import nacaddr



def IsDefaultDeny(term):
  """Returns true if a term is a default deny without IPs, ports, etc."""
  skip_attrs = ['flattened', 'flattened_addr', 'flattened_saddr',
                'flattened_daddr', 'action', 'comment', 'name', 'logging']
  if 'deny' not in term.action:
    return False
  # This lc will look through all methods and attributes of the object.
  # It returns only the attributes that need to be looked at to determine if
  # this is a default deny.
  for i in [a for a in dir(term) if not a.startswith('__') and
            a.islower() and not callable(getattr(term, a))]:
    if i in skip_attrs:
      continue
    v = getattr(term, i)
    if isinstance(v, str) and v:
      return False
    if isinstance(v, list) and v:
      return False

  return True



def GetNextPriority(priority):
  """Get the priority for the next rule."""
  return priority



class Term(gcp.Term):