-
Notifications
You must be signed in to change notification settings - Fork 25
Class Manipulation
- Class Create
- Class Read
- Class Roster Read
- Class Search
- Class Update
- Class Roster Update
- Class Delete
Creates classes (groups of users).
class/create
Only admins may create classes.
- (r) auth_token = The authentication token.
- (r) client = A string representing the client.
- (r) class_urn = The new class' URN.
- (r) class_name = The new class' name.
- (o) description = An optional description for the class.
POST /app/class/create HTTP/1.1
Host: dev.ohmage.org
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
Content-Length: byte-length-of-content
Content-Type: application/x-www-form-urlencoded
auth_token=abcfcd36-ab25-4494-8434-7798cb1d718e
&class_urn=urn:class:new
&class_name=New class.
&client=ohmage-js
curl -v -d "auth_token=6b732614-a81f-426d-aef5-cb65495635cf&class_urn=urn:class:new&class_name=New Class&client=curl" https://localhost:8080/app/class/create
{
"result" : "success"
}
See the error page for a description of error codes and their associated descriptions.
Returns class names, descriptions and users for one or many classes.
class/read
Admins can read all class information in the system. Privileged users can see all class data for classes to which they belong. Restricted users can see all class data, excluding logins, for classes to which they belong.
- (r) auth_token = The authentication token. May also be set using the Set-Cookie header.
- (r) client = A string representing the client.
- (r) class_urn_list = A comma-separated list of class URNs.
- (o) with_user_list = A boolean indicating whether or not the list of users should be returned with the class information. The default is true.
- (o) class_role = A class role, which limits the results to only those classes to which the user has a role and that role is 'privileged'.
POST /app/class/read HTTP/1.1
Host: dev.ohmage.org
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
Content-Length: byte-length-of-content
Content-Type: application/x-www-form-urlencoded
auth_token=abcfcd36-ab25-4494-8434-7798cb1d718e
&class_urn=urn:class:los_angeles
&client=ohmage-MWoC
curl -v -d "auth_token=6b732614-a81f-426d-aef5-cb65495635cf&class_urn=urn:class:ptsd_group_1&client=curl" https://localhost:8080/app/class/read
{
"result":"success",
"data": {
"urn:class:user:is:privileged" : {
"name" : "AndWellness",
"description" : "Ohmage, formerly known as AndWellness and intermittently known as Mobilize and incorrectly pronounced as homage.",
"role" : "privileged",
"users" : {
"joe.shmoe" : "privileged",
"other.guy" : "restricted",
"some.one" : "restricted",
...
}
},
"urn:class:user:is:restricted" : {
"name" : "Other",
"description" : "",
"role" : "restricted",
"users" : {
"this.guy" : "",
"joe.shmoe" : "",
...
}
}
}
See the error page for a description of error codes and their associated descriptions.
Returns a CSV text file containing newline-separated lists of users associated with the provided class URNs.
class/roster/read
The user must be an admin or must be privileged in each of the classes they are attempting to read.
- (r) auth_token = The authentication token. May also be set using the Set-Cookie header.
- (r) client = A string representing the client.
- (r) class_urn_list = A comma-separated list of class URNs.
POST /app/class/read HTTP/1.1
Host: dev.ohmage.org
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
Content-Length: byte-length-of-content
Content-Type: application/x-www-form-urlencoded
auth_token=abcfcd36-ab25-4494-8434-7798cb1d718e
&class_urn_list=urn:class:los_angeles
&client=ohmage-MWoC
curl -v -d "auth_token=6b732614-a81f-426d-aef5-cb65495635cf&class_urn_list=urn:class:ptsd_group_1&client=curl" https://localhost:8080/app/class/roster/read
<class id>,<first username>,<first user's class role>
<class id>,<second username>,<second user's class role>
<second class id>,<third username>,<third user's class role>
<second class id>,<first username>,<first user's second class role>
...
See the error page for a description of error codes and their associated descriptions.
This API is designed for administrators to allow them to read all of the information about any class. If none of the optional parameters that limit the results are given, then all information about all classes will be returned. Great power, great responsibility. Deprecated.
class/search
Only admins may use this API.
- (r) auth_token = The authentication token. May also be set using the Set-Cookie header.
- (r) client = A string representing the client.
- (o) class_urn = A partial class URN limiting the results to only those classes whose URN contains this value.
- (o) class_name = A partial class name limiting the results to only those classes whose name contains this value.
- (o) description = A partial class description limiting the results to only those classes whose description contains this value. Note: If the value is an empty string, this will search for all classes with a description. In other words, if a class never provided a description and this value is an empty string, that class will not be returned.
POST /app/class/search HTTP/1.1
Host: dev.ohmage.org
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
Content-Length: byte-length-of-content
Content-Type: application/x-www-form-urlencoded
auth_token=abcfcd36-ab25-4494-8434-7798cb1d718e
&class_urn=urn:class:los_angeles
&client=ohmage-MWoC
curl -v -d "auth_token=6b732614-a81f-426d-aef5-cb65495635cf&class_urn=los_angeles&client=curl" https://localhost:8080/app/class/search
{
"result" : "success",
"data" : {
"urn:class:one" : {
"name" : "Class One",
"description" : "This class has a description.",
"usernames" : [
"user1",
"user2",
"user3"
],
"campaigns" : [
"urn:campaign:one",
"urn:campaign:two"
],
},
"urn:class:two" : {
"name" : "Class 2",
"usernames" : [
"user3",
"user4",
"user5"
],
"campaigns" : [
"urn:campaign:one"
]
}
}
}
See the error page for a description of error codes and their associated descriptions.
Allows classes to be modified. Users may be added or removed and the class metadata (name and description) may be modified.
class/update
Admins may perform any update operation on a class. Privileged class users may perform any update on a class to which they belong.
- (r) auth_token = The authentication token.
- (r) client = A string representing the client.
- (r) class_urn = URN for the class being modified.
- (o) class_name = A new name for the class.
- (o) description = A new description of the class.
- (o) user_role_list_add = A list of users and their roles to add to the class . The format is
<username1>;<role1>,<username2>;<role2>,...
The users will be added to all of the campaigns associated with this class based on the campaign's default role. - (o) user_list_remove = A list of users to remove from the class and subsequently prunes their permissions if necessary.
POST /app/class/update HTTP/1.1
Host: dev.ohmage.org
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
Content-Length: byte-length-of-content
Content-Type: application/x-www-form-urlencoded
auth_token=abcfcd36-ab25-4494-8434-7798cb1d718e
&client=ohmage-MWoC
&class_urn=urn:some:class:that:user:is:privileged:in
&name=New%20name
&description=Some%20description
&user_list_add=privileged.gal;privileged,restricted.guy;restricted
&user_list_remove=user.to.remove1,user.to.remove2
curl -v -d "auth_token=6b732614-a81f-426d-aef5-cb65495635cf&class_urn=urn:some:class:that:user:is:privileged:in&name=New Name&client=curl" https://localhost:8080/app/class/update
{
"result" : "success"
}
See the error page for a description of error codes and their associated descriptions.
Allows the list of users that belong to a class to be updated. The class rosters are CSV files where each line must be of the form: <Existing class URN>,<Existing username>,<Valid class role>
class/roster/update
Only admins may update class rosters.
- (r) auth_token = The authentication token.
- (r) client = A string representing the client.
- (r) roster =
<Contents of the roster file.>
POST /app/class/roster/update HTTP/1.1
Host: dev.ohmage.org
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
Content-Length: byte-length-of-content
Content-Type: application/x-www-form-urlencoded
auth_token=abcfcd36-ab25-4494-8434-7798cb1d718e
&client=ohmage-MWoC
&roster=<Contents of file.>
curl -v -F "auth_token=6b732614-a81f-426d-aef5-cb65495635cf" -F "client=curl" -F "roster=<contents of file>" https://localhost:8080/app/class/roster/update
{
"result" : "success",
"warning_messages" : [JSONArray of warning messages]
}
See the error page for a description of error codes and their associated descriptions.
Removes a class from the system.
class/delete
Only admins may delete classes.
- (r) auth_token = The authentication token.
- (r) client = A string representing the client.
- (r) class_urn = The URN of the class to remove.
POST /app/class/delete HTTP/1.1
Host: dev.ohmage.org
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
Content-Length: byte-length-of-content
Content-Type: application/x-www-form-urlencoded
auth_token=abcfcd36-ab25-4494-8434-7798cb1d718e
&client=ohmage-MWoC
&class_urn=urn:class:out_of_date
curl -v -d "auth_token=6b732614-a81f-426d-aef5-cb65495635cf&class_urn=urn:class:out_of_date&client=curl" https://localhost:8080/app/class/delete
{
"result" : "success"
}
See the error page for a description of error codes and their associated descriptions.