#!/usr/bin/python3 import os import requests from dotenv import load_dotenv load_dotenv() def gitea(endpoint): server = 'https://' + os.environ["GITEA_CN"] + '/api/v1/' headers = {"Authorization": "token " + os.environ['GITEA_TOKEN']} return requests.get(server+endpoint, headers=headers).json() def mailcow(endpoint): server = 'https://' + os.environ["MAILCOW_CN"] + '/api/v1/' headers = {"X-API-Key": os.environ['MAILCOW_TOKEN']} return requests.get(server+endpoint, headers=headers).json() def mattermost(endpoint): server = 'https://' + os.environ["MATTERMOST_CN"] + '/api/v4/' headers = {"Authorization": "Bearer " + os.environ['MATTERMOST_TOKEN']} return requests.get(server+endpoint, headers=headers).json() def nextcloud(endpoint): server = 'https://' + os.environ["NEXTCLOUD_CN"] + '/ocs/v2.php/' format = "?format=json" auth_user = os.environ["NEXTCLOUD_USER"] auth_token = os.environ["NEXTCLOUD_TOKEN"] headers = { "OCS-APIRequest": "true" } return requests.get(server+endpoint+format, auth=(auth_user, auth_token), headers=headers).json()