6 from operator import itemgetter, attrgetter
8 REST_API="http://node43.princeton.vicci.org:8000/plstackapi/"
9 USERS_API = REST_API + "users/"
11 username = sys.argv[1]
12 password = sys.argv[2]
14 opencloud_auth=(username, password)
16 admin_auth=("scott@onlab.us", "letmein")
18 print "users I can see:"
19 r = requests.get(USERS_API + "?email=%s" % username, auth=opencloud_auth)
21 print " ", user["email"]
25 if myself["phone"] == "123":
26 myself["phone"] = "456"
28 myself["phone"] = "123"
30 r = requests.put(USERS_API + str(myself["id"]) +"/", data=myself, auth=opencloud_auth)
31 if r.status_code == 200:
32 print "I updated my phone to", myself["phone"]
34 print "I failed to update my phone"
36 if myself["is_admin"] == True:
37 myself["is_admin"] = False
39 myself["is_admin"] = True
41 r = requests.put(USERS_API + str(myself["id"]) +"/", data=myself, auth=opencloud_auth)
42 if r.status_code == 200:
43 print "I updated my is_admin to", myself["is_admin"]
45 print "I failed to update my is_admin"
47 r = requests.get(USERS_API + "?email=jhh@cs.arizona.edu", auth=opencloud_auth)
49 print "I was able to read jhh@cs.arizona.edu"
51 print "I was not able to read jhh@cs.arizona.edu"
53 # get john's record using admin, so we can try to update it
54 r = requests.get(USERS_API + "?email=jhh@cs.arizona.edu", auth=admin_auth)
56 print "Admin was able to read jhh@cs.arizona.edu"
59 print "ADmin was not able to read jhh@cs.arizona.edu"
63 # try to update john's user record
64 r = requests.put(USERS_API + str(jhh["id"]) + "/", data=jhh, auth=opencloud_auth)
65 if r.status_code == 200:
66 print "I was able to update user", str(jhh["id"])
68 print "I was not able to update user", str(jhh["id"])