This document describes the stateful CRUD functions for Types, Objects, and their Links in the Foliage CMDB system, analogous to the Graph CRUD API.
Each function is invoked via NATS and composes underlying Graph API calls (vertex.* and link.*).
Invocation pattern:
nats pub --count=1 -s nats://nats:foliage@nats:4222 signal.<domain>.<function_name> '<JSON payload>'Replies include a payload object containing:
status: "ok" | "failed" | "idle"details: human-readable messagedata: JSON object, may includebody,links, andop_stackif requested
-
Type CRUD
-
Object CRUD
-
Type-Link CRUD
-
Object-Link CRUD
Function: CreateType
Request Payload:
{
"body": { /* new type properties */ }
}body(object): JSON document of the new type's attributes.
Behavior:
- Calls
functions.graph.api.vertex.create.<type_id>withpayload.body. - Calls
functions.graph.api.link.create.<types_hub_id>to link hub→new type.
Response: Pass-through of both operations:
{
"payload": {
"status": "ok",
"details": "",
"data": { /* link.create data or null */ }
}
}Function: UpdateType
Request Payload:
{
"body": { /* fields to update */ },
"upsert": <bool>, // optional, default false
"replace": <bool> // optional, default false
}body(object): fields to merge or replace in the type.upsert(boolean): iftrue, create type when missing.replace(boolean): iftrue, overwrite existing body; otherwise merge.
Behavior:
- If
upsert=trueand vertex missing, redirects tofunctions.cmdb.api.type.create. - Otherwise, calls
functions.graph.api.vertex.update.<type_id>.
Response:
{
"payload": {
"status": "ok|failed|idle",
"details": "",
"data": { /* update data or null */ }
}
}Function: DeleteType
Request Payload: None
Behavior:
- Finds all outgoing
OBJECT_TYPELINKlinks from type. - For each linked object ID, calls
functions.cmdb.api.object.delete.<object_id>. - Calls
functions.graph.api.vertex.delete.<type_id>to delete the type vertex.
Response: Aggregated delete responses:
{ "payload": { "status": "ok|failed", "details": "" } }Function: ReadType
Request Payload: None
Behavior:
-
Calls
functions.graph.api.vertex.read.<type_id>withdetails=true. -
Verifies it links from the types hub.
-
Extracts:
body: original type propertiesto_types: IDs from outgoingTO_TYPELINKobject_ids: IDs from outgoingOBJECT_TYPELINKlinks: raw link metadata
Response:
{
"payload": {
"status": "ok",
"details": "",
"data": {
"body": { /* properties */ },
"to_types": ["<type_id>"],
"object_ids": ["<object_id>"],
"links": { /* raw links */ }
}
}
}Function: CreateObject
Request Payload:
{
"origin_type": "<type_id>", // required
"body": { /* new object data */ }
}origin_type(string): ID of the type vertex.body(object): initial properties of the new object.
Behavior:
-
Calls
functions.graph.api.vertex.create.<object_id>. -
Creates three forced links:
- hub→object (
OBJECT_TYPELINK) - object→origin type (
TO_TYPELINK) - origin type→object (
OBJECT_TYPELINK)
- hub→object (
Response: Combined:
{ "payload": { "status": "ok", "data": {/* last link data */} } }Function: UpdateObject
Request Payload:
{
"body": { /* fields to update */ },
"upsert": <bool>, // optional
"replace": <bool>, // optional
"origin_type": "<type_id>" // required if upsert=true
}- Merges or replaces object payload.
upsert=trueredirects tocmdb.api.object.createif missing.
Behavior:
- Calls
functions.graph.api.vertex.update.<object_id>withoptions.op_stack=true. - Executes
executeTriggersFromLLOpStackfor each op in returned stack.
Response:
{ "payload": { "status": "ok", "data": {/* updated payload */} } }Function: DeleteObject
Request Payload: None
Behavior:
- Determines object type via
findObjectType. - Calls
functions.graph.api.vertex.delete.<object_id>withoptions.op_stack=true. - After deletion, executes cleanup triggers via op_stack.
Response:
{ "payload": { "status": "ok", "data": null } }Function: ReadObject
Request Payload: None
Behavior:
-
Calls
functions.graph.api.vertex.read.<object_id>withdetails=true. -
If missing, returns idle status.
-
Extracts:
body: object propertiestype: from outgoingTO_TYPELINKto_objects: other outgoing targetslinks: raw link data
-
Validates inbound links from objects hub and type for consistency.
Response:
{
"payload": {
"status": "ok",
"data": {
"body": {...},
"type": "<type_id>",
"to_objects": ["<object_id>"],
"links": {...}
}
}
}Function: CreateTypesLink
Request Payload:
{
"to": "<type_id>", // required
"object_type": "<string>", // required: label stored in body
"body": { /* optional */ },
"tags": ["<string>"] // optional array of tags
}-
Creates
functions.graph.api.link.create.<type_id>with:payload.to,name,type=TO_TYPELINK,body,tags.
Response:
{ "payload": { "status": "ok" } }Function: UpdateTypesLink
Request Payload:
{
"to": "<type_id>",
"body": { /* optional */ },
"tags": ["<string>"],
"upsert": <bool>,
"replace": <bool>
}- Maps to
functions.graph.api.link.update.<type_id>with proper fields.
Response: Pass-through update result.
Function: DeleteTypesLink
Request Payload:
{ "to": "<type_id>" }- Calls cleanup via
cmdb.api.delete_object_filtered_out_linksper object. - Deletes type→type link via
functions.graph.api.link.delete.<type_id>.
Response: Aggregated results.
Function: ReadTypesLink
Request Payload:
{ "to": "<type_id>" }- Calls
functions.graph.api.link.read.<type_id>withdetails=true.
Response: Raw link data from Graph API.
Function: CreateObjectsLink
Request Payload:
{
"to": "<object_id>",
"name": "<string>", // optional, defaults to target
"body": { /* optional */ },
"tags": ["<string>"]
}- Resolves reference
typebetween objects. - Calls
functions.graph.api.link.createwithto,name,type,body,tags,options.op_stack=true.
Response: Executes triggers on op_stack, returns create result.
Function: UpdateObjectsLink
Request Payload:
{
"to": "<object_id>",
"name": "<string>", // required if upsert=true
"body": { /* optional */ },
"tags": ["<string>"],
"upsert": <bool>,
"replace": <bool>
}- Resolves link type and maps to
link.updatewith full options. - Uses
options.op_stack=trueand triggers cleanup.
Response: Update result, stripped of op_stack.
Function: DeleteObjectsLink
Request Payload:
{ "to": "<object_id>" }- Resolves link type, calls
link.deletewithoptions.op_stack=true. - Executes triggers from op_stack after delete.
Response: Delete result.
Function: ReadObjectsLink
Request Payload:
{ "to": "<object_id>" }- Resolves
from_typeandto_typevia helper. - Calls
functions.graph.api.link.read.<object_id>withdetails=true. - Augments raw data with
from_typeandto_typefields.
Response:
{
"payload": {
"status": "ok",
"data": {
/* raw link fields */,
"from_type": "<type_id>",
"to_type": "<type_id>"
}
}
}