0
Completed

API - list folder by label or list all folders

cbabs 6 years ago updated by Nils Laumaillé 6 years ago 6

Hey Nils,


Unless I haven't found the right document or I'm stupid(plausible), it seems I can't return folders based on any other value than id and that an id *must* be specified.  Also I don't see anything in the API that allows me to list all folders. 


Either one of these would solve my problem.  If I could list all folders I could put into a JSON dict and loop until I found the 'Label' value and then get the 'id', that would work.  Even better would be if the API could do it for me so I could specify the 'Label'.


I'm using these docs, let me know if this is right.  Thanks for all your work!


Chris


https://teampass.readthedocs.io/en/latest/api/api-read/

Under review

Hello Chris


Yes the doc is correct.

Currently the api only has those features detailed in this doc.


I have planned to work on it to improve the possibilities but I'm lacking time.


In the mean time, you can use feature "userfolders". Just create a dummy account that has access to all folders and run <url to teampass>/api/index.php/read/userfolders/<user's login>?apikey=<valid api key>


Please list all the feature that would be useful for your use cases. Add some details so that I understand the purpose.


Thank you

Here's what I'm trying to achieve.  I have many network devices.  These devices are at different customer sites.  I want to make each device password unique.  I want to group each device by customer, that is I want to have each customer have it's own folder. 


The control of the devices is done with python and involves different systems such as IPAM, Net mon, Radius, Cust dbase, and of course Teampass.  The password gen function via the teampass API is working well, but after generation I need to be able to store them in an organized manner. 


So I need to be able to create folder and add to that folder based on label(cust name).  So an API function allow search/add key by label(not just id) would be ideal.


A function that lists all folders would also work and might be easier to create on your side.  I can take all the folders, serialize into JSON, for each loop over them, and pull the 'id' when the label matches.  Then I can create a key with that folder id.


I hope that makes sense.

I've added function "folder_descendants" inside the API.


Call used: <url to teampass>/api/index.php/read/folder_descendants/<id OR title>/<folder_id OR folder_title>?apikey=<valid api key>


Example: http://teampass.net/api/index.php/read/folder_descendants/id/1?apikey=qdqsdqsdqsd will return all folders from root.


Notice that it returns itself too.


Only tested with ID for now

You rock!  Thank you so much. Did you put in devel branch? I see a commit to /api/functions.php 23 mins ago.  Is that all I need?

I just tested and it works great.  Thanks again!