Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 1 | |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 3 | <html><head><title>Python: module apiclient.http</title> |
| 4 | </head><body bgcolor="#f0f0f8"> |
| 5 | |
| 6 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> |
| 7 | <tr bgcolor="#7799ee"> |
| 8 | <td valign=bottom> <br> |
| 9 | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.http</strong></big></big></font></td |
| 10 | ><td align=right valign=bottom |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 11 | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/clean/apiclient/http.py">/home/jcgregorio/projects/clean/apiclient/http.py</a></font></td></tr></table> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 12 | <p><tt>Classes to encapsulate a single HTTP request.<br> |
| 13 | <br> |
| 14 | The classes implement a command pattern, with every<br> |
| 15 | <a href="__builtin__.html#object">object</a> supporting an execute() method that does the<br> |
| 16 | actuall HTTP request.</tt></p> |
| 17 | <p> |
| 18 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
Joe Gregorio | 6e53703 | 2011-02-09 23:04:26 -0500 | [diff] [blame] | 19 | <tr bgcolor="#aa55cc"> |
| 20 | <td colspan=3 valign=bottom> <br> |
| 21 | <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> |
| 22 | |
| 23 | <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 24 | <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="StringIO.html">StringIO</a><br> |
Joe Gregorio | 3d55ac5 | 2012-02-21 10:11:19 -0500 | [diff] [blame] | 25 | <a href="base64.html">base64</a><br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 26 | <a href="copy.html">copy</a><br> |
Joe Gregorio | 3d55ac5 | 2012-02-21 10:11:19 -0500 | [diff] [blame] | 27 | </td><td width="25%" valign=top><a href="gzip.html">gzip</a><br> |
| 28 | <a href="httplib2.html">httplib2</a><br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 29 | <a href="apiclient.mimeparse.html">apiclient.mimeparse</a><br> |
Joe Gregorio | 3d55ac5 | 2012-02-21 10:11:19 -0500 | [diff] [blame] | 30 | </td><td width="25%" valign=top><a href="mimetypes.html">mimetypes</a><br> |
| 31 | <a href="os.html">os</a><br> |
| 32 | <a href="json.html">json</a><br> |
| 33 | </td><td width="25%" valign=top><a href="urllib.html">urllib</a><br> |
| 34 | <a href="urlparse.html">urlparse</a><br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 35 | <a href="uuid.html">uuid</a><br> |
| 36 | </td></tr></table></td></tr></table><p> |
Joe Gregorio | 6e53703 | 2011-02-09 23:04:26 -0500 | [diff] [blame] | 37 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 38 | <tr bgcolor="#ee77aa"> |
| 39 | <td colspan=3 valign=bottom> <br> |
| 40 | <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> |
| 41 | |
| 42 | <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> |
| 43 | <td width="100%"><dl> |
| 44 | <dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> |
| 45 | </font></dt><dd> |
| 46 | <dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 47 | <dt><font face="helvetica, arial"><a href="apiclient.http.html#BatchHttpRequest">BatchHttpRequest</a> |
| 48 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#HttpMock">HttpMock</a> |
| 49 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#HttpMockSequence">HttpMockSequence</a> |
| 50 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#HttpRequest">HttpRequest</a> |
| 51 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#HttpRequestMock">HttpRequestMock</a> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame^] | 52 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#MediaDownloadProgress">MediaDownloadProgress</a> |
| 53 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#MediaIoBaseDownload">MediaIoBaseDownload</a> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 54 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#MediaUpload">MediaUpload</a> |
| 55 | </font></dt><dd> |
| 56 | <dl> |
| 57 | <dt><font face="helvetica, arial"><a href="apiclient.http.html#MediaFileUpload">MediaFileUpload</a> |
| 58 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#MediaInMemoryUpload">MediaInMemoryUpload</a> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 59 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#MediaIoBaseUpload">MediaIoBaseUpload</a> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 60 | </font></dt></dl> |
| 61 | </dd> |
| 62 | <dt><font face="helvetica, arial"><a href="apiclient.http.html#MediaUploadProgress">MediaUploadProgress</a> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 63 | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.http.html#RequestMockBuilder">RequestMockBuilder</a> |
| 64 | </font></dt></dl> |
| 65 | </dd> |
| 66 | </dl> |
| 67 | <p> |
| 68 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 69 | <tr bgcolor="#ffc8d8"> |
| 70 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 71 | <font color="#000000" face="helvetica, arial"><a name="BatchHttpRequest">class <strong>BatchHttpRequest</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 72 | |
| 73 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame^] | 74 | <td colspan=2><tt>Batches multiple <a href="#HttpRequest">HttpRequest</a> objects into a single HTTP request.<br> |
| 75 | <br> |
| 76 | Example:<br> |
| 77 | from apiclient.http import <a href="#BatchHttpRequest">BatchHttpRequest</a><br> |
| 78 | <br> |
| 79 | def list_animals(request_id, response):<br> |
| 80 | """Do something with the animals list response."""<br> |
| 81 | pass<br> |
| 82 | <br> |
| 83 | def list_farmers(request_id, response):<br> |
| 84 | """Do something with the farmers list response."""<br> |
| 85 | pass<br> |
| 86 | <br> |
| 87 | service = build('farm', 'v2')<br> |
| 88 | <br> |
| 89 | batch = <a href="#BatchHttpRequest">BatchHttpRequest</a>()<br> |
| 90 | <br> |
| 91 | batch.<a href="#BatchHttpRequest-add">add</a>(service.animals().list(), list_animals)<br> |
| 92 | batch.<a href="#BatchHttpRequest-add">add</a>(service.farmers().list(), list_farmers)<br> |
| 93 | batch.<a href="#BatchHttpRequest-execute">execute</a>(http)<br> </tt></td></tr> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 94 | <tr><td> </td> |
| 95 | <td width="100%">Methods defined here:<br> |
| 96 | <dl><dt><a name="BatchHttpRequest-__init__"><strong>__init__</strong></a>(self, callback<font color="#909090">=None</font>, batch_uri<font color="#909090">=None</font>)</dt><dd><tt>Constructor for a <a href="#BatchHttpRequest">BatchHttpRequest</a>.<br> |
| 97 | <br> |
| 98 | Args:<br> |
| 99 | callback: callable, A callback to be called for each response, of the<br> |
| 100 | form callback(id, response). The first parameter is the request id, and<br> |
| 101 | the second is the deserialized response <a href="__builtin__.html#object">object</a>.<br> |
| 102 | batch_uri: string, URI to send batch requests to.</tt></dd></dl> |
| 103 | |
| 104 | <dl><dt><a name="BatchHttpRequest-add"><strong>add</strong></a>(self, request, callback<font color="#909090">=None</font>, request_id<font color="#909090">=None</font>)</dt><dd><tt>Add a new request.<br> |
| 105 | <br> |
| 106 | Every callback added will be paired with a unique id, the request_id. That<br> |
| 107 | unique id will be passed back to the callback when the response comes back<br> |
| 108 | from the server. The default behavior is to have the library generate it's<br> |
| 109 | own unique id. If the caller passes in a request_id then they must ensure<br> |
| 110 | uniqueness for each request_id, and if they are not an exception is<br> |
| 111 | raised. Callers should either supply all request_ids or nevery supply a<br> |
| 112 | request id, to avoid such an error.<br> |
| 113 | <br> |
| 114 | Args:<br> |
| 115 | request: <a href="#HttpRequest">HttpRequest</a>, Request to add to the batch.<br> |
| 116 | callback: callable, A callback to be called for this response, of the<br> |
| 117 | form callback(id, response). The first parameter is the request id, and<br> |
| 118 | the second is the deserialized response <a href="__builtin__.html#object">object</a>.<br> |
| 119 | request_id: string, A unique id for the request. The id will be passed to<br> |
| 120 | the callback with the response.<br> |
| 121 | <br> |
| 122 | Returns:<br> |
| 123 | None<br> |
| 124 | <br> |
| 125 | Raises:<br> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame^] | 126 | BatchError if a media request is added to a batch.<br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 127 | KeyError is the request_id is not unique.</tt></dd></dl> |
| 128 | |
| 129 | <dl><dt><a name="BatchHttpRequest-execute"><strong>execute</strong></a>(self, http<font color="#909090">=None</font>)</dt><dd><tt>Execute all the requests as a single batched HTTP request.<br> |
| 130 | <br> |
| 131 | Args:<br> |
| 132 | http: httplib2.Http, an http <a href="__builtin__.html#object">object</a> to be used in place of the one the<br> |
| 133 | <a href="#HttpRequest">HttpRequest</a> request <a href="__builtin__.html#object">object</a> was constructed with. If one isn't supplied<br> |
| 134 | then use a http <a href="__builtin__.html#object">object</a> from the requests in this batch.<br> |
| 135 | <br> |
| 136 | Returns:<br> |
| 137 | None<br> |
| 138 | <br> |
| 139 | Raises:<br> |
| 140 | httplib2.Error if a transport error has occured.<br> |
| 141 | apiclient.errors.BatchError if the response is the wrong format.</tt></dd></dl> |
| 142 | |
| 143 | <hr> |
| 144 | Data descriptors defined here:<br> |
| 145 | <dl><dt><strong>__dict__</strong></dt> |
| 146 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 147 | </dl> |
| 148 | <dl><dt><strong>__weakref__</strong></dt> |
| 149 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 150 | </dl> |
| 151 | </td></tr></table> <p> |
| 152 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 153 | <tr bgcolor="#ffc8d8"> |
| 154 | <td colspan=3 valign=bottom> <br> |
| 155 | <font color="#000000" face="helvetica, arial"><a name="HttpMock">class <strong>HttpMock</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 156 | |
| 157 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 158 | <td colspan=2><tt>Mock of httplib2.Http<br> </tt></td></tr> |
| 159 | <tr><td> </td> |
| 160 | <td width="100%">Methods defined here:<br> |
| 161 | <dl><dt><a name="HttpMock-__init__"><strong>__init__</strong></a>(self, filename, headers<font color="#909090">=None</font>)</dt><dd><tt>Args:<br> |
| 162 | filename: string, absolute filename to read response from<br> |
| 163 | headers: dict, header to return with response</tt></dd></dl> |
| 164 | |
| 165 | <dl><dt><a name="HttpMock-request"><strong>request</strong></a>(self, uri, method<font color="#909090">='GET'</font>, body<font color="#909090">=None</font>, headers<font color="#909090">=None</font>, redirections<font color="#909090">=1</font>, connection_type<font color="#909090">=None</font>)</dt></dl> |
| 166 | |
| 167 | <hr> |
| 168 | Data descriptors defined here:<br> |
| 169 | <dl><dt><strong>__dict__</strong></dt> |
| 170 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 171 | </dl> |
| 172 | <dl><dt><strong>__weakref__</strong></dt> |
| 173 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 174 | </dl> |
| 175 | </td></tr></table> <p> |
| 176 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 177 | <tr bgcolor="#ffc8d8"> |
| 178 | <td colspan=3 valign=bottom> <br> |
| 179 | <font color="#000000" face="helvetica, arial"><a name="HttpMockSequence">class <strong>HttpMockSequence</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 180 | |
| 181 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 182 | <td colspan=2><tt>Mock of httplib2.Http<br> |
| 183 | <br> |
| 184 | Mocks a sequence of calls to request returning different responses for each<br> |
| 185 | call. Create an instance initialized with the desired response headers<br> |
| 186 | and content and then use as if an httplib2.Http instance.<br> |
| 187 | <br> |
| 188 | http = <a href="#HttpMockSequence">HttpMockSequence</a>([<br> |
| 189 | ({'status': '401'}, ''),<br> |
| 190 | ({'status': '200'}, '{"access_token":"1/3w","expires_in":3600}'),<br> |
| 191 | ({'status': '200'}, 'echo_request_headers'),<br> |
| 192 | ])<br> |
| 193 | resp, content = http.<a href="#HttpMockSequence-request">request</a>("<a href="http://examples.com">http://examples.com</a>")<br> |
| 194 | <br> |
| 195 | There are special values you can pass in for content to trigger<br> |
| 196 | behavours that are helpful in testing.<br> |
| 197 | <br> |
| 198 | 'echo_request_headers' means return the request headers in the response body<br> |
| 199 | 'echo_request_headers_as_json' means return the request headers in<br> |
| 200 | the response body<br> |
| 201 | 'echo_request_body' means return the request body in the response body<br> |
| 202 | 'echo_request_uri' means return the request uri in the response body<br> </tt></td></tr> |
| 203 | <tr><td> </td> |
| 204 | <td width="100%">Methods defined here:<br> |
| 205 | <dl><dt><a name="HttpMockSequence-__init__"><strong>__init__</strong></a>(self, iterable)</dt><dd><tt>Args:<br> |
| 206 | iterable: iterable, a sequence of pairs of (headers, body)</tt></dd></dl> |
| 207 | |
| 208 | <dl><dt><a name="HttpMockSequence-request"><strong>request</strong></a>(self, uri, method<font color="#909090">='GET'</font>, body<font color="#909090">=None</font>, headers<font color="#909090">=None</font>, redirections<font color="#909090">=1</font>, connection_type<font color="#909090">=None</font>)</dt></dl> |
| 209 | |
| 210 | <hr> |
| 211 | Data descriptors defined here:<br> |
| 212 | <dl><dt><strong>__dict__</strong></dt> |
| 213 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 214 | </dl> |
| 215 | <dl><dt><strong>__weakref__</strong></dt> |
| 216 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 217 | </dl> |
| 218 | </td></tr></table> <p> |
| 219 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 220 | <tr bgcolor="#ffc8d8"> |
| 221 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 222 | <font color="#000000" face="helvetica, arial"><a name="HttpRequest">class <strong>HttpRequest</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 223 | |
| 224 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 225 | <td colspan=2><tt>Encapsulates a single HTTP request.<br> </tt></td></tr> |
| 226 | <tr><td> </td> |
| 227 | <td width="100%">Methods defined here:<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 228 | <dl><dt><a name="HttpRequest-__init__"><strong>__init__</strong></a>(self, http, postproc, uri, method<font color="#909090">='GET'</font>, body<font color="#909090">=None</font>, headers<font color="#909090">=None</font>, methodId<font color="#909090">=None</font>, resumable<font color="#909090">=None</font>)</dt><dd><tt>Constructor for an <a href="#HttpRequest">HttpRequest</a>.<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 229 | <br> |
| 230 | Args:<br> |
| 231 | http: httplib2.Http, the transport <a href="__builtin__.html#object">object</a> to use to make a request<br> |
Joe Gregorio | abda96f | 2011-02-11 20:19:33 -0500 | [diff] [blame] | 232 | postproc: callable, called on the HTTP response and content to transform<br> |
| 233 | it into a data <a href="__builtin__.html#object">object</a> before returning, or raising an exception<br> |
| 234 | on an error.<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 235 | uri: string, the absolute URI to send the request to<br> |
| 236 | method: string, the HTTP method to use<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 237 | body: string, the request body of the HTTP request,<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 238 | headers: dict, the HTTP request headers<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 239 | methodId: string, a unique identifier for the API method being called.<br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 240 | resumable: <a href="#MediaUpload">MediaUpload</a>, None if this is not a resumbale request.</tt></dd></dl> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 241 | |
| 242 | <dl><dt><a name="HttpRequest-execute"><strong>execute</strong></a>(self, http<font color="#909090">=None</font>)</dt><dd><tt>Execute the request.<br> |
| 243 | <br> |
| 244 | Args:<br> |
| 245 | http: httplib2.Http, an http <a href="__builtin__.html#object">object</a> to be used in place of the<br> |
| 246 | one the <a href="#HttpRequest">HttpRequest</a> request <a href="__builtin__.html#object">object</a> was constructed with.<br> |
| 247 | <br> |
| 248 | Returns:<br> |
| 249 | A deserialized <a href="__builtin__.html#object">object</a> model of the response body as determined<br> |
| 250 | by the postproc.<br> |
| 251 | <br> |
| 252 | Raises:<br> |
| 253 | apiclient.errors.HttpError if the response was not a 2xx.<br> |
| 254 | httplib2.Error if a transport error has occured.</tt></dd></dl> |
| 255 | |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 256 | <dl><dt><a name="HttpRequest-next_chunk"><strong>next_chunk</strong></a>(self, http<font color="#909090">=None</font>)</dt><dd><tt>Execute the next step of a resumable upload.<br> |
| 257 | <br> |
| 258 | Can only be used if the method being executed supports media uploads and<br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 259 | the <a href="#MediaUpload">MediaUpload</a> <a href="__builtin__.html#object">object</a> passed in was flagged as using resumable upload.<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 260 | <br> |
| 261 | Example:<br> |
| 262 | <br> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame^] | 263 | media = <a href="#MediaFileUpload">MediaFileUpload</a>('cow.png', mimetype='image/png',<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 264 | chunksize=1000, resumable=True)<br> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame^] | 265 | request = farm.animals().insert(<br> |
| 266 | id='cow',<br> |
| 267 | name='cow.png',<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 268 | media_body=media)<br> |
| 269 | <br> |
| 270 | response = None<br> |
| 271 | while response is None:<br> |
| 272 | status, response = request.<a href="#HttpRequest-next_chunk">next_chunk</a>()<br> |
| 273 | if status:<br> |
| 274 | print "Upload %d%% complete." % int(status.progress() * 100)<br> |
| 275 | <br> |
| 276 | <br> |
| 277 | Returns:<br> |
| 278 | (status, body): (ResumableMediaStatus, <a href="__builtin__.html#object">object</a>)<br> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 279 | The body will be None until the resumable media is fully uploaded.<br> |
| 280 | <br> |
| 281 | Raises:<br> |
| 282 | apiclient.errors.HttpError if the response was not a 2xx.<br> |
| 283 | httplib2.Error if a transport error has occured.</tt></dd></dl> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 284 | |
| 285 | <dl><dt><a name="HttpRequest-to_json"><strong>to_json</strong></a>(self)</dt><dd><tt>Returns a JSON representation of the <a href="#HttpRequest">HttpRequest</a>.</tt></dd></dl> |
| 286 | |
| 287 | <hr> |
| 288 | Static methods defined here:<br> |
| 289 | <dl><dt><a name="HttpRequest-from_json"><strong>from_json</strong></a>(s, http, postproc)</dt><dd><tt>Returns an <a href="#HttpRequest">HttpRequest</a> populated with info from a JSON <a href="__builtin__.html#object">object</a>.</tt></dd></dl> |
| 290 | |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 291 | <hr> |
| 292 | Data descriptors defined here:<br> |
| 293 | <dl><dt><strong>__dict__</strong></dt> |
| 294 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 295 | </dl> |
| 296 | <dl><dt><strong>__weakref__</strong></dt> |
| 297 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 298 | </dl> |
| 299 | </td></tr></table> <p> |
| 300 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 301 | <tr bgcolor="#ffc8d8"> |
| 302 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 303 | <font color="#000000" face="helvetica, arial"><a name="HttpRequestMock">class <strong>HttpRequestMock</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 304 | |
| 305 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 306 | <td colspan=2><tt>Mock of <a href="#HttpRequest">HttpRequest</a>.<br> |
| 307 | <br> |
| 308 | Do not construct directly, instead use <a href="#RequestMockBuilder">RequestMockBuilder</a>.<br> </tt></td></tr> |
| 309 | <tr><td> </td> |
| 310 | <td width="100%">Methods defined here:<br> |
| 311 | <dl><dt><a name="HttpRequestMock-__init__"><strong>__init__</strong></a>(self, resp, content, postproc)</dt><dd><tt>Constructor for <a href="#HttpRequestMock">HttpRequestMock</a><br> |
| 312 | <br> |
| 313 | Args:<br> |
| 314 | resp: httplib2.Response, the response to emulate coming from the request<br> |
| 315 | content: string, the response body<br> |
| 316 | postproc: callable, the post processing function usually supplied by<br> |
| 317 | the model class. See model.JsonModel.response() as an example.</tt></dd></dl> |
| 318 | |
| 319 | <dl><dt><a name="HttpRequestMock-execute"><strong>execute</strong></a>(self, http<font color="#909090">=None</font>)</dt><dd><tt>Execute the request.<br> |
| 320 | <br> |
| 321 | Same behavior as <a href="#HttpRequest">HttpRequest</a>.<a href="#HttpRequestMock-execute">execute</a>(), but the response is<br> |
| 322 | mocked and not really from an HTTP request/response.</tt></dd></dl> |
| 323 | |
| 324 | <hr> |
| 325 | Data descriptors defined here:<br> |
| 326 | <dl><dt><strong>__dict__</strong></dt> |
| 327 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 328 | </dl> |
| 329 | <dl><dt><strong>__weakref__</strong></dt> |
| 330 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 331 | </dl> |
| 332 | </td></tr></table> <p> |
| 333 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 334 | <tr bgcolor="#ffc8d8"> |
| 335 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame^] | 336 | <font color="#000000" face="helvetica, arial"><a name="MediaDownloadProgress">class <strong>MediaDownloadProgress</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 337 | |
| 338 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 339 | <td colspan=2><tt>Status of a resumable download.<br> </tt></td></tr> |
| 340 | <tr><td> </td> |
| 341 | <td width="100%">Methods defined here:<br> |
| 342 | <dl><dt><a name="MediaDownloadProgress-__init__"><strong>__init__</strong></a>(self, resumable_progress, total_size)</dt><dd><tt>Constructor.<br> |
| 343 | <br> |
| 344 | Args:<br> |
| 345 | resumable_progress: int, bytes received so far.<br> |
| 346 | total_size: int, total bytes in complete download.</tt></dd></dl> |
| 347 | |
| 348 | <dl><dt><a name="MediaDownloadProgress-progress"><strong>progress</strong></a>(self)</dt><dd><tt>Percent of download completed, as a float.<br> |
| 349 | <br> |
| 350 | Returns:<br> |
| 351 | the percentage complete as a float, returning 0.0 if the total size of<br> |
| 352 | the download is unknown.</tt></dd></dl> |
| 353 | |
| 354 | <hr> |
| 355 | Data descriptors defined here:<br> |
| 356 | <dl><dt><strong>__dict__</strong></dt> |
| 357 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 358 | </dl> |
| 359 | <dl><dt><strong>__weakref__</strong></dt> |
| 360 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 361 | </dl> |
| 362 | </td></tr></table> <p> |
| 363 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 364 | <tr bgcolor="#ffc8d8"> |
| 365 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 366 | <font color="#000000" face="helvetica, arial"><a name="MediaFileUpload">class <strong>MediaFileUpload</strong></a>(<a href="apiclient.http.html#MediaUpload">MediaUpload</a>)</font></td></tr> |
| 367 | |
| 368 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 369 | <td colspan=2><tt>A <a href="#MediaUpload">MediaUpload</a> for a file.<br> |
| 370 | <br> |
| 371 | Construct a <a href="#MediaFileUpload">MediaFileUpload</a> and pass as the media_body parameter of the<br> |
| 372 | method. For example, if we had a service that allowed uploading images:<br> |
| 373 | <br> |
| 374 | <br> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame^] | 375 | media = <a href="#MediaFileUpload">MediaFileUpload</a>('cow.png', mimetype='image/png',<br> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 376 | chunksize=1024*1024, resumable=True)<br> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame^] | 377 | farm.animals()..insert(<br> |
| 378 | id='cow',<br> |
| 379 | name='cow.png',<br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 380 | media_body=media).execute()<br> </tt></td></tr> |
| 381 | <tr><td> </td> |
| 382 | <td width="100%"><dl><dt>Method resolution order:</dt> |
| 383 | <dd><a href="apiclient.http.html#MediaFileUpload">MediaFileUpload</a></dd> |
| 384 | <dd><a href="apiclient.http.html#MediaUpload">MediaUpload</a></dd> |
| 385 | <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> |
| 386 | </dl> |
| 387 | <hr> |
| 388 | Methods defined here:<br> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 389 | <dl><dt><a name="MediaFileUpload-__init__"><strong>__init__</strong></a>(self, filename, mimetype<font color="#909090">=None</font>, chunksize<font color="#909090">=524288</font>, resumable<font color="#909090">=False</font>)</dt><dd><tt>Constructor.<br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 390 | <br> |
| 391 | Args:<br> |
| 392 | filename: string, Name of the file.<br> |
| 393 | mimetype: string, Mime-type of the file. If None then a mime-type will be<br> |
| 394 | guessed from the file extension.<br> |
| 395 | chunksize: int, File will be uploaded in chunks of this many bytes. Only<br> |
| 396 | used if resumable=True.<br> |
| 397 | resumable: bool, True if this is a resumable upload. False means upload<br> |
| 398 | in a single request.</tt></dd></dl> |
| 399 | |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 400 | <dl><dt><a name="MediaFileUpload-chunksize"><strong>chunksize</strong></a>(self)</dt><dd><tt>Chunk size for resumable uploads.<br> |
| 401 | <br> |
| 402 | Returns:<br> |
| 403 | Chunk size in bytes.</tt></dd></dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 404 | |
| 405 | <dl><dt><a name="MediaFileUpload-getbytes"><strong>getbytes</strong></a>(self, begin, length)</dt><dd><tt>Get bytes from the media.<br> |
| 406 | <br> |
| 407 | Args:<br> |
| 408 | begin: int, offset from beginning of file.<br> |
| 409 | length: int, number of bytes to read, starting at begin.<br> |
| 410 | <br> |
| 411 | Returns:<br> |
| 412 | A string of bytes read. May be shorted than length if EOF was reached<br> |
| 413 | first.</tt></dd></dl> |
| 414 | |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 415 | <dl><dt><a name="MediaFileUpload-mimetype"><strong>mimetype</strong></a>(self)</dt><dd><tt>Mime type of the body.<br> |
| 416 | <br> |
| 417 | Returns:<br> |
| 418 | Mime type.</tt></dd></dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 419 | |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 420 | <dl><dt><a name="MediaFileUpload-resumable"><strong>resumable</strong></a>(self)</dt><dd><tt>Whether this upload is resumable.<br> |
| 421 | <br> |
| 422 | Returns:<br> |
| 423 | True if resumable upload or False.</tt></dd></dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 424 | |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 425 | <dl><dt><a name="MediaFileUpload-size"><strong>size</strong></a>(self)</dt><dd><tt>Size of upload.<br> |
| 426 | <br> |
| 427 | Returns:<br> |
| 428 | Size of the body, or None of the size is unknown.</tt></dd></dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 429 | |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame^] | 430 | <dl><dt><a name="MediaFileUpload-to_json"><strong>to_json</strong></a>(self)</dt><dd><tt>Creating a JSON representation of an instance of <a href="#MediaFileUpload">MediaFileUpload</a>.<br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 431 | <br> |
| 432 | Returns:<br> |
| 433 | string, a JSON representation of this instance, suitable to pass to<br> |
| 434 | <a href="#MediaFileUpload-from_json">from_json</a>().</tt></dd></dl> |
| 435 | |
| 436 | <hr> |
| 437 | Static methods defined here:<br> |
| 438 | <dl><dt><a name="MediaFileUpload-from_json"><strong>from_json</strong></a>(s)</dt></dl> |
| 439 | |
| 440 | <hr> |
| 441 | Class methods inherited from <a href="apiclient.http.html#MediaUpload">MediaUpload</a>:<br> |
| 442 | <dl><dt><a name="MediaFileUpload-new_from_json"><strong>new_from_json</strong></a>(cls, s)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Utility class method to instantiate a <a href="#MediaUpload">MediaUpload</a> subclass from a JSON<br> |
| 443 | representation produced by <a href="#MediaFileUpload-to_json">to_json</a>().<br> |
| 444 | <br> |
| 445 | Args:<br> |
| 446 | s: string, JSON from <a href="#MediaFileUpload-to_json">to_json</a>().<br> |
| 447 | <br> |
| 448 | Returns:<br> |
| 449 | An instance of the subclass of <a href="#MediaUpload">MediaUpload</a> that was serialized with<br> |
| 450 | <a href="#MediaFileUpload-to_json">to_json</a>().</tt></dd></dl> |
| 451 | |
| 452 | <hr> |
| 453 | Data descriptors inherited from <a href="apiclient.http.html#MediaUpload">MediaUpload</a>:<br> |
| 454 | <dl><dt><strong>__dict__</strong></dt> |
| 455 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 456 | </dl> |
| 457 | <dl><dt><strong>__weakref__</strong></dt> |
| 458 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 459 | </dl> |
| 460 | </td></tr></table> <p> |
| 461 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 462 | <tr bgcolor="#ffc8d8"> |
| 463 | <td colspan=3 valign=bottom> <br> |
| 464 | <font color="#000000" face="helvetica, arial"><a name="MediaInMemoryUpload">class <strong>MediaInMemoryUpload</strong></a>(<a href="apiclient.http.html#MediaUpload">MediaUpload</a>)</font></td></tr> |
| 465 | |
| 466 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 467 | <td colspan=2><tt><a href="#MediaUpload">MediaUpload</a> for a chunk of bytes.<br> |
| 468 | <br> |
| 469 | Construct a <a href="#MediaFileUpload">MediaFileUpload</a> and pass as the media_body parameter of the<br> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame^] | 470 | method.<br> </tt></td></tr> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 471 | <tr><td> </td> |
| 472 | <td width="100%"><dl><dt>Method resolution order:</dt> |
| 473 | <dd><a href="apiclient.http.html#MediaInMemoryUpload">MediaInMemoryUpload</a></dd> |
| 474 | <dd><a href="apiclient.http.html#MediaUpload">MediaUpload</a></dd> |
| 475 | <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> |
| 476 | </dl> |
| 477 | <hr> |
| 478 | Methods defined here:<br> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 479 | <dl><dt><a name="MediaInMemoryUpload-__init__"><strong>__init__</strong></a>(self, body, mimetype<font color="#909090">='application/octet-stream'</font>, chunksize<font color="#909090">=524288</font>, resumable<font color="#909090">=False</font>)</dt><dd><tt>Create a new MediaBytesUpload.<br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 480 | <br> |
| 481 | Args:<br> |
| 482 | body: string, Bytes of body content.<br> |
| 483 | mimetype: string, Mime-type of the file or default of<br> |
| 484 | 'application/octet-stream'.<br> |
| 485 | chunksize: int, File will be uploaded in chunks of this many bytes. Only<br> |
| 486 | used if resumable=True.<br> |
| 487 | resumable: bool, True if this is a resumable upload. False means upload<br> |
| 488 | in a single request.</tt></dd></dl> |
| 489 | |
| 490 | <dl><dt><a name="MediaInMemoryUpload-chunksize"><strong>chunksize</strong></a>(self)</dt><dd><tt>Chunk size for resumable uploads.<br> |
| 491 | <br> |
| 492 | Returns:<br> |
| 493 | Chunk size in bytes.</tt></dd></dl> |
| 494 | |
| 495 | <dl><dt><a name="MediaInMemoryUpload-getbytes"><strong>getbytes</strong></a>(self, begin, length)</dt><dd><tt>Get bytes from the media.<br> |
| 496 | <br> |
| 497 | Args:<br> |
| 498 | begin: int, offset from beginning of file.<br> |
| 499 | length: int, number of bytes to read, starting at begin.<br> |
| 500 | <br> |
| 501 | Returns:<br> |
| 502 | A string of bytes read. May be shorter than length if EOF was reached<br> |
| 503 | first.</tt></dd></dl> |
| 504 | |
| 505 | <dl><dt><a name="MediaInMemoryUpload-mimetype"><strong>mimetype</strong></a>(self)</dt><dd><tt>Mime type of the body.<br> |
| 506 | <br> |
| 507 | Returns:<br> |
| 508 | Mime type.</tt></dd></dl> |
| 509 | |
| 510 | <dl><dt><a name="MediaInMemoryUpload-resumable"><strong>resumable</strong></a>(self)</dt><dd><tt>Whether this upload is resumable.<br> |
| 511 | <br> |
| 512 | Returns:<br> |
| 513 | True if resumable upload or False.</tt></dd></dl> |
| 514 | |
| 515 | <dl><dt><a name="MediaInMemoryUpload-size"><strong>size</strong></a>(self)</dt><dd><tt>Size of upload.<br> |
| 516 | <br> |
| 517 | Returns:<br> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 518 | Size of the body, or None of the size is unknown.</tt></dd></dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 519 | |
| 520 | <dl><dt><a name="MediaInMemoryUpload-to_json"><strong>to_json</strong></a>(self)</dt><dd><tt>Create a JSON representation of a <a href="#MediaInMemoryUpload">MediaInMemoryUpload</a>.<br> |
| 521 | <br> |
| 522 | Returns:<br> |
| 523 | string, a JSON representation of this instance, suitable to pass to<br> |
| 524 | <a href="#MediaInMemoryUpload-from_json">from_json</a>().</tt></dd></dl> |
| 525 | |
| 526 | <hr> |
| 527 | Static methods defined here:<br> |
| 528 | <dl><dt><a name="MediaInMemoryUpload-from_json"><strong>from_json</strong></a>(s)</dt></dl> |
| 529 | |
| 530 | <hr> |
| 531 | Class methods inherited from <a href="apiclient.http.html#MediaUpload">MediaUpload</a>:<br> |
| 532 | <dl><dt><a name="MediaInMemoryUpload-new_from_json"><strong>new_from_json</strong></a>(cls, s)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Utility class method to instantiate a <a href="#MediaUpload">MediaUpload</a> subclass from a JSON<br> |
| 533 | representation produced by <a href="#MediaInMemoryUpload-to_json">to_json</a>().<br> |
| 534 | <br> |
| 535 | Args:<br> |
| 536 | s: string, JSON from <a href="#MediaInMemoryUpload-to_json">to_json</a>().<br> |
| 537 | <br> |
| 538 | Returns:<br> |
| 539 | An instance of the subclass of <a href="#MediaUpload">MediaUpload</a> that was serialized with<br> |
| 540 | <a href="#MediaInMemoryUpload-to_json">to_json</a>().</tt></dd></dl> |
| 541 | |
| 542 | <hr> |
| 543 | Data descriptors inherited from <a href="apiclient.http.html#MediaUpload">MediaUpload</a>:<br> |
| 544 | <dl><dt><strong>__dict__</strong></dt> |
| 545 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 546 | </dl> |
| 547 | <dl><dt><strong>__weakref__</strong></dt> |
| 548 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 549 | </dl> |
| 550 | </td></tr></table> <p> |
| 551 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 552 | <tr bgcolor="#ffc8d8"> |
| 553 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame^] | 554 | <font color="#000000" face="helvetica, arial"><a name="MediaIoBaseDownload">class <strong>MediaIoBaseDownload</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 555 | |
| 556 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 557 | <td colspan=2><tt>"Download media resources.<br> |
| 558 | <br> |
| 559 | Note that the Python file <a href="__builtin__.html#object">object</a> is compatible with io.Base and can be used<br> |
| 560 | with this class also.<br> |
| 561 | <br> |
| 562 | <br> |
| 563 | Example:<br> |
| 564 | request = farms.animals().get_media(id='cow')<br> |
| 565 | fh = io.FileIO('cow.png', mode='wb')<br> |
| 566 | downloader = <a href="#MediaIoBaseDownload">MediaIoBaseDownload</a>(fh, request, chunksize=1024*1024)<br> |
| 567 | <br> |
| 568 | done = False<br> |
| 569 | while done is False:<br> |
| 570 | status, done = downloader.<a href="#MediaIoBaseDownload-next_chunk">next_chunk</a>()<br> |
| 571 | if status:<br> |
| 572 | print "Download %d%%." % int(status.progress() * 100)<br> |
| 573 | print "Download Complete!"<br> </tt></td></tr> |
| 574 | <tr><td> </td> |
| 575 | <td width="100%">Methods defined here:<br> |
| 576 | <dl><dt><a name="MediaIoBaseDownload-__init__"><strong>__init__</strong></a>(self, fh, request, chunksize<font color="#909090">=524288</font>)</dt><dd><tt>Constructor.<br> |
| 577 | <br> |
| 578 | Args:<br> |
| 579 | fh: io.Base or file <a href="__builtin__.html#object">object</a>, The stream in which to write the downloaded<br> |
| 580 | bytes.<br> |
| 581 | request: apiclient.http.<a href="#HttpRequest">HttpRequest</a>, the media request to perform in<br> |
| 582 | chunks.<br> |
| 583 | chunksize: int, File will be downloaded in chunks of this many bytes.</tt></dd></dl> |
| 584 | |
| 585 | <dl><dt><a name="MediaIoBaseDownload-next_chunk"><strong>next_chunk</strong></a>(self)</dt><dd><tt>Get the next chunk of the download.<br> |
| 586 | <br> |
| 587 | Returns:<br> |
| 588 | (status, done): (MediaDownloadStatus, boolean)<br> |
| 589 | The value of 'done' will be True when the media has been fully<br> |
| 590 | downloaded.<br> |
| 591 | <br> |
| 592 | Raises:<br> |
| 593 | apiclient.errors.HttpError if the response was not a 2xx.<br> |
| 594 | httplib2.Error if a transport error has occured.</tt></dd></dl> |
| 595 | |
| 596 | <hr> |
| 597 | Data descriptors defined here:<br> |
| 598 | <dl><dt><strong>__dict__</strong></dt> |
| 599 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 600 | </dl> |
| 601 | <dl><dt><strong>__weakref__</strong></dt> |
| 602 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 603 | </dl> |
| 604 | </td></tr></table> <p> |
| 605 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 606 | <tr bgcolor="#ffc8d8"> |
| 607 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 608 | <font color="#000000" face="helvetica, arial"><a name="MediaIoBaseUpload">class <strong>MediaIoBaseUpload</strong></a>(<a href="apiclient.http.html#MediaUpload">MediaUpload</a>)</font></td></tr> |
| 609 | |
| 610 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 611 | <td colspan=2><tt>A <a href="#MediaUpload">MediaUpload</a> for a io.Base objects.<br> |
| 612 | <br> |
| 613 | Note that the Python file <a href="__builtin__.html#object">object</a> is compatible with io.Base and can be used<br> |
| 614 | with this class also.<br> |
| 615 | <br> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 616 | fh = io.BytesIO('...Some data to upload...')<br> |
| 617 | media = <a href="#MediaIoBaseUpload">MediaIoBaseUpload</a>(fh, mimetype='image/png',<br> |
| 618 | chunksize=1024*1024, resumable=True)<br> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame^] | 619 | farm.animals().insert(<br> |
| 620 | id='cow',<br> |
| 621 | name='cow.png',<br> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 622 | media_body=media).execute()<br> </tt></td></tr> |
| 623 | <tr><td> </td> |
| 624 | <td width="100%"><dl><dt>Method resolution order:</dt> |
| 625 | <dd><a href="apiclient.http.html#MediaIoBaseUpload">MediaIoBaseUpload</a></dd> |
| 626 | <dd><a href="apiclient.http.html#MediaUpload">MediaUpload</a></dd> |
| 627 | <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> |
| 628 | </dl> |
| 629 | <hr> |
| 630 | Methods defined here:<br> |
| 631 | <dl><dt><a name="MediaIoBaseUpload-__init__"><strong>__init__</strong></a>(self, fh, mimetype, chunksize<font color="#909090">=524288</font>, resumable<font color="#909090">=False</font>)</dt><dd><tt>Constructor.<br> |
| 632 | <br> |
| 633 | Args:<br> |
Joe Gregorio | 746096f | 2012-06-15 10:53:36 -0400 | [diff] [blame] | 634 | fh: io.Base or file <a href="__builtin__.html#object">object</a>, The source of the bytes to upload. MUST be<br> |
| 635 | opened in blocking mode, do not use streams opened in non-blocking mode.<br> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 636 | mimetype: string, Mime-type of the file. If None then a mime-type will be<br> |
| 637 | guessed from the file extension.<br> |
| 638 | chunksize: int, File will be uploaded in chunks of this many bytes. Only<br> |
| 639 | used if resumable=True.<br> |
| 640 | resumable: bool, True if this is a resumable upload. False means upload<br> |
| 641 | in a single request.</tt></dd></dl> |
| 642 | |
| 643 | <dl><dt><a name="MediaIoBaseUpload-chunksize"><strong>chunksize</strong></a>(self)</dt><dd><tt>Chunk size for resumable uploads.<br> |
| 644 | <br> |
| 645 | Returns:<br> |
| 646 | Chunk size in bytes.</tt></dd></dl> |
| 647 | |
| 648 | <dl><dt><a name="MediaIoBaseUpload-getbytes"><strong>getbytes</strong></a>(self, begin, length)</dt><dd><tt>Get bytes from the media.<br> |
| 649 | <br> |
| 650 | Args:<br> |
| 651 | begin: int, offset from beginning of file.<br> |
| 652 | length: int, number of bytes to read, starting at begin.<br> |
| 653 | <br> |
| 654 | Returns:<br> |
| 655 | A string of bytes read. May be shorted than length if EOF was reached<br> |
| 656 | first.</tt></dd></dl> |
| 657 | |
| 658 | <dl><dt><a name="MediaIoBaseUpload-mimetype"><strong>mimetype</strong></a>(self)</dt><dd><tt>Mime type of the body.<br> |
| 659 | <br> |
| 660 | Returns:<br> |
| 661 | Mime type.</tt></dd></dl> |
| 662 | |
| 663 | <dl><dt><a name="MediaIoBaseUpload-resumable"><strong>resumable</strong></a>(self)</dt><dd><tt>Whether this upload is resumable.<br> |
| 664 | <br> |
| 665 | Returns:<br> |
| 666 | True if resumable upload or False.</tt></dd></dl> |
| 667 | |
| 668 | <dl><dt><a name="MediaIoBaseUpload-size"><strong>size</strong></a>(self)</dt><dd><tt>Size of upload.<br> |
| 669 | <br> |
| 670 | Returns:<br> |
| 671 | Size of the body, or None of the size is unknown.</tt></dd></dl> |
| 672 | |
| 673 | <dl><dt><a name="MediaIoBaseUpload-to_json"><strong>to_json</strong></a>(self)</dt><dd><tt>This upload type is not serializable.</tt></dd></dl> |
| 674 | |
| 675 | <hr> |
| 676 | Class methods inherited from <a href="apiclient.http.html#MediaUpload">MediaUpload</a>:<br> |
| 677 | <dl><dt><a name="MediaIoBaseUpload-new_from_json"><strong>new_from_json</strong></a>(cls, s)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Utility class method to instantiate a <a href="#MediaUpload">MediaUpload</a> subclass from a JSON<br> |
| 678 | representation produced by <a href="#MediaIoBaseUpload-to_json">to_json</a>().<br> |
| 679 | <br> |
| 680 | Args:<br> |
| 681 | s: string, JSON from <a href="#MediaIoBaseUpload-to_json">to_json</a>().<br> |
| 682 | <br> |
| 683 | Returns:<br> |
| 684 | An instance of the subclass of <a href="#MediaUpload">MediaUpload</a> that was serialized with<br> |
| 685 | <a href="#MediaIoBaseUpload-to_json">to_json</a>().</tt></dd></dl> |
| 686 | |
| 687 | <hr> |
| 688 | Data descriptors inherited from <a href="apiclient.http.html#MediaUpload">MediaUpload</a>:<br> |
| 689 | <dl><dt><strong>__dict__</strong></dt> |
| 690 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 691 | </dl> |
| 692 | <dl><dt><strong>__weakref__</strong></dt> |
| 693 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 694 | </dl> |
| 695 | </td></tr></table> <p> |
| 696 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 697 | <tr bgcolor="#ffc8d8"> |
| 698 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 699 | <font color="#000000" face="helvetica, arial"><a name="MediaUpload">class <strong>MediaUpload</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 700 | |
| 701 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 702 | <td colspan=2><tt>Describes a media <a href="__builtin__.html#object">object</a> to upload.<br> |
| 703 | <br> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 704 | Base class that defines the interface of <a href="#MediaUpload">MediaUpload</a> subclasses.<br> |
| 705 | <br> |
| 706 | Note that subclasses of <a href="#MediaUpload">MediaUpload</a> may allow you to control the chunksize<br> |
| 707 | when upload a media <a href="__builtin__.html#object">object</a>. It is important to keep the size of the chunk as<br> |
| 708 | large as possible to keep the upload efficient. Other factors may influence<br> |
| 709 | the size of the chunk you use, particularly if you are working in an<br> |
| 710 | environment where individual HTTP requests may have a hardcoded time limit,<br> |
| 711 | such as under certain classes of requests under Google App Engine.<br> </tt></td></tr> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 712 | <tr><td> </td> |
| 713 | <td width="100%">Methods defined here:<br> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 714 | <dl><dt><a name="MediaUpload-chunksize"><strong>chunksize</strong></a>(self)</dt><dd><tt>Chunk size for resumable uploads.<br> |
| 715 | <br> |
| 716 | Returns:<br> |
| 717 | Chunk size in bytes.</tt></dd></dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 718 | |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 719 | <dl><dt><a name="MediaUpload-getbytes"><strong>getbytes</strong></a>(self, begin, end)</dt><dd><tt>Get bytes from the media.<br> |
| 720 | <br> |
| 721 | Args:<br> |
| 722 | begin: int, offset from beginning of file.<br> |
| 723 | length: int, number of bytes to read, starting at begin.<br> |
| 724 | <br> |
| 725 | Returns:<br> |
| 726 | A string of bytes read. May be shorter than length if EOF was reached<br> |
| 727 | first.</tt></dd></dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 728 | |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 729 | <dl><dt><a name="MediaUpload-mimetype"><strong>mimetype</strong></a>(self)</dt><dd><tt>Mime type of the body.<br> |
| 730 | <br> |
| 731 | Returns:<br> |
| 732 | Mime type.</tt></dd></dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 733 | |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 734 | <dl><dt><a name="MediaUpload-resumable"><strong>resumable</strong></a>(self)</dt><dd><tt>Whether this upload is resumable.<br> |
| 735 | <br> |
| 736 | Returns:<br> |
| 737 | True if resumable upload or False.</tt></dd></dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 738 | |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 739 | <dl><dt><a name="MediaUpload-size"><strong>size</strong></a>(self)</dt><dd><tt>Size of upload.<br> |
| 740 | <br> |
| 741 | Returns:<br> |
| 742 | Size of the body, or None of the size is unknown.</tt></dd></dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 743 | |
| 744 | <dl><dt><a name="MediaUpload-to_json"><strong>to_json</strong></a>(self)</dt><dd><tt>Create a JSON representation of an instance of <a href="#MediaUpload">MediaUpload</a>.<br> |
| 745 | <br> |
| 746 | Returns:<br> |
| 747 | string, a JSON representation of this instance, suitable to pass to<br> |
| 748 | from_json().</tt></dd></dl> |
| 749 | |
| 750 | <hr> |
| 751 | Class methods defined here:<br> |
| 752 | <dl><dt><a name="MediaUpload-new_from_json"><strong>new_from_json</strong></a>(cls, s)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Utility class method to instantiate a <a href="#MediaUpload">MediaUpload</a> subclass from a JSON<br> |
| 753 | representation produced by <a href="#MediaUpload-to_json">to_json</a>().<br> |
| 754 | <br> |
| 755 | Args:<br> |
| 756 | s: string, JSON from <a href="#MediaUpload-to_json">to_json</a>().<br> |
| 757 | <br> |
| 758 | Returns:<br> |
| 759 | An instance of the subclass of <a href="#MediaUpload">MediaUpload</a> that was serialized with<br> |
| 760 | <a href="#MediaUpload-to_json">to_json</a>().</tt></dd></dl> |
| 761 | |
| 762 | <hr> |
| 763 | Data descriptors defined here:<br> |
| 764 | <dl><dt><strong>__dict__</strong></dt> |
| 765 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 766 | </dl> |
| 767 | <dl><dt><strong>__weakref__</strong></dt> |
| 768 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 769 | </dl> |
| 770 | </td></tr></table> <p> |
| 771 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 772 | <tr bgcolor="#ffc8d8"> |
| 773 | <td colspan=3 valign=bottom> <br> |
| 774 | <font color="#000000" face="helvetica, arial"><a name="MediaUploadProgress">class <strong>MediaUploadProgress</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 775 | |
| 776 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 777 | <td colspan=2><tt>Status of a resumable upload.<br> </tt></td></tr> |
| 778 | <tr><td> </td> |
| 779 | <td width="100%">Methods defined here:<br> |
| 780 | <dl><dt><a name="MediaUploadProgress-__init__"><strong>__init__</strong></a>(self, resumable_progress, total_size)</dt><dd><tt>Constructor.<br> |
| 781 | <br> |
| 782 | Args:<br> |
| 783 | resumable_progress: int, bytes sent so far.<br> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 784 | total_size: int, total bytes in complete upload, or None if the total<br> |
| 785 | upload size isn't known ahead of time.</tt></dd></dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 786 | |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 787 | <dl><dt><a name="MediaUploadProgress-progress"><strong>progress</strong></a>(self)</dt><dd><tt>Percent of upload completed, as a float.<br> |
| 788 | <br> |
| 789 | Returns:<br> |
| 790 | the percentage complete as a float, returning 0.0 if the total size of<br> |
| 791 | the upload is unknown.</tt></dd></dl> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 792 | |
| 793 | <hr> |
| 794 | Data descriptors defined here:<br> |
| 795 | <dl><dt><strong>__dict__</strong></dt> |
| 796 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 797 | </dl> |
| 798 | <dl><dt><strong>__weakref__</strong></dt> |
| 799 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 800 | </dl> |
| 801 | </td></tr></table> <p> |
| 802 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 803 | <tr bgcolor="#ffc8d8"> |
| 804 | <td colspan=3 valign=bottom> <br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 805 | <font color="#000000" face="helvetica, arial"><a name="RequestMockBuilder">class <strong>RequestMockBuilder</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| 806 | |
| 807 | <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| 808 | <td colspan=2><tt>A simple mock of <a href="#HttpRequest">HttpRequest</a><br> |
| 809 | <br> |
| 810 | Pass in a dictionary to the constructor that maps request methodIds to<br> |
Joe Gregorio | a845167 | 2011-09-15 09:53:21 -0400 | [diff] [blame] | 811 | tuples of (httplib2.Response, content, opt_expected_body) that should be<br> |
| 812 | returned when that method is called. None may also be passed in for the<br> |
| 813 | httplib2.Response, in which case a 200 OK response will be generated.<br> |
| 814 | If an opt_expected_body (str or dict) is provided, it will be compared to<br> |
| 815 | the body and UnexpectedBodyError will be raised on inequality.<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 816 | <br> |
| 817 | Example:<br> |
| 818 | response = '{"data": {"id": "tag:google.c...'<br> |
| 819 | requestBuilder = <a href="#RequestMockBuilder">RequestMockBuilder</a>(<br> |
| 820 | {<br> |
Joe Gregorio | c4fc095 | 2011-11-09 12:21:11 -0500 | [diff] [blame] | 821 | 'plus.activities.get': (None, response),<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 822 | }<br> |
| 823 | )<br> |
Joe Gregorio | c4fc095 | 2011-11-09 12:21:11 -0500 | [diff] [blame] | 824 | apiclient.discovery.build("plus", "v1", requestBuilder=requestBuilder)<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 825 | <br> |
| 826 | Methods that you do not supply a response for will return a<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 827 | 200 OK with an empty string as the response content or raise an excpetion<br> |
| 828 | if check_unexpected is set to True. The methodId is taken from the rpcName<br> |
Joe Gregorio | a845167 | 2011-09-15 09:53:21 -0400 | [diff] [blame] | 829 | in the discovery document.<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 830 | <br> |
| 831 | For more details see the project wiki.<br> </tt></td></tr> |
| 832 | <tr><td> </td> |
| 833 | <td width="100%">Methods defined here:<br> |
Joe Gregorio | b417caf | 2011-12-08 12:04:24 -0500 | [diff] [blame] | 834 | <dl><dt><a name="RequestMockBuilder-__call__"><strong>__call__</strong></a>(self, http, postproc, uri, method<font color="#909090">='GET'</font>, body<font color="#909090">=None</font>, headers<font color="#909090">=None</font>, methodId<font color="#909090">=None</font>, resumable<font color="#909090">=None</font>)</dt><dd><tt>Implements the callable interface that discovery.build() expects<br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 835 | of requestBuilder, which is to build an <a href="__builtin__.html#object">object</a> compatible with<br> |
| 836 | <a href="#HttpRequest">HttpRequest</a>.execute(). See that method for the description of the<br> |
| 837 | parameters and the expected response.</tt></dd></dl> |
| 838 | |
Joe Gregorio | a845167 | 2011-09-15 09:53:21 -0400 | [diff] [blame] | 839 | <dl><dt><a name="RequestMockBuilder-__init__"><strong>__init__</strong></a>(self, responses, check_unexpected<font color="#909090">=False</font>)</dt><dd><tt>Constructor for <a href="#RequestMockBuilder">RequestMockBuilder</a><br> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 840 | <br> |
| 841 | The constructed <a href="__builtin__.html#object">object</a> should be a callable <a href="__builtin__.html#object">object</a><br> |
| 842 | that can replace the class HttpResponse.<br> |
| 843 | <br> |
| 844 | responses - A dictionary that maps methodIds into tuples<br> |
| 845 | of (httplib2.Response, content). The methodId<br> |
| 846 | comes from the 'rpcName' field in the discovery<br> |
Joe Gregorio | a845167 | 2011-09-15 09:53:21 -0400 | [diff] [blame] | 847 | document.<br> |
| 848 | check_unexpected - A boolean setting whether or not UnexpectedMethodError<br> |
| 849 | should be raised on unsupplied method.</tt></dd></dl> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 850 | |
| 851 | <hr> |
| 852 | Data descriptors defined here:<br> |
| 853 | <dl><dt><strong>__dict__</strong></dt> |
| 854 | <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| 855 | </dl> |
| 856 | <dl><dt><strong>__weakref__</strong></dt> |
| 857 | <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| 858 | </dl> |
| 859 | </td></tr></table></td></tr></table><p> |
| 860 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
Joe Gregorio | 20a5aa9 | 2011-04-01 17:44:25 -0400 | [diff] [blame] | 861 | <tr bgcolor="#eeaa77"> |
| 862 | <td colspan=3 valign=bottom> <br> |
| 863 | <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> |
| 864 | |
| 865 | <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> |
Joe Gregorio | d9d0090 | 2012-04-13 07:58:30 -0400 | [diff] [blame] | 866 | <td width="100%"><dl><dt><a name="-set_user_agent"><strong>set_user_agent</strong></a>(http, user_agent)</dt><dd><tt>Set the user-agent on every request.<br> |
| 867 | <br> |
| 868 | Args:<br> |
| 869 | http - An instance of httplib2.Http<br> |
| 870 | or something that acts like it.<br> |
| 871 | user_agent: string, the value for the user-agent header.<br> |
| 872 | <br> |
| 873 | Returns:<br> |
| 874 | A modified instance of http that was passed in.<br> |
| 875 | <br> |
| 876 | Example:<br> |
| 877 | <br> |
| 878 | h = httplib2.Http()<br> |
| 879 | h = <a href="#-set_user_agent">set_user_agent</a>(h, "my-app-name/6.0")<br> |
| 880 | <br> |
| 881 | Most of the time the user-agent will be set doing auth, this is for the rare<br> |
| 882 | cases where you are accessing an unauthenticated endpoint.</tt></dd></dl> |
| 883 | <dl><dt><a name="-tunnel_patch"><strong>tunnel_patch</strong></a>(http)</dt><dd><tt>Tunnel PATCH requests over POST.<br> |
Joe Gregorio | 20a5aa9 | 2011-04-01 17:44:25 -0400 | [diff] [blame] | 884 | Args:<br> |
| 885 | http - An instance of httplib2.Http<br> |
| 886 | or something that acts like it.<br> |
| 887 | <br> |
| 888 | Returns:<br> |
| 889 | A modified instance of http that was passed in.<br> |
| 890 | <br> |
| 891 | Example:<br> |
| 892 | <br> |
| 893 | h = httplib2.Http()<br> |
| 894 | h = <a href="#-tunnel_patch">tunnel_patch</a>(h, "my-app-name/6.0")<br> |
| 895 | <br> |
| 896 | Useful if you are running on a platform that doesn't support PATCH.<br> |
| 897 | Apply this last if you are using OAuth 1.0, as changing the method<br> |
| 898 | will result in a different signature.</tt></dd></dl> |
| 899 | </td></tr></table><p> |
| 900 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 901 | <tr bgcolor="#55aa55"> |
| 902 | <td colspan=3 valign=bottom> <br> |
| 903 | <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> |
| 904 | |
| 905 | <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> |
Joe Gregorio | 6621203 | 2012-06-14 09:10:14 -0400 | [diff] [blame] | 906 | <td width="100%"><strong>DEFAULT_CHUNK_SIZE</strong> = 524288<br> |
| 907 | <strong>__author__</strong> = 'jcgregorio@google.com (Joe Gregorio)'</td></tr></table><p> |
Joe Gregorio | 30dfdc3 | 2010-12-09 16:34:22 -0500 | [diff] [blame] | 908 | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| 909 | <tr bgcolor="#7799ee"> |
| 910 | <td colspan=3 valign=bottom> <br> |
| 911 | <font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr> |
| 912 | |
| 913 | <tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td> |
| 914 | <td width="100%">jcgregorio@google.com (Joe Gregorio)</td></tr></table> |
| 915 | </body></html> |