Management

Permission Grants

Mode Business admins can limit and manage access to databases connections in their organization using the grants resource.

Non-admin users or groups who do not have access to a database connection cannot:

  • query the database
  • create, edit, or clone reports that query the database
  • use Definitions built on that database

Permission Grant object

Properties

token

required

string

grantee_token

required

string

grantee_type

required

string

grantee_id

required

string

_links

required

object

All resource responses contain a set of links that describe other related resources or actions that you can take on this resource. A link is comprised of two main pieces: its name (which describes its relationship to this resource) and its href (the URL of the related action or resource). All resources have at least a _self link which is the URL that will return a representation of this resource.

  • creator
  • data_source
  • grantee
  • self
{
  "token": "nht5yh4tgerw",
  "grantee_token": "gfhnyj5hterv",
  "grantee_type": "consequat non",
  "grantee_id": 1001,
  "_links": {
    "self": {
      "href": "dolore veniam occaecat",
      "templated": false
    },
    "grantee": {
      "href": "sint aute ve",
      "templated": false
    },
    "creator": {
      "href": "velit irure dolor sed eu",
      "templated": false
    },
    "data_source": {
      "href": "consectetur ullamco velit",
      "templated": false
    }
  },
  "_embedded": {}
}

Get a permission grant

To retrieve information about a user or group’s permission to access a limited data source, send a GET request to the grants resource.

URL Params

organization

required
string Organization username

data_source

required
string DataSource token

grant_token

required
string DataSourcePermissionGrant token
Responses

200

DataSourcePermissionGrant response

401

Unauthorized

403

Forbidden

404

Membership not found for Organization

GET /{organization}/data_sources/{data_source}/grants/{grant_token}

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants/{grant_token}'
require 'http'

username = 'you_api_key'
password = 'you_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .get('https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants/{grant_token}')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants/{grant_token}', headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'GET',
  url: 'https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants/{grant_token}',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

List permission grants

To fetch a list of all users or groups that have been granted permission to access a limited data source, send a GET request to the grants and include the organization and data source token.

URL Params

organization

required
string Organization username

data_source

required
string DataSource token
Responses

200

DataSourcePermissionGrant collection response

401

Unauthorized

403

Forbidden

404

Membership not found for Organization

GET /{organization}/data_sources/{data_source}/grants

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants'
require 'http'

username = 'you_api_key'
password = 'you_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .get('https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants', headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'GET',
  url: 'https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

Create a permission grant

To give a user or group permission to use a limited data source, send a POST request to the grants resource. Include the organization and data source tokens in your request.

URL Params

organization

required
string Organization username

data_source

required
string DataSource token
POST Body Params

Object: grant

grantee_token

required
string The token of the recipient of the permission grant

grantee_type

required
string The type of the recipient of the permission grant, either User for a user, or UserGroup for a user group
Responses

200

DataSourcePermissionGrant response

400

Bad request

401

Unauthorized

403

Forbidden

404

Membership not found for Organization

POST /{organization}/data_sources/{data_source}/grants

curl --include \
     --request POST \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
     --data-binary "{
  \"grant\": {
    \"grantee_token\": \"ashEaew72l\",
    \"grantee_type\": \"UserGroup\"
  }
}" \
'https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants'
require 'http'

values = {
  grant: {
    grantee_token: 'ashEaew72l',
    grantee_type: 'UserGroup'
  }
}

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .post('https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants', json: values)
puts response
from urllib2 import Request, urlopen

values = """
  {
    "grant": {
      "grantee_token": "ashEaew72l",
      "grantee_type": "UserGroup"
    }
  }
"""

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants', data=values, headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'POST',
  url: 'https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  },
  body: "{  \"grant\": {    \"grantee_token\": \"ashEaew72l\",    \"grantee_type\": \"UserGroup\"  }}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

Delete a permission grant

A DELETE request to the grants resource revokes a user or group’s permission to access a given limited data source.

URL Params

organization

required
string Organization username

data_source

required
string DataSource token

grant_token

required
string DataSourcePermissionGrant token
Responses

200

DataSourcePermissionGrant response

400

Bad request

401

Unauthorized

403

Forbidden

404

Membership not found for Organization

DELETE /{organization}/data_sources/{data_source}/grants/{grant_token}

curl --include \
     --request DELETE \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants/{grant_token}'
require 'http'

username = 'you_api_key'
password = 'you_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .delete('https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants/{grant_token}')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants/{grant_token}', headers=headers)
request.get_method = lambda: 'DELETE'

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'DELETE',
  url: 'https://modeanalytics.com/api/{organization}/data_sources/{data_source}/grants/{grant_token}',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});