Get REST API Versions for Migration

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

Required Roles

Service Administrator, Power User, User, Viewer

REST Resource

GET /interop/rest/

Request

Supported Media Types: application/json

Table 9-3 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
lifecycle The stage in the lifecycle, such as active
version The version, such as 11.1.2.3.600, v1, and v2, for example, "version": "11.1.2.3.600", "v1", v2"
serviceType The service type, such as PCMCS
serverVersion The server version, such as 21.05.70
buildVersion The build version, such as 21.05.52

Example of Response Body

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

{
    "links": [
        {
            "href": "href":"https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/interop/rest/11.1.2.3.600",
            "rel": "self",
            "data": null,
            "action": "GET"
        }
    ],
    "details": null,
    "status": 0,
    "items": [
        {
            "latest": true,
            "links": [
                {
                    "href":"https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/interop/rest/11.1.2.3.600",
                    "rel": "version",
                    "data": null,
                    "action": "GET"
               }
            ],
            "lifecycle": "active",
            "version": "11.1.2.3.600",
            "serviceType": "PCMCS",
            "serverVersion": "21.05.70",
            "buildVersion": "21.05.52"
        }
    ],
}

Getting API Versions of Migration APIs Sample Code

Prerequisites: json.jar

Common functions: See Common Helper Functions for Java

Example 9-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 9-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 9-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
	}
}
Common Functions