Data Source Permissions API

    This API can be used to enable, disable, list, add and remove permissions for a data source.

    Permissions can be set for a user or a team. Permissions cannot be set for Admins - they always have access to everything.

    The permission levels for the permission field:

    • 1 = Query

    Enables permissions for the data source with the given id. No one except Org Admins will be able to query the data source until permissions have been added which permit certain users or teams to query the data source.

    See note in the introduction for an explanation.

    Examples

    Example request:

    Example response:

    1. HTTP/1.1 200 OK
    2. Content-Type: application/json; charset=UTF-8
    3. Content-Length: 35
    4. {"message":"Datasource permissions enabled"}

    Status codes:

    • 200 - Ok
    • 400 - Permissions cannot be enabled, see response body for details
    • 401 - Unauthorized
    • 403 - Access denied
    • 404 - Datasource not found

    POST /api/datasources/:id/disable-permissions

    Required permissions

    See note in the introduction for an explanation.

    Example request:

    1. POST /api/datasources/1/disable-permissions
    2. Accept: application/json
    3. Content-Type: application/json
    4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
    5. {}

    Example response:

    1. HTTP/1.1 200 OK
    2. Content-Type: application/json; charset=UTF-8
    3. Content-Length: 35
    4. {"message":"Datasource permissions disabled"}

    Status codes:

    • 200 - Ok
    • 401 - Unauthorized
    • 403 - Access denied
    • 404 - Datasource not found

    GET /api/datasources/:id/permissions

    Gets all existing permissions for the data source with the given id.

    Required permissions

    See note in the introduction for an explanation.

    Examples

    Example request:

    Example response:

    1. HTTP/1.1 200 OK
    2. Content-Type: application/json; charset=UTF-8
    3. Content-Length: 551
    4. {
    5. "datasourceId": 1,
    6. "enabled": true,
    7. "permissions":
    8. {
    9. "id": 1,
    10. "datasourceId": 1,
    11. "userId": 1,
    12. "userLogin": "user",
    13. "userEmail": "user@test.com",
    14. "userAvatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56",
    15. "permission": 1,
    16. "permissionName": "Query",
    17. "created": "2017-06-20T02:00:00+02:00",
    18. "updated": "2017-06-20T02:00:00+02:00",
    19. },
    20. {
    21. "id": 2,
    22. "datasourceId": 1,
    23. "teamId": 1,
    24. "team": "A Team",
    25. "teamAvatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56",
    26. "permission": 1,
    27. "permissionName": "Query",
    28. "created": "2017-06-20T02:00:00+02:00",
    29. "updated": "2017-06-20T02:00:00+02:00",
    30. }
    31. ]
    32. }

    Status codes:

    • 200 - Ok
    • 403 - Access denied
    • 404 - Datasource not found

    POST /api/datasources/:id/permissions

    See note in the introduction for an explanation.

    Examples

    Example request:

    1. POST /api/datasources/1/permissions
    2. Accept: application/json
    3. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
    4. {
    5. "userId": 1,
    6. "permission": 1
    7. }

    Example response:

    1. HTTP/1.1 200 OK
    2. Content-Type: application/json; charset=UTF-8
    3. Content-Length: 35
    4. {"message":"Datasource permission added"}

    Adds a team permission for the data source with the given id.

    Example request:

    Example response:

    1. HTTP/1.1 200 OK
    2. Content-Type: application/json; charset=UTF-8
    3. Content-Length: 35
    4. {"message":"Datasource permission added"}

    Status codes:

    • 200 - Ok
    • 400 - Permission cannot be added, see response body for details
    • 401 - Unauthorized
    • 403 - Access denied
    • 404 - Datasource not found

    DELETE /api/datasources/:id/permissions/:permissionId

    Removes the permission with the given permissionId for the data source with the given id.

    Required permissions

    See note in the introduction for an explanation.

    Example request:

    1. DELETE /api/datasources/1/permissions/2
    2. Accept: application/json
    3. Content-Type: application/json
    4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
    1. HTTP/1.1 200 OK
    2. Content-Type: application/json; charset=UTF-8
    3. Content-Length: 35
    4. {"message":"Datasource permission removed"}

    Status codes:

    • 200 - Ok
    • 401 - Unauthorized
    • 403 - Access denied