38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
import requests
|
|
import time
|
|
|
|
url = "https://sa-deployment-portal.cmd.navi-tech.in"
|
|
s = requests.Session()
|
|
# tbd: replace it with token
|
|
cookie = "past you cookie here"
|
|
x_xsrf_token = "xxxx-xxx-xxx-xxx-xxxxxx"
|
|
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()
|
|
print("manifest name is", manifest['name'])
|
|
if 'deployment' in manifest and 'alerts' in manifest['deployment']:
|
|
alerts = manifest['deployment']['alerts']
|
|
if 'underUtilisedResources' in alerts:
|
|
perform_post = True
|
|
del alerts['underUtilisedResources']
|
|
if 'database' in alerts:
|
|
final_database_alerts = []
|
|
for database_alert in alerts['database']:
|
|
if database_alert['type'] == 'rdsResourceUnderUtilised' or database_alert['type'] == 'rdsCPUUnderUtilised':
|
|
perform_post = True
|
|
else:
|
|
final_database_alerts.append(database_alert)
|
|
alerts['database'] = final_database_alerts
|
|
manifest['alerts'] = alerts
|
|
if perform_post:
|
|
response = s.post(url + "/api/manifest", json=manifest)
|
|
print("reponse of post is", response.json())
|
|
time.sleep(10)
|