38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import requests
|
|
|
|
# Set up authentication token and base URL
|
|
TOKEN = "squ_ebe55ae1337899b210495f163664abd9f614426e"
|
|
base_url = "https://t-sonarqube-x1.devops.lmru.tech/sonarqube/api/users"
|
|
|
|
# Headers with the authentication
|
|
headers = {
|
|
'Authorization': f'Basic {TOKEN}:'
|
|
}
|
|
|
|
# Function to update user identity provider
|
|
# def update_identity_provider(login):
|
|
# update_url = f"{base_url}/update_identity_provider"
|
|
# params = {
|
|
# 'login': login,
|
|
# 'newExternalProvider': 'saml'
|
|
# }
|
|
# response = requests.post(update_url, headers=headers, params=params)
|
|
# return response.json()
|
|
|
|
for i in range(1, 11):
|
|
url = f"https://t-sonarqube-x1.devops.lmru.tech/sonarqube/api/users/search"
|
|
params = {
|
|
'ps': 500,
|
|
'p': i
|
|
}
|
|
response = requests.get(url, headers=headers, params=params)
|
|
|
|
if response.status_code == 200:
|
|
users = response.json()
|
|
print(users)
|
|
# for user in users:
|
|
# result = update_identity_provider(user['login'])
|
|
# print(f"Updated {user['login']}:", result)
|
|
else:
|
|
print(f"Failed to fetch page {i}, status code {response}")
|