# -*- coding: utf-8 -*-
from operator import attrgetter
from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType
from pyangbind.lib.yangtypes import RestrictedClassType
from pyangbind.lib.yangtypes import TypedListType
from pyangbind.lib.yangtypes import YANGBool
from pyangbind.lib.yangtypes import YANGListType
from pyangbind.lib.yangtypes import YANGDynClass
from pyangbind.lib.yangtypes import ReferenceType
from pyangbind.lib.base import PybindBase
from collections import OrderedDict
from decimal import Decimal
from bitarray import bitarray
import six

# PY3 support of some PY2 keywords (needs improved)
if six.PY3:
    import builtins as __builtin__

    long = int
elif six.PY2:
    import __builtin__


class config(PybindBase):
    """
  This class was auto-generated by the PythonClass plugin for PYANG
  from YANG module openconfig-network-instance - based on the path /network-instances/network-instance/protocols/protocol/ospfv2/global/timers/max-metric/config. Each member element of
  the container is represented as a class variable - with a specific
  YANG type.

  YANG Description: Configuration parameters relating to setting the OSPFv2
maximum metric for a set of advertised entities.
  """
    __slots__ = (
        "_path_helper", "_extmethods", "__set_", "__timeout", "__include", "__trigger"
    )

    _yang_name = "config"

    _pybind_generated_by = "container"

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

        self._path_helper = False

        self._extmethods = False
        self.__set_ = YANGDynClass(
            base=YANGBool,
            is_leaf=True,
            yang_name="set",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="boolean",
            is_config=True,
        )
        self.__timeout = YANGDynClass(
            base=RestrictedClassType(
                base_type=long,
                restriction_dict={"range": ["0..18446744073709551615"]},
                int_size=64,
            ),
            is_leaf=True,
            yang_name="timeout",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="uint64",
            is_config=True,
        )
        self.__include = YANGDynClass(
            base=TypedListType(
                allowed_type=RestrictedClassType(
                    base_type=six.text_type,
                    restriction_type="dict_key",
                    restriction_arg={
                        "MAX_METRIC_INCLUDE_STUB": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospf-types:MAX_METRIC_INCLUDE_STUB": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospft:MAX_METRIC_INCLUDE_STUB": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospf-types:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospft:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                    },
                )
            ),
            is_leaf=False,
            yang_name="include",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="identityref",
            is_config=True,
        )
        self.__trigger = YANGDynClass(
            base=TypedListType(
                allowed_type=RestrictedClassType(
                    base_type=six.text_type,
                    restriction_type="dict_key",
                    restriction_arg={
                        "MAX_METRIC_ON_SYSTEM_BOOT": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospf-types:MAX_METRIC_ON_SYSTEM_BOOT": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospft:MAX_METRIC_ON_SYSTEM_BOOT": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                    },
                )
            ),
            is_leaf=False,
            yang_name="trigger",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="identityref",
            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 [
                "network-instances",
                "network-instance",
                "protocols",
                "protocol",
                "ospfv2",
                "global",
                "timers",
                "max-metric",
                "config",
            ]

    def _get_set_(self):
        """
    Getter method for set_, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/set (boolean)

    YANG Description: When this leaf is set to true, all non-stub interfaces of
the local system are advertised with the maximum metric,
such that the router does not act as a transit system,
(similarly to the IS-IS overload functionality).
    """
        return self.__set_

    def _set_set_(self, v, load=False):
        """
    Setter method for set_, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/set (boolean)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_set_ is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_set_() directly.

    YANG Description: When this leaf is set to true, all non-stub interfaces of
the local system are advertised with the maximum metric,
such that the router does not act as a transit system,
(similarly to the IS-IS overload functionality).
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=YANGBool,
                is_leaf=True,
                yang_name="set",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="boolean",
                is_config=True,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """set_ must be of a type compatible with boolean""",
                    "defined-type": "boolean",
                    "generated-type": """YANGDynClass(base=YANGBool, is_leaf=True, yang_name="set", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='boolean', is_config=True)""",
                }
            )

        self.__set_ = t
        if hasattr(self, "_set"):
            self._set()

    def _unset_set_(self):
        self.__set_ = YANGDynClass(
            base=YANGBool,
            is_leaf=True,
            yang_name="set",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="boolean",
            is_config=True,
        )

    def _get_timeout(self):
        """
    Getter method for timeout, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/timeout (uint64)

    YANG Description: The delay, in seconds, after which the advertisement of
entities with the maximum metric should be cleared, and
the system reverts to the default, or configured, metrics.
    """
        return self.__timeout

    def _set_timeout(self, v, load=False):
        """
    Setter method for timeout, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/timeout (uint64)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_timeout is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_timeout() directly.

    YANG Description: The delay, in seconds, after which the advertisement of
entities with the maximum metric should be cleared, and
the system reverts to the default, or configured, metrics.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=RestrictedClassType(
                    base_type=long,
                    restriction_dict={"range": ["0..18446744073709551615"]},
                    int_size=64,
                ),
                is_leaf=True,
                yang_name="timeout",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="uint64",
                is_config=True,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """timeout must be of a type compatible with uint64""",
                    "defined-type": "uint64",
                    "generated-type": """YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range':  ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="timeout", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='uint64', is_config=True)""",
                }
            )

        self.__timeout = t
        if hasattr(self, "_set"):
            self._set()

    def _unset_timeout(self):
        self.__timeout = YANGDynClass(
            base=RestrictedClassType(
                base_type=long,
                restriction_dict={"range": ["0..18446744073709551615"]},
                int_size=64,
            ),
            is_leaf=True,
            yang_name="timeout",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="uint64",
            is_config=True,
        )

    def _get_include(self):
        """
    Getter method for include, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/include (identityref)

    YANG Description: By default, the maximum metric is advertised for all
non-stub interfaces of a device. When identities are
specified within this leaf-list, additional entities
are also advertised with the maximum metric according
to the values within the list.
    """
        return self.__include

    def _set_include(self, v, load=False):
        """
    Setter method for include, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/include (identityref)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_include is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_include() directly.

    YANG Description: By default, the maximum metric is advertised for all
non-stub interfaces of a device. When identities are
specified within this leaf-list, additional entities
are also advertised with the maximum metric according
to the values within the list.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=TypedListType(
                    allowed_type=RestrictedClassType(
                        base_type=six.text_type,
                        restriction_type="dict_key",
                        restriction_arg={
                            "MAX_METRIC_INCLUDE_STUB": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "oc-ospf-types:MAX_METRIC_INCLUDE_STUB": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "oc-ospft:MAX_METRIC_INCLUDE_STUB": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "oc-ospf-types:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "oc-ospft:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                        },
                    )
                ),
                is_leaf=False,
                yang_name="include",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="identityref",
                is_config=True,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """include must be of a type compatible with identityref""",
                    "defined-type": "openconfig-network-instance:identityref",
                    "generated-type": """YANGDynClass(base=TypedListType(allowed_type=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={'MAX_METRIC_INCLUDE_STUB': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'oc-ospf-types:MAX_METRIC_INCLUDE_STUB': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'oc-ospft:MAX_METRIC_INCLUDE_STUB': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'MAX_METRIC_INCLUDE_TYPE2_EXTERNAL': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'oc-ospf-types:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'oc-ospft:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}},)), is_leaf=False, yang_name="include", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='identityref', is_config=True)""",
                }
            )

        self.__include = t
        if hasattr(self, "_set"):
            self._set()

    def _unset_include(self):
        self.__include = YANGDynClass(
            base=TypedListType(
                allowed_type=RestrictedClassType(
                    base_type=six.text_type,
                    restriction_type="dict_key",
                    restriction_arg={
                        "MAX_METRIC_INCLUDE_STUB": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospf-types:MAX_METRIC_INCLUDE_STUB": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospft:MAX_METRIC_INCLUDE_STUB": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospf-types:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospft:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                    },
                )
            ),
            is_leaf=False,
            yang_name="include",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="identityref",
            is_config=True,
        )

    def _get_trigger(self):
        """
    Getter method for trigger, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/trigger (identityref)

    YANG Description: By default, the maximum metric is only advertised
when the max-metric/set leaf is specified as true.
In the case that identities are specified within this
list, they provide additional triggers (e.g., system
boot) that may cause the max-metric to be set. In this
case, the system should still honour the timeout specified
by the max-metric/timeout leaf, and clear the max-metric
advertisements after the expiration of this timer.
    """
        return self.__trigger

    def _set_trigger(self, v, load=False):
        """
    Setter method for trigger, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/trigger (identityref)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_trigger is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_trigger() directly.

    YANG Description: By default, the maximum metric is only advertised
when the max-metric/set leaf is specified as true.
In the case that identities are specified within this
list, they provide additional triggers (e.g., system
boot) that may cause the max-metric to be set. In this
case, the system should still honour the timeout specified
by the max-metric/timeout leaf, and clear the max-metric
advertisements after the expiration of this timer.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=TypedListType(
                    allowed_type=RestrictedClassType(
                        base_type=six.text_type,
                        restriction_type="dict_key",
                        restriction_arg={
                            "MAX_METRIC_ON_SYSTEM_BOOT": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "oc-ospf-types:MAX_METRIC_ON_SYSTEM_BOOT": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "oc-ospft:MAX_METRIC_ON_SYSTEM_BOOT": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                        },
                    )
                ),
                is_leaf=False,
                yang_name="trigger",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="identityref",
                is_config=True,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """trigger must be of a type compatible with identityref""",
                    "defined-type": "openconfig-network-instance:identityref",
                    "generated-type": """YANGDynClass(base=TypedListType(allowed_type=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={'MAX_METRIC_ON_SYSTEM_BOOT': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'oc-ospf-types:MAX_METRIC_ON_SYSTEM_BOOT': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'oc-ospft:MAX_METRIC_ON_SYSTEM_BOOT': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}},)), is_leaf=False, yang_name="trigger", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='identityref', is_config=True)""",
                }
            )

        self.__trigger = t
        if hasattr(self, "_set"):
            self._set()

    def _unset_trigger(self):
        self.__trigger = YANGDynClass(
            base=TypedListType(
                allowed_type=RestrictedClassType(
                    base_type=six.text_type,
                    restriction_type="dict_key",
                    restriction_arg={
                        "MAX_METRIC_ON_SYSTEM_BOOT": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospf-types:MAX_METRIC_ON_SYSTEM_BOOT": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospft:MAX_METRIC_ON_SYSTEM_BOOT": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                    },
                )
            ),
            is_leaf=False,
            yang_name="trigger",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="identityref",
            is_config=True,
        )

    set_ = __builtin__.property(_get_set_, _set_set_)
    timeout = __builtin__.property(_get_timeout, _set_timeout)
    include = __builtin__.property(_get_include, _set_include)
    trigger = __builtin__.property(_get_trigger, _set_trigger)

    _pyangbind_elements = OrderedDict(
        [
            ("set_", set_),
            ("timeout", timeout),
            ("include", include),
            ("trigger", trigger),
        ]
    )


class config(PybindBase):
    """
  This class was auto-generated by the PythonClass plugin for PYANG
  from YANG module openconfig-network-instance-l2 - based on the path /network-instances/network-instance/protocols/protocol/ospfv2/global/timers/max-metric/config. Each member element of
  the container is represented as a class variable - with a specific
  YANG type.

  YANG Description: Configuration parameters relating to setting the OSPFv2
maximum metric for a set of advertised entities.
  """
    __slots__ = (
        "_path_helper", "_extmethods", "__set_", "__timeout", "__include", "__trigger"
    )

    _yang_name = "config"

    _pybind_generated_by = "container"

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

        self._path_helper = False

        self._extmethods = False
        self.__set_ = YANGDynClass(
            base=YANGBool,
            is_leaf=True,
            yang_name="set",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="boolean",
            is_config=True,
        )
        self.__timeout = YANGDynClass(
            base=RestrictedClassType(
                base_type=long,
                restriction_dict={"range": ["0..18446744073709551615"]},
                int_size=64,
            ),
            is_leaf=True,
            yang_name="timeout",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="uint64",
            is_config=True,
        )
        self.__include = YANGDynClass(
            base=TypedListType(
                allowed_type=RestrictedClassType(
                    base_type=six.text_type,
                    restriction_type="dict_key",
                    restriction_arg={
                        "MAX_METRIC_INCLUDE_STUB": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospf-types:MAX_METRIC_INCLUDE_STUB": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospft:MAX_METRIC_INCLUDE_STUB": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospf-types:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospft:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                    },
                )
            ),
            is_leaf=False,
            yang_name="include",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="identityref",
            is_config=True,
        )
        self.__trigger = YANGDynClass(
            base=TypedListType(
                allowed_type=RestrictedClassType(
                    base_type=six.text_type,
                    restriction_type="dict_key",
                    restriction_arg={
                        "MAX_METRIC_ON_SYSTEM_BOOT": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospf-types:MAX_METRIC_ON_SYSTEM_BOOT": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospft:MAX_METRIC_ON_SYSTEM_BOOT": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                    },
                )
            ),
            is_leaf=False,
            yang_name="trigger",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="identityref",
            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 [
                "network-instances",
                "network-instance",
                "protocols",
                "protocol",
                "ospfv2",
                "global",
                "timers",
                "max-metric",
                "config",
            ]

    def _get_set_(self):
        """
    Getter method for set_, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/set (boolean)

    YANG Description: When this leaf is set to true, all non-stub interfaces of
the local system are advertised with the maximum metric,
such that the router does not act as a transit system,
(similarly to the IS-IS overload functionality).
    """
        return self.__set_

    def _set_set_(self, v, load=False):
        """
    Setter method for set_, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/set (boolean)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_set_ is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_set_() directly.

    YANG Description: When this leaf is set to true, all non-stub interfaces of
the local system are advertised with the maximum metric,
such that the router does not act as a transit system,
(similarly to the IS-IS overload functionality).
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=YANGBool,
                is_leaf=True,
                yang_name="set",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="boolean",
                is_config=True,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """set_ must be of a type compatible with boolean""",
                    "defined-type": "boolean",
                    "generated-type": """YANGDynClass(base=YANGBool, is_leaf=True, yang_name="set", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='boolean', is_config=True)""",
                }
            )

        self.__set_ = t
        if hasattr(self, "_set"):
            self._set()

    def _unset_set_(self):
        self.__set_ = YANGDynClass(
            base=YANGBool,
            is_leaf=True,
            yang_name="set",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="boolean",
            is_config=True,
        )

    def _get_timeout(self):
        """
    Getter method for timeout, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/timeout (uint64)

    YANG Description: The delay, in seconds, after which the advertisement of
entities with the maximum metric should be cleared, and
the system reverts to the default, or configured, metrics.
    """
        return self.__timeout

    def _set_timeout(self, v, load=False):
        """
    Setter method for timeout, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/timeout (uint64)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_timeout is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_timeout() directly.

    YANG Description: The delay, in seconds, after which the advertisement of
entities with the maximum metric should be cleared, and
the system reverts to the default, or configured, metrics.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=RestrictedClassType(
                    base_type=long,
                    restriction_dict={"range": ["0..18446744073709551615"]},
                    int_size=64,
                ),
                is_leaf=True,
                yang_name="timeout",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="uint64",
                is_config=True,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """timeout must be of a type compatible with uint64""",
                    "defined-type": "uint64",
                    "generated-type": """YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range':  ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="timeout", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='uint64', is_config=True)""",
                }
            )

        self.__timeout = t
        if hasattr(self, "_set"):
            self._set()

    def _unset_timeout(self):
        self.__timeout = YANGDynClass(
            base=RestrictedClassType(
                base_type=long,
                restriction_dict={"range": ["0..18446744073709551615"]},
                int_size=64,
            ),
            is_leaf=True,
            yang_name="timeout",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="uint64",
            is_config=True,
        )

    def _get_include(self):
        """
    Getter method for include, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/include (identityref)

    YANG Description: By default, the maximum metric is advertised for all
non-stub interfaces of a device. When identities are
specified within this leaf-list, additional entities
are also advertised with the maximum metric according
to the values within the list.
    """
        return self.__include

    def _set_include(self, v, load=False):
        """
    Setter method for include, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/include (identityref)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_include is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_include() directly.

    YANG Description: By default, the maximum metric is advertised for all
non-stub interfaces of a device. When identities are
specified within this leaf-list, additional entities
are also advertised with the maximum metric according
to the values within the list.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=TypedListType(
                    allowed_type=RestrictedClassType(
                        base_type=six.text_type,
                        restriction_type="dict_key",
                        restriction_arg={
                            "MAX_METRIC_INCLUDE_STUB": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "oc-ospf-types:MAX_METRIC_INCLUDE_STUB": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "oc-ospft:MAX_METRIC_INCLUDE_STUB": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "oc-ospf-types:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "oc-ospft:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                        },
                    )
                ),
                is_leaf=False,
                yang_name="include",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="identityref",
                is_config=True,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """include must be of a type compatible with identityref""",
                    "defined-type": "openconfig-network-instance:identityref",
                    "generated-type": """YANGDynClass(base=TypedListType(allowed_type=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={'MAX_METRIC_INCLUDE_STUB': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'oc-ospf-types:MAX_METRIC_INCLUDE_STUB': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'oc-ospft:MAX_METRIC_INCLUDE_STUB': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'MAX_METRIC_INCLUDE_TYPE2_EXTERNAL': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'oc-ospf-types:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'oc-ospft:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}},)), is_leaf=False, yang_name="include", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='identityref', is_config=True)""",
                }
            )

        self.__include = t
        if hasattr(self, "_set"):
            self._set()

    def _unset_include(self):
        self.__include = YANGDynClass(
            base=TypedListType(
                allowed_type=RestrictedClassType(
                    base_type=six.text_type,
                    restriction_type="dict_key",
                    restriction_arg={
                        "MAX_METRIC_INCLUDE_STUB": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospf-types:MAX_METRIC_INCLUDE_STUB": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospft:MAX_METRIC_INCLUDE_STUB": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospf-types:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospft:MAX_METRIC_INCLUDE_TYPE2_EXTERNAL": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                    },
                )
            ),
            is_leaf=False,
            yang_name="include",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="identityref",
            is_config=True,
        )

    def _get_trigger(self):
        """
    Getter method for trigger, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/trigger (identityref)

    YANG Description: By default, the maximum metric is only advertised
when the max-metric/set leaf is specified as true.
In the case that identities are specified within this
list, they provide additional triggers (e.g., system
boot) that may cause the max-metric to be set. In this
case, the system should still honour the timeout specified
by the max-metric/timeout leaf, and clear the max-metric
advertisements after the expiration of this timer.
    """
        return self.__trigger

    def _set_trigger(self, v, load=False):
        """
    Setter method for trigger, mapped from YANG variable /network_instances/network_instance/protocols/protocol/ospfv2/global/timers/max_metric/config/trigger (identityref)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_trigger is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_trigger() directly.

    YANG Description: By default, the maximum metric is only advertised
when the max-metric/set leaf is specified as true.
In the case that identities are specified within this
list, they provide additional triggers (e.g., system
boot) that may cause the max-metric to be set. In this
case, the system should still honour the timeout specified
by the max-metric/timeout leaf, and clear the max-metric
advertisements after the expiration of this timer.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=TypedListType(
                    allowed_type=RestrictedClassType(
                        base_type=six.text_type,
                        restriction_type="dict_key",
                        restriction_arg={
                            "MAX_METRIC_ON_SYSTEM_BOOT": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "oc-ospf-types:MAX_METRIC_ON_SYSTEM_BOOT": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                            "oc-ospft:MAX_METRIC_ON_SYSTEM_BOOT": {
                                "@module": "openconfig-ospf-types",
                                "@namespace": "http://openconfig.net/yang/ospf-types",
                            },
                        },
                    )
                ),
                is_leaf=False,
                yang_name="trigger",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="identityref",
                is_config=True,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """trigger must be of a type compatible with identityref""",
                    "defined-type": "openconfig-network-instance:identityref",
                    "generated-type": """YANGDynClass(base=TypedListType(allowed_type=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={'MAX_METRIC_ON_SYSTEM_BOOT': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'oc-ospf-types:MAX_METRIC_ON_SYSTEM_BOOT': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}, 'oc-ospft:MAX_METRIC_ON_SYSTEM_BOOT': {'@module': 'openconfig-ospf-types', '@namespace': 'http://openconfig.net/yang/ospf-types'}},)), is_leaf=False, yang_name="trigger", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='identityref', is_config=True)""",
                }
            )

        self.__trigger = t
        if hasattr(self, "_set"):
            self._set()

    def _unset_trigger(self):
        self.__trigger = YANGDynClass(
            base=TypedListType(
                allowed_type=RestrictedClassType(
                    base_type=six.text_type,
                    restriction_type="dict_key",
                    restriction_arg={
                        "MAX_METRIC_ON_SYSTEM_BOOT": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospf-types:MAX_METRIC_ON_SYSTEM_BOOT": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                        "oc-ospft:MAX_METRIC_ON_SYSTEM_BOOT": {
                            "@module": "openconfig-ospf-types",
                            "@namespace": "http://openconfig.net/yang/ospf-types",
                        },
                    },
                )
            ),
            is_leaf=False,
            yang_name="trigger",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="identityref",
            is_config=True,
        )

    set_ = __builtin__.property(_get_set_, _set_set_)
    timeout = __builtin__.property(_get_timeout, _set_timeout)
    include = __builtin__.property(_get_include, _set_include)
    trigger = __builtin__.property(_get_trigger, _set_trigger)

    _pyangbind_elements = OrderedDict(
        [
            ("set_", set_),
            ("timeout", timeout),
            ("include", include),
            ("trigger", trigger),
        ]
    )
