Migration with REST APIs

Migration with REST APIs involves these tasks:

  1. Enable and create the relevant data API keys, both for the source and destination machines; see Managing API Keys. The examples in this article use the Secret API Key that appears when you generate the keys for the first time, as in Creating New API Keys.
  2. Export by submitting a GET request on the source machine. See Exporting with REST APIs,
  3. Import by submitting a POST request on the target machine. Importing with REST APIs.

Exporting 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)

Importing with REST APIs

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