kmip/core/objects.py
def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_2_0):
        """
        Write the Attributes structure encoding to the data stream.

        Args:
            output_stream (stream): A data stream in which to encode
                Attributes structure data, supporting a write method.
            kmip_version (enum): A KMIPVersion enumeration defining the KMIP
                version with which the object will be encoded. Optional,
                defaults to KMIP 2.0.

        Raises:
            AttributeNotSupported: Raised if an unsupported attribute is
                found in the attribute list while encoding.
            VersionNotSupported: Raised when a KMIP version is provided that
                does not support the Attributes object.
        """
        if kmip_version < enums.KMIPVersion.KMIP_2_0:
            raise exceptions.VersionNotSupported(
                "KMIP {} does not support the Attributes object.".format(
                    kmip_version.value
                )
            )

        local_stream = BytearrayStream()

        for attribute in self._attributes:
            tag = attribute.tag
            if not enums.is_attribute(tag, kmip_version=kmip_version):
                raise exceptions.AttributeNotSupported(
                    "Attribute {} is not supported by KMIP {}.".format(
                        tag.name,
                        kmip_version.value
                    )
                )
            attribute.write(local_stream, kmip_version=kmip_version)

        self.length = local_stream.length()
        super(Attributes, self).write(output_stream, kmip_version=kmip_version)
        output_stream.write(local_stream.buffer)
def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_2_0):
        if kmip_version < enums.KMIPVersion.KMIP_2_0:
            raise exceptions.VersionNotSupported(
                "KMIP {} does not support the Attributes object.".format(
                    kmip_version.value
                )
            )

        local_stream = BytearrayStream()

        for attribute in self._attributes:
            tag = attribute.tag
            if not enums.is_attribute(tag, kmip_version=kmip_version):
                raise exceptions.AttributeNotSupported(
                    "Attribute {} is not supported by KMIP {}.".format(
                        tag.name,
                        kmip_version.value
                    )
                )
            attribute.write(local_stream, kmip_version=kmip_version)

        self.length = local_stream.length()
        super(Attributes, self).write(output_stream, kmip_version=kmip_version)
        output_stream.write(local_stream.buffer)
def write ( self , output_stream , kmip_version = enums . KMIPVersion . KMIP_2_0 ) : if kmip_version < enums . KMIPVersion . KMIP_2_0 : raise exceptions . VersionNotSupported ( "KMIP {} does not support the Attributes object." . format ( kmip_version . value ) ) local_stream = BytearrayStream ( ) for attribute in self . _attributes : tag = attribute . tag if not enums . is_attribute ( tag , kmip_version = kmip_version ) : raise exceptions . AttributeNotSupported ( "Attribute {} is not supported by KMIP {}." . format ( tag . name , kmip_version . value ) ) attribute . write ( local_stream , kmip_version = kmip_version ) self . length = local_stream . length ( ) super ( Attributes , self ) . write ( output_stream , kmip_version = kmip_version ) output_stream . write ( local_stream . buffer )
Write the Attributes structure encoding to the data stream.

        Args:
            output_stream (stream): A data stream in which to encode
                Attributes structure data, supporting a write method.
            kmip_version (enum): A KMIPVersion enumeration defining the KMIP
                version with which the object will be encoded. Optional,
                defaults to KMIP 2.0.

        Raises:
            AttributeNotSupported: Raised if an unsupported attribute is
                found in the attribute list while encoding.
            VersionNotSupported: Raised when a KMIP version is provided that
                does not support the Attributes object.
Write the Attributes structure encoding to the data stream .