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

        Args:
            output_buffer (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:
            InvalidField: Raised if the object type or attributes fields are
                not defined.
            VersionNotSupported: Raised when a KMIP version is provided that
                does not support the ObjectDefaults structure.
        """
        if kmip_version < enums.KMIPVersion.KMIP_2_0:
            raise exceptions.VersionNotSupported(
                "KMIP {} does not support the ObjectDefaults object.".format(
                    kmip_version.value
                )
            )

        local_buffer = BytearrayStream()

        if self._object_type:
            self._object_type.write(local_buffer, kmip_version=kmip_version)
        else:
            raise exceptions.InvalidField(
                "The ObjectDefaults structure is missing the object type "
                "field."
            )

        if self._attributes:
            self._attributes.write(local_buffer, kmip_version=kmip_version)
        else:
            raise exceptions.InvalidField(
                "The ObjectDefaults structure is missing the attributes field."
            )

        self.length = local_buffer.length()
        super(ObjectDefaults, self).write(
            output_buffer,
            kmip_version=kmip_version
        )
        output_buffer.write(local_buffer.buffer)
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_2_0):
        """
        Write the ObjectDefaults structure encoding to the data stream.

        Args:
            output_buffer (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:
            InvalidField: Raised if the object type or attributes fields are
                not defined.
            VersionNotSupported: Raised when a KMIP version is provided that
                does not support the ObjectDefaults structure.
        """
        if kmip_version < enums.KMIPVersion.KMIP_2_0:
            raise exceptions.VersionNotSupported(
                "KMIP {} does not support the ObjectDefaults object.".format(
                    kmip_version.value
                )
            )

        local_buffer = BytearrayStream()

        if self._object_type:
            self._object_type.write(local_buffer, kmip_version=kmip_version)
        else:
            raise exceptions.InvalidField(
                "The ObjectDefaults structure is missing the object type "
                "field."
            )

        if self._attributes:
            self._attributes.write(local_buffer, kmip_version=kmip_version)
        else:
            raise exceptions.InvalidField(
                "The ObjectDefaults structure is missing the attributes field."
            )

        self.length = local_buffer.length()
        super(ObjectDefaults, self).write(
            output_buffer,
            kmip_version=kmip_version
        )
        output_buffer.write(local_buffer.buffer)
def write ( self , output_buffer , kmip_version = enums . KMIPVersion . KMIP_2_0 ) : if kmip_version < enums . KMIPVersion . KMIP_2_0 : raise exceptions . VersionNotSupported ( "KMIP {} does not support the ObjectDefaults object." . format ( kmip_version . value ) ) local_buffer = BytearrayStream ( ) if self . _object_type : self . _object_type . write ( local_buffer , kmip_version = kmip_version ) else : raise exceptions . InvalidField ( "The ObjectDefaults structure is missing the object type " "field." ) if self . _attributes : self . _attributes . write ( local_buffer , kmip_version = kmip_version ) else : raise exceptions . InvalidField ( "The ObjectDefaults structure is missing the attributes field." ) self . length = local_buffer . length ( ) super ( ObjectDefaults , self ) . write ( output_buffer , kmip_version = kmip_version ) output_buffer . write ( local_buffer . buffer )
Write the ObjectDefaults structure encoding to the data stream.

        Args:
            output_buffer (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:
            InvalidField: Raised if the object type or attributes fields are
                not defined.
            VersionNotSupported: Raised when a KMIP version is provided that
                does not support the ObjectDefaults structure.
Write the ObjectDefaults structure encoding to the data stream .