# -*- 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__

from . import state
from . import segment_routing_algorithm
from . import segment_routing_capability


class subtlvs(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/isis/levels/level/link-state-database/lsp/tlvs/tlv/router-capabilities/router-capability/subtlvs/subtlvs. Each member element of
  the container is represented as a class variable - with a specific
  YANG type.

  YANG Description: List of subTLV types in the LSDB for the specified TLV
  """
    __slots__ = (
        "_path_helper",
        "_extmethods",
        "__subtlv_type",
        "__state",
        "__segment_routing_algorithm",
        "__segment_routing_capability",
    )

    _yang_name = "subtlvs"

    _pybind_generated_by = "container"

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

        self._path_helper = False

        self._extmethods = False
        self.__subtlv_type = YANGDynClass(
            base=six.text_type,
            is_leaf=True,
            yang_name="subtlv-type",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            is_keyval=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="leafref",
            is_config=False,
        )
        self.__state = YANGDynClass(
            base=state.state,
            is_container="container",
            yang_name="state",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            extensions=None,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="container",
            is_config=False,
        )
        self.__segment_routing_algorithm = YANGDynClass(
            base=segment_routing_algorithm.segment_routing_algorithm,
            is_container="container",
            yang_name="segment-routing-algorithm",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            extensions=None,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="container",
            is_config=False,
        )
        self.__segment_routing_capability = YANGDynClass(
            base=segment_routing_capability.segment_routing_capability,
            is_container="container",
            yang_name="segment-routing-capability",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            extensions=None,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="container",
            is_config=False,
        )

        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",
                "isis",
                "levels",
                "level",
                "link-state-database",
                "lsp",
                "tlvs",
                "tlv",
                "router-capabilities",
                "router-capability",
                "subtlvs",
                "subtlvs",
            ]

    def _get_subtlv_type(self):
        """
    Getter method for subtlv_type, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/subtlv_type (leafref)

    YANG Description: A reference for the TLV type being described within
the LSDB
    """
        return self.__subtlv_type

    def _set_subtlv_type(self, v, load=False):
        """
    Setter method for subtlv_type, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/subtlv_type (leafref)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_subtlv_type is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_subtlv_type() directly.

    YANG Description: A reference for the TLV type being described within
the LSDB
    """
        parent = getattr(self, "_parent", None)
        if parent is not None and load is False:
            raise AttributeError(
                "Cannot set keys directly when" + " within an instantiated list"
            )

        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=six.text_type,
                is_leaf=True,
                yang_name="subtlv-type",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                is_keyval=True,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="leafref",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """subtlv_type must be of a type compatible with leafref""",
                    "defined-type": "leafref",
                    "generated-type": """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subtlv-type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='leafref', is_config=False)""",
                }
            )

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

    def _unset_subtlv_type(self):
        self.__subtlv_type = YANGDynClass(
            base=six.text_type,
            is_leaf=True,
            yang_name="subtlv-type",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            is_keyval=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="leafref",
            is_config=False,
        )

    def _get_state(self):
        """
    Getter method for state, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/state (container)

    YANG Description: State parameters of IS Router Capabilities
    """
        return self.__state

    def _set_state(self, v, load=False):
        """
    Setter method for state, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/state (container)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_state is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_state() directly.

    YANG Description: State parameters of IS Router Capabilities
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=state.state,
                is_container="container",
                yang_name="state",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                extensions=None,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="container",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """state must be of a type compatible with container""",
                    "defined-type": "container",
                    "generated-type": """YANGDynClass(base=state.state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=False)""",
                }
            )

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

    def _unset_state(self):
        self.__state = YANGDynClass(
            base=state.state,
            is_container="container",
            yang_name="state",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            extensions=None,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="container",
            is_config=False,
        )

    def _get_segment_routing_algorithm(self):
        """
    Getter method for segment_routing_algorithm, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/segment_routing_algorithm (container)

    YANG Description: This container defines SR algorithm sub-TLV 19.
    """
        return self.__segment_routing_algorithm

    def _set_segment_routing_algorithm(self, v, load=False):
        """
    Setter method for segment_routing_algorithm, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/segment_routing_algorithm (container)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_segment_routing_algorithm is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_segment_routing_algorithm() directly.

    YANG Description: This container defines SR algorithm sub-TLV 19.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=segment_routing_algorithm.segment_routing_algorithm,
                is_container="container",
                yang_name="segment-routing-algorithm",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                extensions=None,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="container",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """segment_routing_algorithm must be of a type compatible with container""",
                    "defined-type": "container",
                    "generated-type": """YANGDynClass(base=segment_routing_algorithm.segment_routing_algorithm, is_container='container', yang_name="segment-routing-algorithm", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=False)""",
                }
            )

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

    def _unset_segment_routing_algorithm(self):
        self.__segment_routing_algorithm = YANGDynClass(
            base=segment_routing_algorithm.segment_routing_algorithm,
            is_container="container",
            yang_name="segment-routing-algorithm",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            extensions=None,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="container",
            is_config=False,
        )

    def _get_segment_routing_capability(self):
        """
    Getter method for segment_routing_capability, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/segment_routing_capability (container)

    YANG Description: This container defines SR Capability sub-TLV 2.
    """
        return self.__segment_routing_capability

    def _set_segment_routing_capability(self, v, load=False):
        """
    Setter method for segment_routing_capability, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/segment_routing_capability (container)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_segment_routing_capability is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_segment_routing_capability() directly.

    YANG Description: This container defines SR Capability sub-TLV 2.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=segment_routing_capability.segment_routing_capability,
                is_container="container",
                yang_name="segment-routing-capability",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                extensions=None,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="container",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """segment_routing_capability must be of a type compatible with container""",
                    "defined-type": "container",
                    "generated-type": """YANGDynClass(base=segment_routing_capability.segment_routing_capability, is_container='container', yang_name="segment-routing-capability", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=False)""",
                }
            )

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

    def _unset_segment_routing_capability(self):
        self.__segment_routing_capability = YANGDynClass(
            base=segment_routing_capability.segment_routing_capability,
            is_container="container",
            yang_name="segment-routing-capability",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            extensions=None,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="container",
            is_config=False,
        )

    subtlv_type = __builtin__.property(_get_subtlv_type)
    state = __builtin__.property(_get_state)
    segment_routing_algorithm = __builtin__.property(_get_segment_routing_algorithm)
    segment_routing_capability = __builtin__.property(_get_segment_routing_capability)

    _pyangbind_elements = OrderedDict(
        [
            ("subtlv_type", subtlv_type),
            ("state", state),
            ("segment_routing_algorithm", segment_routing_algorithm),
            ("segment_routing_capability", segment_routing_capability),
        ]
    )


from . import state
from . import segment_routing_algorithm
from . import segment_routing_capability


class subtlvs(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/isis/levels/level/link-state-database/lsp/tlvs/tlv/router-capabilities/router-capability/subtlvs/subtlvs. Each member element of
  the container is represented as a class variable - with a specific
  YANG type.

  YANG Description: List of subTLV types in the LSDB for the specified TLV
  """
    __slots__ = (
        "_path_helper",
        "_extmethods",
        "__subtlv_type",
        "__state",
        "__segment_routing_algorithm",
        "__segment_routing_capability",
    )

    _yang_name = "subtlvs"

    _pybind_generated_by = "container"

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

        self._path_helper = False

        self._extmethods = False
        self.__subtlv_type = YANGDynClass(
            base=six.text_type,
            is_leaf=True,
            yang_name="subtlv-type",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            is_keyval=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="leafref",
            is_config=False,
        )
        self.__state = YANGDynClass(
            base=state.state,
            is_container="container",
            yang_name="state",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            extensions=None,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="container",
            is_config=False,
        )
        self.__segment_routing_algorithm = YANGDynClass(
            base=segment_routing_algorithm.segment_routing_algorithm,
            is_container="container",
            yang_name="segment-routing-algorithm",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            extensions=None,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="container",
            is_config=False,
        )
        self.__segment_routing_capability = YANGDynClass(
            base=segment_routing_capability.segment_routing_capability,
            is_container="container",
            yang_name="segment-routing-capability",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            extensions=None,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="container",
            is_config=False,
        )

        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",
                "isis",
                "levels",
                "level",
                "link-state-database",
                "lsp",
                "tlvs",
                "tlv",
                "router-capabilities",
                "router-capability",
                "subtlvs",
                "subtlvs",
            ]

    def _get_subtlv_type(self):
        """
    Getter method for subtlv_type, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/subtlv_type (leafref)

    YANG Description: A reference for the TLV type being described within
the LSDB
    """
        return self.__subtlv_type

    def _set_subtlv_type(self, v, load=False):
        """
    Setter method for subtlv_type, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/subtlv_type (leafref)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_subtlv_type is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_subtlv_type() directly.

    YANG Description: A reference for the TLV type being described within
the LSDB
    """
        parent = getattr(self, "_parent", None)
        if parent is not None and load is False:
            raise AttributeError(
                "Cannot set keys directly when" + " within an instantiated list"
            )

        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=six.text_type,
                is_leaf=True,
                yang_name="subtlv-type",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                is_keyval=True,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="leafref",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """subtlv_type must be of a type compatible with leafref""",
                    "defined-type": "leafref",
                    "generated-type": """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subtlv-type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='leafref', is_config=False)""",
                }
            )

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

    def _unset_subtlv_type(self):
        self.__subtlv_type = YANGDynClass(
            base=six.text_type,
            is_leaf=True,
            yang_name="subtlv-type",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            is_keyval=True,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="leafref",
            is_config=False,
        )

    def _get_state(self):
        """
    Getter method for state, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/state (container)

    YANG Description: State parameters of IS Router Capabilities
    """
        return self.__state

    def _set_state(self, v, load=False):
        """
    Setter method for state, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/state (container)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_state is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_state() directly.

    YANG Description: State parameters of IS Router Capabilities
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=state.state,
                is_container="container",
                yang_name="state",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                extensions=None,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="container",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """state must be of a type compatible with container""",
                    "defined-type": "container",
                    "generated-type": """YANGDynClass(base=state.state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=False)""",
                }
            )

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

    def _unset_state(self):
        self.__state = YANGDynClass(
            base=state.state,
            is_container="container",
            yang_name="state",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            extensions=None,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="container",
            is_config=False,
        )

    def _get_segment_routing_algorithm(self):
        """
    Getter method for segment_routing_algorithm, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/segment_routing_algorithm (container)

    YANG Description: This container defines SR algorithm sub-TLV 19.
    """
        return self.__segment_routing_algorithm

    def _set_segment_routing_algorithm(self, v, load=False):
        """
    Setter method for segment_routing_algorithm, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/segment_routing_algorithm (container)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_segment_routing_algorithm is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_segment_routing_algorithm() directly.

    YANG Description: This container defines SR algorithm sub-TLV 19.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=segment_routing_algorithm.segment_routing_algorithm,
                is_container="container",
                yang_name="segment-routing-algorithm",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                extensions=None,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="container",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """segment_routing_algorithm must be of a type compatible with container""",
                    "defined-type": "container",
                    "generated-type": """YANGDynClass(base=segment_routing_algorithm.segment_routing_algorithm, is_container='container', yang_name="segment-routing-algorithm", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=False)""",
                }
            )

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

    def _unset_segment_routing_algorithm(self):
        self.__segment_routing_algorithm = YANGDynClass(
            base=segment_routing_algorithm.segment_routing_algorithm,
            is_container="container",
            yang_name="segment-routing-algorithm",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            extensions=None,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="container",
            is_config=False,
        )

    def _get_segment_routing_capability(self):
        """
    Getter method for segment_routing_capability, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/segment_routing_capability (container)

    YANG Description: This container defines SR Capability sub-TLV 2.
    """
        return self.__segment_routing_capability

    def _set_segment_routing_capability(self, v, load=False):
        """
    Setter method for segment_routing_capability, mapped from YANG variable /network_instances/network_instance/protocols/protocol/isis/levels/level/link_state_database/lsp/tlvs/tlv/router_capabilities/router_capability/subtlvs/subtlvs/segment_routing_capability (container)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_segment_routing_capability is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_segment_routing_capability() directly.

    YANG Description: This container defines SR Capability sub-TLV 2.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=segment_routing_capability.segment_routing_capability,
                is_container="container",
                yang_name="segment-routing-capability",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                extensions=None,
                namespace="http://openconfig.net/yang/network-instance",
                defining_module="openconfig-network-instance",
                yang_type="container",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """segment_routing_capability must be of a type compatible with container""",
                    "defined-type": "container",
                    "generated-type": """YANGDynClass(base=segment_routing_capability.segment_routing_capability, is_container='container', yang_name="segment-routing-capability", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/network-instance', defining_module='openconfig-network-instance', yang_type='container', is_config=False)""",
                }
            )

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

    def _unset_segment_routing_capability(self):
        self.__segment_routing_capability = YANGDynClass(
            base=segment_routing_capability.segment_routing_capability,
            is_container="container",
            yang_name="segment-routing-capability",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            extensions=None,
            namespace="http://openconfig.net/yang/network-instance",
            defining_module="openconfig-network-instance",
            yang_type="container",
            is_config=False,
        )

    subtlv_type = __builtin__.property(_get_subtlv_type)
    state = __builtin__.property(_get_state)
    segment_routing_algorithm = __builtin__.property(_get_segment_routing_algorithm)
    segment_routing_capability = __builtin__.property(_get_segment_routing_capability)

    _pyangbind_elements = OrderedDict(
        [
            ("subtlv_type", subtlv_type),
            ("state", state),
            ("segment_routing_algorithm", segment_routing_algorithm),
            ("segment_routing_capability", segment_routing_capability),
        ]
    )
