def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_2_0):
if kmip_version < enums.KMIPVersion.KMIP_2_0:<EOL><INDENT>raise exceptions.VersionNotSupported(<EOL>"<STR_LIT>".format(<EOL>kmip_version.value<EOL>)<EOL>)<EOL><DEDENT>local_stream = BytearrayStream()<EOL>for attribute in self._attributes:<EOL><INDENT>tag = attribute.tag<EOL>if not enums.is_attribute(tag, kmip_version=kmip_version):<EOL><INDENT>raise exceptions.AttributeNotSupported(<EOL>"<STR_LIT>".format(<EOL>tag.name,<EOL>kmip_version.value<EOL>)<EOL>)<EOL><DEDENT>attribute.write(local_stream, kmip_version=kmip_version)<EOL><DEDENT>self.length = local_stream.length()<EOL>super(Attributes, self).write(output_stream, kmip_version=kmip_version)<EOL>output_stream.write(local_stream.buffer)<EOL>
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.