Migration with REST APIs involves these tasks:
GET
request on the source machine. See Exporting with REST APIs,POST
request on the target machine. Importing with REST APIs.Authenticate the user using the data API.
After authenticating, the user has to submit a GET
request to the
following address for a source machine:
source_arcviz_ip/arc/migration/api/export/
Here is a sample Python code snippet for authenticating and submitting the
GET
request that exports dashboards with IDs 2115 and 2110, and then
writing the response to a file my_app.json
.
import requests
headers = {'AUTHORIZATION':'apikey secret_api_key'}
payload = {'dashboards': '[2115, 2110]', 'filename': 'apitestmigration', 'dry_run':'False'}
r = requests.get('source_arcviz_ip/arc/migration/api/export/', headers=headers, params=payload)
with open('my_app.json', 'w') as f:
f.write(r.text)
The *.json
file with information about exported visual artifacts must be
on the destination machine.
Just as with export, authenticate the user using the data API.
After authenticating, submit a POST
request to the following address for a
destination machine:
destination_arcviz_ip/arc/migration/api/import/
Here is a sample Python code snippet for authenticating and submitting the
POST
request that imports dashboards with IDs 2115 and 2110, which were
earlier saved (from a metadata perspective) as my_app.json
. This
file is uploaded to the ArcViz server during the import.
import requests
headers = {'AUTHORIZATION':'apikey secret_api_key'}
payload = {'dry_run': False, "dataconnection_name":"data_connection"}
files = {'import_file': open('/Users/my_name/Downloads/my_app.json','r')}
r = requests.post('destination_arcviz_ip/arc/migration/api/import/',files=files, data=payload, headers=headers)
print r.status_code # 200 is success