View Source

{note}This API is added since QuickBuild 6.0.6.{note}

h1. Search Audits

h2. Syntax
Audits can be searched using http GET method through below url:
{code}http://localhost:8810/rest/audits?<search criteria1>=<value1>&<search criteria2>=<value2>&...{code}
Query string part of the url represents various search criterias to restrict the search result. Supported search criterias are:
||Search criteria||Explanation||
|username|Name of the user to audit. If not specified, audit log of all users will be searched.|
|source|Specify source of audit to match. The character _*_ can be used in the source string to do wildcard match. If not specified, audits from all sources will be matched.|
|action|Action of the audit to match. If left empty, any action will be matched.|
|since|In the format of _yyyy-MM-dd_ HH:mm, for example: _2009-11-12 13:00_. If specified, search audits generated after this date|
|until|In the format of _yyyy-MM-dd_ HH:mm, for example: _2009-11-12 14:00_. If specified, search builds generated before this date|
|first|Specified first audit entry to return. If not specified, value _0_ is assumed|
|count|Specified number of audit entries to return. This param must be specified in order not to mistakenly return all audits to stress the system|


The response is of mime type _application/xml_, and the content is XML representation of list of matched builds. If no any search criterias are specified, all builds in the system will be returned.

h2. Security
You will need to use http BASIC authentication to login as administrator if the anonymous does not have administative permission.

h2. Demo
Below [curl|http://curl.haxx.se/] commands demonstrates how to combine different criterias to perform search:
# Search recent 100 audit entries for user _robin_ under configuration tree _root/test_:
{code}curl -u admin:admin "http://localhost:8810/rest/audits?username=robin&source=root/test/*&count=100"{code}
{note}Make sure to append "/" to configuration path if you want to search against certain configuration as QuickBuild uses trailing slash to differenticate audits generated from configurations and other sources. In this example we also append _*_ to end of source param to match all sub configurations under _root/test_{note}
# Search all audits bewteen generated after _2015-01-12 13:00_ and after _2015-01-12 23:00_ in the system:
{code}curl -u admin:admin "http://localhost:8810/rest/audits?since=2015-01-12+13:00&until=2015-01-12+23:00"{code}
{note}Here we use _2015-01-12+13:00_ instead of _2015-01-12 13:00_ as the white space in query string has to be encoded as plus sign.{note}

h1. Count Audits

Counting audits uses the same syntax as searching audits, except that:
# It goes to url _http://localhost:8810/rest/audits/count_ instead of _http://localhost:8810/rest/audits_.
# first and count param should not be specified.