API v2.0 query datasets in datasets

newcomer

Cadet
Joined
Dec 16, 2020
Messages
2
Hi Everyone,

I'm playing around with the new API version 2.0 and have some trouble, when it comes to fetch information from a not top level dataset.

I try to use the following curl command to get responses:

Code:
curl "https://$host/api/v2.0/pool/dataset/id/$2" -k -X GET -H "Authorization: Bearer $key"


while $key is my api key generated on the webinterface and $2 is the actual dataset id I want to query.

Here some example ids I also get from the API v2.0 as response:

Code:
id: localpool-one
    id: localpool-one/iocage
      id: localpool-one/iocage/images
      id: localpool-one/iocage/releases


now to my Problem I can get detailed information from the dataset(basiclly it is the pool) localpool-one with the curl above without problems.
But as soon as I what to get details for one of the sub-datasets(actually datasets) I get a 404: Not Found as response.
I tried the following combinations with the first one working and the following 2 are not.

Code:
curl "https://$host/api/v2.0/pool/dataset/id/localpool-one" -k -X GET -H "Authorization: Bearer $key"
curl "https://$host/api/v2.0/pool/dataset/id/localpool-one/iocage -k -X GET -H "Authorization: Bearer $key"
curl "https://$host/api/v2.0/pool/dataset/id/iocage" -k -X GET -H "Authorization: Bearer $key"


I see 3 possibilities with this issue:

first:
I also noticed that the JSON response from the top-level had many informations about the so called "childrens".
So am I supposed to only get Informations from the top-level and search my way thru the JSON response for children informations, but if this is the case i think the naming dataset for the query is confusing.

second:
I am doing some thing wrong. In this case I hope someone can help me.

third:
Is this as Bug?

I already scripted this stuff together so I can post it if it will help.

And I'm running an Truenas Core Release 12

Regards,
Alex

PS: as much as I dislike this sentence in formus. I'm not a native english speaker, so I'm sorry for any kind of misspelling or grammatical failures.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,702
I see that the answer comes back for me as (in part, for example):
"id": "tank/iocage/releases/11.1-RELEASE",
"type": "FILESYSTEM",


Maybe the clue is there in that these are filesystems, not datasets.

There's the filesystem function set which may get you what you want. (all depends on what you want... perhaps it's already there but needs filtering or parsing in the response you already get)

I note that you may need to use the post method and specify some arguments in order to get filtering to happen.
 

newcomer

Cadet
Joined
Dec 16, 2020
Messages
2
Thanks for your response,
the datasets are listed as type: FILESYSTEM, but as far as I understand these are datasets from the zfs point of view. So I will stick with it.

In the API Doku I didn't see the availability to get information like used space, quota or snapshots.
sadly making querys for filesystem isn't a option for me.

I still don't get why the api query is called dataset if it cannot query datasets.
:(

I guess I need to sit down and make my analyses with the big JSON dump I am getting from a top-level query.
at this point is there a way to open a git like issue at ixsystems, and hope the will add the function to the API?
 

JCL

Dabbler
Joined
Nov 18, 2015
Messages
14
Hi,
I am struggling too with this api v2.0, but I have an answer for you :smile:. To get access to the dataset beyond the pool name, use the following syntax:

$host/api/v2.0/pool/dataset?id=dataset_path_name

Example with your : localpool-one/iocage

curl "https://$host/api/v2.0/pool/dataset?id=localpool-one/iocage" -k -X GET -H "Authorization: Bearer $key"

JC
 

Jfs

Dabbler
Joined
Feb 23, 2023
Messages
23
So how can I get the current permissions (matching the 'edit permissions' GUI menu stuff) using the curl API v2 stuff? I know it must be there, but I just can't seem to find where it is. Is this under the 'filesystem/getacl' section? Any good examples of using this?
 
Top