A unit must belong to a domain and one domain only. A unit can contain one or many (child) units, but a unit can only belong to one (parent) unit only. In other words, the relationship between units is one-many.
Attributes
Attribute |
|
type |
|
values |
|
default |
|
mandate |
|
comment |
|
name |
|
string |
|
|
|
|
|
true |
|
|
|
description |
|
string |
|
|
|
|
|
false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
domain |
|
object |
|
|
|
|
|
true |
|
the domain that the unit belongs to |
|
parent |
|
object |
|
|
|
|
|
true |
|
the parent unit |
|
hasChildren |
|
boolean |
|
|
|
|
|
|
|
|
|
children |
|
coll |
|
|
|
|
|
|
|
|
|
repository |
object |
|
|
|
|
|
|
|
|
|
|
radiusProfile |
object |
|
|
|
|
|
|
|
|
|
|
policies |
|
coll |
|
|
|
|
|
|
|
Assigned policies |
|
radiusProfile |
|
object |
|
|
|
|
|
|
|
|
|
radiusAttributes |
|
coll |
|
|
|
|
|
|
|
|
|
/unit/create
To create a new unit, we must specify the name of the unit and its parent: either a domain or a unit. On success, the method always returns the internal unit id of the newly created unit.
Parameters:
{
"attrs":{list of attribute value pairs}
}
Response:
{
"error":0,
"result":{"id":the id of the newly created unit}
}
Examples:
- Creating a top-level unit without parent.
Method:/unit/create
Parameters:
{
"attrs":
{
"name":"sales",
"description":"sales dept.",
"domain.id":2
}
}
Response: {"error":0, "result":{"id":1}}
- Creating a sub-level unit by specifying its parent unit.
Method:/unit/create
Parameters:
{
"attrs":
{
"name":"sales - london",
"description":"sales team in London",
"parent.id":1
}
}
Response: {"error":0, "result":{"id":2}}
/unit/search
Examples:
- Search units in the entire domain
Method:/unit/search
Parameters:
{
"match":
[
[domain.id", "=", 1],
[name", "like", "sales%"]
],
"return":["name", "id", "domain.id", "parent.id"],
"sort":"name",
"order":"asc",
"max": 20,
"offset": 0
}
Response:
{
"error":0,
"result":
[
{
"name":"sales",
"id":"1",
"domain.id":1,
"parent.id":null
},
{
"name":"sales - london",
"id":"2",
"domain.id":1,
"parent.id":1
},
{
...
}
]
}
- Search top-level units
Method:/unit/search
Parameters:
{
"match":
[
[domain.id", "=", 1]
[parent.id", "=", null]
],
"return":["name", "id"],
"sort":"name",
"order":"asc",
"max": 20,
"offset": 0
}
Response:
{
"error":0,
"result":
[
{
"name":"sales",
"id":1,
},
{
...
}
]
}
- Searchchild units of a specific unit
Method:/unit/search
Parameters:
{
"match":
[
[domain.id", "=", 1],
[parent.id", "=", 2]
],
"return":["name", "id"],
"sort":"name",
"order":"asc",
"max": 20,
"offset": 0
}
Response:
{
"error":0,
"result":
[
{
"name":"sales - london",
"id":2,
},
{
...
}
]
}
/unit/get
Method:/unit/get
Parameters:
{
"match":
[
["id", "=", 2],
],
"return":["name", "id", "domain.id","parent.id"],
}
Response:
{
"error":0,
"result":
{
"name":"sales - london",
"id":"2",
"domain.id":1,
"parent.id":1
}
}
/unit/set
Method:/unit/set
Parameters:
{
"id":1,
"attrs":{"description":"new description"}
}
Response:
{
"error":0
}
/unit/delete
Method:/unit/delete
Parameters:
{
"id":1
}
Response:
{
"error":0
}
/unit/addUsers
Method:/unit/addUsers
Parameters:
{
"id":unit_id,
"users":
[
{id:uid1},
{id:uid2}
]
}
Response:
{
"error":0
}
/unit/deployTokens
Method:/unit/deployTokens
Parameters:
{
"attrs":
{
"unit.id":unit_id,
"product.id":product_id
}
}
Response:
{
"error":0
}
Other Methods:
- applyPolicy(apply/unapply)