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