List Files (v11.1.2.3.600)

This API (v11.1.2.3.600) lists the files in the Planning repository and returns information about the available file and application snapshots.

This topic describes the original version of this REST API. You can also use the simplified v2 version of the REST API. The v2 version contains all parameters in the payload and does not require URL encoding while calling the REST APIs. This makes the v2 API easier to use. The v2 version is backwards compatible.

This API provides details such as name, type, size and last modified time. Size and last modified are not available for LCM snapshots. See About EPM Automate in Working with EPM Automate for Oracle Enterprise Performance Management Cloud.

This REST API is version 11.1.2.3.600.

Required Roles

Service Administrator

Power User assigned to the Migration Administrator Profitability and Cost Management application role

REST Resource

GET /interop/rest/{api_version}/applicationsnapshots

Supported Media Types: application/json

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.

Response

Table 9-25 Parameters

Name Description
Details Will be published in case of error with the error string
Status See Migration Status Codes
Items  
Name Name of the application snapshot
Type

Can be LCM or EXTERNAL

Type signifies if this snapshot is for LCM or EXTERNAL. LCM indicates that the file is an LCM snapshot. EXTERNAL indicates that files are not LCM, such as Planning files.

Size Size of the application snapshot in bytes. Available only for type EXTERNAL
Lastmodifiedtime Time in Long value as per the last modified time of the file. Available only for type EXTERNAL
Links Detailed information about the link
Href Link to API call/ status API
Action The HTTP call type
Rel Will be self
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.

{
	"status":0,
	"items":[{
		"name":"sample.csv",
		"type":"EXTERNAL",
		"size":"18",
		"lastmodifiedtime":"1422534438000"
		},{
		"name":"snapshot1",
		"type":"LCM",
		"size":null,
		"lastmodifiedtime":null
	}],
	"details":null,
	"links":[{
		"data":null,
		"action":"GET",
		"href":"https://<BASE-URL>/interop/rest/11.1.2.3.600/applicationsnapshots",
		"rel":"self"
	}]
}

List Files Sample Code

Example 9-9 Java Sample – listFiles.java

Prerequisites: json.jar

Common Functions: See Common Helper Functions for Java

//
// BEGIN - List all the files in PBCS
//
public void listFiles() throws Exception {
	String urlString = String.format("%s/interop/rest/%s/applicationsnapshots", serverUrl, apiVersion);
	String response = executeRequest(urlString, "GET", null);
	JSONObject json = new JSONObject(response);
	int resStatus = json.getInt("status");
	if (resStatus == 0) {
		if (json.get("items").equals(JSONObject.NULL))
			System.out.println("No files found");
		else {
			System.out.println("List of files :");
			JSONArray itemsArray = json.getJSONArray("items");			
			JSONObject jObj = null;
			for (int i=0; i < itemsArray.length(); i++){
				jObj = (JSONObject)itemsArray.get(i);
				System.out.println(jObj.getString("name"));
			}
		}
	}
}
//
// END - List all the files in PBCS
//

Example 9-10 cURL Sample– ListFiles.sh

Prerequisites: json.jar

Common Functions: See Common Helper Functions for cURL

funcListFiles() {
	url=$SERVER_URL/interop/rest/$API_VERSION/applicationsnapshots
	funcExecuteRequest "GET" $url

	list=`cat response.txt | jq 'select(.items != null) | .items[].name'`
	if [[ ! -z $list ]]; then
		echo $list
	else
		echo "No files found"
	fi
	funcRemoveTempFiles "respHeader.txt" "response.txt"
}
Prerequisites: jq (http://stedolan.github.io/jq/download/linux64/jq) 

Example 9-11 Groovy Sample– ListFiles.groovy

Prerequisites: json.jar

See CSS Common Helper Functions for Groovy

def listFiles() {
	def url;
	try {
			url = new URL(serverUrl + "/interop/rest/" + apiVersion + "/applicationsnapshots")
	} catch (MalformedURLException e) {
			println "Malformed URL. Please pass valid URL"
			System.exit(0);
	}
	response = executeRequest(url, "GET", null);
	def object = new JsonSlurper().parseText(response)
	def status = object.status
	if (status == 0 ) {
		def items = object.items
		if (items == null) {
			println "No files found"
		}
		else {
			println "List of files :"
			items.each{
				println it.name
			}
		}
	} else {
		println "Error occurred while listing files"
		if (object.details != null)
				println "Error details: " + object.details
	}
}
Common Functions