Jump to content

Adding Access Control Entries to a Datasource with Seeq Data Lab


Patrick

Recommended Posts

  • Seeq Team

There are instances where it's desirable to add or remove Access Control to a user created datasource.  For instance, you may want to push data from Seeq Datalab to a Datasource that is only available to a sub-set of users.  Below is a tip how to add additional entries to a Datasource Access Control List (ACL) using `spy.acl`.

 

1) Identify Datasource ID

If not already known, retrieve the ID for the Datasource.  This can be done via the Seeq REST API (accessible via the "hamburger" menu in the upper right corner of your browser window).  This is different from the datasourceId identifier and will contain a series of characters as shown below.  It can be retrieved via the `GET/datasources` endpoint under the `Datasources` section.

image.png

The response body will contain the ID:

image.png

2) Identify User and/or Group ID

We will also want to identify the User and/or Group ID.  Below is an example of how to retrieve a Group ID via the `UserGroups` GET/usergroups endpoint:

image.png

The response body will contain the ID:

image.png

3) Use `spy.acl()` to add group to the Datasource Access Control List (ACL)

  1. Launch a Seeq Datalab Project and create a new ipynb Notebook
  2. Assign the two IDs to a variable
    datasource_id='65BDFD4F-1FA3-4EB5-B21E-069FA5A772DF'
    group_id='19F1B7DC-69BE-4402-AD3B-DF89B1B9A1A4'
  3. (Optional) - Check the current Access Control List for the Datasource using `spy.acl.pull()`
    current_access_control_df=spy.acl.pull(datasource_id)
    current_access_control_df.iloc[0]['Access Control']
  4. Add the group_id to the Datasource ACL using `spy.acl.push()`
    spy.acl.push(datasource_id, {
        'ID': group_id,
        'Read': True,
        'Write': True,
        'Manage': False
    }, replace=False)

    Note I've set `replace=False`, which means the group will be appended to the current access list.  If the desire is to the replace the entire existing ACL list, this can be toggled to `replace=True`.  Similarly, you can adjust the read/write/manage permissions to fit your need.

    For more information on `spy.acl.push`, reference the `spy.acl.ipynb` document located in the SPy Documentation folder or access the docstring by executing

    help(spy.acl.push)
  5. (Optional) - To confirm the correct ID has been added, re-pull the ACL via `spy.acl.pull()`
    current_access_control_df=spy.acl.pull(datasource_id)
    current_access_control_df.iloc[0]['Access Control']

     

 

Edited by Patrick
added code
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...