Export/import custom report definitions

You can use Edge APIs to export and import custom reports from one org environment to another. This useful technique lets you reuse custom report designs that you like in different orgs and environments. Furthermore, you can store the design (a simple JSON text file) in your CSV.

First, use the Lists analytics report definitions API to get the UUIDs of all reports defined for an org:

curl -X GET "https://api.enterprise.apigee.com/v1/organizations/org-name/reports" \
  -u email:password 

For each report, the output contains its display name (the name you see in the Edge UI) and its UUID:

{
  "qualifier": [
    {
      "displayName": "My Report 1",
      "name": "cb7cd16a-44c4-0bc83c3b9c92"
    },
    {
      "displayName": "My Other Report",
      "name": "a7e3fc4e-992a2ffc0e3d49d"
    },
    ...
  ]
}

Now use the UUID of the desired report to retrieve its definition by calling the Get an analytics report definition API. In this example, you get the definition of the report named "My Report 1":

curl -X GET "https://api.enterprise.apigee.com/v1/organizations/org-name/reports/cb7cd16a-44c4-0bc83c3b9c92" \
  -u email:password 

The output contains the report definition:

{
  "chartType": "column",
  "comments": [],
  "createdAt": 1506922614000,
  "createdBy": "11.111.121.57",
  "dimensions": [
    "apiproxy",
    "proxy_pathsuffix",
    "proxy_client_ip"
  ],
  "displayName": "My Report 1",
  "environment": "prod",
  "lastModifiedAt": 1512435450000,
  "lastModifiedBy": "111.111.121.57",
  "lastViewedAt": 1512435450000,
  "metrics": [
    {
      "function": "avg",
      "name": "response_size"
    },
    {
      "function": "avg",
      "name": "request_size"
    }
  ],
  "name": "cb7cd16a-44c4-0bc83c3b9c92",
  "organization": "myOrg",
  "properties": [
    {
      "property": "__ui__",
      "value": [
        {
          "name": "description"
        },
        {
          "name": "accuracy"
        }
      ]
    }
  ],
  "sortbyCols": [],
  "tags": [],
  "timeUnit": "hour"
}

Copy the JSON output and update the environment and organization fields as necessary for the destination, and then import the definition by using the Create an analytics report definition API.

For example, to import the definition into the test environment of an org named destOrg:

curl -X POST -H "Content-Type: application/json" "https://api.enterprise.apigee.com/v1/organizations/destOrg/reports" \
-d "{
  "chartType": "column",
  "comments": [],
  "createdAt": 1506922614000,
  "createdBy": "11.111.121.57",
  "dimensions": [
    "apiproxy",
    "proxy_pathsuffix",
    "proxy_client_ip"
  ],
  "displayName": "My Report 1",
  "environment": "test",
  "lastModifiedAt": 1512435450000,
  "lastModifiedBy": "111.111.121.57",
  "lastViewedAt": 1512435450000,
  "metrics": [
    {
      "function": "avg",
      "name": "response_size"
    },
    {
      "function": "avg",
      "name": "request_size"
    }
  ],
  "name": "cb7cd16a-44c4-0bc83c3b9c92",
  "organization": "destOrg",
  "properties": [
    {
      "property": "__ui__",
      "value": [
        {
          "name": "description"
        },
        {
          "name": "accuracy"
        }
      ]
    }
  ],
  "sortbyCols": [],
  "tags": [],
  "timeUnit": "hour"
}" \
-u email:password 

You should now see the report in the Edge UI for the organization.