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