Copy Application Snapshot

This API copies a snapshot from one Planning environment (source) to another Planning environment (target).

This API is executed on the target environment after details are provided for the source environment from which the snapshot is to be copied.

This REST API is version v1.

Prerequisites: The password of the source EPM Cloud environment must have already been encrypted using EPM Automate. The encrypted password.epw file must then be passed as one of the parameters for the copysnapshot REST API. See the encrypt command in Command Reference in Working with EPM Automate for Oracle Enterprise Performance Management Cloud.

REST Resource

POST /interop/rest/v1/services/{servicename}/copysnapshot

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

Table 6-30 Tasks for Copy Application Snapshot

Task Request REST Resource
Trigger copysnapshot POST /interop/rest/v1/services/{servicename}/copysnapshot
Retrieve copysnapshot status GET /interop/rest/v1/services/{servicename}/copysnapshot/777

Parameters:

The following table summarizes the POST request parameters.

Table 6-31 Parameters

Name Description Type Required Default
api_version Specific API version Path Yes None
serviceName Name of the service, such as PBCS Path Yes None
snapshotName Name of the snapshot to be copied Form Yes None
userName User with access to the source instance Form Yes None
fpwd

The encrypted password for the source user to be passed as a string..

For information on encrypting and generating the password.epw password file with EPM Automate, see the encrypt command in Command Reference in Working with EPM Automate for Oracle Enterprise Performance Management Cloud.

Form Yes None
sourceURL

The URL of the source instance

Note: This API also supports the previous name of this parameter, targetURL.

Form Yes None
dom The identity domain to which the source instance belongs. Form Yes None

Response

Supported Media Types: application/json

Parameters:

Table 6-32 Parameters

Name Description
details In the 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 or status API
action The HTTP call type
rel Possible values: self or Job Status. If the value is set to Job Status, you can use the href to get the status of the recreate service
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":-1, "items": null, "links":[{"rel":"self", "href":"https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/interop/rest/v1/services/PBCS/copysnapshot","data":null,"action":"POST"},{"rel":"Job Status","href":"https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/interop/rest/v1/services/PBCS/copysnapshot/1502357937045","data":null,"action":"GET"}],"details":null

Java Sample – CopySnapshot.java

//
// BEGIN - copysnapshotfrominstance
//
public void copysnapshot() throws Exception {

String snapshotName = "SNAPSHOT NAME";
String srcUserName = "USER NAME";	
String targetURL = "https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com";	
String srcEPWfilePath = "C:\\logs\\pwd.epw";
String srcDomain = null;

String urlString = String.format("%s/interop/rest/v1/services/PBCS/copysnapshot", serverUrl);

String fpwd = fetchPwdFromFile(srcEPWfilePath);
String params = null;

if (null == srcDomain) {
 params = "snapshotName=" + snapshotName + "&userName=" + srcUserName + "&fpwd=" + fpwd + "&sourceURL="
					+ targetURL;
} else {
 params = "snapshotName=" + snapshotName + "&userName=" + srcUserName + "&fpwd=" + fpwd + "&sourceURL="
					+ targetURL + "&dom=" + srcDomain;
}

String response = executeRequest(urlString, "POST", params, "application/x-www-form-urlencoded");

getJobStatus(fetchPingUrlFromResponse(response, "Job Status"), "GET");
}

private String fetchPwdFromFile(String filePath) {
		BufferedReader br = null;

		try {
			br = new BufferedReader(new FileReader(filePath));
			String line = null;
			String pwdString = null;
			while ((line = br.readLine()) != null) {
				pwdString = line;
			}
			return pwdString;
		} catch (Exception e) {
		} finally {
			if (null != br)
				try {
					br.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

		}

		return null;
}
//
// END - copysnapshotfrominstance
//

cURL Sample – copysnapshot.sh

funcCopySnapshot() {
		url=$SERVER_URL/interop/rest/v1/services/PBCS/copysnapshot
		
		snapshotName="SNAPSHOT NAME"
		srcUserName="USER NAME"	
		targetURL="https://<SERVICE NAME>-TENANT NAME>.pbcs.<dcX>.oraclecloud.com"	
		srcEPWfilePath="pwd.epw"
		srcDomain=""

		fpwd=`cat $ srcEPWfilePath`
		
if [ "X" == "X$ srcDomain " ]; then 
param="snapshotName=$snapshotName&userName=$srcUserName &fpwd=$fpwd&sourceURL=$targetURL"
else
param="snapshotName=$snapshotName&userName=$srcUserName &fpwd=$fpwd&targetURL=$sourceURL&dom=$srcDomain"
fi	
		
		funcExecuteRequest "POST" $url $param "application/json"
		output=`cat response.txt`
		status=`echo $output | jq '.status'`
		if [ $status == -1 ]; then
		echo "Started Copysnapshot"
		funcGetStatus "GET"
		else
		error=`echo $output | jq '.details'`
		echo "Error occurred. " $error
		fi
		funcRemoveTempFiles "respHeader.txt" "response.txt"
}

Groovy Sample – copysnapshot.groovy

def copy() {

	def url;
	def params;
	
	try {
	
	snapshotName = "test";
	srcUserName = "epm_default_cloud_admin";	
	sourceURL = "https://<SERVICE NAME>-TENANT NAME>.pbcs.<dcX>.oraclecloud.com";	
	srcEPWfilePath = "pwd.epw";
	fpwd = fetchPwdFromFile(srcEPWfilePath);
	srcDomain = null;
	
	//println fpwd
	if (null == srcDomain) {
			params = "snapshotName=" + snapshotName + "&userName=" + srcUserName + "&fpwd=" + fpwd + "&targetURL=" + targetURL;
	} else {
			params = "snapshotName=" + snapshotName + "&userName=" + srcUserName + "&fpwd=" + fpwd + "&targetURL="	+ targetURL + "&dom=" + srcDomain;
	}
	//println params
	url = new URL(serverUrl + "/interop/rest/v1/services/PBCS/copysnapshot");
	} catch (MalformedURLException e) {
	println "Incorrect URL. Please a pass valid URL"
	System.exit(0);
	}
	response = executeRequest(url, "POST", params, "application/json");
	
	if (response != null) {
		getJobStatus(fetchPingUrlFromResponse(response, "Job Status"), "GET");
	}

}

def fetchPwdFromFile(filePath) {
		BufferedReader br = null;

		try {
			br = new BufferedReader(new FileReader(filePath));
			String line = null;
			String pwdString = null;
			while ((line = br.readLine()) != null) {
				pwdString = line;
			}
			return pwdString;
		} catch (Exception e) {
		} finally {
			if (null != br)
				try {
					br.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

		}

		return null;
}