Management

Group Memberships

A Group Membership is an object representing a Mode Group. Admins can use groups to manage access to database connections and Spaces for clusters of members with similar needs (e.g., departments, project teams, etc.).

You can use the group memberships resource to get information about or manage group membership.

Please note that groups are only available to Mode Business customers, and access to this resource is only available to admins.

Group Membership object

Properties

token

required

string

member_token

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
  • member
  • self
  • user_group
  "token": "bfdeg2tb",
  "member_token": "fgdhr453g2few",
  {
    "_links": {
      "self": {
        "href": "officia esse non",
        "templated": false
      },
      "creator": {
        "href": "elit Duis pariatur enim",
        "templated": false
      },
      "member": {
        "href": "elit Excepteur quis qui",
        "templated": false
      },
      "user_group": {
        "href": "velit deserunt exercitation ullamco",
        "templated": false
      }
    },
  "_embedded": {}
}

Get a group membership

To retrieve information about a given group member, send a GET request to the group memberships resource with a membership_token.

URL Params

organization

required
string Organization username

group_token

required
string UserGroup token

membership_token

required
string UserGroupMembership token
Responses

200

UserGroupMembership response

401

Unauthorized

403

Forbidden

404

Membership not found for Organization

GET /{organization}/groups/{group_token}/memberships/{membership_token}

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{organization}/groups/{group_token}/memberships/{membership_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}/groups/{group_token}/memberships/{membership_token}')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://modeanalytics.com/api/{organization}/groups/{group_token}/memberships/{membership_token}', headers=headers)

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

request({
  method: 'GET',
  url: 'https://modeanalytics.com/api/{organization}/groups/{group_token}/memberships/{membership_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 group memberships

To retrieve a list of all memberships in a given group, send a GET request including the group_token to the group memberships resource.

URL Params

organization

required
string Organization username

group_token

required
string UserGroup token
Responses

200

UserGroupMembership collection response

401

Unauthorized

403

Forbidden

404

Membership not found for Organization

GET /{organization}/groups/{group_token}/memberships

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{organization}/groups/{group_token}/memberships'
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}/groups/{group_token}/memberships')
puts response
from urllib2 import Request, urlopen

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

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

request({
  method: 'GET',
  url: 'https://modeanalytics.com/api/{organization}/groups/{group_token}/memberships',
  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 group membership

To add a user to a given group, send a POST request to the group memberships resource.

URL Params

organization

required
string Organization username

group_token

required
string UserGroup token
POST Body Params

Object: membership

member_token

required
string The token of the user to become a member
Responses

200

UserGroupMembership response

400

Bad request

401

Unauthorized

403

Forbidden

404

Membership not found for Organization

POST /{organization}/groups/{group_token}/memberships

curl --include \
     --request POST \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
     --data-binary "{
  \"membership\": {
    \"member_token\": \"ut aute\"
  }
}" \
'https://modeanalytics.com/api/{organization}/groups/{group_token}/memberships'
require 'http'

values = {
  membership: {
    member_token: 'ut aute'
  }
}

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}/groups/{group_token}/memberships', json: values)
puts response
from urllib2 import Request, urlopen

values = """
  {
    "membership": {
      "member_token": "fgt342fewreth"
    }
  }
"""

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://modeanalytics.com/api/{organization}/groups/{group_token}/memberships', 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}/groups/{group_token}/memberships',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  },
  body: "{  \"membership\": {    \"member_token\": \"ut aute\"  }}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

Delete a group membership

To remove a user from a group, send a DELETE request to the group memberships resource.

URL Params

organization

required
string Organization username

group_token

required
string UserGroup token

membership_token

required
string UserGroupMembership token
Responses

200

UserGroupMembership response

400

Bad request

401

Unauthorized

403

Forbidden

404

Membership not found for Organization

DELETE /{organization}/groups/{group_token}/memberships/{membership_token}

curl --include \
     --request DELETE \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{organization}/groups/{group_token}/memberships/{membership_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}/groups/{group_token}/memberships/{membership_token}')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://modeanalytics.com/api/{organization}/groups/{group_token}/memberships/{membership_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}/groups/{group_token}/memberships/{membership_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);
});