mirror of
https://gitlab.sectorq.eu/home/docker-compose.git
synced 2025-07-01 16:08:32 +02:00
80 lines
2.1 KiB
Python
Executable File
80 lines
2.1 KiB
Python
Executable File
import requests
|
|
import json
|
|
import getopt
|
|
import sys
|
|
try:
|
|
opts, args = getopt.getopt(sys.argv[1:], "amftDr:bd:sSO", ["command=", "help", "output="])
|
|
except getopt.GetoptError as err:
|
|
#usage()
|
|
sys.exit(2)
|
|
output = None
|
|
# QJ : getopts
|
|
_MODE = "manual"
|
|
_FIRST = _TEST = _RESTORE = _BACKUP = _SYNC = _START = _STOP = False
|
|
_EXECUTE = True
|
|
_DATE = "pick"
|
|
|
|
for o, a in opts:
|
|
if o == "-a":
|
|
_MODE = "auto"
|
|
elif o in ("-m", "--manual"):
|
|
_MODE = "manual"
|
|
elif o in ("-f", "--first"):
|
|
_FIRST = True
|
|
elif o in ("-d", "--date"):
|
|
_DATE = a
|
|
|
|
url = "https://portainer.sectorq.eu/api/auth"
|
|
body = {
|
|
"password": "l4c1j4yd33Du5lo",
|
|
"username": "admin"
|
|
}
|
|
|
|
x = requests.post(url, json=body)
|
|
# https://portainer.sectorq.eu/api/stacks/webhooks/02f5acae-1462-49d4-be3f-9d9c6a73a9ab
|
|
# https://portainer.sectorq.eu/api/stacks/webhooks/1b355925-5b71-48b5-8406-bc32a68d17ec
|
|
|
|
cook = x.cookies
|
|
apikey = x.cookies.get_dict()["portainer_api_key"]
|
|
input(cook)
|
|
envs = {}
|
|
|
|
headers = {"Authorization": "Bearer " + apikey}
|
|
input(headers)
|
|
url = "https://portainer.sectorq.eu/api/endpoints"
|
|
x = requests.get(url, cookies=cook)
|
|
data = json.loads(x.text)
|
|
for d in data:
|
|
print(d["Name"], " : ", d["Id"])
|
|
envs[d["Id"]] = d["Name"]
|
|
print(envs)
|
|
url = "https://portainer.sectorq.eu/api/stacks"
|
|
x = requests.get(url, cookies=cook)
|
|
data = json.loads(x.text)
|
|
#print(data)
|
|
for d in data:
|
|
if d["Name"] == "bitwarden":
|
|
print(d)
|
|
#print(d)
|
|
print(d["EndpointId"])
|
|
try:
|
|
print(d["Name"], " : ", envs[int(d["EndpointId"])], " : ", d["AutoUpdate"]["Webhook"])
|
|
except:
|
|
print(d["Name"], " : ", envs[int(d["EndpointId"])], " : ", "")
|
|
|
|
|
|
|
|
url = "https://portainer.sectorq.eu/api/webhooks"
|
|
x = requests.get(url, cookies=cook)
|
|
data = json.loads(x.text)
|
|
#print(data)
|
|
|
|
|
|
|
|
|
|
f = {'AutoUpdate': {'Interval': '', 'Webhook': '02f5acae-1462-49d4-be3f-9d9c6a73a9ab', 'JobID': '', 'ForceUpdate': False, 'ForcePullImage': True}}
|
|
print(headers)
|
|
url = "https://portainer.sectorq.eu/api/stacks/527/git"
|
|
x = requests.post(url, json=f, headers=headers)
|
|
print(x)
|
|
data = json.loads(x.text) |