andyhollin
Cadet
- Joined
- Feb 20, 2016
- Messages
- 3
I'm trying to update a set of ansible tasks from API v1 to API v2. I'm having some trouble identifying zvols in v2 as there doesn't seem to be a perfect analog for the
It seems like the best approach is to use the
Here's an example request:
To which I receive the following response:
/api/v1.0/storage/volume/(int:id|string:name)/zvols/
endpoint in API v1.It seems like the best approach is to use the
/api/v2.0/pool/dataset
or /api/v2.0/pool/dataset/id/{id}
endpoints with a "query-filter" in the request body. But I'm having trouble with the syntax of the request body and continually run into 500 errors with message "Invalid filter".Here's an example request:
Code:
curl -X GET \ http://{HOSTNAME}/api/v2.0/pool/dataset/ \ -H 'Authorization: Basic {PASSWORD}' \ -H 'Content-Type: application/json' \ -d '{ "query-filters": [{ "type": { "type": "string", "enum": ["VOLUME"] } }] }'
To which I receive the following response:
{
"message": "Invalid filter {'type': {'type': 'string', 'enum': ['VOLUME']}}",
"traceback": "Traceback (most recent call last):\n File \"/usr/local/lib/python3.7/site-packages/middlewared/restful.py\", line 543, in do\n result = await self.middleware.call(methodname, *method_args, **method_kwargs)\n File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1141, in call\n app=app, pipes=pipes, job_on_progress_cb=job_on_progress_cb, io_thread=True,\n File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1098, in _call\n return await run_method(methodobj, *args)\n File \"/usr/local/lib/python3.7/site-packages/middlewared/utils/run_in_thread.py\", line 10, in run_in_thread\n return await self.loop.run_in_executor(self.run_in_thread_executor, functools.partial(method, *args, **kwargs))\n File \"/usr/local/lib/python3.7/site-packages/middlewared/utils/io_thread_pool_executor.py\", line 25, in run\n result = self.fn(*self.args, **self.kwargs)\n File \"/usr/local/lib/python3.7/site-packages/middlewared/schema.py\", line 965, in nf\n return f(*args, **kwargs)\n File \"/usr/local/lib/python3.7/site-packages/middlewared/plugins/pool.py\", line 2549, in query\n return filter_list(self.__transform(datasets), filters, options)\n File \"/usr/local/lib/python3.7/site-packages/middlewared/utils/__init__.py\", line 287, in filter_list\n elif not filterop(f):\n File \"/usr/local/lib/python3.7/site-packages/middlewared/utils/__init__.py\", line 261, in filterop\n raise ValueError(f'Invalid filter {f}')\nValueError: Invalid filter {'type': {'type': 'string', 'enum': ['VOLUME']}}\n"
}
[/CODE]
I'm sure it's a relatively simple change to the request body. But I've been trying for a couple hours and haven't been able to figure out the format from the documentation. Any help is appreciated.