'* PUT /api/workflows/{id}
updates the workflow stored with ``id``
:type   id:      str
:param  id:      the encoded id of the workflow to update
:type   payload: dict
:param  payload: a dictionary containing any or all the
* workflow   the json description of the workflow as would be
produced by GET workflows/<id>/download or
given to `POST workflows`
The workflow contents will be updated to target
this.
* name       optional string name for the workflow, if not present in payload,
name defaults to existing name
* annotation optional string annotation for the workflow, if not present in payload,
annotation defaults to existing annotation
* menu_entry optional boolean marking if the workflow should appear in the user\'s menu,
if not present, workflow menu entries are not modified
:rtype:     dict
:returns:   serialized version of the workflow'

@expose_api
def update(self, trans, id, payload, **kwds):

    stored_workflow = self.__get_stored_workflow(trans, id)
    if ('workflow' in payload):
        stored_workflow.name = (sanitize_html(payload['name']) if ('name' in payload) else stored_workflow.name)
        if ('annotation' in payload):
            newAnnotation = sanitize_html(payload['annotation'])
            self.add_item_annotation(trans.sa_session, trans.get_user(), stored_workflow, newAnnotation)
        if ('menu_entry' in payload):
            if payload['menu_entry']:
                menuEntry = model.StoredWorkflowMenuEntry()
                menuEntry.stored_workflow = stored_workflow
                trans.get_user().stored_workflow_menu_entries.append(menuEntry)
            else:
                entries = {x.stored_workflow_id: x for x in trans.get_user().stored_workflow_menu_entries}
                if (trans.security.decode_id(id) in entries):
                    trans.get_user().stored_workflow_menu_entries.remove(entries[trans.security.decode_id(id)])
        try:
            (workflow, errors) = self.workflow_contents_manager.update_workflow_from_dict(trans, stored_workflow, payload['workflow'])
        except workflows.MissingToolsException:
            raise exceptions.MessageException('This    workflow    contains    missing    tools.    It    cannot    be    saved    until    they    have    been    removed    from    the    workflow    or    installed.')
    else:
        message = "Updating    workflow    requires    dictionary    containing    'workflow'    attribute    with    new    JSON    description."
        raise exceptions.RequestParameterInvalidException(message)
    return self.workflow_contents_manager.workflow_to_dict(trans, stored_workflow, style='instance')
