Consider permissions

This commit is contained in:
Benjamin Loison 2024-02-23 17:35:22 +01:00
parent ff783f41da
commit 334546209a
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

20
main.py
View File

@ -8,8 +8,22 @@ headers = {
'Authorization': f'token {config.TOKEN}'
}
url = f'{GITEA_INSTANCE}/api/v1/repos/Benjamin_Loison/Synchronous_reactive_systems/collaborators'
def getApi(url):
url = f'{GITEA_INSTANCE}/api/v1/{url}'
response = requests.get(url, headers = headers)
return response.json()
collaborators = requests.get(url, headers = headers).json()
repositories = getApi(f'user/repos')
print(json.dumps(repositories, indent = 4))
for repository in repositories:
repositoryFullName = repository['full_name']
collaborators = getApi(f'repos/{repositoryFullName}/collaborators')
for collaborator in collaborators:
print(json.dumps(collaborators, indent = 4))
permission = getApi(f'repos/{repositoryFullName}/collaborators/{collaborator["login"]}/permission')
if permission['permission'] != 'read':
print(repositoryFullName)
print(json.dumps(permission, indent = 4))
print(json.dumps(collaborators, indent = 4))