def importBundle(org, name, data):
  hdrs = { 'Content-Type': 'application/octet-stream' }
  uri = '/v1/organizations/%s/apis?action=import&name=%s' \
        % (org, name)
  print 'Importing new application %s' % name

  resp = None

  try:
    resp = httptools.httpCall('POST', uri, hdrs, data)

  except __HOLE__, e:
    print traceback.format_exc()

    err_message = IOError_messages.get(e.errno)

    if err_message:
      print '%s uploading API Bundle!\nHINT: %s' % (e, err_message)

    return -1

  except Exception, e:
    print traceback.format_exc()
    print e

    return -1

  if resp.status != 200 and resp.status != 201:
    message = HTTP_messages.get(resp.status)

    if not message:
      message = resp.read()

    print 'Import failed to %s with status %i:\nHINT: %s' % (uri, resp.status, message)
    return -1

  deployment = json.load(resp)
  revision = int(deployment['revision'])
  return revision
dataset/ETHPy150Open apigee/api-platform-tools/ApigeePlatformTools/deploytools.py/importBundle