User Audit Report (v1)

Generates a user audit report in the system and writes the report to the filename provided. The output CSV file contains the first character as a Byte Order Mark(BOM) character \ufeff. The API writes an encrypted application identifier following the BOM character. This application identifier is written between double quotes. Headers for the CSV file follow the application identifier. The report contains the details regarding the users logged into the system in a given time range.

The generated CSV file is compressed and the output is a ZIP file. The file can be downloaded using the Download REST API.

This is an asynchronous command, so use the job status URI to determine whether the operation is complete.

This API is version v1.

Required Roles

Service Administrator

Table 10-56 User Audit Report

Task Request REST Resource
User Audit Report POST

/interop/rest/{api_version}/reports?q={type:userauditreport,fileName:useraudit report.csv,since:2017-12-10,until:2018-06-10}

REST Resource

POST /interop/rest/{api_version}/reports?q={type:userauditreport,fileName:userauditreport.csv,since:2017-12-10,until:2018 -06-10}

Note:

Before using the REST resources, you must understand how to access the REST resources and other important concepts. See Implementation Best Practices for EPM Cloud REST APIs. Using this REST API requires prerequisites. See Prerequisites.

Request

Supported Media Types: application/x-www-form-urlencoded

The following table summarizes the request parameters.

Table 10-57 Parameters

Name Description Type Required Default
api_version Specific API version Path Yes None
fileName File where report is to be populated Query Yes None
since Report generation start date Query Yes None
until Report generation end date Query Yes None
type Type of report being generated, provisionreport or userauditreport Query Yes None

Response

Supported Media Types: application/json

Table 10-58 Parameters

Parameters Description
details In case of errors, details are published with the error string
status See Migration Status Codes
links Detailed information about the link
href Links to API call
action The HTTP call type
rel Can be self and/or Job Status. If set to Job Status, you can use the href to get the status of the import operation
data Parameters as key value pairs passed in the request

Example of Response Body

The following shows an example of the response body in JSON format.

{
   "links": [
      {
         "rel": "self",
         "href": "https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.cominterop/rest/{api_version}/reports?q={type:userauditreport,fileName:useraudit 
report.csv,since:2017-12-10,until:2018-06-10}",
         "data": null,
         "action": "POST"
      },
      {
         "rel": "Job Status",
         "href": "https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/interop/rest/v1/reports/3180621025673301",
         "data": null,
         "action": "GET"
      }
   ],
   "status": -1,
   "details": null
}

User Audit Report Sample Code

Example 10-31 Java Sample – UserAuditReport.java

Prerequisites: json.jar

Common Functions: See CSS Common Helper Functions for Java

//
// BEGIN 
//
public void userAuditReport (String fileName, String type, String since, String until) throws Exception {
	JSONObject params = new JSONObject();
	params.put("fileName",java.net.URLEncoder.encode(fileName));
	params.put("type",java.net.URLEncoder.encode(type));
	params.put("since",java.net.URLEncoder.encode(since));
	params.put("until",java.net.URLEncoder.encode(until));			

	String urlString = String.format("%s/interop/rest/%s/reports?q=%s", serverUrl, lcmVersion, params.toString());
	String response = executeRequest(urlString, "POST", params.toString(), "application/x-www-form-urlencoded");
	waitForCompletion(fetchPingUrlFromResponse(response, "Job Status"));}
//
// END 
//

Example 10-32 cURL Sample – userauditreport.sh

Prerequisites: jq (http://stedolan.github.io/jq/download/linux64/jq)

Common Functions: See Common Helper Functions for cURL

funcUserAuditReport () {
     url=$SERVER_URL/interop/rest/$LCM_VERSION/reports/	
	
     param=$(echo "q={type:$reporttype,fileName:$fileName,since:$since,until:$until}" | sed -f urlencode.sed)  

     url=$url?$param
	
     funcExecuteRequest "POST" $url $param "application/json"

     output='cat response.txt'
     status='echo $output | jq '.status''
    if [ $status == -1 ]; then
        echo "copying snapshot in progress"
		funcGetStatus "GET"
    else
        error='echo $output | jq '.details''
        echo "Error occured. " $error
    fi
	funcRemoveTempFiles "respHeader.txt" "response.txt"
}

Example 10-33 Groovy Sample – userauditreport.groovy

Prerequisites: json.jar

Common Functions: See CSS Common Helper Functions for Groovy

def userAuditReport (fileName, type, since, until) {
        def url;
        JSONObject param = new JSONObject();		
		try {		    	    			

			param.put("fileName",fileName);
			param.put("type",type);
			param.put("since",since);
			param.put("until",until);
                        		
			url = new URL(serverUrl + "/interop/rest/" + lcmVersion + "/reports?q=" + param.toString());
		} catch (MalformedURLException e) {
			println "Malformed URL. Please pass valid URL"
			System.exit(0);
		}
		response = executeRequest(url, "POST", param.toString(), "application/x-www-form-urlencoded");
		
		if (response != null) {
			waitForCompletion(fetchPingUrlFromResponse(response, "Job Status"));
		}	 
}
Common Functions