#!/bin/bash


TOKEN="squ_ebe55ae1337899b210495f163664abd9f614426e"
BASE_URL="https://t-sonarqube-x1.devops.lmru.tech/sonarqube/api/users"

update_identity_provider() {
	login=$1
	curl -s -u "${TOKEN}:" -X POST "${BASE_URL}/update_identity_provider?login=${login}&newExternalProvider=saml"
}

for i in {1..2};
do
	#response=$(curl -s -u "${TOKEN}:" "${BASE_URL}/search?ps=500&p=$i")
	#logins=$(echo $response | jq -r '.users[] | select(.login | . != "admin"  and . !="bricks-sonar-service-account" and . !="jenkins") | .login')
	logins=60231159
	for login in $logins; do
		update_result=$(update_identity_provider $login)
		echo "Updated $login: $update_result"
	done
done