Skip to content

Audit APIs

Joshua Selsky edited this page Aug 19, 2013 · 6 revisions

What does it do?

Allows users to read audit data. Audit data is composed of metadata regarding all requests made to ohmage.

URI

audit/read

Access Rules

Only admins may read audits.

Input Parameters

  • (r) auth_token = A valid authentication token for the requester. May also be set using the Set-Cookie header.
  • (r) client = The client that is making this API call.
  • (o) request_type = Limits the results to only those with this HTTP request type. One of: post / get / options / head / put / delete / trace / unknown
  • (o) uri = Limits the results to only those to this URI. The URI doesn't have to be an ohmage URI, but those not in the ohmage domain will never be caught by ohmage and will always return nothing.
  • (o) client_value = Limits the results to only those requests that gave this value as a client value.
  • (o) device_id_value = Limits the results to only those requests that gave this device ID.
  • (o) response_type = Limits the results to only those that had a response type of "success" or "failure".
  • (o) error_code = When the response_type is set to "failure" this will further limit the results to only those that failed with this error code. If the response type is set to "success" this is ignored.
  • (o) start_date = Limits the results to only those audits that were recorded on or after this date. This may be a date or a date and time.
  • (o) end_date = Limits the results to only those audits that were recorded on or before this date. This may be a date or a date and time.

Notes

Warning! If no parameters are given, all audits are returned. This will probably be a large amount of data and should only be used with caution.

Example POST

POST /app/audit/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=816ad120-538c-11e1-8f3d-c82a142568c4
  &client=curl
  &uri=/app/user/read
  &start_date=2011-01-01
  &end_date=2012-01-01

cURL Example

curl -v -d "auth_token=816ad120-538c-11e1-8f3d-c82a142568c4&client=curl&uri=/app/user/read&start_date=2011-01-01&end_date=2012-01-01" https://dev.andwellness.org/app/audit/read

Output Format

Success

{
    "result":"success",
    "audits":[
        {
            "timestamp":"2011-08-07 16:43:28.0",
            "response":{
                "result":"success"
            },
            "client":"testWeb",
            "request_type":"POST",
            "responded_millis":1312847597927,
            "received_millis":1312847597096,
            "request_parameters":{
                "client":[
                    "testWeb"
                ],
                "password":[
                    "omitted"
                 ],
                 "user":[
                     "example.user"
                 ]
            },
            "uri":"/app/user/auth_token",
            "extra_data":{
                "cache-control":[
                    "max-age=0"
                ],
                "content-type":[
                    "application/x-www-form-urlencoded"
                ],
                "cookie":[
                     "JSESSIONID=FA122B42FE6B7CC3345CCFBB4740408C; auth_token=7077ee13-0293-4a9c-9875-e7ad98546054"
                ],
                "connection":[
                    "keep-alive"
                ],
                "host":[
                    "localhost:8080"
                ],
                "accept-language":[
                    "en-US,en;q=0.8"
                ],
                "content-length":[
                    "50"
                ],
                "accept":[
                    "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
                ],
                "origin":[
                    "null"
                ],
                "user-agent":[
                    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.107 Safari/535.1"
                ],
                "accept-encoding":[
                    "gzip,deflate,sdch"
                ],
                "accept-charset":[
                    "ISO-8859-1,utf-8;q=0.7,*;q=0.3"
                ]
            }
         },
         {
             "timestamp":"2011-08-07 16:43:28.0",
             "response":{
                 "result":"success"
             },
             "client":"testWeb",
             "request_type":"POST",
             "responded_millis":1312847604512,
             "received_millis":1312847604441,
             "request_parameters":{
                 "user_role":[
                     ""
                 ],
                 "end_date":[
                     ""
                 ],
                 "campaign_urn_list":[
                     ""
                 ],
                 "client":[
                     "testWeb"
                 ],
                 "privacy_state":[
                     ""
                 ],
                 "output_format":[
                     "short"
                 ],
                 "start_date":[
                     ""
                 ],
                 "running_state":[
                     ""
                 ],
                 "class_urn_list":[
                      ""
                 ]
             },
             "uri":"/app/campaign/read",
             "extra_data":{
             "content-type":[
                 "application/x-www-form-urlencoded"
              ],
              "connection":[
                  "keep-alive"
              ],
              "host":[
                  "localhost:8080"
              ],
              "accept-language":[
                  "en-US,en;q=0.8"
              ],
              "campaign_urn":[
                  "urn:campaign:ca:ucla:Mobilize:May:2011:Sleep:Test",
                  "urn:andwellness:chipts:campaign:test",
                  "urn:campaign:ca:lausd:Addams_HS:CS101:Fall:2011:Advertisement",
                  "urn:andwellness:chipts:pattern",
                  "urn:campaign:ca:lausd:Jefferson:ECS:May:2013:Advertisement",
                  "urn:campaign:ca:lausd:Addams_HS:CS101:Fall:2011:Sleep",
                  "urn:campaign:ca:lausd:Jefferson:ECS:May:2012:Advertisement",
                  "urn:campaign:ca:lausd:Verdugo:ECS:May:2011:Snack",
                  "urn:campaign:ca:ucla:Mobilize:May:2011:Advertisement:Test",
                  "urn:campaign:ca:ucla:CS219:May:2011:Loadtest",
                  "urn:campaign:ca:lausd:Addams_HS:CS101:Fall:2011:Snack",
                  "urn:andwellness:nih"
              ],
              "accept":[
                  "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
              ],
              "origin":[
                  "null"
              ],
              "user-agent":[
                  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.107 Safari/535.1"
              ],
              "accept-charset":[
                  "ISO-8859-1,utf-8;q=0.7,*;q=0.3"
              ],
              "cache-control":[
                  "max-age=0"
              ],
              "cookie":[
                  "JSESSIONID=687418801D45536F846A249F42C1C810; auth_token=959406e7-a5a4-412a-8c46-3f8a461f48bb"
              ],
              "content-length":[
                  "132"
              ],
              "accept-encoding":[
                  "gzip,deflate,sdch"
              ]
          }
      },
      ...
   ]
}

Failure

See the error page for a description of error codes and their associated descriptions.

Back to Top