API (v2) Find related
Command | Supported | Notes |
---|---|---|
FIND | ✅ | Arbitrary key/value args |
FINDX | ✅ | Enhanced FIND with sorting and regex |
GETOBJECT | ✅ | Find + GET in one with sorting and regex |
GETALL | ✅ | Bulk fetch of objects and NameSpaces with sorting and regex |
Find:
Find requests (if successful) return the Object ID (OID) of an CODB Object matching the search criteria.
Local request:
curl -k -s -X POST https://127.0.0.1:9092/v2/cce -d '{
"cmd": "FIND Vsite name = \"site1\"",
"oid": "",
"user": "admin",
"sessionid": "tK46aZ885HA1QxEiti1dlq.....VpQM3cfavn1yxfF8vFEBeoH3"
}' | jq
Remote request:
curl -k -s -X POST https://API-IP:9092/v2/cce -H "Content-Type: application/json"
-H "X-Client-Secret: CLIENT-SECRET"
-d '{
"cmd": "FIND Vsite name = \"site1\"",
"token": "TOKEN"
}' | jq<br />
Response (success):
{
"status": 201,
"message": "GOODBYE",
"data": {
"oidlist": [
"34"
]
}
}
Response (fail):
{
"status": 201,
"message": "GOODBYE"
}
FINDX:
The FINDX function is designed to search for objects of a given class based on specified criteria. It is typically used in an API interaction to query objects within a particular class, with optional filtering, sorting, and additional criteria. Below are two examples: one for local access (where the function is called within the same system) and one for remote access (where the function is called through an external API endpoint).
Payload:
- cmd: The command being executed (FINDX).
- user: The username making the request.
- sessionid (local access): A valid session ID for authentication.
- token (remote access): A valid token for authentication.
- class: The class of objects you want to search for (UserClass).
- args: A filter applied to the class (e.g., status = active).
- regex_args: Additional filtering based on regular expressions (e.g., usernames starting with "admin").
- sorttype: Sorting order (asc for ascending).
- sortprop: The property to sort by (name in this case).
Local request:
curl -sk -X POST https://127.0.0.1:9092/v2/cce -H "Content-Type: application/json" -H "X-Client-Secret: CLIENT-SECRET" -d '{
"cmd": "FINDX",
"user": "admin",
"sessionid": "SESSION-ID",
"class": "UserClass",
"args": {"status": "active"},
"regex_args": {"username": "/^admin/"},
"sorttype": "asc",
"sortprop": "name"
}' | jq
Remote request:
curl -sk -X POST https://API-IP:9092/api/cce -H "Content-Type: application/json" -H "X-Client-Secret: CLIENT-SECRET" -d '{
"cmd": "FINDX",
"user": "admin",
"sessionid": "SESSION-ID",
"class": "UserClass",
"args": {"status": "active"},
"regex_args": {"username": "/^admin/"},
"sorttype": "asc",
"sortprop": "name",
"token": "TOKEN"
}' | jq
Response (success):
{
"status": 201,
"message": "GOODBYE",
"data": {
"oidlist": [
"34"
]
}
}
Response (fail):
{
"status": 201,
"message": "OK",
"data": {
"oidlist": []
}
}
GETOBJECT:
The command GETOBJECT combines FIND and GET and will return an object that matches the search criteria.
Local request:
curl -k -s -X POST https://127.0.0.1:9092/v2/cce -d '{
"cmd": "GETOBJECT",
"class": "Vsite",
"args": { "name": "site1" },
"namespace": "",
"user": "admin",
"sessionid": "SESSION-ID"
}' | jq
Remote request:
curl -k -s -X POST https://API-IP:9092/v2/cce -H "Content-Type: application/json"
-H "X-Client-Secret: CLIENT-SECRET"
-d '{
"cmd": "GETOBJECT",
"class": "Vsite",
"args": { "name": "site1" },
"namespace": "",
"token": "TOKEN"
}' | jq
Response (success):
{
"status": 201,
"message": "OK",
"data": {
"DATA": {
"basedir": "/home/.sites/site1",
"class": "Vsite",
"classver": "1.0",
"createduser": "admin",
"dns_auto": "1",
"domain": "smd.net",
"emaildisabled": "0",
"force_update": "1747164973",
"fqdn": "t1.smd.net",
"hostname": "t1",
"ipaddr": "208.77.151.218",
"ipaddripv6": "",
"mailaliases": "",
"mailcatchall": "",
"maxusers": "25",
"name": "site1",
"namespace": "",
"oid": "34",
"prefix": "",
"site_preview": "0",
"siteadmincaps": "",
"suspend": "0",
"userprefixenabled": "0",
"userprefixfield": "",
"userwebsdisabled": "0",
"volume": "/home",
"webaliases": "",
"webaliasredirects": "1"
}
}
}
Response (fail):
{
"status": 404,
"message": "Object not found"
}
GETALL:
The command GETALL combines FIND and GET and will return one or more objects that matches the search criteria AND all its NameSpaces. You can search by OIDs (if you know them already), or by specifying arguments.
Local request:
curl -k -s -X POST https://127.0.0.1:9092/v2/cce -d '{
"cmd": "GETALL",
"oids": ["56", "58"],
"args": { "name": "site1" },
"user": "admin",
"sessionid": "SESSION-ID"
}' | jq
Remote request:
curl -k -s -X POST https://API-IP:9092/v2/cce -H "Content-Type: application/json"
-H "X-Client-Secret: CLIENT-SECRET" -d '{
"cmd": "GETALL",
"oids": ["56", "58"],
"args": { "name": "site1" },
"token": "TOKEN"
}' | jq
Response (success):
{
"status": 201,
"message": "OK",
"data": {
"objects": {
"56": { // <--- First OID with all NameSpaces
"Disk": {
[...]
},
"Email": {
[...]
},
"ImapSync": {
[...]
},
"OBJECT": {
[...]
},
"Radicale": {
[...]
},
"RootAccess": {
[...]
},
"SSH": {
[...]
},
"Shell": {
[...]
},
"Sites": {
[...]
},
[...]
},
"58": { // <--- Second OID with all NameSpaces
"Disk": {
[...]
},
"Email": {
[...]
},
[...]
"OBJECT": {
[...]
},
"Radicale": {
[...]
},
"RootAccess": {
[...]
},
"SSH": {
[...]
},
"Shell": {
[...]
},
"Sites": {
[...]
},
"subdomains": {
[...]
}
}
}
}
}
Response (fail):
{
"status": 201,
"message": "GOODBYE",
"data": {
"errors": [
{
"code": 401,
"message": "FAIL"
}
],
"oid": "-1"
}
}