Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 1 | <?xml version="1.0" encoding="ascii"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 3 | "DTD/xhtml1-transitional.dtd"> |
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 5 | <head> |
| 6 | <title>apiclient.http.BatchHttpRequest</title> |
| 7 | <link rel="stylesheet" href="epydoc.css" type="text/css" /> |
| 8 | <script type="text/javascript" src="epydoc.js"></script> |
| 9 | </head> |
| 10 | |
| 11 | <body bgcolor="white" text="black" link="blue" vlink="#204080" |
| 12 | alink="#204080"> |
| 13 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 14 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 15 | bgcolor="#a0c0ff" cellspacing="0"> |
| 16 | <tr valign="middle"> |
| 17 | |
| 18 | <!-- Tree link --> |
| 19 | <th> <a |
| 20 | href="module-tree.html">Trees</a> </th> |
| 21 | |
| 22 | <!-- Index link --> |
| 23 | <th> <a |
| 24 | href="identifier-index.html">Indices</a> </th> |
| 25 | |
| 26 | <!-- Help link --> |
| 27 | <th> <a |
| 28 | href="help.html">Help</a> </th> |
| 29 | |
| 30 | <th class="navbar" width="100%"></th> |
| 31 | </tr> |
| 32 | </table> |
| 33 | <table width="100%" cellpadding="0" cellspacing="0"> |
| 34 | <tr valign="top"> |
| 35 | <td width="100%"> |
| 36 | <span class="breadcrumbs"> |
| 37 | <a href="apiclient-module.html">Package apiclient</a> :: |
| 38 | <a href="apiclient.http-module.html">Module http</a> :: |
| 39 | Class BatchHttpRequest |
| 40 | </span> |
| 41 | </td> |
| 42 | <td> |
| 43 | <table cellpadding="0" cellspacing="0"> |
| 44 | <!-- hide/show private --> |
| 45 | <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink" |
| 46 | onclick="toggle_private();">hide private</a>]</span></td></tr> |
| 47 | <tr><td align="right"><span class="options" |
| 48 | >[<a href="frames.html" target="_top">frames</a |
| 49 | >] | <a href="apiclient.http.BatchHttpRequest-class.html" |
| 50 | target="_top">no frames</a>]</span></td></tr> |
| 51 | </table> |
| 52 | </td> |
| 53 | </tr> |
| 54 | </table> |
| 55 | <!-- ==================== CLASS DESCRIPTION ==================== --> |
| 56 | <h1 class="epydoc">Class BatchHttpRequest</h1><p class="nomargin-top"><span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest">source code</a></span></p> |
| 57 | <center> |
Joe Gregorio | 746096f | 2012-06-15 10:53:36 -0400 | [diff] [blame] | 58 | <center> <map id="class_hierarchy_for_batchhttpr" name="class_hierarchy_for_batchhttpr"> |
| 59 | <area shape="rect" href="apiclient.http.BatchHttpRequest-class.html" title="BatchHttpRequest" alt="" coords="5,5,133,32"/> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 60 | </map> |
Joe Gregorio | 746096f | 2012-06-15 10:53:36 -0400 | [diff] [blame] | 61 | <img src="class_hierarchy_for_batchhttpr.gif" alt='' usemap="#class_hierarchy_for_batchhttpr" ismap="ismap" class="graph-without-title" /> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 62 | </center> |
| 63 | </center> |
| 64 | <hr /> |
| 65 | <pre class="literalblock"> |
| 66 | Batches multiple HttpRequest objects into a single HTTP request. |
| 67 | |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 68 | Example: |
| 69 | from apiclient.http import BatchHttpRequest |
| 70 | |
Joe Gregorio | e7a0c47 | 2012-07-12 11:46:04 -0400 | [diff] [blame^] | 71 | def list_animals(request_id, response, exception): |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 72 | """Do something with the animals list response.""" |
Joe Gregorio | e7a0c47 | 2012-07-12 11:46:04 -0400 | [diff] [blame^] | 73 | if exception is not None: |
| 74 | # Do something with the exception. |
| 75 | pass |
| 76 | else: |
| 77 | # Do something with the response. |
| 78 | pass |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 79 | |
Joe Gregorio | e7a0c47 | 2012-07-12 11:46:04 -0400 | [diff] [blame^] | 80 | def list_farmers(request_id, response, exception): |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 81 | """Do something with the farmers list response.""" |
Joe Gregorio | e7a0c47 | 2012-07-12 11:46:04 -0400 | [diff] [blame^] | 82 | if exception is not None: |
| 83 | # Do something with the exception. |
| 84 | pass |
| 85 | else: |
| 86 | # Do something with the response. |
| 87 | pass |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 88 | |
| 89 | service = build('farm', 'v2') |
| 90 | |
| 91 | batch = BatchHttpRequest() |
| 92 | |
| 93 | batch.add(service.animals().list(), list_animals) |
| 94 | batch.add(service.farmers().list(), list_farmers) |
| 95 | batch.execute(http) |
| 96 | |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 97 | </pre> |
| 98 | |
| 99 | <!-- ==================== INSTANCE METHODS ==================== --> |
| 100 | <a name="section-InstanceMethods"></a> |
| 101 | <table class="summary" border="1" cellpadding="3" |
| 102 | cellspacing="0" width="100%" bgcolor="white"> |
| 103 | <tr bgcolor="#70b0f0" class="table-header"> |
| 104 | <td colspan="2" class="table-header"> |
| 105 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 106 | <tr valign="top"> |
| 107 | <td align="left"><span class="table-header">Instance Methods</span></td> |
| 108 | <td align="right" valign="top" |
| 109 | ><span class="options">[<a href="#section-InstanceMethods" |
| 110 | class="privatelink" onclick="toggle_private();" |
| 111 | >hide private</a>]</span></td> |
| 112 | </tr> |
| 113 | </table> |
| 114 | </td> |
| 115 | </tr> |
| 116 | <tr> |
| 117 | <td width="15%" align="right" valign="top" class="summary"> |
| 118 | <span class="summary-type"> </span> |
| 119 | </td><td class="summary"> |
| 120 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 121 | <tr> |
| 122 | <td><span class="summary-sig"><a href="apiclient.http.BatchHttpRequest-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>, |
| 123 | <span class="summary-sig-arg">callback</span>=<span class="summary-sig-default">None</span>, |
| 124 | <span class="summary-sig-arg">batch_uri</span>=<span class="summary-sig-default">None</span>)</span><br /> |
| 125 | Constructor for a BatchHttpRequest.</td> |
| 126 | <td align="right" valign="top"> |
| 127 | <span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest.__init__">source code</a></span> |
| 128 | |
| 129 | </td> |
| 130 | </tr> |
| 131 | </table> |
| 132 | |
| 133 | </td> |
| 134 | </tr> |
| 135 | <tr class="private"> |
| 136 | <td width="15%" align="right" valign="top" class="summary"> |
| 137 | <span class="summary-type"> </span> |
| 138 | </td><td class="summary"> |
| 139 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 140 | <tr> |
| 141 | <td><span class="summary-sig"><a href="apiclient.http.BatchHttpRequest-class.html#_refresh_and_apply_credentials" class="summary-sig-name" onclick="show_private();">_refresh_and_apply_credentials</a>(<span class="summary-sig-arg">self</span>, |
| 142 | <span class="summary-sig-arg">request</span>, |
| 143 | <span class="summary-sig-arg">http</span>)</span><br /> |
| 144 | Refresh the credentials and apply to the request.</td> |
| 145 | <td align="right" valign="top"> |
| 146 | <span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._refresh_and_apply_credentials">source code</a></span> |
| 147 | |
| 148 | </td> |
| 149 | </tr> |
| 150 | </table> |
| 151 | |
| 152 | </td> |
| 153 | </tr> |
| 154 | <tr class="private"> |
| 155 | <td width="15%" align="right" valign="top" class="summary"> |
| 156 | <span class="summary-type"> </span> |
| 157 | </td><td class="summary"> |
| 158 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 159 | <tr> |
| 160 | <td><span class="summary-sig"><a href="apiclient.http.BatchHttpRequest-class.html#_id_to_header" class="summary-sig-name" onclick="show_private();">_id_to_header</a>(<span class="summary-sig-arg">self</span>, |
| 161 | <span class="summary-sig-arg">id_</span>)</span><br /> |
| 162 | Convert an id to a Content-ID header value.</td> |
| 163 | <td align="right" valign="top"> |
| 164 | <span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._id_to_header">source code</a></span> |
| 165 | |
| 166 | </td> |
| 167 | </tr> |
| 168 | </table> |
| 169 | |
| 170 | </td> |
| 171 | </tr> |
| 172 | <tr class="private"> |
| 173 | <td width="15%" align="right" valign="top" class="summary"> |
| 174 | <span class="summary-type"> </span> |
| 175 | </td><td class="summary"> |
| 176 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 177 | <tr> |
| 178 | <td><span class="summary-sig"><a href="apiclient.http.BatchHttpRequest-class.html#_header_to_id" class="summary-sig-name" onclick="show_private();">_header_to_id</a>(<span class="summary-sig-arg">self</span>, |
| 179 | <span class="summary-sig-arg">header</span>)</span><br /> |
| 180 | Convert a Content-ID header value to an id.</td> |
| 181 | <td align="right" valign="top"> |
| 182 | <span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._header_to_id">source code</a></span> |
| 183 | |
| 184 | </td> |
| 185 | </tr> |
| 186 | </table> |
| 187 | |
| 188 | </td> |
| 189 | </tr> |
| 190 | <tr class="private"> |
| 191 | <td width="15%" align="right" valign="top" class="summary"> |
| 192 | <span class="summary-type"> </span> |
| 193 | </td><td class="summary"> |
| 194 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 195 | <tr> |
| 196 | <td><span class="summary-sig"><a href="apiclient.http.BatchHttpRequest-class.html#_serialize_request" class="summary-sig-name" onclick="show_private();">_serialize_request</a>(<span class="summary-sig-arg">self</span>, |
| 197 | <span class="summary-sig-arg">request</span>)</span><br /> |
| 198 | Convert an HttpRequest object into a string.</td> |
| 199 | <td align="right" valign="top"> |
| 200 | <span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._serialize_request">source code</a></span> |
| 201 | |
| 202 | </td> |
| 203 | </tr> |
| 204 | </table> |
| 205 | |
| 206 | </td> |
| 207 | </tr> |
| 208 | <tr class="private"> |
| 209 | <td width="15%" align="right" valign="top" class="summary"> |
| 210 | <span class="summary-type"> </span> |
| 211 | </td><td class="summary"> |
| 212 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 213 | <tr> |
| 214 | <td><span class="summary-sig"><a href="apiclient.http.BatchHttpRequest-class.html#_deserialize_response" class="summary-sig-name" onclick="show_private();">_deserialize_response</a>(<span class="summary-sig-arg">self</span>, |
| 215 | <span class="summary-sig-arg">payload</span>)</span><br /> |
| 216 | Convert string into httplib2 response and content.</td> |
| 217 | <td align="right" valign="top"> |
| 218 | <span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._deserialize_response">source code</a></span> |
| 219 | |
| 220 | </td> |
| 221 | </tr> |
| 222 | </table> |
| 223 | |
| 224 | </td> |
| 225 | </tr> |
| 226 | <tr class="private"> |
| 227 | <td width="15%" align="right" valign="top" class="summary"> |
| 228 | <span class="summary-type"> </span> |
| 229 | </td><td class="summary"> |
| 230 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 231 | <tr> |
| 232 | <td><span class="summary-sig"><a href="apiclient.http.BatchHttpRequest-class.html#_new_id" class="summary-sig-name" onclick="show_private();">_new_id</a>(<span class="summary-sig-arg">self</span>)</span><br /> |
| 233 | Create a new id.</td> |
| 234 | <td align="right" valign="top"> |
| 235 | <span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._new_id">source code</a></span> |
| 236 | |
| 237 | </td> |
| 238 | </tr> |
| 239 | </table> |
| 240 | |
| 241 | </td> |
| 242 | </tr> |
| 243 | <tr> |
| 244 | <td width="15%" align="right" valign="top" class="summary"> |
| 245 | <span class="summary-type"> </span> |
| 246 | </td><td class="summary"> |
| 247 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 248 | <tr> |
| 249 | <td><span class="summary-sig"><a href="apiclient.http.BatchHttpRequest-class.html#add" class="summary-sig-name">add</a>(<span class="summary-sig-arg">self</span>, |
| 250 | <span class="summary-sig-arg">request</span>, |
| 251 | <span class="summary-sig-arg">callback</span>=<span class="summary-sig-default">None</span>, |
| 252 | <span class="summary-sig-arg">request_id</span>=<span class="summary-sig-default">None</span>)</span><br /> |
| 253 | Add a new request.</td> |
| 254 | <td align="right" valign="top"> |
| 255 | <span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest.add">source code</a></span> |
| 256 | |
| 257 | </td> |
| 258 | </tr> |
| 259 | </table> |
| 260 | |
| 261 | </td> |
| 262 | </tr> |
| 263 | <tr class="private"> |
| 264 | <td width="15%" align="right" valign="top" class="summary"> |
| 265 | <span class="summary-type"> </span> |
| 266 | </td><td class="summary"> |
| 267 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 268 | <tr> |
| 269 | <td><span class="summary-sig"><a href="apiclient.http.BatchHttpRequest-class.html#_execute" class="summary-sig-name" onclick="show_private();">_execute</a>(<span class="summary-sig-arg">self</span>, |
| 270 | <span class="summary-sig-arg">http</span>, |
| 271 | <span class="summary-sig-arg">order</span>, |
| 272 | <span class="summary-sig-arg">requests</span>)</span><br /> |
| 273 | Serialize batch request, send to server, process response.</td> |
| 274 | <td align="right" valign="top"> |
| 275 | <span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._execute">source code</a></span> |
| 276 | |
| 277 | </td> |
| 278 | </tr> |
| 279 | </table> |
| 280 | |
| 281 | </td> |
| 282 | </tr> |
| 283 | <tr> |
| 284 | <td width="15%" align="right" valign="top" class="summary"> |
| 285 | <span class="summary-type"> </span> |
| 286 | </td><td class="summary"> |
| 287 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 288 | <tr> |
| 289 | <td><span class="summary-sig"><a href="apiclient.http.BatchHttpRequest-class.html#execute" class="summary-sig-name">execute</a>(<span class="summary-sig-arg">self</span>, |
| 290 | <span class="summary-sig-arg">http</span>=<span class="summary-sig-default">None</span>)</span><br /> |
| 291 | Execute all the requests as a single batched HTTP request.</td> |
| 292 | <td align="right" valign="top"> |
| 293 | <span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest.execute">source code</a></span> |
| 294 | |
| 295 | </td> |
| 296 | </tr> |
| 297 | </table> |
| 298 | |
| 299 | </td> |
| 300 | </tr> |
| 301 | <tr> |
| 302 | <td colspan="2" class="summary"> |
| 303 | <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>: |
| 304 | <code>__delattr__</code>, |
| 305 | <code>__format__</code>, |
| 306 | <code>__getattribute__</code>, |
| 307 | <code>__hash__</code>, |
| 308 | <code>__new__</code>, |
| 309 | <code>__reduce__</code>, |
| 310 | <code>__reduce_ex__</code>, |
| 311 | <code>__repr__</code>, |
| 312 | <code>__setattr__</code>, |
| 313 | <code>__sizeof__</code>, |
| 314 | <code>__str__</code>, |
| 315 | <code>__subclasshook__</code> |
| 316 | </p> |
| 317 | </td> |
| 318 | </tr> |
| 319 | </table> |
| 320 | <!-- ==================== PROPERTIES ==================== --> |
| 321 | <a name="section-Properties"></a> |
| 322 | <table class="summary" border="1" cellpadding="3" |
| 323 | cellspacing="0" width="100%" bgcolor="white"> |
| 324 | <tr bgcolor="#70b0f0" class="table-header"> |
| 325 | <td colspan="2" class="table-header"> |
| 326 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 327 | <tr valign="top"> |
| 328 | <td align="left"><span class="table-header">Properties</span></td> |
| 329 | <td align="right" valign="top" |
| 330 | ><span class="options">[<a href="#section-Properties" |
| 331 | class="privatelink" onclick="toggle_private();" |
| 332 | >hide private</a>]</span></td> |
| 333 | </tr> |
| 334 | </table> |
| 335 | </td> |
| 336 | </tr> |
| 337 | <tr> |
| 338 | <td colspan="2" class="summary"> |
| 339 | <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>: |
| 340 | <code>__class__</code> |
| 341 | </p> |
| 342 | </td> |
| 343 | </tr> |
| 344 | </table> |
| 345 | <!-- ==================== METHOD DETAILS ==================== --> |
| 346 | <a name="section-MethodDetails"></a> |
| 347 | <table class="details" border="1" cellpadding="3" |
| 348 | cellspacing="0" width="100%" bgcolor="white"> |
| 349 | <tr bgcolor="#70b0f0" class="table-header"> |
| 350 | <td colspan="2" class="table-header"> |
| 351 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 352 | <tr valign="top"> |
| 353 | <td align="left"><span class="table-header">Method Details</span></td> |
| 354 | <td align="right" valign="top" |
| 355 | ><span class="options">[<a href="#section-MethodDetails" |
| 356 | class="privatelink" onclick="toggle_private();" |
| 357 | >hide private</a>]</span></td> |
| 358 | </tr> |
| 359 | </table> |
| 360 | </td> |
| 361 | </tr> |
| 362 | </table> |
| 363 | <a name="__init__"></a> |
| 364 | <div> |
| 365 | <table class="details" border="1" cellpadding="3" |
| 366 | cellspacing="0" width="100%" bgcolor="white"> |
| 367 | <tr><td> |
| 368 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 369 | <tr valign="top"><td> |
| 370 | <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>, |
| 371 | <span class="sig-arg">callback</span>=<span class="sig-default">None</span>, |
| 372 | <span class="sig-arg">batch_uri</span>=<span class="sig-default">None</span>)</span> |
| 373 | <br /><em class="fname">(Constructor)</em> |
| 374 | </h3> |
| 375 | </td><td align="right" valign="top" |
| 376 | ><span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest.__init__">source code</a></span> |
| 377 | </td> |
| 378 | </tr></table> |
| 379 | |
| 380 | <pre class="literalblock"> |
| 381 | Constructor for a BatchHttpRequest. |
| 382 | |
| 383 | Args: |
| 384 | callback: callable, A callback to be called for each response, of the |
Joe Gregorio | e7a0c47 | 2012-07-12 11:46:04 -0400 | [diff] [blame^] | 385 | form callback(id, response, exception). The first parameter is the |
| 386 | request id, and the second is the deserialized response object. The |
| 387 | third is an apiclient.errors.HttpError exception object if an HTTP error |
| 388 | occurred while processing the request, or None if no error occurred. |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 389 | batch_uri: string, URI to send batch requests to. |
| 390 | |
| 391 | </pre> |
| 392 | <dl class="fields"> |
| 393 | <dt>Overrides: |
| 394 | object.__init__ |
| 395 | </dt> |
| 396 | </dl> |
| 397 | </td></tr></table> |
| 398 | </div> |
| 399 | <a name="_refresh_and_apply_credentials"></a> |
| 400 | <div class="private"> |
| 401 | <table class="details" border="1" cellpadding="3" |
| 402 | cellspacing="0" width="100%" bgcolor="white"> |
| 403 | <tr><td> |
| 404 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 405 | <tr valign="top"><td> |
| 406 | <h3 class="epydoc"><span class="sig"><span class="sig-name">_refresh_and_apply_credentials</span>(<span class="sig-arg">self</span>, |
| 407 | <span class="sig-arg">request</span>, |
| 408 | <span class="sig-arg">http</span>)</span> |
| 409 | </h3> |
| 410 | </td><td align="right" valign="top" |
| 411 | ><span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._refresh_and_apply_credentials">source code</a></span> |
| 412 | </td> |
| 413 | </tr></table> |
| 414 | |
| 415 | <pre class="literalblock"> |
| 416 | Refresh the credentials and apply to the request. |
| 417 | |
| 418 | Args: |
| 419 | request: HttpRequest, the request. |
| 420 | http: httplib2.Http, the global http object for the batch. |
| 421 | |
| 422 | </pre> |
| 423 | <dl class="fields"> |
| 424 | </dl> |
| 425 | </td></tr></table> |
| 426 | </div> |
| 427 | <a name="_id_to_header"></a> |
| 428 | <div class="private"> |
| 429 | <table class="details" border="1" cellpadding="3" |
| 430 | cellspacing="0" width="100%" bgcolor="white"> |
| 431 | <tr><td> |
| 432 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 433 | <tr valign="top"><td> |
| 434 | <h3 class="epydoc"><span class="sig"><span class="sig-name">_id_to_header</span>(<span class="sig-arg">self</span>, |
| 435 | <span class="sig-arg">id_</span>)</span> |
| 436 | </h3> |
| 437 | </td><td align="right" valign="top" |
| 438 | ><span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._id_to_header">source code</a></span> |
| 439 | </td> |
| 440 | </tr></table> |
| 441 | |
| 442 | <pre class="literalblock"> |
| 443 | Convert an id to a Content-ID header value. |
| 444 | |
| 445 | Args: |
| 446 | id_: string, identifier of individual request. |
| 447 | |
| 448 | Returns: |
| 449 | A Content-ID header with the id_ encoded into it. A UUID is prepended to |
| 450 | the value because Content-ID headers are supposed to be universally |
| 451 | unique. |
| 452 | |
| 453 | </pre> |
| 454 | <dl class="fields"> |
| 455 | </dl> |
| 456 | </td></tr></table> |
| 457 | </div> |
| 458 | <a name="_header_to_id"></a> |
| 459 | <div class="private"> |
| 460 | <table class="details" border="1" cellpadding="3" |
| 461 | cellspacing="0" width="100%" bgcolor="white"> |
| 462 | <tr><td> |
| 463 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 464 | <tr valign="top"><td> |
| 465 | <h3 class="epydoc"><span class="sig"><span class="sig-name">_header_to_id</span>(<span class="sig-arg">self</span>, |
| 466 | <span class="sig-arg">header</span>)</span> |
| 467 | </h3> |
| 468 | </td><td align="right" valign="top" |
| 469 | ><span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._header_to_id">source code</a></span> |
| 470 | </td> |
| 471 | </tr></table> |
| 472 | |
| 473 | <pre class="literalblock"> |
| 474 | Convert a Content-ID header value to an id. |
| 475 | |
| 476 | Presumes the Content-ID header conforms to the format that _id_to_header() |
| 477 | returns. |
| 478 | |
| 479 | Args: |
| 480 | header: string, Content-ID header value. |
| 481 | |
| 482 | Returns: |
| 483 | The extracted id value. |
| 484 | |
| 485 | Raises: |
| 486 | BatchError if the header is not in the expected format. |
| 487 | |
| 488 | </pre> |
| 489 | <dl class="fields"> |
| 490 | </dl> |
| 491 | </td></tr></table> |
| 492 | </div> |
| 493 | <a name="_serialize_request"></a> |
| 494 | <div class="private"> |
| 495 | <table class="details" border="1" cellpadding="3" |
| 496 | cellspacing="0" width="100%" bgcolor="white"> |
| 497 | <tr><td> |
| 498 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 499 | <tr valign="top"><td> |
| 500 | <h3 class="epydoc"><span class="sig"><span class="sig-name">_serialize_request</span>(<span class="sig-arg">self</span>, |
| 501 | <span class="sig-arg">request</span>)</span> |
| 502 | </h3> |
| 503 | </td><td align="right" valign="top" |
| 504 | ><span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._serialize_request">source code</a></span> |
| 505 | </td> |
| 506 | </tr></table> |
| 507 | |
| 508 | <pre class="literalblock"> |
| 509 | Convert an HttpRequest object into a string. |
| 510 | |
| 511 | Args: |
| 512 | request: HttpRequest, the request to serialize. |
| 513 | |
| 514 | Returns: |
| 515 | The request as a string in application/http format. |
| 516 | |
| 517 | </pre> |
| 518 | <dl class="fields"> |
| 519 | </dl> |
| 520 | </td></tr></table> |
| 521 | </div> |
| 522 | <a name="_deserialize_response"></a> |
| 523 | <div class="private"> |
| 524 | <table class="details" border="1" cellpadding="3" |
| 525 | cellspacing="0" width="100%" bgcolor="white"> |
| 526 | <tr><td> |
| 527 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 528 | <tr valign="top"><td> |
| 529 | <h3 class="epydoc"><span class="sig"><span class="sig-name">_deserialize_response</span>(<span class="sig-arg">self</span>, |
| 530 | <span class="sig-arg">payload</span>)</span> |
| 531 | </h3> |
| 532 | </td><td align="right" valign="top" |
| 533 | ><span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._deserialize_response">source code</a></span> |
| 534 | </td> |
| 535 | </tr></table> |
| 536 | |
| 537 | <pre class="literalblock"> |
| 538 | Convert string into httplib2 response and content. |
| 539 | |
| 540 | Args: |
| 541 | payload: string, headers and body as a string. |
| 542 | |
| 543 | Returns: |
Joe Gregorio | e7a0c47 | 2012-07-12 11:46:04 -0400 | [diff] [blame^] | 544 | A pair (resp, content), such as would be returned from httplib2.request. |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 545 | |
| 546 | </pre> |
| 547 | <dl class="fields"> |
| 548 | </dl> |
| 549 | </td></tr></table> |
| 550 | </div> |
| 551 | <a name="_new_id"></a> |
| 552 | <div class="private"> |
| 553 | <table class="details" border="1" cellpadding="3" |
| 554 | cellspacing="0" width="100%" bgcolor="white"> |
| 555 | <tr><td> |
| 556 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 557 | <tr valign="top"><td> |
| 558 | <h3 class="epydoc"><span class="sig"><span class="sig-name">_new_id</span>(<span class="sig-arg">self</span>)</span> |
| 559 | </h3> |
| 560 | </td><td align="right" valign="top" |
| 561 | ><span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._new_id">source code</a></span> |
| 562 | </td> |
| 563 | </tr></table> |
| 564 | |
| 565 | <pre class="literalblock"> |
| 566 | Create a new id. |
| 567 | |
| 568 | Auto incrementing number that avoids conflicts with ids already used. |
| 569 | |
| 570 | Returns: |
| 571 | string, a new unique id. |
| 572 | |
| 573 | </pre> |
| 574 | <dl class="fields"> |
| 575 | </dl> |
| 576 | </td></tr></table> |
| 577 | </div> |
| 578 | <a name="add"></a> |
| 579 | <div> |
| 580 | <table class="details" border="1" cellpadding="3" |
| 581 | cellspacing="0" width="100%" bgcolor="white"> |
| 582 | <tr><td> |
| 583 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 584 | <tr valign="top"><td> |
| 585 | <h3 class="epydoc"><span class="sig"><span class="sig-name">add</span>(<span class="sig-arg">self</span>, |
| 586 | <span class="sig-arg">request</span>, |
| 587 | <span class="sig-arg">callback</span>=<span class="sig-default">None</span>, |
| 588 | <span class="sig-arg">request_id</span>=<span class="sig-default">None</span>)</span> |
| 589 | </h3> |
| 590 | </td><td align="right" valign="top" |
| 591 | ><span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest.add">source code</a></span> |
| 592 | </td> |
| 593 | </tr></table> |
| 594 | |
| 595 | <pre class="literalblock"> |
| 596 | Add a new request. |
| 597 | |
| 598 | Every callback added will be paired with a unique id, the request_id. That |
| 599 | unique id will be passed back to the callback when the response comes back |
| 600 | from the server. The default behavior is to have the library generate it's |
| 601 | own unique id. If the caller passes in a request_id then they must ensure |
| 602 | uniqueness for each request_id, and if they are not an exception is |
| 603 | raised. Callers should either supply all request_ids or nevery supply a |
| 604 | request id, to avoid such an error. |
| 605 | |
| 606 | Args: |
| 607 | request: HttpRequest, Request to add to the batch. |
| 608 | callback: callable, A callback to be called for this response, of the |
Joe Gregorio | e7a0c47 | 2012-07-12 11:46:04 -0400 | [diff] [blame^] | 609 | form callback(id, response, exception). The first parameter is the |
| 610 | request id, and the second is the deserialized response object. The |
| 611 | third is an apiclient.errors.HttpError exception object if an HTTP error |
| 612 | occurred while processing the request, or None if no errors occurred. |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 613 | request_id: string, A unique id for the request. The id will be passed to |
| 614 | the callback with the response. |
| 615 | |
| 616 | Returns: |
| 617 | None |
| 618 | |
| 619 | Raises: |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 620 | BatchError if a media request is added to a batch. |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 621 | KeyError is the request_id is not unique. |
| 622 | |
| 623 | </pre> |
| 624 | <dl class="fields"> |
| 625 | </dl> |
| 626 | </td></tr></table> |
| 627 | </div> |
| 628 | <a name="_execute"></a> |
| 629 | <div class="private"> |
| 630 | <table class="details" border="1" cellpadding="3" |
| 631 | cellspacing="0" width="100%" bgcolor="white"> |
| 632 | <tr><td> |
| 633 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 634 | <tr valign="top"><td> |
| 635 | <h3 class="epydoc"><span class="sig"><span class="sig-name">_execute</span>(<span class="sig-arg">self</span>, |
| 636 | <span class="sig-arg">http</span>, |
| 637 | <span class="sig-arg">order</span>, |
| 638 | <span class="sig-arg">requests</span>)</span> |
| 639 | </h3> |
| 640 | </td><td align="right" valign="top" |
| 641 | ><span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest._execute">source code</a></span> |
| 642 | </td> |
| 643 | </tr></table> |
| 644 | |
| 645 | <pre class="literalblock"> |
| 646 | Serialize batch request, send to server, process response. |
| 647 | |
| 648 | Args: |
| 649 | http: httplib2.Http, an http object to be used to make the request with. |
| 650 | order: list, list of request ids in the order they were added to the |
| 651 | batch. |
| 652 | request: list, list of request objects to send. |
| 653 | |
| 654 | Raises: |
| 655 | httplib2.Error if a transport error has occured. |
| 656 | apiclient.errors.BatchError if the response is the wrong format. |
| 657 | |
| 658 | </pre> |
| 659 | <dl class="fields"> |
| 660 | </dl> |
| 661 | </td></tr></table> |
| 662 | </div> |
| 663 | <a name="execute"></a> |
| 664 | <div> |
| 665 | <table class="details" border="1" cellpadding="3" |
| 666 | cellspacing="0" width="100%" bgcolor="white"> |
| 667 | <tr><td> |
| 668 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 669 | <tr valign="top"><td> |
| 670 | <h3 class="epydoc"><span class="sig"><span class="sig-name">execute</span>(<span class="sig-arg">self</span>, |
| 671 | <span class="sig-arg">http</span>=<span class="sig-default">None</span>)</span> |
| 672 | </h3> |
| 673 | </td><td align="right" valign="top" |
| 674 | ><span class="codelink"><a href="apiclient.http-pysrc.html#BatchHttpRequest.execute">source code</a></span> |
| 675 | </td> |
| 676 | </tr></table> |
| 677 | |
| 678 | <pre class="literalblock"> |
| 679 | Execute all the requests as a single batched HTTP request. |
| 680 | |
| 681 | Args: |
| 682 | http: httplib2.Http, an http object to be used in place of the one the |
| 683 | HttpRequest request object was constructed with. If one isn't supplied |
| 684 | then use a http object from the requests in this batch. |
| 685 | |
| 686 | Returns: |
| 687 | None |
| 688 | |
| 689 | Raises: |
| 690 | httplib2.Error if a transport error has occured. |
| 691 | apiclient.errors.BatchError if the response is the wrong format. |
| 692 | |
| 693 | </pre> |
| 694 | <dl class="fields"> |
| 695 | </dl> |
| 696 | </td></tr></table> |
| 697 | </div> |
| 698 | <br /> |
| 699 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 700 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 701 | bgcolor="#a0c0ff" cellspacing="0"> |
| 702 | <tr valign="middle"> |
| 703 | |
| 704 | <!-- Tree link --> |
| 705 | <th> <a |
| 706 | href="module-tree.html">Trees</a> </th> |
| 707 | |
| 708 | <!-- Index link --> |
| 709 | <th> <a |
| 710 | href="identifier-index.html">Indices</a> </th> |
| 711 | |
| 712 | <!-- Help link --> |
| 713 | <th> <a |
| 714 | href="help.html">Help</a> </th> |
| 715 | |
| 716 | <th class="navbar" width="100%"></th> |
| 717 | </tr> |
| 718 | </table> |
| 719 | <table border="0" cellpadding="0" cellspacing="0" width="100%%"> |
| 720 | <tr> |
| 721 | <td align="left" class="footer"> |
Joe Gregorio | e7a0c47 | 2012-07-12 11:46:04 -0400 | [diff] [blame^] | 722 | Generated by Epydoc 3.0.1 on Thu Jul 12 10:44:09 2012 |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 723 | </td> |
| 724 | <td align="right" class="footer"> |
| 725 | <a target="mainFrame" href="http://epydoc.sourceforge.net" |
| 726 | >http://epydoc.sourceforge.net</a> |
| 727 | </td> |
| 728 | </tr> |
| 729 | </table> |
| 730 | |
| 731 | <script type="text/javascript"> |
| 732 | <!-- |
| 733 | // Private objects are initially displayed (because if |
| 734 | // javascript is turned off then we want them to be |
| 735 | // visible); but by default, we want to hide them. So hide |
| 736 | // them unless we have a cookie that says to show them. |
| 737 | checkCookie(); |
| 738 | // --> |
| 739 | </script> |
| 740 | </body> |
| 741 | </html> |