API query method with properties

I have a question about API query methods and object that return ‘properties’. I can’t seem to select from properties. For instance pool.snapshot.query returns an object with properties. When I try to select name, properties.guid, properties.creation I only get named returned.

Can properties be used as select or order_by in these types of objects?

Hey @BooMShanKerX

Do you mean this?

midclt call  zfs.dataset.query '[["pool","=","p0-25-8z2"],["name","^","p0-25-8z2/pve/nfs"]]' '{"extra": {"properties": ["quota","creation"]},"select": ["name","properties","pool","dataset"]}' | jq

The docs don’t really describe it that well tho /ö

EDIT: added an example with more extra-opts that also make some sense in the queries context..

Example Output

Command

midclt call  zfs.dataset.query \
  '[["pool","=","p0-25-8z2"],["name","^","p0-25-8z2/pve/nfs"]]' \
   '{"extra": {"properties": ["used","creation","mountpoint","snapshots_changed"]},"select": ["name","properties","pool","dataset"]}' \
  | jq last

Return

{
  "name": "p0-25-8z2/pve/nfs/iso",
  "properties": {
    "org.truenas:managedby": {
      "value": "10.29.1.6",
      "rawvalue": "10.29.1.6",
      "source": "LOCAL",
      "parsed": "10.29.1.6"
    },
    "org.freebsd.ioc:active": {
      "value": "yes",
      "rawvalue": "yes",
      "source": "INHERITED",
      "parsed": "yes"
    },
    "creation": {
      "parsed": {
        "$date": 1716208488000
      },
      "rawvalue": "1716208488",
      "value": "Mon May 20 14:34 2024",
      "source": "NONE",
      "source_info": null
    },
    "snapshots_changed": {
      "parsed": "1760738400",
      "rawvalue": "1760738400",
      "value": "Sat Oct 18  0:00:00 2025",
      "source": "NONE",
      "source_info": null
    },
    "used": {
      "parsed": 15758582112,
      "rawvalue": "15758582112",
      "value": "14.7G",
      "source": "NONE",
      "source_info": null
    },
    "mountpoint": {
      "parsed": "/mnt/p0-25-8z2/pve/nfs/iso",
      "rawvalue": "/mnt/p0-25-8z2/pve/nfs/iso",
      "value": "/mnt/p0-25-8z2/pve/nfs/iso",
      "source": "DEFAULT",
      "source_info": null
    }
  },
  "pool": "p0-25-8z2"
}
1 Like

If that works, then I believe that’s what I was looking for. The ‘extras’ field isn’t explained very well at all. I was trying properties.property in the select statement.

At the end of the day grabbing all the properties doesn cost much but I like to be precise when I can. I’ll give it a shot while I’m cleaning up a few other things.

Thanks!