INFRA-2270 | Saqib | Change threshold values to numbers

This commit is contained in:
saqib-perwaiz_navi
2023-09-29 15:13:27 +05:30
parent 6be416453b
commit 4e4803ce0b

View File

@@ -0,0 +1,31 @@
import time
import requests
url = "" #deployment portal url
s = requests.Session()
cookie = "" #cookie
x_xsrf_token = "" # token
s.headers.update({'cookie': cookie, 'x-xsrf-token': x_xsrf_token})
list_manifest_path = "/api/manifest/list"
r = s.get(url + list_manifest_path)
manifest_list = r.json()
for i in manifest_list:
perform_post = False
r = s.get(url + "/api/manifest/" + str(i['id']))
manifest = r.json()
if 'deployment' in manifest:
deployment = manifest['deployment']
if 'alerts' in deployment:
alerts = deployment['alerts']
for alert_type, alert_list in alerts.items():
for alert in alert_list:
if 'threshold' in alert and isinstance(alert['threshold'], str) and alert['threshold'].isdigit():
alert['threshold'] = int(alert['threshold'])
response = s.post(url + "/api/manifest", json=manifest)
print("{} response of post is {}".format(i['id'], response.json()))
time.sleep(2)