@@ -21,29 +21,31 @@ def modifyRules():
2121 ruleids = str (input ("Enter rule ID's to modify (Example: 1010010,931100,931110): " )).lower ().strip ()
2222 action = str (input ("Enter action to perform on rules (disabled, log, block):" )).lower ().strip ()
2323 ruleList = ruleids .split ("," )
24- data = {}
24+ body = {}
2525 datatemp = {}
2626 attributes = {}
2727 for rid in ruleList :
28+ print (str (rid ))
2829 wrid = str (dfObj ['WAF ID' ].iloc [inVar ]) + "-" + str (rid )
2930 datatemp .update ({"id" :wrid })
3031 datatemp .update ({"type" :"rule_status" })
3132 attributes .update ({"status" :action })
3233 datatemp .update ({"attributes" :attributes })
33- data .update ({"data" :datatemp })
34+ body .update ({"data" :datatemp })
3435 #print(json.dumps(data))
3536 header = {"Accept" :"application/vnd.api+json" }
3637 header .update ({"Fastly-Key" :scripts .getKeyFromConfig ()})
3738 #r=requests.get("https://api.fastly.com/service/" + str(dfObj['Service ID'].iloc[inVar]) + "/wafs/" + str(dfObj['WAF ID'].iloc[inVar]) + "/rules/" + str(rid) + "/rule_status",headers=header)
3839 #pprint.pprint(r.json()['data'])
3940 header .update ({"Content-Type" :"application/vnd.api+json" })
40- #print("https://api.fastly.com/service/" + str(dfObj['Service ID'].iloc[inVar]) + "/wafs/" + str(dfObj['WAF ID'].iloc[inVar]) + "/rules/" + str(rid) + "/rule_status")
41- r = requests .patch ("https://api.fastly.com/service/" + str (dfObj ['Service ID' ].iloc [inVar ]) + "/wafs/" + str (dfObj ['WAF ID' ].iloc [inVar ]) + "/rules/" + str (rid ) + "/rule_status" , data = data ,headers = header )
41+ #print(json.dumps(header))
42+ #print(json.dumps(body))
43+ #print("https://api.fastly.com/service/" + str(dfObj['Service ID'].iloc[inVar]) + "/wafs/" + str(dfObj['WAF ID'].iloc[inVar]) + "/rules/" + str(row['Num ID']) + "/rule_status")
44+ r = requests .patch ("https://api.fastly.com/service/" + str (dfObj ['Service ID' ].iloc [inVar ]) + "/wafs/" + str (dfObj ['WAF ID' ].iloc [inVar ]) + "/rules/" + str (rid ) + "/rule_status" , data = str (json .dumps (body )) ,headers = header )
4245 if r .status_code == 200 :
4346 pprint .pprint (r .json ()['data' ])
4447 else :
4548 print (scripts .bcolors .WARNING + "Error with services request.\n Status: " + str (r .status_code ) + scripts .bcolors .ENDC )
46- break
4749 while "Not a valid response." :
4850 reply = str (input ("Modify another set [Y/n]: " )).lower ().strip ()
4951 if reply == 'y' :
0 commit comments