Change a dashboard owner through the REST API

Dashboards are owned by the logged in user that created them. If a user is no longer with your company, you might need to change the owner of the dashboard to maintain that dashboard.

To transfer ownership of a dashboard, you need the dashboard ID and the username of the dashboard owner. You can only view the username of the owner of a dashboard through the REST API.

Before you begin

  • You must log into the ExtraHop appliance with an account that has full system privileges to generate an API key.
  • You need a valid API key to make changes through the REST API and complete the procedures below. (See Generate an API key.)
  • Familiarize yourself with the ExtraHop REST API Guide to learn how to navigate the ExtraHop REST API Explorer.

Retrieve the dashboard IDs

  1. In a browser, navigate to the ExtraHop API Explorer.
    The URL is the hostname or IP address of your ExtraHop Discover or Command appliance, followed by /api/v1/explore/. For example, if your hostname is seattle-eda, the URL is https://seattle-eda/api/v1/explore/.
  2. Paste or type your API Key into the api_key field at the top of the page.
  3. Click Dashboard to display dashboard operations.
  4. Click GET /dashboards.
  5. Click Try it out! to send the request to your appliance.
    The request returns a response body with information about each dashboard.
  6. Search for the dashboards by the dashboard name or by the user account listed in the "owner" field. If your list of dashboards is long, you can press control-F and search the response body.
    For our example, we want to change the "LDAP Server Health" dashboard created by the user account for "marksmith":
    {
        "id": 1876,
        "comment": null,
        "mod_time": 1507576983922,
        "author": "Mark Smith",
        "name": "LDAP Server Health",
        "owner": "marksmith",
        "built-in": false,
        "short_code": "MpXgk",
        "rights": [
          "transfer",
          "view",
          "edit",
          "share",
          "delete"
        ]
      }
  7. Note the number in the "id" field for each dashboard you want to modify.

Change the dashboard owner

  1. Scroll down the page of Dashboard operations to the /dashboards/{id} section.
  2. Click PATCH /dashboards/{id}.
  3. In the Parameters section, click Model Schema, and then click in the box to automatically add the JSON schema to the body parameter text box.
  4. In the "owner" field, replace string with the username of the new owner.
  5. In the id field, type the number you previously noted for the dashboard.
    For our example, this value is 1876. (You can only modify one dashboard at a time through the ExtraHop API Explorer.)
    In the following figure, we added the JSON "string" for the "owner" parameter to the body parameter text box, changed "string" to "paulanderson", and typed "1876" in the id field.
  6. Click Try it out! to send the request to your appliance.
    Warning:The Try it out! button sends the request to your appliance and can make permanent changes.
    The Response Code field displays 204 if the operation is successful. You can click GET /dashboards again to verify that the "owner" field has changed. Note that you can only change the dashboard owner. You cannot change the dashboard name or author fields through the REST API.
    {
        "id": 1876,
        "comment": null,
        "mod_time": 1507576983922,
        "author": "Mark Smith",
        "name": "LDAP Server Health",
        "owner": "paulanderson",
        "built-in": false,
        "short_code": "MpXgk",
        "rights": [
          "transfer",
          "view",
          "edit",
          "share",
          "delete"
        ]
      }

    The dashboard is now available under My Dashboards in the ExtraHop Web UI for the new user. As the new owner, you can now log into your ExtraHop appliance and change other dashboard properties, such as the dashboard name or author.

Tip:If you want to permanently delete the dashboard, instead of changing the owner, click DELETE /dashboards/{id}, type the value in the id field, and then click Try it out!.
Tip:After you click Try it out!, the ExtraHop API Explorer provides scripts for the operation in Curl, Python 2.7, or Ruby.

Python Script Example

The following example script searches for all dashboards owned by the user account marksmith on an ExtraHop appliance with the hostname example.extrahop.com and then changes the owner for all of those dashboards to the user account paulanderson.

import httplib
import json

HOST = 'example.extrahop.com'
APIKEY = 'f6876657888a7c1f24ac77827'

headers = {'Accept': 'application/json',
           'Authorization': 'ExtraHop apikey=%s' % APIKEY}
conn = httplib.HTTPSConnection(HOST)
conn.request('GET', '/api/v1/dashboards', headers=headers)
resp = conn.getresponse()
parsed_resp = json.loads(resp.read())

for dashboard in parsed_resp:
    if dashboard['owner'] == 'marksmith':
        print('Dashboard {id} owned by marksmith.'
              ' Switching ownership...'.format(id=dashboard['id']))
        config = {'owner': 'paulanderson'}
        conn.request('PATCH', '/api/v1/dashboards/{id}'.format(
                id=dashboard['id']), json.dumps(config), headers=headers)
        conn.getresponse()
Published 2017-12-11 19:17