main.py: create missing lists

This commit is contained in:
Antoine Martin 2024-03-03 00:31:06 -05:00
parent 916e037b26
commit 3b07155f20
Signed by: forge
GPG key ID: D62A472A4AA7D541

12
main.py
View file

@ -84,6 +84,18 @@ def listmonk_get_list(list):
json_object = json_object['data']['results']
return json_object[0]
# ensure that groups exist as lists
for group_info in authentik_get_groups():
try:
list_info = listmonk_get_list(group_info['name'])
except Exception as e:
print('> Failed to find group as list, creating ' + group_info['name'])
create_resp = listmonk_create_list(group_info['name'])
print(create_resp)
continue
# ensure that users are synced
for user_info in authentik_get_users():
print('>>> Checking user ' + user_info['username'])