Tenants
  • Updated on 12 Nov 2019
  • 12 minutes to read
  • Contributors
  • Print
  • Share
  • Dark
    Light

Tenants

  • Print
  • Share
  • Dark
    Light

Overview

C8 follows a multitenancy model. A tenant is a group of users who share a common isolated enviroment within the federation, and one tenant cannot access the information of another.

Each tenant has a tenant admin called root who has privileges to create geo-fabrics, users, streams and functions within that tenant. The tenant admin can create users and geo-fabrics within that tenant, and can define different privileges for each tenant user on the geo-fabrics, collections and other information contained within the tenant.

Note: Tenants can only be created and deleted by the superadmin. A tenant admin cannot create, delete or access other tenants.

Each tenant on C8 can have an arbitrary number of geofabrics. Each tenant fabric has its own set of collections, graphs, streams and functions. For each tenant, there is a special fabric named _system, which cannot be dropped and which provides operations for managing users, permissions and other geofabrics.

These operations can only be executed by the tenant admin. Tenant users who have been given the relevant access privileges by the tenant admin may create collections, streams, functions and documents within tenant fabrics to which the users have been given read/write access.


Get Tenant

GET /tenant/{tenant-name}

Fetches data about the given tenant. The call will return a JSON object with the tenant details.

You need to be root user of system tenant to execute this REST call.

Parameters

Name In Type Required Description
tenant-name path string true The tenant name for whom we want to fetch info.

Responses

Status Meaning Description Schema
200 OK The details for the given tenant. None
401 Unauthorized Returned if you have No access database access level to the _system geofabric. None
403 Forbidden Returned if you have No access server access level. None

Get Tenants

GET /tenants

Return a list of tenants in the system.

Note: You need to be root user of system tenant to execute this REST call.

Responses

Status Meaning Description Schema
200 OK is returned if the call succeeded. None

Note:-
tenant needs to have Geo fabrics feature gate enabled to create geofabric.

Create Tenant

POST /tenant

Create a tenant. A JSON object with following properties is required:

  • passwd: The user password as a string. If no password is specified, the empty string will be used.
  • extra: An optional JSON object with arbitrary extra data about the user.
  • name: The name of the tenant as a string. This is mandatory.
  • dcList: A comma-separated string containing the datacenter names on which this tenant is to be created. If an empty string is passed in, the tenant is assumed to be global to the federation and will be created on all current datacenters in the federation.
Note: You need to be root user of system tenant to execute this REST call.

Parameters

Name In Type Required Description
body body Tenant_create true none

Body parameter

{
  "dcList": "string",
  "extra": {
    "property1": null,
    "property2": null
  },
  "name": "string",
  "passwd": "string"
}

Responses

Status Meaning Description Schema
201 Created Returned if the tenant can be added by the server None
400 Bad Request If the JSON representation is malformed or mandatory data is missing
from the request. None
401 Unauthorized Returned if you have No access database access level to the _system
database. None
403 Forbidden Returned if you have No access server access level. None
409 Conflict Returned if a tenant with the same name already exists.

Delete Tenant

DELETE /tenant/{tenant-name}

Removes an existing tenant, identified by tenant-name.

Note: You need to be root user of system tenant to execute this REST call.

Parameters

Name In Type Required Description
tenant-name path string true The tenant name to delete, as string.

Responses

Status Meaning Description Schema
202 Accepted Is returned if the tenant was removed by the server None
401 Unauthorized Returned if you have No access fabric access level to the _system geo fabric. None
403 Forbidden Returned if you have No access server access level. None
404 Not Found The specified tenant does not exist None

Update Tenant

PATCH /tenant/{tenant-name}

Partially updates the data of an existing tenant. The name of an existing tenant must be specified in tenant. A JSON object with these properties is required:

  • passwd: The tenant password as a string. Specifying a password is mandatory.
  • extra: An optional JSON object with arbitrary extra data about the tenant.
Note: You need to be root user of system tenant to execute this REST call and needs Administrate access level .

Parameters

Name In Type Required Description
tenant-name path string(string) true The tenant name to modify.
body body Tenant_modify true none

Sample body:

{
  "extra": {
    "property1": null,
    "property2": null
  },
  "passwd": "string"
}

Responses

Status Meaning Description Schema
200 OK Is returned if the tenant data can be replaced by the server. None
400 Bad Request The JSON representation is malformed or mandatory data is missing from the request. None
401 Unauthorized Returned if you have No access fabric access level to the _system database. None
403 Forbidden Returned if you have No access server access level. None
404 Not Found The specified tenant does not exist None

Add Datacenters to Tenant

POST /tenant/{tenant-name}/datacenter

Add new Datacenters to Tenant. A JSON object with following properties is required:

  • dcList: The full list of Datacenters to be added to the Tenant including the new datacenters to be added, as a string. The Datacenter list cannot be empty. Each edge location in the string should be separated from the previous one with a comma character ','.

Adds new Datacenters to the specified tenant. The tenant's internal system metadata will be updated with the new locations, however the individual geofabrics present in the tenant will not automatically be updated with the new edge locations. You must use the corresponding REST endpoint for fabrics to add new locations to a fabric.

Note:
While the new locations are being added to the tenant, the tenant account will not be available for normal operations in the new locations until the tenant data sync from the corresponding tenant in the originating location has been completed. After all the tenant data has been synced from the originating location, the tenant will be available in the new regions.

Body parameter

{
  "dcList": "string"
}

Parameters

Name In Type Required Description
tenant-name path string true The tenant name for which you want to add new Datacenters.
body body Tenant_add_locations true none

Responses

Status Meaning Description Schema
200 OK Is returned if the tenant datacenters can be updated by the server. None
400 Bad Request The JSON representation is malformed or mandatory data is missing from the request. None
401 Unauthorized Returned if you have No access database access level to the _system database. None
403 Forbidden Returned if you have No access server access level. None
404 Not Found The specified tenant does not exist None

Sample Code

Sample Code:

Get Tenant

# You can also use wget
curl -X GET /tenant/{tenant-name}
  
Get All Tenants

# You can also use wget
curl -X GET /tenant/{tenant-name}
  
Ceate a Tenant

# You can also use wget
curl -X POST /tenant \
  -H 'Content-Type: application/json'
  
Delete a Tenant

# You can also use wget
curl -X DELETE /tenant/{tenant-name}
Update a Tenant

# You can also use wget
curl -X PATCH /tenant/{tenant-name} \
  -H 'Content-Type: application/json'
Add Data Center to a Tenant

# You can also use wget
curl -X POST /tenant/{tenant-name}/datacenter \
  -H 'Content-Type: application/json'
Get Tenant

$.ajax({
  url: '/tenant/{tenant-name}',
  method: 'get',
  success: function(data) {
    console.log(JSON.stringify(data));
  }
})
  
Get All Tenants

$.ajax({
  url: '/tenants',
  method: 'get',
  success: function(data) {
    console.log(JSON.stringify(data));
  }
})
  
Ceate a Tenant

var headers = {
  'Content-Type':'application/json'
};
$.ajax({
  url: '/tenant',
  method: 'post',
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  }
})
  
Delete a Tenant

$.ajax({
  url: '/tenant/{tenant-name}',
  method: 'delete',
  success: function(data) {
    console.log(JSON.stringify(data));
  }
})
Update a Tenant

var headers = {
  'Content-Type':'application/json'
};
$.ajax({
  url: '/tenant/{tenant-name}',
  method: 'patch',
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  }
})
Add Data Center to a Tenant

var headers = {
  'Content-Type':'application/json'
};
$.ajax({
  url: '/tenant/{tenant-name}/datacenter',
  method: 'post',
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  }
})
Get Tenant

const fetch = require('node-fetch');
fetch('/tenant/{tenant-name}',
{
  method: 'GET'
    }).then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
});
  
Get All Tenants

const fetch = require('node-fetch');
fetch('/tenants',
{
  method: 'GET'
    }).then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
});
  
Ceate a Tenant

const fetch = require('node-fetch');
const inputBody = '{
  "dcList": "string",
  "extra": {
    "property1": null,
    "property2": null
  },
  "name": "string",
  "passwd": "string"
}';
const headers = {
  'Content-Type':'application/json'
};
fetch('/tenant',
{
  method: 'POST',
  body: inputBody,
  headers: headers
    }).then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
});
  
Delete a Tenant

const fetch = require('node-fetch');
fetch('/tenant/{tenant-name}',
{
  method: 'DELETE'
    }).then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
});
Update a Tenant

const fetch = require('node-fetch');
const inputBody = '{
  "extra": {
    "property1": null,
    "property2": null
  },
  "passwd": "string"
}';
const headers = {
  'Content-Type':'application/json'
};
fetch('/tenant/{tenant-name}',
{
  method: 'PATCH',
  body: inputBody,
  headers: headers
    }).then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
});
Add Data Center to a Tenant

const fetch = require('node-fetch');
const inputBody = '{
  "dcList": "string"
}';
const headers = {
  'Content-Type':'application/json'
};
fetch('/tenant/{tenant-name}/datacenter',
{
  method: 'POST',
  body: inputBody,
  headers: headers
    }).then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
});
Get Tenant

require 'rest-client'
require 'json'
result = RestClient.get '/tenant/{tenant-name}',
  params: {
  }
p JSON.parse(result)
  
Get All Tenants

require 'rest-client'
require 'json'
result = RestClient.get '/tenants',
  params: {
  }
p JSON.parse(result)
  
Ceate a Tenant

require 'rest-client'
require 'json'
headers = {
  'Content-Type' => 'application/json'
}
result = RestClient.post '/tenant',
  params: {
  }, headers: headers
p JSON.parse(result)
  
Delete a Tenant

require 'rest-client'
require 'json'
result = RestClient.delete '/tenant/{tenant-name}',
  params: {
  }
p JSON.parse(result)
Update a Tenant

require 'rest-client'
require 'json'
headers = {
  'Content-Type' => 'application/json'
}
result = RestClient.patch '/tenant/{tenant-name}',
  params: {
  }, headers: headers
p JSON.parse(result)
Add Data Center to a Tenant

require 'rest-client'
require 'json'
headers = {
  'Content-Type' => 'application/json'
}
result = RestClient.post '/tenant/{tenant-name}/datacenter',
  params: {
  }, headers: headers
p JSON.parse(result)
Get Tenant

import requests
r = requests.get('/tenant/{tenant-name}', params={})
print r.json()
  
Get All Tenants

import requests
r = requests.get('/tenants', params={})
print r.json()
  
Ceate a Tenant

import requests
headers = {
  'Content-Type': 'application/json'
}
r = requests.post('/tenant', params={}, headers = headers)
print r.json()
Delete a Tenant

import requests
r = requests.delete('/tenant/{tenant-name}', params={})
print r.json()
Update a Tenant

import requests
headers = {
  'Content-Type': 'application/json'
}
r = requests.patch('/tenant/{tenant-name}', params={}
, headers = headers)
print r.json()
Add Data Center to a Tenant

import requests
headers = {
  'Content-Type': 'application/json'
}
r = requests.post('/tenant/{tenant-name}/datacenter', params={}, headers = headers)
print r.json()
Get Tenant

package main
import (
       "bytes"
       "net/http"
)
func main() {
    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("GET", "/tenant/{tenant-name}", data)
    req.Header = headers
    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}
  
Get All Tenants

package main
import (
       "bytes"
       "net/http"
)
func main() {
    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("GET", "/tenants", data)
    req.Header = headers
    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}
  
Ceate a Tenant

package main
import (
       "bytes"
       "net/http"
)
func main() {
    headers := map[string][]string{
        "Content-Type": []string{"application/json"}, 
    }
    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("POST", "/tenant", data)
    req.Header = headers
    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}
  
Delete a Tenant

package main
import (
       "bytes"
       "net/http"
)
func main() {
    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("DELETE", "/tenant/{tenant-name}", data)
    req.Header = headers
    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}
Update a Tenant

package main
import (
       "bytes"
       "net/http"
)
func main() {
    headers := map[string][]string{
        "Content-Type": []string{"application/json"},
    }
    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("PATCH", "/tenant/{tenant-name}", data)
    req.Header = headers
    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}
Add Data Center to a Tenant

package main
import (
       "bytes"
       "net/http"
)
func main() {
    headers := map[string][]string{
        "Content-Type": []string{"application/json"},
    }
    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("POST", "/tenant/{tenant-name}/datacenter", data)
    req.Header = headers
    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}
Get Tenant

URL obj = new URL("/tenant/{tenant-name}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
  
Get All Tenants

URL obj = new URL("/tenants");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
  
Ceate a Tenant

URL obj = new URL("/tenant");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
Delete a Tenant

URL obj = new URL("/tenant/{tenant-name}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("DELETE");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
Update a Tenant

URL obj = new URL("/tenant/{tenant-name}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("PATCH");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
Add Data Center to a Tenant

URL obj = new URL("/tenant/{tenant-name}/datacenter");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
Was this article helpful?