AD groups configuration

Hi,

you take the total count of groups from json response and use in a loop.
Here’s an example using Groovy printing the group name.

import groovy.json.*

def sonarRest(url,method) {
  jsonSlurper = new JsonSlurper()
  raw = 'someusertoken:'
  bauth = 'Basic ' + javax.xml.bind.DatatypeConverter.printBase64Binary(raw.getBytes())
  conn = new URL(url).openConnection() as HttpURLConnection
  conn.setRequestMethod(method)
  conn.setRequestProperty("Authorization", bauth)
  conn.connect()
  httpstatus = conn.responseCode
  object = jsonSlurper.parse(conn.content)
}

json = sonarRest('https://somesonarhost/api/user_groups/search?&ps=1', 'GET')
total = (json.paging.total.toFloat()/100).round()

counter = 1

while(counter <= total) {
  json = sonarRest("https://somesonarhost/api/user_groups/search?ps=100&p=$counter", 'GET')
   json.groups.each {
     println it.name
     counter++
   }
}

Gilbert