kmip/core/objects.py
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_2_0):
        """
        Read the data encoding the DefaultsInformation structure and decode it
        into its constituent parts.

        Args:
            input_buffer (stream): A data stream containing encoded object
                data, supporting a read method; usually a BytearrayStream
                object.
            kmip_version (KMIPVersion): An enumeration defining the KMIP
                version with which the object will be decoded. Optional,
                defaults to KMIP 2.0.

        Raises:
            InvalidKmipEncoding: Raised if the object defaults are missing
                from the encoding.
            VersionNotSupported: Raised when a KMIP version is provided that
                does not support the DefaultsInformation structure.
        """
        if kmip_version < enums.KMIPVersion.KMIP_2_0:
            raise exceptions.VersionNotSupported(
                "KMIP {} does not support the DefaultsInformation "
                "object.".format(
                    kmip_version.value
                )
            )

        super(DefaultsInformation, self).read(
            input_buffer,
            kmip_version=kmip_version
        )
        local_buffer = utils.BytearrayStream(input_buffer.read(self.length))

        object_defaults = []
        while self.is_tag_next(enums.Tags.OBJECT_DEFAULTS, local_buffer):
            object_default = ObjectDefaults()
            object_default.read(local_buffer, kmip_version=kmip_version)
            object_defaults.append(object_default)

        if len(object_defaults) == 0:
            raise exceptions.InvalidKmipEncoding(
                "The DefaultsInformation encoding is missing the object "
                "defaults structure."
            )
        else:
            self._object_defaults = object_defaults

        self.is_oversized(local_buffer)
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_2_0):
        """
        Read the data encoding the DefaultsInformation structure and decode it
        into its constituent parts.

        Args:
            input_buffer (stream): A data stream containing encoded object
                data, supporting a read method; usually a BytearrayStream
                object.
            kmip_version (KMIPVersion): An enumeration defining the KMIP
                version with which the object will be decoded. Optional,
                defaults to KMIP 2.0.

        Raises:
            InvalidKmipEncoding: Raised if the object defaults are missing
                from the encoding.
            VersionNotSupported: Raised when a KMIP version is provided that
                does not support the DefaultsInformation structure.
        """
        if kmip_version < enums.KMIPVersion.KMIP_2_0:
            raise exceptions.VersionNotSupported(
                "KMIP {} does not support the DefaultsInformation "
                "object.".format(
                    kmip_version.value
                )
            )

        super(DefaultsInformation, self).read(
            input_buffer,
            kmip_version=kmip_version
        )
        local_buffer = utils.BytearrayStream(input_buffer.read(self.length))

        object_defaults = []
        while self.is_tag_next(enums.Tags.OBJECT_DEFAULTS, local_buffer):
            object_default = ObjectDefaults()
            object_default.read(local_buffer, kmip_version=kmip_version)
            object_defaults.append(object_default)

        if len(object_defaults) == 0:
            raise exceptions.InvalidKmipEncoding(
                "The DefaultsInformation encoding is missing the object "
                "defaults structure."
            )
        else:
            self._object_defaults = object_defaults

        self.is_oversized(local_buffer)
Read the data encoding the DefaultsInformation structure and decode it
        into its constituent parts.

        Args:
            input_buffer (stream): A data stream containing encoded object
                data, supporting a read method; usually a BytearrayStream
                object.
            kmip_version (KMIPVersion): An enumeration defining the KMIP
                version with which the object will be decoded. Optional,
                defaults to KMIP 2.0.

        Raises:
            InvalidKmipEncoding: Raised if the object defaults are missing
                from the encoding.
            VersionNotSupported: Raised when a KMIP version is provided that
                does not support the DefaultsInformation structure.