<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">I’ve packaged this up as a batch script:</div><div class=""><br class=""></div><div class=""><a href="https://gist.github.com/sdm7g/93b9e072cffd398484ca" class="">https://gist.github.com/sdm7g/93b9e072cffd398484ca</a></div><div class=""><br class=""></div><div class="">Requires curl and jq . (It should probably check for that.)</div><div class="">Edit to change HOST and admin user and password. </div><div class="">( It’s using localhost:8089 and admin/admin as defaults for testing. ) </div><div class=""><br class=""></div><div class="">You give it a repository id#, a group-code, and a list of usernames. </div><div class=""><br class=""></div><div class="">If you just give it a repo-id, it displays the group-codes for that repo. </div><div class=""><br class=""></div><div class="">./adduserstogroup.sh $REPOID repository-viewers userid1 userid2 userid3 … </div><div class=""><br class=""></div><div class="">will add users in the list to repository-viewers group of $REPOID . </div><div class=""><br class=""></div><div class="">So if you’ve got one or two dozen users and several repos it makes it easier to manage groups. </div><div class=""><br class=""></div><div class="">( It probably would have been simpler to do in Ruby or Python, but since I started</div><div class=""> testing with curl and jq, that seemed the path of least resistance at the time. )</div><div class=""><br class=""></div><div class="">I’ld still like to see a better management interface in the frontend webapp. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">— Steve Majewski</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 10, 2015, at 4:31 PM, Steven Majewski <<a href="mailto:sdm7g@virginia.edu" class="">sdm7g@virginia.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">OK: I found a formula that seems to work. </div><div class=""><br class=""></div><div class="">I also found that the clue as to why modifying permissions in the POST /users API method didn’t work is in the schema docs (if you click ‘view source’), where the permissions attribute of user is marked: “readonly”: true .</div><div class=""><br class=""></div><div class="">However, passing the groups URI as a parameter string also didn’t work.</div><div class=""><br class=""></div><div class="">And it still seems rather misleading that those API calls returned a status of “Updated” with “warnings”:[]. A warning would seem appropriate here (if possible).</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Also, I’ld still like to know if there is a way to set default permissions for new users. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">The working method:</div><div class=""><br class=""></div><div class="">If $UU = a list of usernames already created in AS: [ “user1”, “user2”, “user3” … ] </div><div class="">and /repositories/5/group/28 = "group_code": "repository-viewers", "description": "Viewers of the workspace repository” … </div><div class=""><br class=""></div><div class="">This retrieves JSON for that group and adds the list of usernames to the JSON:</div><div class=""><br class=""></div><div class="">GG=$(curl_as_osx admin pwd <a href="http://localhost:8089/repositories/5/groups/28" class="">http://localhost:8089/repositories/5/groups/28</a> | jq " .member_usernames = $UU")</div><div class=""><br class=""></div><div class="">And posts the modified JSON to the backend:</div><div class=""><br class=""></div><div class="">curl_as_osx -d "$GG" admin pwd <a href="http://localhost:8089/repositories/5/groups/28" class="">http://localhost:8089/repositories/5/groups/28</a> </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Now retrieving the group JSON from the backend shows the updated users, and going to the “Manage User Access” page for that repository now shows that group checked for each the users. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">— Steve Majewski</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Aug 5, 2015, at 8:38 PM, Steven Majewski <<a href="mailto:sdm7g@virginia.edu" class="">sdm7g@virginia.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">I would like to use the backend API to set user permissions to avoid a couple hundred mouse clicks on the admin web forms. ( Adding users to a group seems to require you add them one at a time. It would be nicer if you could paste a list of user ids into that field and click Add just once. Or maybe put everything in a checkbox matrix so you can set several user/repo/groups/permissions at once. ) </div><div class=""><br class=""></div><div class="">I’ve tried doing a "GET /users/$ID” , pulling the permissions out of one user as a template and merging those permissions into another users json with jq, and posting again to "POST /users/$ID” . </div><div class=""><br class=""></div><div class="">The return value from that makes it appear to have updated:</div><div class=""><div style="margin: 0px; font-size: 15px; background-color: rgb(255, 238, 219);" class="">{"status":"Updated","id":13,"lock_version":3,"stale":null,"uri":"/users/13","warnings":[]}</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">But doing another GET shows nothing changed. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I’ve also tried appending <span style="font-size: 15px; background-color: rgb(255, 238, 219);" class="">?groups%5B%5D=/repositories/3/groups/15 </span>to the URL </div><div class="">( which should be "repository-basic-data-entry” group for that repo ) which also returns what</div><div class="">looks like an updated status, but again, it appears unchanged. </div><div class=""><br class=""></div><div class="">In both cases, *something* got updated, if only the modification date, because if I do the same operation a second time using the same JSON, it rejects the 2nd attempt with:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 15px; background-color: rgb(255, 238, 219);" class="">{"error":"The record you tried to update has been modified since you fetched it."}</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I haven’t yet tried posting to /repositories/$REPO/groups yet. Is that the one that works ?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Can anyone suggest a working API formula ? </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">— Steve. </div></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></body></html>