Get REST API Versions for Migration

Returns information about which REST APIs are available and supported. Multiple versions may be supported simultaneously.

REST Resource

GET /interop/rest/

Request

Supported Media Types: application/json

Parameters:

Table 6-2 Parameters

Name Description
Details In case of errors, details are published with the error string
Status See Migration Status Codes
Items Detailed information about the API
Version The version
Lifecycle Possible values: active, deprecated
Latest Whether this version is the latest
Links Detailed information about the link
Href Links to API call
Action The HTTP call type
Rel Possible values: 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":[{
		"version":"11.1.2.3.600",
		"lifecycle":"active",
		"latest":true,
		"links":[{
			"data":null,
			"action":"GET",
			"href":"https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/interop/rest/11.1.2.3.600",
			"rel":"version"
		}]
	}],
	"details":null,
	"links":[{
		"data":null,
		"action":"GET",
		"href":"https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/interop/rest/",
		"rel":"self"
	}]
}

Getting API Versions of Migration APIs Sample Code

Prerequisites: json.jar

Common functions: See Common Helper Functions for Java

Example 6-1 Java Sample – getVersionsOfLCM.java

//
//
// BEGIN - List all the versions in PBCS
//
public void getLCMVersions() throws Exception {
	String urlString = String.format("%s/interop/rest", serverUrl);
	String response = executeRequest(urlString, "GET", null);
	JSONObject json = new JSONObject(response);
	int resStatus = json.getInt("status");
	if (resStatus == 0) {
		JSONArray fileList = json.getJSONArray("items");
		System.out.println("List of files are :");
		JSONObject jObj = null;
		for(int i=0; i<fileList.length();i++){
     System.out.println("Version :" + jObj.getString("version"));
		  System.out.println("Lifecycle :" + jObj.getString("lifecycle"));
		  System.out.println("Latest :" + jObj.getString("latest"));
		  System.out.println("Link :" + ((JSONObject) ((JSONArray) 
jObj.getJSONArray("links")).get(0)).getString("href") + "\n");
		}
	}
}
//
// END - List all the versions in PBCS
//

Example 6-2 cURL Sample – GetVersionsOfLCM.sh

Prerequisites: jq

Common functions: See Common Helper Functions for cURL

funcGetLCMVersions() {
	url=$SERVER_URL/interop/rest
	funcExecuteRequest "GET" $url

	output=`cat response.txt`
	status=`echo $output | jq '.status'`
	if [ $status == 0 ]; then
		echo "List of versions :"
		count=`echo $output | jq '.items | length'`
		i=0
		while [ $i -lt $count ]; do
			echo "Version : " `echo $output | jq '.items['$i'].version'`
			echo "Lifecycle :" `echo $output | jq '.items['$i'].lifecycle'`
			echo "Latest :" `echo $output | jq '.items['$i'].latest'`
			echo "Link :" `echo $output | jq '.items['$i'].links[0].href'`
			echo ""
			i=`expr $i + 1`
		done
	else
		error=`echo $output | jq '.details'`
		echo "Error occurred. " $error
	fi
	funcRemoveTempFiles "respHeader.txt" "response.txt"
}

Example 6-3 Groovy Sample – GetVersionsOfLCM.groovy

Prerequisites: json.jar

Common functions: See CSS Common Helper Functions for Groovy

def getLCMVersions() {
	def url;
	try {
			url = new URL(serverUrl + "/interop/rest/")
	} 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
		println "List of versions :"
		items.each{
			println "Version : " + it.version
			println "Lifecycle : " + it.lifecycle
			println "Latest : " + it.latest
			println "Link : " + it.links[0].href + "\n"
		}
	} else {
		println "Error occurred while listing versions"
		if (object.details != null)
				println "Error details: " + object.details
	}
}