Migrate Project Spaces and Projects
Because all assets are linked to a Project Space and project, re-create them in the new environment before migrating assets. Before you start, determine which process you will use to migrate assets:
If you subscribe to the Git Integration, you can use a Git checkout to re-create the projects. A benefit to this approach is that it also re-creates the assets. You can do this one at a time in the user interface, or use the Git operation APIs to automate the process. Depending on your Git provider, you might have to change some configuration and re-authorize SnapLogic before using Git.
If you don’t subscribe to the Git Integration, you can export projects and their assets and import them. If you use the APIs, you only need to re-create Project Spaces, because the import API creates the project if it doesn’t exist.
Assuming input from an output.csv
file that contains project names and permissions, the following example Python script creates Project Spaces and projects in the new environment:
import requests
import time
import json
US_CP_orgName = "<your-environment-name>"
EMEA_CP_orgName = "<your-new-environment-name>"
US_PWD = 'XXXXXXXXXXX'
EMEA_PWD = 'XXXXXXXXXXX'
headers = {
'Content-Type': 'application/json'
}
try:
with open('output.csv', 'r') as file:
for line in file:
# Retrieve privileges of user from US org
prjPath = "/" + line.strip() # .strip() removes the newline character at the end of each line
print( " =====> Process", US_CP_orgName + prjPath )
response = requests.get('https://cdn.elastic.snaplogic.com/api/1/rest/public/assetapi/acl/' + US_CP_orgName + prjPath, headers=headers, auth=('<your-email>', US_PWD))
if response.status_code == 200 :
print( response.text )
else :
print( "Status:", response.status_code, response.reason, response.text )
data = json.loads( response.text )
if next(iter(data)) == "success" :
permData = {
"permissions": data['success']['acl']
}
# Create project / Space on EMEA org
response = requests.post('https://cdn.emea.snaplogic.com/api/1/rest/public/assetapi/project/' + EMEA_CP_orgName + prjPath, headers=headers, json=permData, auth=('<your-email>', EMEA_PWD))
if response.status_code == 200 :
# print( response.text )
print( prjPath, "created" )
else :
print( "Status:", response.status_code, response.reason, response.text )
except Exception as e:
print(e)
input("Error... press enter")
exit()
input("Process completed... press enter to close this window")
Â
Have feedback? Email documentation@snaplogic.com | Ask a question in the SnapLogic Community
© 2017-2024 SnapLogic, Inc.