Copy Application Snapshot (v1)

Use this API (v1) to copy a snapshot from one environment (source) to another environment (target).

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 is executed on the target environment after details are provided for the source environment from which the snapshot is to be copied.

Prerequisites: The password of the source EPM Cloud environment must have already been encrypted using EPM Automate. The encrypted password 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.

This REST API is version v1.

Required Roles

Service Administrator

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

REST Resource

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

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

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.

Table 9-61 Tasks for Copy Application Snapshot

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

Parameters:

The following table summarizes the POST request parameters.

Table 9-62 Parameters

Name Description Type Required Default
api_version Specific API version, such as v1 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. The encrypted password must then be passed as one of the parameters for the REST API.

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

Response

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

Table 9-63 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 copy snapshot
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/x-www-form-urlencoded"
		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/x-www-form-urlencoded");
	
	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;
}
Common Functions