
from operator import attrgetter
import pyangbind.lib.xpathhelper as xpathhelper
from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType, RestrictedClassType, TypedListType
from pyangbind.lib.yangtypes import YANGBool, YANGListType, YANGDynClass, ReferenceType
from pyangbind.lib.base import PybindBase
from decimal import Decimal
from bitarray import bitarray
class config(PybindBase):
  """
  This class was auto-generated by the PythonClass plugin for PYANG
  from YANG module openconfig-routing-policy - based on the path /routing-policy/policy-definitions/policy-definition/statements/statement/conditions/config. Each member element of
  the container is represented as a class variable - with a specific
  YANG type.

  YANG Description: Configuration data for policy conditions
  """
  __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__call_policy','__install_protocol_eq',)

  _yang_name = 'config'

  _pybind_generated_by = 'container'

  def __init__(self, *args, **kwargs):

    helper = kwargs.pop("path_helper", None)
    if helper is False:
      self._path_helper = False
    elif helper is not None and isinstance(helper, xpathhelper.YANGPathHelper):
      self._path_helper = helper
    elif hasattr(self, "_parent"):
      helper = getattr(self._parent, "_path_helper", False)
      self._path_helper = helper
    else:
      self._path_helper = False

    self._extmethods = False
    self.__install_protocol_eq = YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'oc-pol-types:ISIS': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'ISIS': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:OSPF': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:STATIC': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:DIRECTLY_CONNECTED': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:OSPF3': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:BGP': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:OSPF': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:LOCAL_AGGREGATE': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'BGP': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'LOCAL_AGGREGATE': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:OSPF3': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'STATIC': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:STATIC': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:BGP': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'DIRECTLY_CONNECTED': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:LOCAL_AGGREGATE': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'OSPF': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:ISIS': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'OSPF3': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:DIRECTLY_CONNECTED': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}},), is_leaf=True, yang_name="install-protocol-eq", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/routing-policy', defining_module='openconfig-routing-policy', yang_type='identityref', is_config=True)
    self.__call_policy = YANGDynClass(base=ReferenceType(referenced_path='/oc-rpol:routing-policy/oc-rpol:policy-definitions/oc-rpol:policy-definition/oc-rpol:name', caller=self._path() + ['call-policy'], path_helper=self._path_helper, require_instance=True), is_leaf=True, yang_name="call-policy", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/routing-policy', defining_module='openconfig-routing-policy', yang_type='leafref', is_config=True)

    load = kwargs.pop("load", None)
    if args:
      if len(args) > 1:
        raise TypeError("cannot create a YANG container with >1 argument")
      all_attr = True
      for e in self._pyangbind_elements:
        if not hasattr(args[0], e):
          all_attr = False
          break
      if not all_attr:
        raise ValueError("Supplied object did not have the correct attributes")
      for e in self._pyangbind_elements:
        nobj = getattr(args[0], e)
        if nobj._changed() is False:
          continue
        setmethod = getattr(self, "_set_%s" % e)
        if load is None:
          setmethod(getattr(args[0], e))
        else:
          setmethod(getattr(args[0], e), load=load)

  def _path(self):
    if hasattr(self, "_parent"):
      return self._parent._path()+[self._yang_name]
    else:
      return [u'routing-policy', u'policy-definitions', u'policy-definition', u'statements', u'statement', u'conditions', u'config']

  def _get_call_policy(self):
    """
    Getter method for call_policy, mapped from YANG variable /routing_policy/policy_definitions/policy_definition/statements/statement/conditions/config/call_policy (leafref)

    YANG Description: Applies the statements from the specified policy
definition and then returns control the current
policy statement. Note that the called policy may
itself call other policies (subject to
implementation limitations). This is intended to
provide a policy 'subroutine' capability.  The
called policy should contain an explicit or a
default route disposition that returns an
effective true (accept-route) or false
(reject-route), otherwise the behavior may be
ambiguous and implementation dependent
    """
    return self.__call_policy
      
  def _set_call_policy(self, v, load=False):
    """
    Setter method for call_policy, mapped from YANG variable /routing_policy/policy_definitions/policy_definition/statements/statement/conditions/config/call_policy (leafref)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_call_policy is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_call_policy() directly.

    YANG Description: Applies the statements from the specified policy
definition and then returns control the current
policy statement. Note that the called policy may
itself call other policies (subject to
implementation limitations). This is intended to
provide a policy 'subroutine' capability.  The
called policy should contain an explicit or a
default route disposition that returns an
effective true (accept-route) or false
(reject-route), otherwise the behavior may be
ambiguous and implementation dependent
    """
    try:
      t = YANGDynClass(v,base=ReferenceType(referenced_path='/oc-rpol:routing-policy/oc-rpol:policy-definitions/oc-rpol:policy-definition/oc-rpol:name', caller=self._path() + ['call-policy'], path_helper=self._path_helper, require_instance=True), is_leaf=True, yang_name="call-policy", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/routing-policy', defining_module='openconfig-routing-policy', yang_type='leafref', is_config=True)
    except (TypeError, ValueError):
      raise ValueError({
          'error-string': """call_policy must be of a type compatible with leafref""",
          'defined-type': "leafref",
          'generated-type': """YANGDynClass(base=ReferenceType(referenced_path='/oc-rpol:routing-policy/oc-rpol:policy-definitions/oc-rpol:policy-definition/oc-rpol:name', caller=self._path() + ['call-policy'], path_helper=self._path_helper, require_instance=True), is_leaf=True, yang_name="call-policy", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/routing-policy', defining_module='openconfig-routing-policy', yang_type='leafref', is_config=True)""",
        })

    self.__call_policy = t
    if hasattr(self, '_set'):
      self._set()

  def _unset_call_policy(self):
    self.__call_policy = YANGDynClass(base=ReferenceType(referenced_path='/oc-rpol:routing-policy/oc-rpol:policy-definitions/oc-rpol:policy-definition/oc-rpol:name', caller=self._path() + ['call-policy'], path_helper=self._path_helper, require_instance=True), is_leaf=True, yang_name="call-policy", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/routing-policy', defining_module='openconfig-routing-policy', yang_type='leafref', is_config=True)


  def _get_install_protocol_eq(self):
    """
    Getter method for install_protocol_eq, mapped from YANG variable /routing_policy/policy_definitions/policy_definition/statements/statement/conditions/config/install_protocol_eq (identityref)

    YANG Description: Condition to check the protocol / method used to install
the route into the local routing table
    """
    return self.__install_protocol_eq
      
  def _set_install_protocol_eq(self, v, load=False):
    """
    Setter method for install_protocol_eq, mapped from YANG variable /routing_policy/policy_definitions/policy_definition/statements/statement/conditions/config/install_protocol_eq (identityref)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_install_protocol_eq is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_install_protocol_eq() directly.

    YANG Description: Condition to check the protocol / method used to install
the route into the local routing table
    """
    try:
      t = YANGDynClass(v,base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'oc-pol-types:ISIS': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'ISIS': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:OSPF': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:STATIC': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:DIRECTLY_CONNECTED': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:OSPF3': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:BGP': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:OSPF': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:LOCAL_AGGREGATE': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'BGP': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'LOCAL_AGGREGATE': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:OSPF3': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'STATIC': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:STATIC': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:BGP': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'DIRECTLY_CONNECTED': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:LOCAL_AGGREGATE': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'OSPF': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:ISIS': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'OSPF3': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:DIRECTLY_CONNECTED': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}},), is_leaf=True, yang_name="install-protocol-eq", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/routing-policy', defining_module='openconfig-routing-policy', yang_type='identityref', is_config=True)
    except (TypeError, ValueError):
      raise ValueError({
          'error-string': """install_protocol_eq must be of a type compatible with identityref""",
          'defined-type': "openconfig-routing-policy:identityref",
          'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'oc-pol-types:ISIS': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'ISIS': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:OSPF': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:STATIC': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:DIRECTLY_CONNECTED': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:OSPF3': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:BGP': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:OSPF': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:LOCAL_AGGREGATE': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'BGP': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'LOCAL_AGGREGATE': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:OSPF3': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'STATIC': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:STATIC': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:BGP': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'DIRECTLY_CONNECTED': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:LOCAL_AGGREGATE': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'OSPF': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:ISIS': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'OSPF3': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:DIRECTLY_CONNECTED': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}},), is_leaf=True, yang_name="install-protocol-eq", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/routing-policy', defining_module='openconfig-routing-policy', yang_type='identityref', is_config=True)""",
        })

    self.__install_protocol_eq = t
    if hasattr(self, '_set'):
      self._set()

  def _unset_install_protocol_eq(self):
    self.__install_protocol_eq = YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'oc-pol-types:ISIS': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'ISIS': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:OSPF': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:STATIC': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:DIRECTLY_CONNECTED': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:OSPF3': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:BGP': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:OSPF': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:LOCAL_AGGREGATE': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'BGP': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'LOCAL_AGGREGATE': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:OSPF3': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'STATIC': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:STATIC': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:BGP': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'DIRECTLY_CONNECTED': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:LOCAL_AGGREGATE': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'OSPF': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'openconfig-policy-types:ISIS': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'OSPF3': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}, u'oc-pol-types:DIRECTLY_CONNECTED': {'@module': u'openconfig-policy-types', '@namespace': u'http://openconfig.net/yang/policy-types'}},), is_leaf=True, yang_name="install-protocol-eq", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/routing-policy', defining_module='openconfig-routing-policy', yang_type='identityref', is_config=True)

  call_policy = property(_get_call_policy, _set_call_policy)
  install_protocol_eq = property(_get_install_protocol_eq, _set_install_protocol_eq)


  _pyangbind_elements = {'call_policy': call_policy, 'install_protocol_eq': install_protocol_eq, }


