kmip/core/messages/payloads/derive_key.py
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
        """
        Write the data encoding the DeriveKey request payload to a stream.

        Args:
            output_buffer (stream): A data stream in which to encode object
                data, supporting a write method; usually a BytearrayStream
                object.
            kmip_version (KMIPVersion): An enumeration defining the KMIP
                version with which the object will be encoded. Optional,
                defaults to KMIP 1.0.

        Raises:
            ValueError: Raised if the data attribute is not defined.
        """
        local_buffer = utils.BytearrayStream()

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

        if self._unique_identifiers:
            for unique_identifier in self._unique_identifiers:
                unique_identifier.write(
                    local_buffer,
                    kmip_version=kmip_version
                )
        else:
            raise exceptions.InvalidField(
                "The DeriveKey request payload is missing the unique "
                "identifiers field."
            )

        if self._derivation_method:
            self._derivation_method.write(
                local_buffer,
                kmip_version=kmip_version
            )
        else:
            raise exceptions.InvalidField(
                "The DeriveKey request payload is missing the derivation "
                "method field."
            )

        if self._derivation_parameters:
            self._derivation_parameters.write(
                local_buffer,
                kmip_version=kmip_version
            )
        else:
            raise exceptions.InvalidField(
                "The DeriveKey request payload is missing the derivation "
                "parameters field."
            )

        if kmip_version < enums.KMIPVersion.KMIP_2_0:
            if self._template_attribute:
                self._template_attribute.write(
                    local_buffer,
                    kmip_version=kmip_version
                )
            else:
                raise exceptions.InvalidField(
                    "The DeriveKey request payload is missing the template "
                    "attribute field."
                )
        else:
            if self._template_attribute:
                attrs = objects.convert_template_attribute_to_attributes(
                    self._template_attribute
                )
                attrs.write(local_buffer, kmip_version=kmip_version)
            else:
                raise exceptions.InvalidField(
                    "The DeriveKey request payload is missing the template "
                    "attribute field."
                )

        self.length = local_buffer.length()
        super(DeriveKeyRequestPayload, self).write(
            output_buffer,
            kmip_version=kmip_version
        )
        output_buffer.write(local_buffer.buffer)
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
        local_buffer = utils.BytearrayStream()

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

        if self._unique_identifiers:
            for unique_identifier in self._unique_identifiers:
                unique_identifier.write(
                    local_buffer,
                    kmip_version=kmip_version
                )
        else:
            raise exceptions.InvalidField(
                "The DeriveKey request payload is missing the unique "
                "identifiers field."
            )

        if self._derivation_method:
            self._derivation_method.write(
                local_buffer,
                kmip_version=kmip_version
            )
        else:
            raise exceptions.InvalidField(
                "The DeriveKey request payload is missing the derivation "
                "method field."
            )

        if self._derivation_parameters:
            self._derivation_parameters.write(
                local_buffer,
                kmip_version=kmip_version
            )
        else:
            raise exceptions.InvalidField(
                "The DeriveKey request payload is missing the derivation "
                "parameters field."
            )

        if kmip_version < enums.KMIPVersion.KMIP_2_0:
            if self._template_attribute:
                self._template_attribute.write(
                    local_buffer,
                    kmip_version=kmip_version
                )
            else:
                raise exceptions.InvalidField(
                    "The DeriveKey request payload is missing the template "
                    "attribute field."
                )
        else:
            if self._template_attribute:
                attrs = objects.convert_template_attribute_to_attributes(
                    self._template_attribute
                )
                attrs.write(local_buffer, kmip_version=kmip_version)
            else:
                raise exceptions.InvalidField(
                    "The DeriveKey request payload is missing the template "
                    "attribute field."
                )

        self.length = local_buffer.length()
        super(DeriveKeyRequestPayload, self).write(
            output_buffer,
            kmip_version=kmip_version
        )
        output_buffer.write(local_buffer.buffer)
def write ( self , output_buffer , kmip_version = enums . KMIPVersion . KMIP_1_0 ) : local_buffer = utils . BytearrayStream ( ) if self . _object_type : self . _object_type . write ( local_buffer , kmip_version = kmip_version ) else : raise exceptions . InvalidField ( "The DeriveKey request payload is missing the object type " "field." ) if self . _unique_identifiers : for unique_identifier in self . _unique_identifiers : unique_identifier . write ( local_buffer , kmip_version = kmip_version ) else : raise exceptions . InvalidField ( "The DeriveKey request payload is missing the unique " "identifiers field." ) if self . _derivation_method : self . _derivation_method . write ( local_buffer , kmip_version = kmip_version ) else : raise exceptions . InvalidField ( "The DeriveKey request payload is missing the derivation " "method field." ) if self . _derivation_parameters : self . _derivation_parameters . write ( local_buffer , kmip_version = kmip_version ) else : raise exceptions . InvalidField ( "The DeriveKey request payload is missing the derivation " "parameters field." ) if kmip_version < enums . KMIPVersion . KMIP_2_0 : if self . _template_attribute : self . _template_attribute . write ( local_buffer , kmip_version = kmip_version ) else : raise exceptions . InvalidField ( "The DeriveKey request payload is missing the template " "attribute field." ) else : if self . _template_attribute : attrs = objects . convert_template_attribute_to_attributes ( self . _template_attribute ) attrs . write ( local_buffer , kmip_version = kmip_version ) else : raise exceptions . InvalidField ( "The DeriveKey request payload is missing the template " "attribute field." ) self . length = local_buffer . length ( ) super ( DeriveKeyRequestPayload , self ) . write ( output_buffer , kmip_version = kmip_version ) output_buffer . write ( local_buffer . buffer )
Write the data encoding the DeriveKey request payload to a stream.

        Args:
            output_buffer (stream): A data stream in which to encode object
                data, supporting a write method; usually a BytearrayStream
                object.
            kmip_version (KMIPVersion): An enumeration defining the KMIP
                version with which the object will be encoded. Optional,
                defaults to KMIP 1.0.

        Raises:
            ValueError: Raised if the data attribute is not defined.
Write the data encoding the DeriveKey request payload to a stream .