########################################################################### # CLOUD SERVER API DOCUMENTATION # # Name: deleteFirewallServer # Language: Python # # Description: removes firewall policy ########################################################################### from urllib.request import Request, urlopen import urllib import json #ID access to API TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a" url = "https://cloudpanel-api.1and1.com/v1" def _deleteFirewallServer(id, ip_id): #Configure the request _command = url + "/servers/" + id + "/ips/" + ip_id + "/firewall_policy" _method = 'DELETE' request = Request(_command, headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, method=_method) #Try to get the response try: response = urlopen(request) content = response.read() return (content.decode()) #Fetch error except urllib.error.URLError as e: return("Error " + str(e.code) + ":" + e.reason) #PARAMETERS id = "{YOUR_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20" ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20" #Delete firewall policy print(_deleteFirewallServer(id, ip_id))