duplicate results with group listing
I am trying to export all groups with their members to JSON so I can determine groups which may or may not be in use. We have multiple domains set up at my company, so I picked one with the fewest groups to build my query. The domain in question has 2 groups in it. When I run my query, with the "--all" parameter, it never completes. I let it run for 30+ minutes and no results were returned to screen. I changed the --all parameter to --limit 2 and it came back very fast which made me happy as I could script that out and I'd be good, but this was not a realistic approach for other domains where group numbers are inconsistent and growing. So I decided to try a large number for the limit knowing that there are only 2 groups in that domain - I set it to 1000 thinking it should still be quick with a limit 1000 for 2 groups but nope - it sat there thinking for 20 minutes before I cancelled it. Dropped that 1000 down to 100 and it completed in a few minutes, but instead of giving me 2 results, I got 100 rows. So loaded up the JSON to see and there are 67 records BUT if I expand all of the elements in there that I extracted (members and owners), 100 rows are in the output. So, the only way to get the proper number of rows back is for me to limit it to 2, but that means I need to check how many rows I should be getting back prior to requesting everything which is a bit silly, no? I mean, it's not THAT hard to do, but feels like overkill.
Note - this works fine using --all with users with the query I have in place but with groups it is just unhappy. My full command is: `set query="data.resources[].{GroupName: "display-name" }"
oci identity-domains groups list --endpoint %endpoint% --attribute-sets all --query %query% --output json --config-file c:\users\
Plus I define my endpoint, but I'd rather not publish my endpoint. I reduced my query down to just the display-name for testing purposes and I get 67 rows back with that above query. My actual query has a lot more details than that.
EDIT - edited to remove my username from the command for the config file for privacy reasons.
Tried it out locally. Findings:
- The command is behaving abnormally (as specified above) if we use the
--attribute-sets allparameter. - Without this parameter, the command is working fine and giving the expected output everytime.
Just in case anyone else hits this and needs a workaround while the bug is worked on, this is how I worked around it (PowerShell this time instead of bat file/command prompt because I ran into issues with bat files too):
param (
[Parameter(Mandatory = $true)]
[string]$endpoint
)
# Get the number of groups to avoid duplication due to OCI CLI bug
$groupCountQuery = '"length(data.resources[])"'
$limit = oci identity-domains groups list `
--endpoint $endpoint `
--query $groupCountQuery `
--output json `
--config-file "$env:USERPROFILE\.oci\config" `
--profile DEFAULT `
--all | ConvertFrom-Json
#Get the data
oci identity-domains groups list `
--endpoint $endpoint `
--attribute-sets all `
--output json `
--config-file "$env:USERPROFILE\.oci\config" `
--profile DEFAULT `
--limit $limit
Above powershell takes 1 required parameter which is your endpoint and it spits out all data. Also tailored to be able to be run on any Windows system as it no longer relies on the user profile directory being hard-coded in; it uses the environment variable for it.