| |
| <!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:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/http.py">/usr/local/google/home/jcgregorio/projects/apiclient/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><a href="simplejson.html">simplejson</a><br> |
| </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#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="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, opt_expected_body) that should be<br> |
| returned when that method is called. None may also be passed in for the<br> |
| httplib2.Response, in which case a 200 OK response will be generated.<br> |
| If an opt_expected_body (str or dict) is provided, it will be compared to<br> |
| the body and UnexpectedBodyError will be raised on inequality.<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 or raise an excpetion if<br> |
| check_unexpected is set to True. The methodId is taken from the rpcName<br> |
| 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, check_unexpected<font color="#909090">=False</font>)</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.<br> |
| check_unexpected - A boolean setting whether or not UnexpectedMethodError<br> |
| should be raised on unsupplied method.</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="#eeaa77"> |
| <td colspan=3 valign=bottom> <br> |
| <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> |
| |
| <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> |
| <td width="100%"><dl><dt><a name="-tunnel_patch"><strong>tunnel_patch</strong></a>(http)</dt><dd><tt>Tunnel PATCH requests over POST.<br> |
| Args:<br> |
| http - An instance of httplib2.Http<br> |
| or something that acts like it.<br> |
| <br> |
| Returns:<br> |
| A modified instance of http that was passed in.<br> |
| <br> |
| Example:<br> |
| <br> |
| h = httplib2.Http()<br> |
| h = <a href="#-tunnel_patch">tunnel_patch</a>(h, "my-app-name/6.0")<br> |
| <br> |
| Useful if you are running on a platform that doesn't support PATCH.<br> |
| Apply this last if you are using OAuth 1.0, as changing the method<br> |
| will result in a different signature.</tt></dd></dl> |
| </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', 'HttpMockset_user_agent', 'tunnel_patch']<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> |