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