1 __author__ = "Basheeruddin Ahmed"
2 __copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
3 __license__ = "New-style BSD"
4 __email__ = "syedbahm@cisco.com"
10 #Helps in making GET REST calls
13 def get(url, userId, password):
16 headers['Accept']= 'application/xml'
18 # Send the GET request
19 req = requests.get(url, None, headers)
25 #Helps in making POST REST calls without outputs
27 def nonprintpost(url, userId, password,data):
30 headers['Content-Type'] = 'application/json'
31 #headers['Accept']= 'application/xml'
33 resp = requests.post(url,data.encode(),headers=headers)
39 #Helps in making POST REST calls
41 def post(url, userId, password,data):
42 print("post request with url "+url)
43 print("post request with data "+data)
45 headers['Content-Type'] = 'application/json'
46 #headers['Accept']= 'application/xml'
48 resp = requests.post(url,data.encode(),headers=headers)
50 #print (resp.raise_for_status())
56 #Helps in making DELET REST calls
58 def delete(url,userId,password):
59 print("delete all resources belonging to url"+url)
60 resp=requests.delete(url)