code: def delete_events(environment, start_response, headers):
    
    request_json = environment['json']
    try:
      stream = request_json['stream']
      validate_stream(stream)
    except Exception, e:
      log.exception('delete_events: stream validation failed for `%s`.',
                    request_json.get('stream'))
      start_response('400 Bad Request', headers)
      return {ERRORS_FIELD: [repr(e)]}
  
    namespace = request_json.get('namespace', settings.default_namespace)
    backends = router.backends_to_mutate(namespace, stream)
    statuses = {}
    for backend, conf in backends.iteritems():
      statuses[backend.name] = execute_greenlet_async(
        backend.delete,
        namespace,
        stream,
        long(request_json.get('start_time', 0)),
        long(request_json['end_time']),
        request_json.get('start_id'),
        conf)
    wait(statuses.values())
  
    success = True
    response = {}
    for backend, status in statuses.iteritems():
      try:
        num_deleted, errors = status.get()
        response[backend] = {'num_deleted': num_deleted}
        if errors:
          success = False
          response[ERRORS_FIELD] = errors
      except Exception, e:
        log.exception('delete_events: delete from backend `%s` failed.', backend)
        success = False
        response[backend] = {'num_deleted': -1,
                             ERRORS_FIELD: [repr(e)]}
  
    response = {request_json['stream']: response,
                SUCCESS_FIELD: success}
  
    start_response('200 OK', headers)
    return response
docs: Delete events
    POST body should contain a JSON encoded version of:
      { namespace: namespace_name (optional),
        stream : stream_name,
        start_time : starting_time_as_kronos_time,
        end_time : ending_time_as_kronos_time,
        start_id : only_delete_events_with_id_gte_me,
      }
    Either start_time or start_id should be specified.