List Files

Lists the files in the Planning repository and returns information about the available file and application snapshots. It provides details such as name, type, size and last modified time. Size and last modified are not available for LCM snapshots. See About the EPM Automate Utility. This REST API is version 11.1.2.3.600.

REST Resource

GET /interop/rest/{api_version}/applicationsnapshots

Supported Media Types: application/json

Parameters:

Table 6-12 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 Request 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://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/interop/rest/11.1.2.3.600/applicationsnapshots",
		"rel":"self"
	}]
}

List Files Sample Code

Example 6-13 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 6-14 cURL Sample– ListFiles.sh

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)

Common Functions: See Common Helper Functions for cURL

Example 6-15 Groovy Sample– ListFiles.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
	}
}

Prerequisites: json.jar

Common Functions: See CSS Common Helper Functions for Groovy