I am not a java developer, so was looking at a way to do this with either sql or the API. This user is right in that doing the sql queries is difficult, the arrays make it difficult to see the friendly names. Is there a way to use the API to cycle through the “test permissions” tool so that I can get that information for every octopus user?
Yes I understand, but this is going to take some time, and my scripting abilities are not up to task to get this done in a quick turnover. Since we are a customer can we please get some assistance in writing the script?
We do not write custom scripts like that, but I can definitely give you a hand to start with it.
The below script will get all users, then get the permission for each user and save it into the $Permissions collection. It’ll be up to you or someone in your team proficient with Powershell to format the data in the way your current system expects.
$OctopusAPIkey = "" #Your Octopus API Key
$OctopusURL = "" #Your Octopus portal base URL
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }
#Getting all users from API
$AllUsers = (Invoke-WebRequest "$OctopusURL/api/users/all" -Method Get -Headers $header).content | ConvertFrom-Json
$Permissions = @()
#Gathering permissions of all users into the $Permissions collection
foreach($user in $AllUsers){
$permissions += (Invoke-WebRequest $OctopusURL/api/users/$($user.id)/permissions -Method Get -Headers $header).content | ConvertFrom-Json
}
<#
$Permissions will hold 1 object per user. Each object will have a "Permissions" member which holds all the permissions that a user has.
You can work with this $permissions collection to build your report. I recommend trying to create a CSV spreadsheet out of this using convertto-csv
#>