########################################################################### # CLOUD SERVER API DOCUMENTATION # # Name: listMonitoringPolicies # Language: Python # # Description: retrieves a list with all monitoring policies ########################################################################### from urllib.request import Request, urlopen import urllib #ID access to API TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a" url = "https://cloudpanel-api.ionos.com/v1" def _listMonitoringPolicies(): #Configure the request _command = url + "/monitoring_policies" _method = 'GET' 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 #List monitoring policies print(_listMonitoringPolicies())