I don’t want to mention how many years I spent coding and using APIs, I’d be even more ashamed.
Seriously, I thought it’d be a 10mn think to start using the API and consolidate an Infra As Code base.
I can’t understand how to read its documentation. It only shows an exemple of connection, and the link to: TrueNAS uses DDP: meteor/packages/ddp/DDP.md at devel · meteor/meteor · GitHub, which isn’t helpful at all.
I can only find few examples on the forum, AI is wrong wrong wrong, I’m stuck.
I’m using midctl hoping for a no-auth quick start:
Shouldn’t this be working?
Agreed, new API docs really could be better. Filters should be list of lists where each item is [key, op, value], possible keys and value types are in second column (or one could just call method without filters and look for anything useful in output), operations are =, !=, >, <
Just to understand what we’re talking about here, are we referring to the “new” API docs meaning the 13.0 Websocket documentation linked in the first post?
Unfortunately, like the rest of CORE, there aren’t any planned changes to improve on the 13.0 API docs, beyond possible API updates in the case of a security fix.
On a positive note, the actual new API docs coming with 25.04 have been completely rewritten to, among other things, include more how-to content.
No that shouldn’t work because {"dataset": "tank/mydataset"} is not a list. midclt call pool.snapshottask.query '[["dataset", "=", "tank/mydataset"]]'
is a properly-formatted query-filter. We actually have pretty extensive documentation on how to use query-filters under ip of server/api/docs
Thanks, that’s the proper section to be able to understand how to query the API.
It’s hard to find somehow, I would expect it to be the first section of the documentation
There are no example in this documentation, it feels it’s a pure technical representation of the EP available in the python library behind it.
NB: some working EP are not even in the API doc anymore, e.g. midclt call disk.temperature
Deprecation?
How on earth is it possible to use midclt call config.save ?
I get a ValueError: Pipe ‘output’ is not open
I know I’m supposed to provide an output, but HOW ?
25.04 was in a transitional phase on the backend between our old auto-generated API documentation and the new one. Hence, not all public API methods are documented. Look at 25.10 API documentation. If you review the documentation for 25.10 there is explicit example of how to generate a downloadable configuration from config.save in the section on middleware jobs.
Not everything is going to be achievable using the midclt command. That tool was initially developed for internal / developer purposes and is a thin shell wrapper around the python API client.
That said, I’m not sure what the point is of running the midclt command locally to save a config file. There’s already a cronjob writes config backups to the configured system dataset. The point of that endpoint is to use with the core.download method to generate a http path / token from which to download the config file remotely.
That said, I opened a ticket to improve documentation for API endpoints like this: Jira
Nice! I got it working.
It still feels a little too complex for integration tasks to me though.
An Ansible module would be ideal to wrap-up this code and provide an easy to use task.