Delete Files

Deletes a file from the Oracle Planning and Budgeting Cloud repository. SeeAbout the EPM Automate Utility.

REST Resource

DELETE /interop/rest/{api_version}/applicationsnapshots/{applicationSnapshotName

Request

Supported Media Types: application/json

Parameters:

The following table summarizes the request parameters.

Table 6-13 Parameters

Name Description Type Required Default
api_version Specific API version Path Yes None
applicationSnapshotName Application snapshot name that needs to be deleted Path Yes None

Response

Supported Media Types: application/json

Table 6-14 Parameters

Parameters Description
Details Published if there is an error with the error string
Status See Migration Status Codes
Links Detailed information about the link
Href Links to the API call
Action The HTTP call type
Rel Possible value: self
Data Parameters as key value pair passed in the request

Example of Response Body

{
        "status":0,
        "links":[{
                "data":null,
                "action":"DELETE",
                "rel":"self",
                "href":"https://<SERVICE_NAME>-<TENANT_NAME>.<dcX>.oraclecloud.com/interop/rest/11.1.2.3.600/applicationsnapshots/ss2"
        }],
        "details":null
}

Delete Files Sample Code

Example 6-16 Java Sample – deleteFile.java

Prerequisites: Java-JSON.jar

Common Functions: See Common Helper Functions for Java

//
// BEGIN - Delete a file in PBCS
//
public void deleteFile(String fileName) throws Exception {
        String urlString = String.format("%s/interop/rest/%s/applicationsnapshots/%s", serverUrl, apiVersion, fileName);
        String response = executeRequest(urlString, "DELETE", null);
        JSONObject json = new JSONObject(response);
        int resStatus = json.getInt("status");
        if (resStatus == 0)
                System.out.println("File deleted successfully");
        else
                System.out.println("Error deleting file : " + json.getString("details"));
}
//
// END - Delete a file in PBCS
//

Example 6-17 cURL Sample – DeleteFile.sh

Prerequisites: jq (http://stedolan.github.io/jq/download/linux64/jq)

Common Functions: See Common Helper Functions for cURL

funcDeleteFile() {
        encodedFileName=$(echo $1 | sed -f urlencode.sed)
        url=$SERVER_URL/interop/rest/$API_VERSION/applicationsnapshots/$encodedFileName
        funcExecuteRequest "DELETE" $url

        output=`cat response.txt`
        status=`echo $output | jq '.status'`
    if [ $status == 0 ]; then
        echo "Deleted successfully"
    else
        error=`echo $output | jq '.details'`
        echo "Error occurred. " $error
    fi
        funcRemoveTempFiles "respHeader.txt" "response.txt"
}

Example 6-18 Groovy Sample – DeleteFile.groovy

Prerequisites: Java-JSON.jar

Common Functions: Common Helper Functions for Groovy

def deleteFile(filename) {
        def url;
        try {
                String encodedFileName = URLEncoder.encode(filename, "UTF-8");
                url = new URL(serverUrl + "/interop/rest/" + apiVersion + "/applicationsnapshots/" + encodedFileName)
        } catch (MalformedURLException e) {
                println "Malformed URL. Please pass valid URL"
                System.exit(0);
        }
        response = executeRequest(url, "DELETE", null);
        def object = new JsonSlurper().parseText(response)
        def status = object.status
        if (status == 0 )
                println "File deleted successfully"
        else {
                println "Error occurred while deleting file"
                if (object.details != null)
                        println "Error details: " + object.details
        }
}