How Do I Recover My Extension After Deleting the Project?

Even after deleting a project, you can still recover your deployed extension's source files, if needed. Use the script provided below to retrieve the source files, which you can then import into a new workspace for continued testing and configuration work.

Before running the script, make sure you have these details:
  • The deployed extension ID and extension version

    (If you need help finding this information, file a service request and include as many details about your deployed extension as possible, such as the base application you're configuring and deployment date.)

  • The URL of the environment where the extension was deployed
  • Credentials of a user who can access the Oracle Cloud Applications instance

You'll also need to be able to edit and run a Python script, or use curl to duplicate what the Python script does. If running this script in Windows, you must have curl installed.

  1. Copy this Python script and save it as get_extension_files.py:
    '''
    Usage: python3 get_extension_files.py
    What is this? A python3 script to retrieve customer extension source code files for a specific extension identified by its extensionID and extensionVersion.
    
    How to configure this script before using it:
     Set these variables: userid, pw, extensionID, extensionVersion, envURL
     To run this script in Windows
     - curl must be installed
     - set the Windows variable to True
    '''
    
    import json
    import requests
    from requests.auth import HTTPBasicAuth
    import os
    
    userid=""
    pw=""
    envURL=""
    extensionID=""
    extensionVersion=""
    Windows=False # set to True if running this script in Windows, else set it to False
    
    curlfile="curlfile.sh"
    if Windows:
      curlfile="curlfile.bat"
    
    #get extension file list  
    response = requests.get(envURL+"/fscmRestApi/vx/v2/extensions/"+extensionID+"/"+extensionVersion,auth=(userid,pw))
    print ( response )
    response_dict = response.json()
    print(json.dumps(response_dict, indent=4)) #pretty print the json received through the above GET cmd
    #write a shell script file containing the curl commands to download the necessary extension files, while recreating the exact directory structure of the deployed extension
    if os.path.exists(curlfile): os.remove(curlfile)
    baseURL=response_dict["baseUrl"]
    for x in response_dict["files"]:
      # ignore files in the extension-digest folder and bundles folder, and ignore build-info.json.
      if not (("bundle" in x) or ("build-info.json" in x) or ("extension-digest" in x)):
        with open(curlfile, 'a', encoding="utf-8") as f:
            if Windows:
                newX=x.replace("/","\\")
                f.write("curl -u \"" +userid+ ":" +pw+ "\" --create-dirs -o " +response_dict["id"]+ "\\" +response_dict["version"]+ "\\sources\\" +newX+ " " +baseURL+ "/" +x+ "\n\n")
            else:  
                f.write("curl -u \"" +userid+ ":" +pw+ "\" --create-dirs -o " +response_dict["id"]+ "/" +response_dict["version"]+ "/sources/" +x+ " " +baseURL+ "/" +x+ "\n\n")
    #run the shell script
    if Windows:
      os.system(curlfile)
    else:
      os.system("sh " +curlfile)
  2. In the script, define the userid, pw, envURL, extensionID, and extensionVersion variables using your extension-specific values.
  3. Set the Windows variable.
  4. Run the script (recommended version is Python 3). For example:
    python3 get_extension_files.py
    The script creates a directory structure for the extension and extracts the source files into a sources subdirectory.
  5. Create a .zip file of the sources subdirectory, only.

    Note:

    On a Mac, don't use the Finder to do this because it will create an archive that's incompatible with VB Studio.
  6. In VB Studio, create a workspace with a scratch Git repository. We're using a scratch repository in this example, but you can use any Git repository that fits your own best practices.
  7. Open the Source tab, right-click extension1, and click Import to import the sources.zip file into your workspace.


    The extension is now available in VB Studio for testing and validation.