Skip Navigation Links | |
Exit Print View | |
Oracle® ZFS Storage Appliance RESTful Application Programming Interface |
A Python RESTful API client is provided along with a rest test library to aid in test development of RESTful services.
Example RESTful Client Program:
>>> import urllib2 >>> import json >>> request = urllib2.Request("https://zfsssa.example:215/api/access/v1", "") >>> request.add_header("X-Auth-User", "rest_user") >>> request.add_header("X-Auth-Key", "letmein") >>> response = urllib2.urlopen(request) >>> response.getcode() 201 >>> info = response.info() >>> opener = urllib2.build_opener(urllib2.HTTPHandler) >>> opener.addheaders = [("X-Auth-Session", info.getheader("X-Auth-Session")), ... ('Content-Type', 'application/json'), ('Accept', 'appplication/json')]
The opener can then be used to open requests that are already pre-authenticated and ready to send/receive JSON data.