Tree

The asset Tree is a structural representation of the assets in the Inventory. The tree is built up by top-level assets, without a parent, and their children. You can use multiple filtering options to request a customized tree.

Note: The tree has no windowing function. Depending on the number of assets in your Inventory, you should consider which tree depth you choose.

POST /api/inventory/tree

Request the asset tree using given filter functions. You can also send an empty request to fetch the whole tree. In that case, you can use the HTTP-GET method, too.

REQUEST Fields Value Type Description
query String The search query. It can be empty.
depth Number (optional) The tree depth to return. Default: 1
treeVisibility String (optional) The following values can be used to restrict the tree: all and mine. By default, all assets in the inventory will be returned.
treeFilter String (optional) The tree filter allows to restrict the tree to active, all or archived assets. By default, all assets will be returned.
treeGrouping List<String> (optional) Using the tree grouping, you can create a tree grouped by asset fields. In the list you can use the keys of asset fields.

The response is a list of assets with their child nodes in the specified depth:

RESPONSE Fields Value Type Description
id String The GUID of the asset
name String The display name of the asset
iconUrl String The URL, relative from the server base, to load an icon for the current node
isGrouingNode Boolean True, if this is node is a grouping node, instead of an actual asset
isArchived Boolean True, if this entry is an archived asset
isDummy Boolean True, if this is an in-between entry, not actually matching the query
children List<Tree Entry> A list of entries, with the same fields as this current entry

Example Request

# Request
POST /api/inventory/tree HTTP/1.1
Authorization: Bearer VGhpcyBpcyBqdXN0IGEgZGVtbyBhY2Nlc3MgdG9rZW4u
 
{
    "query": "",
    "depth": 2,
    "treeVisibility": "all",
    "treeFilter": "active",
    "treeGrouping": [
        "location",
        "room"
    ]
}
 
# Response
HTTP/1.1 200 OK
Content-Type: application/json
 
[
  {
    "id": "g.location.1",
    "name": "Berlin",
    "isGroupingNode": true,
    "iconUrl": "/api?method=inventory.asseticon&&size=128&field=location&value=1",
    "isArchived": false,
    "isDummy": false,
    "children": [
      {
        "id": "g.location.1.room.",
        "name": "<Room not set>",
        "isGroupingNode": true,
        "iconUrl": null,
        "isArchived": false,
        "isDummy": false,
        "children": [
          {
            "id": "08pvabncfelg0vu853wp59i6s",
            "name": "ASUS EeeBook Netbook",
            "isGroupingNode": false,
            "iconUrl": "/api?method=inventory.asseticon&&size=128&field=type&value=23",
            "isArchived": false,
            "isDummy": false,
            "children": [
              {
                "id": "a1ot3sit934b6h66i6wa9f1ue",
                "name": "LogiTech TravelMate Mini",
                "isGroupingNode": false,
                "iconUrl": "/api?method=inventory.asseticon&&size=128&field=type&value=31",
                "isArchived": false,
                "isDummy": false,
                "children": []
              }
            ]
          },
          ...
        ]
      }  
    ]
  },
  ...
]

Application Example

# Browser access
http://127.0.0.1:9000/api/inventory/tree
 
# Shell access using curl
curl -Ls "http://127.0.0.1:9000/api/inventory/tree" \
     --header 'Authorization: Bearer VGhpcyBpcyBqdXN0IGEgZGVtbyBhY2Nlc3MgdG9rZW4u' \
     --header "Content-Type: application/json" \
     --request POST \
     --data '{"query":"Computer"}'
 
# Shell access using curl with username and password
curl -Lsu username:password "http://127.0.0.1:9000/api/inventory/tree" \
     --header "Content-Type: application/json" \
     --request POST \
     --data '{"query":"Computer"}'