Migration with REST APIs

In addition to the UI-enabled migration (export/import), Arcadia Enterprise provides REST APIs that give more flexibility in choosing what objects to migrate.

While migration with UI allows the user to directly specify export of visuals, dashboards, and apps, REST APIs enable you to specify a wider range of migratable objects. Note that we do not migrate events and segments separately, but as part of dataset migration. Similarly, we migrate thumbnails along with dashboards or visuals that they represent.

Migratable Artifacts

The artifacts that may be migrated through REST APIs follow:

Apps
Apps use the appgroups object type.
Dashboards

Dashboards use the dashboards object type.

For information of UI-based migration, see Exporting Dashboards and Importing Dashboards.

Visuals

Visuals use the visuals object type.

We recommend UI-based migration whenever possible; see Exporting Linked Visuals and Importing Linked Visuals for working linked visuals. The non-linked visuals are part of dashboard export and import.

Datasets
Datasets use the datasets object type.
Date Ranges
Datasets use the daterange object type.
Static Assets
Static assets, such as images or video, use staticasset object type.
Custom Styles
Custom styles that include CSS and JS specifications use the customcss object type.
Custom Color
Custom colors that you define and use in the visual artifacts use the colorpalette object type.

Migration Tasks

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.

    Generating an API key
  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