|  |  | 
|  | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | 
|  | <html><head><title>Python: module apiclient.http</title> | 
|  | </head><body bgcolor="#f0f0f8"> | 
|  |  | 
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> | 
|  | <tr bgcolor="#7799ee"> | 
|  | <td valign=bottom> <br> | 
|  | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.http</strong></big></big></font></td | 
|  | ><td align=right valign=bottom | 
|  | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/http.py">/home/jcgregorio/projects/apiary/apiclient/http.py</a></font></td></tr></table> | 
|  | <p><tt>Classes to encapsulate a single HTTP request.<br> | 
|  |  <br> | 
|  | The classes implement a command pattern, with every<br> | 
|  | <a href="__builtin__.html#object">object</a> supporting an execute() method that does the<br> | 
|  | actuall HTTP request.</tt></p> | 
|  | <p> | 
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | 
|  | <tr bgcolor="#aa55cc"> | 
|  | <td colspan=3 valign=bottom> <br> | 
|  | <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> | 
|  |  | 
|  | <tr><td bgcolor="#aa55cc"><tt>      </tt></td><td> </td> | 
|  | <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="httplib2.html">httplib2</a><br> | 
|  | </td><td width="25%" valign=top><a href="os.html">os</a><br> | 
|  | </td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p> | 
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | 
|  | <tr bgcolor="#ee77aa"> | 
|  | <td colspan=3 valign=bottom> <br> | 
|  | <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> | 
|  |  | 
|  | <tr><td bgcolor="#ee77aa"><tt>      </tt></td><td> </td> | 
|  | <td width="100%"><dl> | 
|  | <dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> | 
|  | </font></dt><dd> | 
|  | <dl> | 
|  | <dt><font face="helvetica, arial"><a href="apiclient.http.html#HttpMock">HttpMock</a> | 
|  | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#HttpRequest">HttpRequest</a> | 
|  | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#RequestMockBuilder">RequestMockBuilder</a> | 
|  | </font></dt></dl> | 
|  | </dd> | 
|  | </dl> | 
|  | <p> | 
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | 
|  | <tr bgcolor="#ffc8d8"> | 
|  | <td colspan=3 valign=bottom> <br> | 
|  | <font color="#000000" face="helvetica, arial"><a name="HttpMock">class <strong>HttpMock</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> | 
|  |  | 
|  | <tr bgcolor="#ffc8d8"><td rowspan=2><tt>   </tt></td> | 
|  | <td colspan=2><tt>Mock of httplib2.Http<br> </tt></td></tr> | 
|  | <tr><td> </td> | 
|  | <td width="100%">Methods defined here:<br> | 
|  | <dl><dt><a name="HttpMock-__init__"><strong>__init__</strong></a>(self, filename, headers<font color="#909090">=None</font>)</dt><dd><tt>Args:<br> | 
|  |   filename: string, absolute filename to read response from<br> | 
|  |   headers: dict, header to return with response</tt></dd></dl> | 
|  |  | 
|  | <dl><dt><a name="HttpMock-request"><strong>request</strong></a>(self, uri, method<font color="#909090">='GET'</font>, body<font color="#909090">=None</font>, headers<font color="#909090">=None</font>, redirections<font color="#909090">=1</font>, connection_type<font color="#909090">=None</font>)</dt></dl> | 
|  |  | 
|  | <hr> | 
|  | Data descriptors defined here:<br> | 
|  | <dl><dt><strong>__dict__</strong></dt> | 
|  | <dd><tt>dictionary for instance variables (if defined)</tt></dd> | 
|  | </dl> | 
|  | <dl><dt><strong>__weakref__</strong></dt> | 
|  | <dd><tt>list of weak references to the object (if defined)</tt></dd> | 
|  | </dl> | 
|  | </td></tr></table> <p> | 
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | 
|  | <tr bgcolor="#ffc8d8"> | 
|  | <td colspan=3 valign=bottom> <br> | 
|  | <font color="#000000" face="helvetica, arial"><a name="HttpRequest">class <strong>HttpRequest</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> | 
|  |  | 
|  | <tr bgcolor="#ffc8d8"><td rowspan=2><tt>   </tt></td> | 
|  | <td colspan=2><tt>Encapsulates a single HTTP request.<br> </tt></td></tr> | 
|  | <tr><td> </td> | 
|  | <td width="100%">Methods defined here:<br> | 
|  | <dl><dt><a name="HttpRequest-__init__"><strong>__init__</strong></a>(self, http, postproc, uri, method<font color="#909090">='GET'</font>, body<font color="#909090">=None</font>, headers<font color="#909090">=None</font>, methodId<font color="#909090">=None</font>)</dt><dd><tt>Constructor for an <a href="#HttpRequest">HttpRequest</a>.<br> | 
|  |  <br> | 
|  | Args:<br> | 
|  |   http: httplib2.Http, the transport <a href="__builtin__.html#object">object</a> to use to make a request<br> | 
|  |   postproc: callable, called on the HTTP response and content to transform<br> | 
|  |             it into a data <a href="__builtin__.html#object">object</a> before returning, or raising an exception<br> | 
|  |             on an error.<br> | 
|  |   uri: string, the absolute URI to send the request to<br> | 
|  |   method: string, the HTTP method to use<br> | 
|  |   body: string, the request body of the HTTP request<br> | 
|  |   headers: dict, the HTTP request headers<br> | 
|  |   methodId: string, a unique identifier for the API method being called.</tt></dd></dl> | 
|  |  | 
|  | <dl><dt><a name="HttpRequest-execute"><strong>execute</strong></a>(self, http<font color="#909090">=None</font>)</dt><dd><tt>Execute the request.<br> | 
|  |  <br> | 
|  | Args:<br> | 
|  |   http: httplib2.Http, an http <a href="__builtin__.html#object">object</a> to be used in place of the<br> | 
|  |         one the <a href="#HttpRequest">HttpRequest</a> request <a href="__builtin__.html#object">object</a> was constructed with.<br> | 
|  |  <br> | 
|  | Returns:<br> | 
|  |   A deserialized <a href="__builtin__.html#object">object</a> model of the response body as determined<br> | 
|  |   by the postproc.<br> | 
|  |  <br> | 
|  | Raises:<br> | 
|  |   apiclient.errors.HttpError if the response was not a 2xx.<br> | 
|  |   httplib2.Error if a transport error has occured.</tt></dd></dl> | 
|  |  | 
|  | <hr> | 
|  | Data descriptors defined here:<br> | 
|  | <dl><dt><strong>__dict__</strong></dt> | 
|  | <dd><tt>dictionary for instance variables (if defined)</tt></dd> | 
|  | </dl> | 
|  | <dl><dt><strong>__weakref__</strong></dt> | 
|  | <dd><tt>list of weak references to the object (if defined)</tt></dd> | 
|  | </dl> | 
|  | </td></tr></table> <p> | 
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | 
|  | <tr bgcolor="#ffc8d8"> | 
|  | <td colspan=3 valign=bottom> <br> | 
|  | <font color="#000000" face="helvetica, arial"><a name="RequestMockBuilder">class <strong>RequestMockBuilder</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> | 
|  |  | 
|  | <tr bgcolor="#ffc8d8"><td rowspan=2><tt>   </tt></td> | 
|  | <td colspan=2><tt>A simple mock of <a href="#HttpRequest">HttpRequest</a><br> | 
|  |  <br> | 
|  | Pass in a dictionary to the constructor that maps request methodIds to<br> | 
|  | tuples of (httplib2.Response, content) that should be returned when that<br> | 
|  | method is called. None may also be passed in for the httplib2.Response, in<br> | 
|  | which case a 200 OK response will be generated.<br> | 
|  |  <br> | 
|  | Example:<br> | 
|  |   response = '{"data": {"id": "tag:google.c...'<br> | 
|  |   requestBuilder = <a href="#RequestMockBuilder">RequestMockBuilder</a>(<br> | 
|  |     {<br> | 
|  |       'chili.activities.get': (None, response),<br> | 
|  |     }<br> | 
|  |   )<br> | 
|  |   apiclient.discovery.build("buzz", "v1", requestBuilder=requestBuilder)<br> | 
|  |  <br> | 
|  | Methods that you do not supply a response for will return a<br> | 
|  | 200 OK with an empty string as the response content. The methodId<br> | 
|  | is taken from the rpcName in the discovery document.<br> | 
|  |  <br> | 
|  | For more details see the project wiki.<br> </tt></td></tr> | 
|  | <tr><td> </td> | 
|  | <td width="100%">Methods defined here:<br> | 
|  | <dl><dt><a name="RequestMockBuilder-__call__"><strong>__call__</strong></a>(self, http, postproc, uri, method<font color="#909090">='GET'</font>, body<font color="#909090">=None</font>, headers<font color="#909090">=None</font>, methodId<font color="#909090">=None</font>)</dt><dd><tt>Implements the callable interface that discovery.build() expects<br> | 
|  | of requestBuilder, which is to build an <a href="__builtin__.html#object">object</a> compatible with<br> | 
|  | <a href="#HttpRequest">HttpRequest</a>.execute(). See that method for the description of the<br> | 
|  | parameters and the expected response.</tt></dd></dl> | 
|  |  | 
|  | <dl><dt><a name="RequestMockBuilder-__init__"><strong>__init__</strong></a>(self, responses)</dt><dd><tt>Constructor for <a href="#RequestMockBuilder">RequestMockBuilder</a><br> | 
|  |  <br> | 
|  | The constructed <a href="__builtin__.html#object">object</a> should be a callable <a href="__builtin__.html#object">object</a><br> | 
|  | that can replace the class HttpResponse.<br> | 
|  |  <br> | 
|  | responses - A dictionary that maps methodIds into tuples<br> | 
|  |             of (httplib2.Response, content). The methodId<br> | 
|  |             comes from the 'rpcName' field in the discovery<br> | 
|  |             document.</tt></dd></dl> | 
|  |  | 
|  | <hr> | 
|  | Data descriptors defined here:<br> | 
|  | <dl><dt><strong>__dict__</strong></dt> | 
|  | <dd><tt>dictionary for instance variables (if defined)</tt></dd> | 
|  | </dl> | 
|  | <dl><dt><strong>__weakref__</strong></dt> | 
|  | <dd><tt>list of weak references to the object (if defined)</tt></dd> | 
|  | </dl> | 
|  | </td></tr></table></td></tr></table><p> | 
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | 
|  | <tr bgcolor="#55aa55"> | 
|  | <td colspan=3 valign=bottom> <br> | 
|  | <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> | 
|  |  | 
|  | <tr><td bgcolor="#55aa55"><tt>      </tt></td><td> </td> | 
|  | <td width="100%"><strong>__all__</strong> = ['HttpRequest', 'RequestMockBuilder', 'HttpMock']<br> | 
|  | <strong>__author__</strong> = 'jcgregorio@google.com (Joe Gregorio)'</td></tr></table><p> | 
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | 
|  | <tr bgcolor="#7799ee"> | 
|  | <td colspan=3 valign=bottom> <br> | 
|  | <font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr> | 
|  |  | 
|  | <tr><td bgcolor="#7799ee"><tt>      </tt></td><td> </td> | 
|  | <td width="100%">jcgregorio@google.com (Joe Gregorio)</td></tr></table> | 
|  | </body></html> |