Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 1 | |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 3 | <html><head><title>Python: module apiclient.http</title> |
| 4 | </head><body bgcolor="#f0f0f8"> |
| 5 | |
| 6 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> |
| 7 | <tr bgcolor="#7799ee"> |
| 8 | <td valign=bottom> <br> |
| 9 | <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 |
| 10 | ><td align=right valign=bottom |
Joe Gregorio | 6121dd9 | 2012-04-13 07:50:04 -0400 | [diff] [blame] | 11 | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiclient/apiclient/http.py">/home/jcgregorio/projects/apiclient/apiclient/http.py</a></font></td></tr></table> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 12 | <p><tt>Classes to encapsulate a single HTTP request.<br> |
| 13 | <br> |
| 14 | The classes implement a command pattern, with every<br> |
| 15 | <a href="__builtin__.html#object">object</a> supporting an execute() method that does the<br> |
| 16 | actuall HTTP request.</tt></p> |
| 17 | <p> |
| 18 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
Joe Gregorio | 6e53703 | 2011-02-09 23:04:26 -0500 | [diff] [blame] | 19 | <tr bgcolor="#aa55cc"> |
| 20 | <td colspan=3 valign=bottom> <br> |
| 21 | <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> |
| 22 | |
| 23 | <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 24 | <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="StringIO.html">StringIO</a><br> |
Joe Gregorio | 3d55ac5 | 2012-02-21 10:11:19 -0500 | [diff] [blame] | 25 | <a href="base64.html">base64</a><br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 26 | <a href="copy.html">copy</a><br> |
Joe Gregorio | 3d55ac5 | 2012-02-21 10:11:19 -0500 | [diff] [blame] | 27 | </td><td width="25%" valign=top><a href="gzip.html">gzip</a><br> |
| 28 | <a href="httplib2.html">httplib2</a><br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 29 | <a href="apiclient.mimeparse.html">apiclient.mimeparse</a><br> |
Joe Gregorio | 3d55ac5 | 2012-02-21 10:11:19 -0500 | [diff] [blame] | 30 | </td><td width="25%" valign=top><a href="mimetypes.html">mimetypes</a><br> |
| 31 | <a href="os.html">os</a><br> |
| 32 | <a href="json.html">json</a><br> |
| 33 | </td><td width="25%" valign=top><a href="urllib.html">urllib</a><br> |
| 34 | <a href="urlparse.html">urlparse</a><br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 35 | <a href="uuid.html">uuid</a><br> |
| 36 | </td></tr></table></td></tr></table><p> |
Joe Gregorio | 6e53703 | 2011-02-09 23:04:26 -0500 | [diff] [blame] | 37 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 38 | <tr bgcolor="#ee77aa"> |
| 39 | <td colspan=3 valign=bottom> <br> |
| 40 | <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> |
| 41 | |
| 42 | <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> |
| 43 | <td width="100%"><dl> |
| 44 | <dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> |
| 45 | </font></dt><dd> |
| 46 | <dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame^] | 47 | <dt><font face="helvetica, arial"><a href="apiclient.http.html#BatchHttpRequest">BatchHttpRequest</a> |
| 48 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#HttpMock">HttpMock</a> |
| 49 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#HttpMockSequence">HttpMockSequence</a> |
| 50 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#HttpRequest">HttpRequest</a> |
| 51 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#HttpRequestMock">HttpRequestMock</a> |
| 52 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#MediaUpload">MediaUpload</a> |
| 53 | </font></dt><dd> |
| 54 | <dl> |
| 55 | <dt><font face="helvetica, arial"><a href="apiclient.http.html#MediaFileUpload">MediaFileUpload</a> |
| 56 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#MediaInMemoryUpload">MediaInMemoryUpload</a> |
| 57 | </font></dt></dl> |
| 58 | </dd> |
| 59 | <dt><font face="helvetica, arial"><a href="apiclient.http.html#MediaUploadProgress">MediaUploadProgress</a> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 60 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#RequestMockBuilder">RequestMockBuilder</a> |
| 61 | </font></dt></dl> |
| 62 | </dd> |
| 63 | </dl> |
| 64 | <p> |
| 65 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 66 | <tr bgcolor="#ffc8d8"> |
| 67 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame^] | 68 | <font color="#000000" face="helvetica, arial"><a name="BatchHttpRequest">class <strong>BatchHttpRequest</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 69 | |
| 70 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 71 | <td colspan=2><tt>Batches multiple <a href="#HttpRequest">HttpRequest</a> objects into a single HTTP request.<br> </tt></td></tr> |
| 72 | <tr><td> </td> |
| 73 | <td width="100%">Methods defined here:<br> |
| 74 | <dl><dt><a name="BatchHttpRequest-__init__"><strong>__init__</strong></a>(self, callback<font color="#909090">=None</font>, batch_uri<font color="#909090">=None</font>)</dt><dd><tt>Constructor for a <a href="#BatchHttpRequest">BatchHttpRequest</a>.<br> |
| 75 | <br> |
| 76 | Args:<br> |
| 77 | callback: callable, A callback to be called for each response, of the<br> |
| 78 | form callback(id, response). The first parameter is the request id, and<br> |
| 79 | the second is the deserialized response <a href="__builtin__.html#object">object</a>.<br> |
| 80 | batch_uri: string, URI to send batch requests to.</tt></dd></dl> |
| 81 | |
| 82 | <dl><dt><a name="BatchHttpRequest-add"><strong>add</strong></a>(self, request, callback<font color="#909090">=None</font>, request_id<font color="#909090">=None</font>)</dt><dd><tt>Add a new request.<br> |
| 83 | <br> |
| 84 | Every callback added will be paired with a unique id, the request_id. That<br> |
| 85 | unique id will be passed back to the callback when the response comes back<br> |
| 86 | from the server. The default behavior is to have the library generate it's<br> |
| 87 | own unique id. If the caller passes in a request_id then they must ensure<br> |
| 88 | uniqueness for each request_id, and if they are not an exception is<br> |
| 89 | raised. Callers should either supply all request_ids or nevery supply a<br> |
| 90 | request id, to avoid such an error.<br> |
| 91 | <br> |
| 92 | Args:<br> |
| 93 | request: <a href="#HttpRequest">HttpRequest</a>, Request to add to the batch.<br> |
| 94 | callback: callable, A callback to be called for this response, of the<br> |
| 95 | form callback(id, response). The first parameter is the request id, and<br> |
| 96 | the second is the deserialized response <a href="__builtin__.html#object">object</a>.<br> |
| 97 | request_id: string, A unique id for the request. The id will be passed to<br> |
| 98 | the callback with the response.<br> |
| 99 | <br> |
| 100 | Returns:<br> |
| 101 | None<br> |
| 102 | <br> |
| 103 | Raises:<br> |
| 104 | BatchError if a resumable request is added to a batch.<br> |
| 105 | KeyError is the request_id is not unique.</tt></dd></dl> |
| 106 | |
| 107 | <dl><dt><a name="BatchHttpRequest-execute"><strong>execute</strong></a>(self, http<font color="#909090">=None</font>)</dt><dd><tt>Execute all the requests as a single batched HTTP request.<br> |
| 108 | <br> |
| 109 | Args:<br> |
| 110 | http: httplib2.Http, an http <a href="__builtin__.html#object">object</a> to be used in place of the one the<br> |
| 111 | <a href="#HttpRequest">HttpRequest</a> request <a href="__builtin__.html#object">object</a> was constructed with. If one isn't supplied<br> |
| 112 | then use a http <a href="__builtin__.html#object">object</a> from the requests in this batch.<br> |
| 113 | <br> |
| 114 | Returns:<br> |
| 115 | None<br> |
| 116 | <br> |
| 117 | Raises:<br> |
| 118 | httplib2.Error if a transport error has occured.<br> |
| 119 | apiclient.errors.BatchError if the response is the wrong format.</tt></dd></dl> |
| 120 | |
| 121 | <hr> |
| 122 | Data descriptors defined here:<br> |
| 123 | <dl><dt><strong>__dict__</strong></dt> |
| 124 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 125 | </dl> |
| 126 | <dl><dt><strong>__weakref__</strong></dt> |
| 127 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 128 | </dl> |
| 129 | </td></tr></table> <p> |
| 130 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 131 | <tr bgcolor="#ffc8d8"> |
| 132 | <td colspan=3 valign=bottom> <br> |
| 133 | <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> |
| 134 | |
| 135 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 136 | <td colspan=2><tt>Mock of httplib2.Http<br> </tt></td></tr> |
| 137 | <tr><td> </td> |
| 138 | <td width="100%">Methods defined here:<br> |
| 139 | <dl><dt><a name="HttpMock-__init__"><strong>__init__</strong></a>(self, filename, headers<font color="#909090">=None</font>)</dt><dd><tt>Args:<br> |
| 140 | filename: string, absolute filename to read response from<br> |
| 141 | headers: dict, header to return with response</tt></dd></dl> |
| 142 | |
| 143 | <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> |
| 144 | |
| 145 | <hr> |
| 146 | Data descriptors defined here:<br> |
| 147 | <dl><dt><strong>__dict__</strong></dt> |
| 148 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 149 | </dl> |
| 150 | <dl><dt><strong>__weakref__</strong></dt> |
| 151 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 152 | </dl> |
| 153 | </td></tr></table> <p> |
| 154 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 155 | <tr bgcolor="#ffc8d8"> |
| 156 | <td colspan=3 valign=bottom> <br> |
| 157 | <font color="#000000" face="helvetica, arial"><a name="HttpMockSequence">class <strong>HttpMockSequence</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 158 | |
| 159 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 160 | <td colspan=2><tt>Mock of httplib2.Http<br> |
| 161 | <br> |
| 162 | Mocks a sequence of calls to request returning different responses for each<br> |
| 163 | call. Create an instance initialized with the desired response headers<br> |
| 164 | and content and then use as if an httplib2.Http instance.<br> |
| 165 | <br> |
| 166 | http = <a href="#HttpMockSequence">HttpMockSequence</a>([<br> |
| 167 | ({'status': '401'}, ''),<br> |
| 168 | ({'status': '200'}, '{"access_token":"1/3w","expires_in":3600}'),<br> |
| 169 | ({'status': '200'}, 'echo_request_headers'),<br> |
| 170 | ])<br> |
| 171 | resp, content = http.<a href="#HttpMockSequence-request">request</a>("<a href="http://examples.com">http://examples.com</a>")<br> |
| 172 | <br> |
| 173 | There are special values you can pass in for content to trigger<br> |
| 174 | behavours that are helpful in testing.<br> |
| 175 | <br> |
| 176 | 'echo_request_headers' means return the request headers in the response body<br> |
| 177 | 'echo_request_headers_as_json' means return the request headers in<br> |
| 178 | the response body<br> |
| 179 | 'echo_request_body' means return the request body in the response body<br> |
| 180 | 'echo_request_uri' means return the request uri in the response body<br> </tt></td></tr> |
| 181 | <tr><td> </td> |
| 182 | <td width="100%">Methods defined here:<br> |
| 183 | <dl><dt><a name="HttpMockSequence-__init__"><strong>__init__</strong></a>(self, iterable)</dt><dd><tt>Args:<br> |
| 184 | iterable: iterable, a sequence of pairs of (headers, body)</tt></dd></dl> |
| 185 | |
| 186 | <dl><dt><a name="HttpMockSequence-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> |
| 187 | |
| 188 | <hr> |
| 189 | Data descriptors defined here:<br> |
| 190 | <dl><dt><strong>__dict__</strong></dt> |
| 191 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 192 | </dl> |
| 193 | <dl><dt><strong>__weakref__</strong></dt> |
| 194 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 195 | </dl> |
| 196 | </td></tr></table> <p> |
| 197 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 198 | <tr bgcolor="#ffc8d8"> |
| 199 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 200 | <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> |
| 201 | |
| 202 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 203 | <td colspan=2><tt>Encapsulates a single HTTP request.<br> </tt></td></tr> |
| 204 | <tr><td> </td> |
| 205 | <td width="100%">Methods defined here:<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 206 | <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>, resumable<font color="#909090">=None</font>)</dt><dd><tt>Constructor for an <a href="#HttpRequest">HttpRequest</a>.<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 207 | <br> |
| 208 | Args:<br> |
| 209 | http: httplib2.Http, the transport <a href="__builtin__.html#object">object</a> to use to make a request<br> |
Joe Gregorio | abda96f | 2011-02-11 20:19:33 -0500 | [diff] [blame] | 210 | postproc: callable, called on the HTTP response and content to transform<br> |
| 211 | it into a data <a href="__builtin__.html#object">object</a> before returning, or raising an exception<br> |
| 212 | on an error.<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 213 | uri: string, the absolute URI to send the request to<br> |
| 214 | method: string, the HTTP method to use<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 215 | body: string, the request body of the HTTP request,<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 216 | headers: dict, the HTTP request headers<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 217 | methodId: string, a unique identifier for the API method being called.<br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame^] | 218 | resumable: <a href="#MediaUpload">MediaUpload</a>, None if this is not a resumbale request.</tt></dd></dl> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 219 | |
| 220 | <dl><dt><a name="HttpRequest-execute"><strong>execute</strong></a>(self, http<font color="#909090">=None</font>)</dt><dd><tt>Execute the request.<br> |
| 221 | <br> |
| 222 | Args:<br> |
| 223 | http: httplib2.Http, an http <a href="__builtin__.html#object">object</a> to be used in place of the<br> |
| 224 | one the <a href="#HttpRequest">HttpRequest</a> request <a href="__builtin__.html#object">object</a> was constructed with.<br> |
| 225 | <br> |
| 226 | Returns:<br> |
| 227 | A deserialized <a href="__builtin__.html#object">object</a> model of the response body as determined<br> |
| 228 | by the postproc.<br> |
| 229 | <br> |
| 230 | Raises:<br> |
| 231 | apiclient.errors.HttpError if the response was not a 2xx.<br> |
| 232 | httplib2.Error if a transport error has occured.</tt></dd></dl> |
| 233 | |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 234 | <dl><dt><a name="HttpRequest-next_chunk"><strong>next_chunk</strong></a>(self, http<font color="#909090">=None</font>)</dt><dd><tt>Execute the next step of a resumable upload.<br> |
| 235 | <br> |
| 236 | Can only be used if the method being executed supports media uploads and<br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame^] | 237 | the <a href="#MediaUpload">MediaUpload</a> <a href="__builtin__.html#object">object</a> passed in was flagged as using resumable upload.<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 238 | <br> |
| 239 | Example:<br> |
| 240 | <br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame^] | 241 | media = <a href="#MediaFileUpload">MediaFileUpload</a>('smiley.png', mimetype='image/png',<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 242 | chunksize=1000, resumable=True)<br> |
| 243 | request = service.objects().insert(<br> |
| 244 | bucket=buckets['items'][0]['id'],<br> |
| 245 | name='smiley.png',<br> |
| 246 | media_body=media)<br> |
| 247 | <br> |
| 248 | response = None<br> |
| 249 | while response is None:<br> |
| 250 | status, response = request.<a href="#HttpRequest-next_chunk">next_chunk</a>()<br> |
| 251 | if status:<br> |
| 252 | print "Upload %d%% complete." % int(status.progress() * 100)<br> |
| 253 | <br> |
| 254 | <br> |
| 255 | Returns:<br> |
| 256 | (status, body): (ResumableMediaStatus, <a href="__builtin__.html#object">object</a>)<br> |
| 257 | The body will be None until the resumable media is fully uploaded.</tt></dd></dl> |
| 258 | |
| 259 | <dl><dt><a name="HttpRequest-to_json"><strong>to_json</strong></a>(self)</dt><dd><tt>Returns a JSON representation of the <a href="#HttpRequest">HttpRequest</a>.</tt></dd></dl> |
| 260 | |
| 261 | <hr> |
| 262 | Static methods defined here:<br> |
| 263 | <dl><dt><a name="HttpRequest-from_json"><strong>from_json</strong></a>(s, http, postproc)</dt><dd><tt>Returns an <a href="#HttpRequest">HttpRequest</a> populated with info from a JSON <a href="__builtin__.html#object">object</a>.</tt></dd></dl> |
| 264 | |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 265 | <hr> |
| 266 | Data descriptors defined here:<br> |
| 267 | <dl><dt><strong>__dict__</strong></dt> |
| 268 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 269 | </dl> |
| 270 | <dl><dt><strong>__weakref__</strong></dt> |
| 271 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 272 | </dl> |
| 273 | </td></tr></table> <p> |
| 274 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 275 | <tr bgcolor="#ffc8d8"> |
| 276 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame^] | 277 | <font color="#000000" face="helvetica, arial"><a name="HttpRequestMock">class <strong>HttpRequestMock</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 278 | |
| 279 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 280 | <td colspan=2><tt>Mock of <a href="#HttpRequest">HttpRequest</a>.<br> |
| 281 | <br> |
| 282 | Do not construct directly, instead use <a href="#RequestMockBuilder">RequestMockBuilder</a>.<br> </tt></td></tr> |
| 283 | <tr><td> </td> |
| 284 | <td width="100%">Methods defined here:<br> |
| 285 | <dl><dt><a name="HttpRequestMock-__init__"><strong>__init__</strong></a>(self, resp, content, postproc)</dt><dd><tt>Constructor for <a href="#HttpRequestMock">HttpRequestMock</a><br> |
| 286 | <br> |
| 287 | Args:<br> |
| 288 | resp: httplib2.Response, the response to emulate coming from the request<br> |
| 289 | content: string, the response body<br> |
| 290 | postproc: callable, the post processing function usually supplied by<br> |
| 291 | the model class. See model.JsonModel.response() as an example.</tt></dd></dl> |
| 292 | |
| 293 | <dl><dt><a name="HttpRequestMock-execute"><strong>execute</strong></a>(self, http<font color="#909090">=None</font>)</dt><dd><tt>Execute the request.<br> |
| 294 | <br> |
| 295 | Same behavior as <a href="#HttpRequest">HttpRequest</a>.<a href="#HttpRequestMock-execute">execute</a>(), but the response is<br> |
| 296 | mocked and not really from an HTTP request/response.</tt></dd></dl> |
| 297 | |
| 298 | <hr> |
| 299 | Data descriptors defined here:<br> |
| 300 | <dl><dt><strong>__dict__</strong></dt> |
| 301 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 302 | </dl> |
| 303 | <dl><dt><strong>__weakref__</strong></dt> |
| 304 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 305 | </dl> |
| 306 | </td></tr></table> <p> |
| 307 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 308 | <tr bgcolor="#ffc8d8"> |
| 309 | <td colspan=3 valign=bottom> <br> |
| 310 | <font color="#000000" face="helvetica, arial"><a name="MediaFileUpload">class <strong>MediaFileUpload</strong></a>(<a href="apiclient.http.html#MediaUpload">MediaUpload</a>)</font></td></tr> |
| 311 | |
| 312 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 313 | <td colspan=2><tt>A <a href="#MediaUpload">MediaUpload</a> for a file.<br> |
| 314 | <br> |
| 315 | Construct a <a href="#MediaFileUpload">MediaFileUpload</a> and pass as the media_body parameter of the<br> |
| 316 | method. For example, if we had a service that allowed uploading images:<br> |
| 317 | <br> |
| 318 | <br> |
| 319 | media = <a href="#MediaFileUpload">MediaFileUpload</a>('smiley.png', mimetype='image/png', chunksize=1000,<br> |
| 320 | resumable=True)<br> |
| 321 | service.objects().insert(<br> |
| 322 | bucket=buckets['items'][0]['id'],<br> |
| 323 | name='smiley.png',<br> |
| 324 | media_body=media).execute()<br> </tt></td></tr> |
| 325 | <tr><td> </td> |
| 326 | <td width="100%"><dl><dt>Method resolution order:</dt> |
| 327 | <dd><a href="apiclient.http.html#MediaFileUpload">MediaFileUpload</a></dd> |
| 328 | <dd><a href="apiclient.http.html#MediaUpload">MediaUpload</a></dd> |
| 329 | <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> |
| 330 | </dl> |
| 331 | <hr> |
| 332 | Methods defined here:<br> |
| 333 | <dl><dt><a name="MediaFileUpload-__init__"><strong>__init__</strong></a>(self, filename, mimetype<font color="#909090">=None</font>, chunksize<font color="#909090">=262144</font>, resumable<font color="#909090">=False</font>)</dt><dd><tt>Constructor.<br> |
| 334 | <br> |
| 335 | Args:<br> |
| 336 | filename: string, Name of the file.<br> |
| 337 | mimetype: string, Mime-type of the file. If None then a mime-type will be<br> |
| 338 | guessed from the file extension.<br> |
| 339 | chunksize: int, File will be uploaded in chunks of this many bytes. Only<br> |
| 340 | used if resumable=True.<br> |
| 341 | resumable: bool, True if this is a resumable upload. False means upload<br> |
| 342 | in a single request.</tt></dd></dl> |
| 343 | |
| 344 | <dl><dt><a name="MediaFileUpload-chunksize"><strong>chunksize</strong></a>(self)</dt></dl> |
| 345 | |
| 346 | <dl><dt><a name="MediaFileUpload-getbytes"><strong>getbytes</strong></a>(self, begin, length)</dt><dd><tt>Get bytes from the media.<br> |
| 347 | <br> |
| 348 | Args:<br> |
| 349 | begin: int, offset from beginning of file.<br> |
| 350 | length: int, number of bytes to read, starting at begin.<br> |
| 351 | <br> |
| 352 | Returns:<br> |
| 353 | A string of bytes read. May be shorted than length if EOF was reached<br> |
| 354 | first.</tt></dd></dl> |
| 355 | |
| 356 | <dl><dt><a name="MediaFileUpload-mimetype"><strong>mimetype</strong></a>(self)</dt></dl> |
| 357 | |
| 358 | <dl><dt><a name="MediaFileUpload-resumable"><strong>resumable</strong></a>(self)</dt></dl> |
| 359 | |
| 360 | <dl><dt><a name="MediaFileUpload-size"><strong>size</strong></a>(self)</dt></dl> |
| 361 | |
| 362 | <dl><dt><a name="MediaFileUpload-to_json"><strong>to_json</strong></a>(self)</dt><dd><tt>Creating a JSON representation of an instance of Credentials.<br> |
| 363 | <br> |
| 364 | Returns:<br> |
| 365 | string, a JSON representation of this instance, suitable to pass to<br> |
| 366 | <a href="#MediaFileUpload-from_json">from_json</a>().</tt></dd></dl> |
| 367 | |
| 368 | <hr> |
| 369 | Static methods defined here:<br> |
| 370 | <dl><dt><a name="MediaFileUpload-from_json"><strong>from_json</strong></a>(s)</dt></dl> |
| 371 | |
| 372 | <hr> |
| 373 | Class methods inherited from <a href="apiclient.http.html#MediaUpload">MediaUpload</a>:<br> |
| 374 | <dl><dt><a name="MediaFileUpload-new_from_json"><strong>new_from_json</strong></a>(cls, s)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Utility class method to instantiate a <a href="#MediaUpload">MediaUpload</a> subclass from a JSON<br> |
| 375 | representation produced by <a href="#MediaFileUpload-to_json">to_json</a>().<br> |
| 376 | <br> |
| 377 | Args:<br> |
| 378 | s: string, JSON from <a href="#MediaFileUpload-to_json">to_json</a>().<br> |
| 379 | <br> |
| 380 | Returns:<br> |
| 381 | An instance of the subclass of <a href="#MediaUpload">MediaUpload</a> that was serialized with<br> |
| 382 | <a href="#MediaFileUpload-to_json">to_json</a>().</tt></dd></dl> |
| 383 | |
| 384 | <hr> |
| 385 | Data descriptors inherited from <a href="apiclient.http.html#MediaUpload">MediaUpload</a>:<br> |
| 386 | <dl><dt><strong>__dict__</strong></dt> |
| 387 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 388 | </dl> |
| 389 | <dl><dt><strong>__weakref__</strong></dt> |
| 390 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 391 | </dl> |
| 392 | </td></tr></table> <p> |
| 393 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 394 | <tr bgcolor="#ffc8d8"> |
| 395 | <td colspan=3 valign=bottom> <br> |
| 396 | <font color="#000000" face="helvetica, arial"><a name="MediaInMemoryUpload">class <strong>MediaInMemoryUpload</strong></a>(<a href="apiclient.http.html#MediaUpload">MediaUpload</a>)</font></td></tr> |
| 397 | |
| 398 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 399 | <td colspan=2><tt><a href="#MediaUpload">MediaUpload</a> for a chunk of bytes.<br> |
| 400 | <br> |
| 401 | Construct a <a href="#MediaFileUpload">MediaFileUpload</a> and pass as the media_body parameter of the<br> |
| 402 | method. For example, if we had a service that allowed plain text:<br> </tt></td></tr> |
| 403 | <tr><td> </td> |
| 404 | <td width="100%"><dl><dt>Method resolution order:</dt> |
| 405 | <dd><a href="apiclient.http.html#MediaInMemoryUpload">MediaInMemoryUpload</a></dd> |
| 406 | <dd><a href="apiclient.http.html#MediaUpload">MediaUpload</a></dd> |
| 407 | <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> |
| 408 | </dl> |
| 409 | <hr> |
| 410 | Methods defined here:<br> |
| 411 | <dl><dt><a name="MediaInMemoryUpload-__init__"><strong>__init__</strong></a>(self, body, mimetype<font color="#909090">='application/octet-stream'</font>, chunksize<font color="#909090">=262144</font>, resumable<font color="#909090">=False</font>)</dt><dd><tt>Create a new MediaBytesUpload.<br> |
| 412 | <br> |
| 413 | Args:<br> |
| 414 | body: string, Bytes of body content.<br> |
| 415 | mimetype: string, Mime-type of the file or default of<br> |
| 416 | 'application/octet-stream'.<br> |
| 417 | chunksize: int, File will be uploaded in chunks of this many bytes. Only<br> |
| 418 | used if resumable=True.<br> |
| 419 | resumable: bool, True if this is a resumable upload. False means upload<br> |
| 420 | in a single request.</tt></dd></dl> |
| 421 | |
| 422 | <dl><dt><a name="MediaInMemoryUpload-chunksize"><strong>chunksize</strong></a>(self)</dt><dd><tt>Chunk size for resumable uploads.<br> |
| 423 | <br> |
| 424 | Returns:<br> |
| 425 | Chunk size in bytes.</tt></dd></dl> |
| 426 | |
| 427 | <dl><dt><a name="MediaInMemoryUpload-getbytes"><strong>getbytes</strong></a>(self, begin, length)</dt><dd><tt>Get bytes from the media.<br> |
| 428 | <br> |
| 429 | Args:<br> |
| 430 | begin: int, offset from beginning of file.<br> |
| 431 | length: int, number of bytes to read, starting at begin.<br> |
| 432 | <br> |
| 433 | Returns:<br> |
| 434 | A string of bytes read. May be shorter than length if EOF was reached<br> |
| 435 | first.</tt></dd></dl> |
| 436 | |
| 437 | <dl><dt><a name="MediaInMemoryUpload-mimetype"><strong>mimetype</strong></a>(self)</dt><dd><tt>Mime type of the body.<br> |
| 438 | <br> |
| 439 | Returns:<br> |
| 440 | Mime type.</tt></dd></dl> |
| 441 | |
| 442 | <dl><dt><a name="MediaInMemoryUpload-resumable"><strong>resumable</strong></a>(self)</dt><dd><tt>Whether this upload is resumable.<br> |
| 443 | <br> |
| 444 | Returns:<br> |
| 445 | True if resumable upload or False.</tt></dd></dl> |
| 446 | |
| 447 | <dl><dt><a name="MediaInMemoryUpload-size"><strong>size</strong></a>(self)</dt><dd><tt>Size of upload.<br> |
| 448 | <br> |
| 449 | Returns:<br> |
| 450 | Size of the body.</tt></dd></dl> |
| 451 | |
| 452 | <dl><dt><a name="MediaInMemoryUpload-to_json"><strong>to_json</strong></a>(self)</dt><dd><tt>Create a JSON representation of a <a href="#MediaInMemoryUpload">MediaInMemoryUpload</a>.<br> |
| 453 | <br> |
| 454 | Returns:<br> |
| 455 | string, a JSON representation of this instance, suitable to pass to<br> |
| 456 | <a href="#MediaInMemoryUpload-from_json">from_json</a>().</tt></dd></dl> |
| 457 | |
| 458 | <hr> |
| 459 | Static methods defined here:<br> |
| 460 | <dl><dt><a name="MediaInMemoryUpload-from_json"><strong>from_json</strong></a>(s)</dt></dl> |
| 461 | |
| 462 | <hr> |
| 463 | Class methods inherited from <a href="apiclient.http.html#MediaUpload">MediaUpload</a>:<br> |
| 464 | <dl><dt><a name="MediaInMemoryUpload-new_from_json"><strong>new_from_json</strong></a>(cls, s)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Utility class method to instantiate a <a href="#MediaUpload">MediaUpload</a> subclass from a JSON<br> |
| 465 | representation produced by <a href="#MediaInMemoryUpload-to_json">to_json</a>().<br> |
| 466 | <br> |
| 467 | Args:<br> |
| 468 | s: string, JSON from <a href="#MediaInMemoryUpload-to_json">to_json</a>().<br> |
| 469 | <br> |
| 470 | Returns:<br> |
| 471 | An instance of the subclass of <a href="#MediaUpload">MediaUpload</a> that was serialized with<br> |
| 472 | <a href="#MediaInMemoryUpload-to_json">to_json</a>().</tt></dd></dl> |
| 473 | |
| 474 | <hr> |
| 475 | Data descriptors inherited from <a href="apiclient.http.html#MediaUpload">MediaUpload</a>:<br> |
| 476 | <dl><dt><strong>__dict__</strong></dt> |
| 477 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 478 | </dl> |
| 479 | <dl><dt><strong>__weakref__</strong></dt> |
| 480 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 481 | </dl> |
| 482 | </td></tr></table> <p> |
| 483 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 484 | <tr bgcolor="#ffc8d8"> |
| 485 | <td colspan=3 valign=bottom> <br> |
| 486 | <font color="#000000" face="helvetica, arial"><a name="MediaUpload">class <strong>MediaUpload</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 487 | |
| 488 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 489 | <td colspan=2><tt>Describes a media <a href="__builtin__.html#object">object</a> to upload.<br> |
| 490 | <br> |
| 491 | Base class that defines the interface of <a href="#MediaUpload">MediaUpload</a> subclasses.<br> </tt></td></tr> |
| 492 | <tr><td> </td> |
| 493 | <td width="100%">Methods defined here:<br> |
| 494 | <dl><dt><a name="MediaUpload-chunksize"><strong>chunksize</strong></a>(self)</dt></dl> |
| 495 | |
| 496 | <dl><dt><a name="MediaUpload-getbytes"><strong>getbytes</strong></a>(self, begin, end)</dt></dl> |
| 497 | |
| 498 | <dl><dt><a name="MediaUpload-mimetype"><strong>mimetype</strong></a>(self)</dt></dl> |
| 499 | |
| 500 | <dl><dt><a name="MediaUpload-resumable"><strong>resumable</strong></a>(self)</dt></dl> |
| 501 | |
| 502 | <dl><dt><a name="MediaUpload-size"><strong>size</strong></a>(self)</dt></dl> |
| 503 | |
| 504 | <dl><dt><a name="MediaUpload-to_json"><strong>to_json</strong></a>(self)</dt><dd><tt>Create a JSON representation of an instance of <a href="#MediaUpload">MediaUpload</a>.<br> |
| 505 | <br> |
| 506 | Returns:<br> |
| 507 | string, a JSON representation of this instance, suitable to pass to<br> |
| 508 | from_json().</tt></dd></dl> |
| 509 | |
| 510 | <hr> |
| 511 | Class methods defined here:<br> |
| 512 | <dl><dt><a name="MediaUpload-new_from_json"><strong>new_from_json</strong></a>(cls, s)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Utility class method to instantiate a <a href="#MediaUpload">MediaUpload</a> subclass from a JSON<br> |
| 513 | representation produced by <a href="#MediaUpload-to_json">to_json</a>().<br> |
| 514 | <br> |
| 515 | Args:<br> |
| 516 | s: string, JSON from <a href="#MediaUpload-to_json">to_json</a>().<br> |
| 517 | <br> |
| 518 | Returns:<br> |
| 519 | An instance of the subclass of <a href="#MediaUpload">MediaUpload</a> that was serialized with<br> |
| 520 | <a href="#MediaUpload-to_json">to_json</a>().</tt></dd></dl> |
| 521 | |
| 522 | <hr> |
| 523 | Data descriptors defined here:<br> |
| 524 | <dl><dt><strong>__dict__</strong></dt> |
| 525 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 526 | </dl> |
| 527 | <dl><dt><strong>__weakref__</strong></dt> |
| 528 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 529 | </dl> |
| 530 | </td></tr></table> <p> |
| 531 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 532 | <tr bgcolor="#ffc8d8"> |
| 533 | <td colspan=3 valign=bottom> <br> |
| 534 | <font color="#000000" face="helvetica, arial"><a name="MediaUploadProgress">class <strong>MediaUploadProgress</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 535 | |
| 536 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 537 | <td colspan=2><tt>Status of a resumable upload.<br> </tt></td></tr> |
| 538 | <tr><td> </td> |
| 539 | <td width="100%">Methods defined here:<br> |
| 540 | <dl><dt><a name="MediaUploadProgress-__init__"><strong>__init__</strong></a>(self, resumable_progress, total_size)</dt><dd><tt>Constructor.<br> |
| 541 | <br> |
| 542 | Args:<br> |
| 543 | resumable_progress: int, bytes sent so far.<br> |
| 544 | total_size: int, total bytes in complete upload.</tt></dd></dl> |
| 545 | |
| 546 | <dl><dt><a name="MediaUploadProgress-progress"><strong>progress</strong></a>(self)</dt><dd><tt>Percent of upload completed, as a float.</tt></dd></dl> |
| 547 | |
| 548 | <hr> |
| 549 | Data descriptors defined here:<br> |
| 550 | <dl><dt><strong>__dict__</strong></dt> |
| 551 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 552 | </dl> |
| 553 | <dl><dt><strong>__weakref__</strong></dt> |
| 554 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 555 | </dl> |
| 556 | </td></tr></table> <p> |
| 557 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 558 | <tr bgcolor="#ffc8d8"> |
| 559 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 560 | <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> |
| 561 | |
| 562 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 563 | <td colspan=2><tt>A simple mock of <a href="#HttpRequest">HttpRequest</a><br> |
| 564 | <br> |
| 565 | Pass in a dictionary to the constructor that maps request methodIds to<br> |
Joe Gregorio | a845167 | 2011-09-15 09:53:21 -0400 | [diff] [blame] | 566 | tuples of (httplib2.Response, content, opt_expected_body) that should be<br> |
| 567 | returned when that method is called. None may also be passed in for the<br> |
| 568 | httplib2.Response, in which case a 200 OK response will be generated.<br> |
| 569 | If an opt_expected_body (str or dict) is provided, it will be compared to<br> |
| 570 | the body and UnexpectedBodyError will be raised on inequality.<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 571 | <br> |
| 572 | Example:<br> |
| 573 | response = '{"data": {"id": "tag:google.c...'<br> |
| 574 | requestBuilder = <a href="#RequestMockBuilder">RequestMockBuilder</a>(<br> |
| 575 | {<br> |
Joe Gregorio | c4fc095 | 2011-11-09 12:21:11 -0500 | [diff] [blame] | 576 | 'plus.activities.get': (None, response),<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 577 | }<br> |
| 578 | )<br> |
Joe Gregorio | c4fc095 | 2011-11-09 12:21:11 -0500 | [diff] [blame] | 579 | apiclient.discovery.build("plus", "v1", requestBuilder=requestBuilder)<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 580 | <br> |
| 581 | Methods that you do not supply a response for will return a<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 582 | 200 OK with an empty string as the response content or raise an excpetion<br> |
| 583 | if check_unexpected is set to True. The methodId is taken from the rpcName<br> |
Joe Gregorio | a845167 | 2011-09-15 09:53:21 -0400 | [diff] [blame] | 584 | in the discovery document.<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 585 | <br> |
| 586 | For more details see the project wiki.<br> </tt></td></tr> |
| 587 | <tr><td> </td> |
| 588 | <td width="100%">Methods defined here:<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 589 | <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>, resumable<font color="#909090">=None</font>)</dt><dd><tt>Implements the callable interface that discovery.build() expects<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 590 | of requestBuilder, which is to build an <a href="__builtin__.html#object">object</a> compatible with<br> |
| 591 | <a href="#HttpRequest">HttpRequest</a>.execute(). See that method for the description of the<br> |
| 592 | parameters and the expected response.</tt></dd></dl> |
| 593 | |
Joe Gregorio | a845167 | 2011-09-15 09:53:21 -0400 | [diff] [blame] | 594 | <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> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 595 | <br> |
| 596 | The constructed <a href="__builtin__.html#object">object</a> should be a callable <a href="__builtin__.html#object">object</a><br> |
| 597 | that can replace the class HttpResponse.<br> |
| 598 | <br> |
| 599 | responses - A dictionary that maps methodIds into tuples<br> |
| 600 | of (httplib2.Response, content). The methodId<br> |
| 601 | comes from the 'rpcName' field in the discovery<br> |
Joe Gregorio | a845167 | 2011-09-15 09:53:21 -0400 | [diff] [blame] | 602 | document.<br> |
| 603 | check_unexpected - A boolean setting whether or not UnexpectedMethodError<br> |
| 604 | should be raised on unsupplied method.</tt></dd></dl> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 605 | |
| 606 | <hr> |
| 607 | Data descriptors defined here:<br> |
| 608 | <dl><dt><strong>__dict__</strong></dt> |
| 609 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 610 | </dl> |
| 611 | <dl><dt><strong>__weakref__</strong></dt> |
| 612 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 613 | </dl> |
| 614 | </td></tr></table></td></tr></table><p> |
| 615 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
Joe Gregorio | 20a5aa9 | 2011-04-01 17:44:25 -0400 | [diff] [blame] | 616 | <tr bgcolor="#eeaa77"> |
| 617 | <td colspan=3 valign=bottom> <br> |
| 618 | <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> |
| 619 | |
| 620 | <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame^] | 621 | <td width="100%"><dl><dt><a name="-set_user_agent"><strong>set_user_agent</strong></a>(http, user_agent)</dt><dd><tt>Set the user-agent on every request.<br> |
| 622 | <br> |
| 623 | Args:<br> |
| 624 | http - An instance of httplib2.Http<br> |
| 625 | or something that acts like it.<br> |
| 626 | user_agent: string, the value for the user-agent header.<br> |
| 627 | <br> |
| 628 | Returns:<br> |
| 629 | A modified instance of http that was passed in.<br> |
| 630 | <br> |
| 631 | Example:<br> |
| 632 | <br> |
| 633 | h = httplib2.Http()<br> |
| 634 | h = <a href="#-set_user_agent">set_user_agent</a>(h, "my-app-name/6.0")<br> |
| 635 | <br> |
| 636 | Most of the time the user-agent will be set doing auth, this is for the rare<br> |
| 637 | cases where you are accessing an unauthenticated endpoint.</tt></dd></dl> |
| 638 | <dl><dt><a name="-tunnel_patch"><strong>tunnel_patch</strong></a>(http)</dt><dd><tt>Tunnel PATCH requests over POST.<br> |
Joe Gregorio | 20a5aa9 | 2011-04-01 17:44:25 -0400 | [diff] [blame] | 639 | Args:<br> |
| 640 | http - An instance of httplib2.Http<br> |
| 641 | or something that acts like it.<br> |
| 642 | <br> |
| 643 | Returns:<br> |
| 644 | A modified instance of http that was passed in.<br> |
| 645 | <br> |
| 646 | Example:<br> |
| 647 | <br> |
| 648 | h = httplib2.Http()<br> |
| 649 | h = <a href="#-tunnel_patch">tunnel_patch</a>(h, "my-app-name/6.0")<br> |
| 650 | <br> |
| 651 | Useful if you are running on a platform that doesn't support PATCH.<br> |
| 652 | Apply this last if you are using OAuth 1.0, as changing the method<br> |
| 653 | will result in a different signature.</tt></dd></dl> |
| 654 | </td></tr></table><p> |
| 655 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 656 | <tr bgcolor="#55aa55"> |
| 657 | <td colspan=3 valign=bottom> <br> |
| 658 | <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> |
| 659 | |
| 660 | <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame^] | 661 | <td width="100%"><strong>__author__</strong> = 'jcgregorio@google.com (Joe Gregorio)'</td></tr></table><p> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 662 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 663 | <tr bgcolor="#7799ee"> |
| 664 | <td colspan=3 valign=bottom> <br> |
| 665 | <font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr> |
| 666 | |
| 667 | <tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td> |
| 668 | <td width="100%">jcgregorio@google.com (Joe Gregorio)</td></tr></table> |
| 669 | </body></html> |