# -*- 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 state(PybindBase):
    """
  This class was auto-generated by the PythonClass plugin for PYANG
  from YANG module openconfig-system - based on the path /system/ntp/servers/server/state. Each member element of
  the container is represented as a class variable - with a specific
  YANG type.

  YANG Description: Operational state data for an NTP server.
  """
    __slots__ = (
        "_path_helper",
        "_extmethods",
        "__address",
        "__port",
        "__version",
        "__association_type",
        "__iburst",
        "__prefer",
        "__stratum",
        "__root_delay",
        "__root_dispersion",
        "__offset",
        "__poll_interval",
    )

    _yang_name = "state"

    _pybind_generated_by = "container"

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

        self._path_helper = False

        self._extmethods = False
        self.__address = YANGDynClass(
            base=[
                RestrictedClassType(
                    base_type=six.text_type,
                    restriction_dict={
                        "pattern": "(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\\p{N}\\p{L}]+)?"
                    },
                ),
                RestrictedClassType(
                    base_type=six.text_type,
                    restriction_dict={
                        "pattern": "((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(%[\\p{N}\\p{L}]+)?"
                    },
                ),
                RestrictedClassType(
                    base_type=six.text_type,
                    restriction_dict={
                        "pattern": "((([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.)*([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.?)|\\.",
                        "length": ["1..253"],
                    },
                ),
            ],
            is_leaf=True,
            yang_name="address",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="inet:host",
            is_config=False,
        )
        self.__port = YANGDynClass(
            base=RestrictedClassType(
                base_type=RestrictedClassType(
                    base_type=int, restriction_dict={"range": ["0..65535"]}, int_size=16
                ),
                restriction_dict={"range": ["0..65535"]},
            ),
            default=RestrictedClassType(
                base_type=int, restriction_dict={"range": ["0..65535"]}, int_size=16
            )(
                123
            ),
            is_leaf=True,
            yang_name="port",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="inet:port-number",
            is_config=False,
        )
        self.__version = YANGDynClass(
            base=RestrictedClassType(
                base_type=RestrictedClassType(
                    base_type=int, restriction_dict={"range": ["0..255"]}, int_size=8
                ),
                restriction_dict={"range": ["1..4"]},
            ),
            default=RestrictedClassType(
                base_type=int, restriction_dict={"range": ["0..255"]}, int_size=8
            )(
                4
            ),
            is_leaf=True,
            yang_name="version",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="uint8",
            is_config=False,
        )
        self.__association_type = YANGDynClass(
            base=RestrictedClassType(
                base_type=six.text_type,
                restriction_type="dict_key",
                restriction_arg={"SERVER": {}, "PEER": {}, "POOL": {}},
            ),
            default=six.text_type("SERVER"),
            is_leaf=True,
            yang_name="association-type",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="enumeration",
            is_config=False,
        )
        self.__iburst = YANGDynClass(
            base=YANGBool,
            default=YANGBool("false"),
            is_leaf=True,
            yang_name="iburst",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="boolean",
            is_config=False,
        )
        self.__prefer = YANGDynClass(
            base=YANGBool,
            default=YANGBool("false"),
            is_leaf=True,
            yang_name="prefer",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="boolean",
            is_config=False,
        )
        self.__stratum = YANGDynClass(
            base=RestrictedClassType(
                base_type=int, restriction_dict={"range": ["0..255"]}, int_size=8
            ),
            is_leaf=True,
            yang_name="stratum",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="uint8",
            is_config=False,
        )
        self.__root_delay = YANGDynClass(
            base=RestrictedClassType(
                base_type=long,
                restriction_dict={"range": ["0..4294967295"]},
                int_size=32,
            ),
            is_leaf=True,
            yang_name="root-delay",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="uint32",
            is_config=False,
        )
        self.__root_dispersion = YANGDynClass(
            base=RestrictedClassType(
                base_type=long,
                restriction_dict={"range": ["0..18446744073709551615"]},
                int_size=64,
            ),
            is_leaf=True,
            yang_name="root-dispersion",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="uint64",
            is_config=False,
        )
        self.__offset = YANGDynClass(
            base=RestrictedClassType(
                base_type=long,
                restriction_dict={"range": ["0..18446744073709551615"]},
                int_size=64,
            ),
            is_leaf=True,
            yang_name="offset",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="uint64",
            is_config=False,
        )
        self.__poll_interval = YANGDynClass(
            base=RestrictedClassType(
                base_type=long,
                restriction_dict={"range": ["0..4294967295"]},
                int_size=32,
            ),
            is_leaf=True,
            yang_name="poll-interval",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="uint32",
            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 ["system", "ntp", "servers", "server", "state"]

    def _get_address(self):
        """
    Getter method for address, mapped from YANG variable /system/ntp/servers/server/state/address (inet:host)

    YANG Description: [adapted from IETF system model RFC 7317]

The address or hostname of the NTP server.
    """
        return self.__address

    def _set_address(self, v, load=False):
        """
    Setter method for address, mapped from YANG variable /system/ntp/servers/server/state/address (inet:host)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_address is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_address() directly.

    YANG Description: [adapted from IETF system model RFC 7317]

The address or hostname of the NTP server.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=[
                    RestrictedClassType(
                        base_type=six.text_type,
                        restriction_dict={
                            "pattern": "(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\\p{N}\\p{L}]+)?"
                        },
                    ),
                    RestrictedClassType(
                        base_type=six.text_type,
                        restriction_dict={
                            "pattern": "((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(%[\\p{N}\\p{L}]+)?"
                        },
                    ),
                    RestrictedClassType(
                        base_type=six.text_type,
                        restriction_dict={
                            "pattern": "((([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.)*([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.?)|\\.",
                            "length": ["1..253"],
                        },
                    ),
                ],
                is_leaf=True,
                yang_name="address",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/system",
                defining_module="openconfig-system",
                yang_type="inet:host",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """address must be of a type compatible with inet:host""",
                    "defined-type": "inet:host",
                    "generated-type": """YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\\p{N}\\p{L}]+)?'}),RestrictedClassType(base_type=six.text_type, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(%[\\p{N}\\p{L}]+)?'}),RestrictedClassType(base_type=six.text_type, restriction_dict={'pattern': '((([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.)*([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.?)|\\.', 'length': ['1..253']}),], is_leaf=True, yang_name="address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='inet:host', is_config=False)""",
                }
            )

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

    def _unset_address(self):
        self.__address = YANGDynClass(
            base=[
                RestrictedClassType(
                    base_type=six.text_type,
                    restriction_dict={
                        "pattern": "(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\\p{N}\\p{L}]+)?"
                    },
                ),
                RestrictedClassType(
                    base_type=six.text_type,
                    restriction_dict={
                        "pattern": "((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(%[\\p{N}\\p{L}]+)?"
                    },
                ),
                RestrictedClassType(
                    base_type=six.text_type,
                    restriction_dict={
                        "pattern": "((([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.)*([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.?)|\\.",
                        "length": ["1..253"],
                    },
                ),
            ],
            is_leaf=True,
            yang_name="address",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="inet:host",
            is_config=False,
        )

    def _get_port(self):
        """
    Getter method for port, mapped from YANG variable /system/ntp/servers/server/state/port (inet:port-number)

    YANG Description: [adapted from IETF system model RFC 7317]

The port number of the NTP server.
    """
        return self.__port

    def _set_port(self, v, load=False):
        """
    Setter method for port, mapped from YANG variable /system/ntp/servers/server/state/port (inet:port-number)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_port is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_port() directly.

    YANG Description: [adapted from IETF system model RFC 7317]

The port number of the NTP server.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=RestrictedClassType(
                    base_type=RestrictedClassType(
                        base_type=int,
                        restriction_dict={"range": ["0..65535"]},
                        int_size=16,
                    ),
                    restriction_dict={"range": ["0..65535"]},
                ),
                default=RestrictedClassType(
                    base_type=int, restriction_dict={"range": ["0..65535"]}, int_size=16
                )(
                    123
                ),
                is_leaf=True,
                yang_name="port",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/system",
                defining_module="openconfig-system",
                yang_type="inet:port-number",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """port must be of a type compatible with inet:port-number""",
                    "defined-type": "inet:port-number",
                    "generated-type": """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}), default=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16)(123), is_leaf=True, yang_name="port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='inet:port-number', is_config=False)""",
                }
            )

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

    def _unset_port(self):
        self.__port = YANGDynClass(
            base=RestrictedClassType(
                base_type=RestrictedClassType(
                    base_type=int, restriction_dict={"range": ["0..65535"]}, int_size=16
                ),
                restriction_dict={"range": ["0..65535"]},
            ),
            default=RestrictedClassType(
                base_type=int, restriction_dict={"range": ["0..65535"]}, int_size=16
            )(
                123
            ),
            is_leaf=True,
            yang_name="port",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="inet:port-number",
            is_config=False,
        )

    def _get_version(self):
        """
    Getter method for version, mapped from YANG variable /system/ntp/servers/server/state/version (uint8)

    YANG Description: [adapted from IETF system model RFC 7317]

Version number to put in outgoing NTP packets
    """
        return self.__version

    def _set_version(self, v, load=False):
        """
    Setter method for version, mapped from YANG variable /system/ntp/servers/server/state/version (uint8)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_version is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_version() directly.

    YANG Description: [adapted from IETF system model RFC 7317]

Version number to put in outgoing NTP packets
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=RestrictedClassType(
                    base_type=RestrictedClassType(
                        base_type=int,
                        restriction_dict={"range": ["0..255"]},
                        int_size=8,
                    ),
                    restriction_dict={"range": ["1..4"]},
                ),
                default=RestrictedClassType(
                    base_type=int, restriction_dict={"range": ["0..255"]}, int_size=8
                )(
                    4
                ),
                is_leaf=True,
                yang_name="version",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/system",
                defining_module="openconfig-system",
                yang_type="uint8",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """version must be of a type compatible with uint8""",
                    "defined-type": "uint8",
                    "generated-type": """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['1..4']}), default=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8)(4), is_leaf=True, yang_name="version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='uint8', is_config=False)""",
                }
            )

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

    def _unset_version(self):
        self.__version = YANGDynClass(
            base=RestrictedClassType(
                base_type=RestrictedClassType(
                    base_type=int, restriction_dict={"range": ["0..255"]}, int_size=8
                ),
                restriction_dict={"range": ["1..4"]},
            ),
            default=RestrictedClassType(
                base_type=int, restriction_dict={"range": ["0..255"]}, int_size=8
            )(
                4
            ),
            is_leaf=True,
            yang_name="version",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="uint8",
            is_config=False,
        )

    def _get_association_type(self):
        """
    Getter method for association_type, mapped from YANG variable /system/ntp/servers/server/state/association_type (enumeration)

    YANG Description: [adapted from IETF system model RFC 7317]

The desired association type for this NTP server.
    """
        return self.__association_type

    def _set_association_type(self, v, load=False):
        """
    Setter method for association_type, mapped from YANG variable /system/ntp/servers/server/state/association_type (enumeration)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_association_type is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_association_type() directly.

    YANG Description: [adapted from IETF system model RFC 7317]

The desired association type for this NTP server.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=RestrictedClassType(
                    base_type=six.text_type,
                    restriction_type="dict_key",
                    restriction_arg={"SERVER": {}, "PEER": {}, "POOL": {}},
                ),
                default=six.text_type("SERVER"),
                is_leaf=True,
                yang_name="association-type",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/system",
                defining_module="openconfig-system",
                yang_type="enumeration",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """association_type must be of a type compatible with enumeration""",
                    "defined-type": "openconfig-system:enumeration",
                    "generated-type": """YANGDynClass(base=RestrictedClassType(base_type=six.text_type,                                     restriction_type="dict_key",                                     restriction_arg={'SERVER': {}, 'PEER': {}, 'POOL': {}},), default=six.text_type("SERVER"), is_leaf=True, yang_name="association-type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='enumeration', is_config=False)""",
                }
            )

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

    def _unset_association_type(self):
        self.__association_type = YANGDynClass(
            base=RestrictedClassType(
                base_type=six.text_type,
                restriction_type="dict_key",
                restriction_arg={"SERVER": {}, "PEER": {}, "POOL": {}},
            ),
            default=six.text_type("SERVER"),
            is_leaf=True,
            yang_name="association-type",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="enumeration",
            is_config=False,
        )

    def _get_iburst(self):
        """
    Getter method for iburst, mapped from YANG variable /system/ntp/servers/server/state/iburst (boolean)

    YANG Description: [adapted from IETF system model RFC 7317]

Indicates whether this server should enable burst
synchronization or not.
    """
        return self.__iburst

    def _set_iburst(self, v, load=False):
        """
    Setter method for iburst, mapped from YANG variable /system/ntp/servers/server/state/iburst (boolean)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_iburst is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_iburst() directly.

    YANG Description: [adapted from IETF system model RFC 7317]

Indicates whether this server should enable burst
synchronization or not.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=YANGBool,
                default=YANGBool("false"),
                is_leaf=True,
                yang_name="iburst",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/system",
                defining_module="openconfig-system",
                yang_type="boolean",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """iburst must be of a type compatible with boolean""",
                    "defined-type": "boolean",
                    "generated-type": """YANGDynClass(base=YANGBool, default=YANGBool("false"), is_leaf=True, yang_name="iburst", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='boolean', is_config=False)""",
                }
            )

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

    def _unset_iburst(self):
        self.__iburst = YANGDynClass(
            base=YANGBool,
            default=YANGBool("false"),
            is_leaf=True,
            yang_name="iburst",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="boolean",
            is_config=False,
        )

    def _get_prefer(self):
        """
    Getter method for prefer, mapped from YANG variable /system/ntp/servers/server/state/prefer (boolean)

    YANG Description: [adapted from IETF system model RFC 7317]

Indicates whether this server should be preferred
or not.
    """
        return self.__prefer

    def _set_prefer(self, v, load=False):
        """
    Setter method for prefer, mapped from YANG variable /system/ntp/servers/server/state/prefer (boolean)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_prefer is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_prefer() directly.

    YANG Description: [adapted from IETF system model RFC 7317]

Indicates whether this server should be preferred
or not.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=YANGBool,
                default=YANGBool("false"),
                is_leaf=True,
                yang_name="prefer",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/system",
                defining_module="openconfig-system",
                yang_type="boolean",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """prefer must be of a type compatible with boolean""",
                    "defined-type": "boolean",
                    "generated-type": """YANGDynClass(base=YANGBool, default=YANGBool("false"), is_leaf=True, yang_name="prefer", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='boolean', is_config=False)""",
                }
            )

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

    def _unset_prefer(self):
        self.__prefer = YANGDynClass(
            base=YANGBool,
            default=YANGBool("false"),
            is_leaf=True,
            yang_name="prefer",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="boolean",
            is_config=False,
        )

    def _get_stratum(self):
        """
    Getter method for stratum, mapped from YANG variable /system/ntp/servers/server/state/stratum (uint8)

    YANG Description: Indicates the level of the server in the NTP hierarchy. As
stratum number increases, the accuracy is degraded.  Primary
servers are stratum while a maximum value of 16 indicates
unsynchronized.  The values have the following specific
semantics:

| 0      | unspecified or invalid
| 1      | primary server (e.g., equipped with a GPS receiver)
| 2-15   | secondary server (via NTP)
| 16     | unsynchronized
| 17-255 | reserved
    """
        return self.__stratum

    def _set_stratum(self, v, load=False):
        """
    Setter method for stratum, mapped from YANG variable /system/ntp/servers/server/state/stratum (uint8)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_stratum is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_stratum() directly.

    YANG Description: Indicates the level of the server in the NTP hierarchy. As
stratum number increases, the accuracy is degraded.  Primary
servers are stratum while a maximum value of 16 indicates
unsynchronized.  The values have the following specific
semantics:

| 0      | unspecified or invalid
| 1      | primary server (e.g., equipped with a GPS receiver)
| 2-15   | secondary server (via NTP)
| 16     | unsynchronized
| 17-255 | reserved
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=RestrictedClassType(
                    base_type=int, restriction_dict={"range": ["0..255"]}, int_size=8
                ),
                is_leaf=True,
                yang_name="stratum",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/system",
                defining_module="openconfig-system",
                yang_type="uint8",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """stratum must be of a type compatible with uint8""",
                    "defined-type": "uint8",
                    "generated-type": """YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), is_leaf=True, yang_name="stratum", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='uint8', is_config=False)""",
                }
            )

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

    def _unset_stratum(self):
        self.__stratum = YANGDynClass(
            base=RestrictedClassType(
                base_type=int, restriction_dict={"range": ["0..255"]}, int_size=8
            ),
            is_leaf=True,
            yang_name="stratum",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="uint8",
            is_config=False,
        )

    def _get_root_delay(self):
        """
    Getter method for root_delay, mapped from YANG variable /system/ntp/servers/server/state/root_delay (uint32)

    YANG Description: The round-trip delay to the server, in milliseconds.
    """
        return self.__root_delay

    def _set_root_delay(self, v, load=False):
        """
    Setter method for root_delay, mapped from YANG variable /system/ntp/servers/server/state/root_delay (uint32)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_root_delay is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_root_delay() directly.

    YANG Description: The round-trip delay to the server, in milliseconds.
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=RestrictedClassType(
                    base_type=long,
                    restriction_dict={"range": ["0..4294967295"]},
                    int_size=32,
                ),
                is_leaf=True,
                yang_name="root-delay",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/system",
                defining_module="openconfig-system",
                yang_type="uint32",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """root_delay must be of a type compatible with uint32""",
                    "defined-type": "uint32",
                    "generated-type": """YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="root-delay", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='uint32', is_config=False)""",
                }
            )

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

    def _unset_root_delay(self):
        self.__root_delay = YANGDynClass(
            base=RestrictedClassType(
                base_type=long,
                restriction_dict={"range": ["0..4294967295"]},
                int_size=32,
            ),
            is_leaf=True,
            yang_name="root-delay",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="uint32",
            is_config=False,
        )

    def _get_root_dispersion(self):
        """
    Getter method for root_dispersion, mapped from YANG variable /system/ntp/servers/server/state/root_dispersion (uint64)

    YANG Description: Dispersion (epsilon) represents the maximum error inherent
in the measurement
    """
        return self.__root_dispersion

    def _set_root_dispersion(self, v, load=False):
        """
    Setter method for root_dispersion, mapped from YANG variable /system/ntp/servers/server/state/root_dispersion (uint64)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_root_dispersion is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_root_dispersion() directly.

    YANG Description: Dispersion (epsilon) represents the maximum error inherent
in the measurement
    """
        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="root-dispersion",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/system",
                defining_module="openconfig-system",
                yang_type="uint64",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """root_dispersion 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="root-dispersion", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='uint64', is_config=False)""",
                }
            )

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

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

    def _get_offset(self):
        """
    Getter method for offset, mapped from YANG variable /system/ntp/servers/server/state/offset (uint64)

    YANG Description: Estimate of the current time offset from the peer.  This is
the time difference between the local and reference clock.
    """
        return self.__offset

    def _set_offset(self, v, load=False):
        """
    Setter method for offset, mapped from YANG variable /system/ntp/servers/server/state/offset (uint64)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_offset is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_offset() directly.

    YANG Description: Estimate of the current time offset from the peer.  This is
the time difference between the local and reference clock.
    """
        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="offset",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/system",
                defining_module="openconfig-system",
                yang_type="uint64",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """offset 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="offset", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='uint64', is_config=False)""",
                }
            )

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

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

    def _get_poll_interval(self):
        """
    Getter method for poll_interval, mapped from YANG variable /system/ntp/servers/server/state/poll_interval (uint32)

    YANG Description: Polling interval of the peer
    """
        return self.__poll_interval

    def _set_poll_interval(self, v, load=False):
        """
    Setter method for poll_interval, mapped from YANG variable /system/ntp/servers/server/state/poll_interval (uint32)
    If this variable is read-only (config: false) in the
    source YANG file, then _set_poll_interval is considered as a private
    method. Backends looking to populate this variable should
    do so via calling thisObj._set_poll_interval() directly.

    YANG Description: Polling interval of the peer
    """
        if hasattr(v, "_utype"):
            v = v._utype(v)
        try:
            t = YANGDynClass(
                v,
                base=RestrictedClassType(
                    base_type=long,
                    restriction_dict={"range": ["0..4294967295"]},
                    int_size=32,
                ),
                is_leaf=True,
                yang_name="poll-interval",
                parent=self,
                path_helper=self._path_helper,
                extmethods=self._extmethods,
                register_paths=True,
                namespace="http://openconfig.net/yang/system",
                defining_module="openconfig-system",
                yang_type="uint32",
                is_config=False,
            )
        except (TypeError, ValueError):
            raise ValueError(
                {
                    "error-string": """poll_interval must be of a type compatible with uint32""",
                    "defined-type": "uint32",
                    "generated-type": """YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="poll-interval", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='uint32', is_config=False)""",
                }
            )

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

    def _unset_poll_interval(self):
        self.__poll_interval = YANGDynClass(
            base=RestrictedClassType(
                base_type=long,
                restriction_dict={"range": ["0..4294967295"]},
                int_size=32,
            ),
            is_leaf=True,
            yang_name="poll-interval",
            parent=self,
            path_helper=self._path_helper,
            extmethods=self._extmethods,
            register_paths=True,
            namespace="http://openconfig.net/yang/system",
            defining_module="openconfig-system",
            yang_type="uint32",
            is_config=False,
        )

    address = __builtin__.property(_get_address)
    port = __builtin__.property(_get_port)
    version = __builtin__.property(_get_version)
    association_type = __builtin__.property(_get_association_type)
    iburst = __builtin__.property(_get_iburst)
    prefer = __builtin__.property(_get_prefer)
    stratum = __builtin__.property(_get_stratum)
    root_delay = __builtin__.property(_get_root_delay)
    root_dispersion = __builtin__.property(_get_root_dispersion)
    offset = __builtin__.property(_get_offset)
    poll_interval = __builtin__.property(_get_poll_interval)

    _pyangbind_elements = OrderedDict(
        [
            ("address", address),
            ("port", port),
            ("version", version),
            ("association_type", association_type),
            ("iburst", iburst),
            ("prefer", prefer),
            ("stratum", stratum),
            ("root_delay", root_delay),
            ("root_dispersion", root_dispersion),
            ("offset", offset),
            ("poll_interval", poll_interval),
        ]
    )
