def api(type): l=lib.container(options) u=lib.user(options) d=lib.domain(options) db=lib.database(options) b=lib.backup(options) a=lib.admin(options) if request.method=="GET": if type=="container": return Response(json.dumps(l.list()),mimetype="application/json") elif type=="user": return Response(json.dumps(u.list()),mimetype="application/json") elif type=="domain": return Response(json.dumps(d.list()),mimetype="application/json") elif type=="database": return Response(json.dumps(db.list()),mimetype="application/json") elif type=="backup": return Response(json.dumps(b.list()),mimetype="application/json") elif type=="admin": return Response(json.dumps(a.list()),mimetype="application/json") elif type=="images": return Response(json.dumps(l.images()),mimetype="application/json") else: return Response(json.dumps({'status':'Error','extstatus':'service not defined'}),mimetype="application/json") else: print("not implemented") return json.dumps({})
def apinamedadmin(name): a=lib.admin(options) if request.method=="DELETE": return Response(json.dumps(a.delete(name)),mimetype="application/json") elif request.method=="PUT": return Response(json.dumps(a.create(name,request.form)),mimetype="application/json") else: print(request.method+" not implemented") return json.dumps({})