'delete( self, trans, id, **kwd )
* DELETE /api/histories/{id}
delete the history with the given ``id``
.. note:: Stops all active jobs in the history if purge is set.
:type   id:     str
:param  id:     the encoded id of the history to delete
:type   kwd:    dict
:param  kwd:    (optional) dictionary structure containing extra parameters
You can purge a history, removing all it\'s datasets from disk (if unshared),
by passing in ``purge=True`` in the url.
:param  keys: same as the use of `keys` in the `index` function above
:param  view: same as the use of `view` in the `index` function above
:rtype:     dict
:returns:   the deleted or purged history'

@expose_api
def delete(self, trans, id, **kwd):

    history_id = id
    purge = string_as_bool(kwd.get('purge', False))
    if kwd.get('payload', None):
        purge = string_as_bool(kwd['payload'].get('purge', purge))
    history = self.history_manager.get_owned(self.decode_id(history_id), trans.user, current_history=trans.history)
    if purge:
        self.history_manager.purge(history)
    else:
        self.history_manager.delete(history)
    return self.history_serializer.serialize_to_view(history, user=trans.user, trans=trans, **self._parse_serialization_params(kwd, 'detailed'))
