1.9.30 sync.
[gae.git] / python / google / appengine / api / urlfetch_service_pb.py
blob2bcff8c2dff7a6678209ace6f0eac6ec6be07f3e
1 #!/usr/bin/env python
3 # Copyright 2007 Google Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 from google.net.proto import ProtocolBuffer
21 import array
22 import dummy_thread as thread
24 __pychecker__ = """maxreturns=0 maxbranches=0 no-callinit
25 unusednames=printElemNumber,debug_strs no-special"""
27 if hasattr(ProtocolBuffer, 'ExtendableProtocolMessage'):
28 _extension_runtime = True
29 _ExtendableProtocolMessage = ProtocolBuffer.ExtendableProtocolMessage
30 else:
31 _extension_runtime = False
32 _ExtendableProtocolMessage = ProtocolBuffer.ProtocolMessage
34 class URLFetchServiceError(ProtocolBuffer.ProtocolMessage):
37 OK = 0
38 INVALID_URL = 1
39 FETCH_ERROR = 2
40 UNSPECIFIED_ERROR = 3
41 RESPONSE_TOO_LARGE = 4
42 DEADLINE_EXCEEDED = 5
43 SSL_CERTIFICATE_ERROR = 6
44 DNS_ERROR = 7
45 CLOSED = 8
46 INTERNAL_TRANSIENT_ERROR = 9
47 TOO_MANY_REDIRECTS = 10
48 MALFORMED_REPLY = 11
49 CONNECTION_ERROR = 12
51 _ErrorCode_NAMES = {
52 0: "OK",
53 1: "INVALID_URL",
54 2: "FETCH_ERROR",
55 3: "UNSPECIFIED_ERROR",
56 4: "RESPONSE_TOO_LARGE",
57 5: "DEADLINE_EXCEEDED",
58 6: "SSL_CERTIFICATE_ERROR",
59 7: "DNS_ERROR",
60 8: "CLOSED",
61 9: "INTERNAL_TRANSIENT_ERROR",
62 10: "TOO_MANY_REDIRECTS",
63 11: "MALFORMED_REPLY",
64 12: "CONNECTION_ERROR",
67 def ErrorCode_Name(cls, x): return cls._ErrorCode_NAMES.get(x, "")
68 ErrorCode_Name = classmethod(ErrorCode_Name)
71 def __init__(self, contents=None):
72 pass
73 if contents is not None: self.MergeFromString(contents)
76 def MergeFrom(self, x):
77 assert x is not self
79 def Equals(self, x):
80 if x is self: return 1
81 return 1
83 def IsInitialized(self, debug_strs=None):
84 initialized = 1
85 return initialized
87 def ByteSize(self):
88 n = 0
89 return n
91 def ByteSizePartial(self):
92 n = 0
93 return n
95 def Clear(self):
96 pass
98 def OutputUnchecked(self, out):
99 pass
101 def OutputPartial(self, out):
102 pass
104 def TryMerge(self, d):
105 while d.avail() > 0:
106 tt = d.getVarInt32()
109 if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
110 d.skipData(tt)
113 def __str__(self, prefix="", printElemNumber=0):
114 res=""
115 return res
118 def _BuildTagLookupTable(sparse, maxtag, default=None):
119 return tuple([sparse.get(i, default) for i in xrange(0, 1+maxtag)])
122 _TEXT = _BuildTagLookupTable({
123 0: "ErrorCode",
124 }, 0)
126 _TYPES = _BuildTagLookupTable({
127 0: ProtocolBuffer.Encoder.NUMERIC,
128 }, 0, ProtocolBuffer.Encoder.MAX_TYPE)
131 _STYLE = """"""
132 _STYLE_CONTENT_TYPE = """"""
133 _PROTO_DESCRIPTOR_NAME = 'apphosting.URLFetchServiceError'
134 class URLFetchRequest_Header(ProtocolBuffer.ProtocolMessage):
135 has_key_ = 0
136 key_ = ""
137 has_value_ = 0
138 value_ = ""
140 def __init__(self, contents=None):
141 if contents is not None: self.MergeFromString(contents)
143 def key(self): return self.key_
145 def set_key(self, x):
146 self.has_key_ = 1
147 self.key_ = x
149 def clear_key(self):
150 if self.has_key_:
151 self.has_key_ = 0
152 self.key_ = ""
154 def has_key(self): return self.has_key_
156 def value(self): return self.value_
158 def set_value(self, x):
159 self.has_value_ = 1
160 self.value_ = x
162 def clear_value(self):
163 if self.has_value_:
164 self.has_value_ = 0
165 self.value_ = ""
167 def has_value(self): return self.has_value_
170 def MergeFrom(self, x):
171 assert x is not self
172 if (x.has_key()): self.set_key(x.key())
173 if (x.has_value()): self.set_value(x.value())
175 def Equals(self, x):
176 if x is self: return 1
177 if self.has_key_ != x.has_key_: return 0
178 if self.has_key_ and self.key_ != x.key_: return 0
179 if self.has_value_ != x.has_value_: return 0
180 if self.has_value_ and self.value_ != x.value_: return 0
181 return 1
183 def IsInitialized(self, debug_strs=None):
184 initialized = 1
185 if (not self.has_key_):
186 initialized = 0
187 if debug_strs is not None:
188 debug_strs.append('Required field: key not set.')
189 if (not self.has_value_):
190 initialized = 0
191 if debug_strs is not None:
192 debug_strs.append('Required field: value not set.')
193 return initialized
195 def ByteSize(self):
196 n = 0
197 n += self.lengthString(len(self.key_))
198 n += self.lengthString(len(self.value_))
199 return n + 2
201 def ByteSizePartial(self):
202 n = 0
203 if (self.has_key_):
204 n += 1
205 n += self.lengthString(len(self.key_))
206 if (self.has_value_):
207 n += 1
208 n += self.lengthString(len(self.value_))
209 return n
211 def Clear(self):
212 self.clear_key()
213 self.clear_value()
215 def OutputUnchecked(self, out):
216 out.putVarInt32(34)
217 out.putPrefixedString(self.key_)
218 out.putVarInt32(42)
219 out.putPrefixedString(self.value_)
221 def OutputPartial(self, out):
222 if (self.has_key_):
223 out.putVarInt32(34)
224 out.putPrefixedString(self.key_)
225 if (self.has_value_):
226 out.putVarInt32(42)
227 out.putPrefixedString(self.value_)
229 def TryMerge(self, d):
230 while 1:
231 tt = d.getVarInt32()
232 if tt == 28: break
233 if tt == 34:
234 self.set_key(d.getPrefixedString())
235 continue
236 if tt == 42:
237 self.set_value(d.getPrefixedString())
238 continue
241 if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
242 d.skipData(tt)
245 def __str__(self, prefix="", printElemNumber=0):
246 res=""
247 if self.has_key_: res+=prefix+("Key: %s\n" % self.DebugFormatString(self.key_))
248 if self.has_value_: res+=prefix+("Value: %s\n" % self.DebugFormatString(self.value_))
249 return res
251 class URLFetchRequest(ProtocolBuffer.ProtocolMessage):
254 GET = 1
255 POST = 2
256 HEAD = 3
257 PUT = 4
258 DELETE = 5
259 PATCH = 6
261 _RequestMethod_NAMES = {
262 1: "GET",
263 2: "POST",
264 3: "HEAD",
265 4: "PUT",
266 5: "DELETE",
267 6: "PATCH",
270 def RequestMethod_Name(cls, x): return cls._RequestMethod_NAMES.get(x, "")
271 RequestMethod_Name = classmethod(RequestMethod_Name)
273 has_method_ = 0
274 method_ = 0
275 has_url_ = 0
276 url_ = ""
277 has_payload_ = 0
278 payload_ = ""
279 has_followredirects_ = 0
280 followredirects_ = 1
281 has_deadline_ = 0
282 deadline_ = 0.0
283 has_mustvalidateservercertificate_ = 0
284 mustvalidateservercertificate_ = 1
286 def __init__(self, contents=None):
287 self.header_ = []
288 if contents is not None: self.MergeFromString(contents)
290 def method(self): return self.method_
292 def set_method(self, x):
293 self.has_method_ = 1
294 self.method_ = x
296 def clear_method(self):
297 if self.has_method_:
298 self.has_method_ = 0
299 self.method_ = 0
301 def has_method(self): return self.has_method_
303 def url(self): return self.url_
305 def set_url(self, x):
306 self.has_url_ = 1
307 self.url_ = x
309 def clear_url(self):
310 if self.has_url_:
311 self.has_url_ = 0
312 self.url_ = ""
314 def has_url(self): return self.has_url_
316 def header_size(self): return len(self.header_)
317 def header_list(self): return self.header_
319 def header(self, i):
320 return self.header_[i]
322 def mutable_header(self, i):
323 return self.header_[i]
325 def add_header(self):
326 x = URLFetchRequest_Header()
327 self.header_.append(x)
328 return x
330 def clear_header(self):
331 self.header_ = []
332 def payload(self): return self.payload_
334 def set_payload(self, x):
335 self.has_payload_ = 1
336 self.payload_ = x
338 def clear_payload(self):
339 if self.has_payload_:
340 self.has_payload_ = 0
341 self.payload_ = ""
343 def has_payload(self): return self.has_payload_
345 def followredirects(self): return self.followredirects_
347 def set_followredirects(self, x):
348 self.has_followredirects_ = 1
349 self.followredirects_ = x
351 def clear_followredirects(self):
352 if self.has_followredirects_:
353 self.has_followredirects_ = 0
354 self.followredirects_ = 1
356 def has_followredirects(self): return self.has_followredirects_
358 def deadline(self): return self.deadline_
360 def set_deadline(self, x):
361 self.has_deadline_ = 1
362 self.deadline_ = x
364 def clear_deadline(self):
365 if self.has_deadline_:
366 self.has_deadline_ = 0
367 self.deadline_ = 0.0
369 def has_deadline(self): return self.has_deadline_
371 def mustvalidateservercertificate(self): return self.mustvalidateservercertificate_
373 def set_mustvalidateservercertificate(self, x):
374 self.has_mustvalidateservercertificate_ = 1
375 self.mustvalidateservercertificate_ = x
377 def clear_mustvalidateservercertificate(self):
378 if self.has_mustvalidateservercertificate_:
379 self.has_mustvalidateservercertificate_ = 0
380 self.mustvalidateservercertificate_ = 1
382 def has_mustvalidateservercertificate(self): return self.has_mustvalidateservercertificate_
385 def MergeFrom(self, x):
386 assert x is not self
387 if (x.has_method()): self.set_method(x.method())
388 if (x.has_url()): self.set_url(x.url())
389 for i in xrange(x.header_size()): self.add_header().CopyFrom(x.header(i))
390 if (x.has_payload()): self.set_payload(x.payload())
391 if (x.has_followredirects()): self.set_followredirects(x.followredirects())
392 if (x.has_deadline()): self.set_deadline(x.deadline())
393 if (x.has_mustvalidateservercertificate()): self.set_mustvalidateservercertificate(x.mustvalidateservercertificate())
395 def Equals(self, x):
396 if x is self: return 1
397 if self.has_method_ != x.has_method_: return 0
398 if self.has_method_ and self.method_ != x.method_: return 0
399 if self.has_url_ != x.has_url_: return 0
400 if self.has_url_ and self.url_ != x.url_: return 0
401 if len(self.header_) != len(x.header_): return 0
402 for e1, e2 in zip(self.header_, x.header_):
403 if e1 != e2: return 0
404 if self.has_payload_ != x.has_payload_: return 0
405 if self.has_payload_ and self.payload_ != x.payload_: return 0
406 if self.has_followredirects_ != x.has_followredirects_: return 0
407 if self.has_followredirects_ and self.followredirects_ != x.followredirects_: return 0
408 if self.has_deadline_ != x.has_deadline_: return 0
409 if self.has_deadline_ and self.deadline_ != x.deadline_: return 0
410 if self.has_mustvalidateservercertificate_ != x.has_mustvalidateservercertificate_: return 0
411 if self.has_mustvalidateservercertificate_ and self.mustvalidateservercertificate_ != x.mustvalidateservercertificate_: return 0
412 return 1
414 def IsInitialized(self, debug_strs=None):
415 initialized = 1
416 if (not self.has_method_):
417 initialized = 0
418 if debug_strs is not None:
419 debug_strs.append('Required field: method not set.')
420 if (not self.has_url_):
421 initialized = 0
422 if debug_strs is not None:
423 debug_strs.append('Required field: url not set.')
424 for p in self.header_:
425 if not p.IsInitialized(debug_strs): initialized=0
426 return initialized
428 def ByteSize(self):
429 n = 0
430 n += self.lengthVarInt64(self.method_)
431 n += self.lengthString(len(self.url_))
432 n += 2 * len(self.header_)
433 for i in xrange(len(self.header_)): n += self.header_[i].ByteSize()
434 if (self.has_payload_): n += 1 + self.lengthString(len(self.payload_))
435 if (self.has_followredirects_): n += 2
436 if (self.has_deadline_): n += 9
437 if (self.has_mustvalidateservercertificate_): n += 2
438 return n + 2
440 def ByteSizePartial(self):
441 n = 0
442 if (self.has_method_):
443 n += 1
444 n += self.lengthVarInt64(self.method_)
445 if (self.has_url_):
446 n += 1
447 n += self.lengthString(len(self.url_))
448 n += 2 * len(self.header_)
449 for i in xrange(len(self.header_)): n += self.header_[i].ByteSizePartial()
450 if (self.has_payload_): n += 1 + self.lengthString(len(self.payload_))
451 if (self.has_followredirects_): n += 2
452 if (self.has_deadline_): n += 9
453 if (self.has_mustvalidateservercertificate_): n += 2
454 return n
456 def Clear(self):
457 self.clear_method()
458 self.clear_url()
459 self.clear_header()
460 self.clear_payload()
461 self.clear_followredirects()
462 self.clear_deadline()
463 self.clear_mustvalidateservercertificate()
465 def OutputUnchecked(self, out):
466 out.putVarInt32(8)
467 out.putVarInt32(self.method_)
468 out.putVarInt32(18)
469 out.putPrefixedString(self.url_)
470 for i in xrange(len(self.header_)):
471 out.putVarInt32(27)
472 self.header_[i].OutputUnchecked(out)
473 out.putVarInt32(28)
474 if (self.has_payload_):
475 out.putVarInt32(50)
476 out.putPrefixedString(self.payload_)
477 if (self.has_followredirects_):
478 out.putVarInt32(56)
479 out.putBoolean(self.followredirects_)
480 if (self.has_deadline_):
481 out.putVarInt32(65)
482 out.putDouble(self.deadline_)
483 if (self.has_mustvalidateservercertificate_):
484 out.putVarInt32(72)
485 out.putBoolean(self.mustvalidateservercertificate_)
487 def OutputPartial(self, out):
488 if (self.has_method_):
489 out.putVarInt32(8)
490 out.putVarInt32(self.method_)
491 if (self.has_url_):
492 out.putVarInt32(18)
493 out.putPrefixedString(self.url_)
494 for i in xrange(len(self.header_)):
495 out.putVarInt32(27)
496 self.header_[i].OutputPartial(out)
497 out.putVarInt32(28)
498 if (self.has_payload_):
499 out.putVarInt32(50)
500 out.putPrefixedString(self.payload_)
501 if (self.has_followredirects_):
502 out.putVarInt32(56)
503 out.putBoolean(self.followredirects_)
504 if (self.has_deadline_):
505 out.putVarInt32(65)
506 out.putDouble(self.deadline_)
507 if (self.has_mustvalidateservercertificate_):
508 out.putVarInt32(72)
509 out.putBoolean(self.mustvalidateservercertificate_)
511 def TryMerge(self, d):
512 while d.avail() > 0:
513 tt = d.getVarInt32()
514 if tt == 8:
515 self.set_method(d.getVarInt32())
516 continue
517 if tt == 18:
518 self.set_url(d.getPrefixedString())
519 continue
520 if tt == 27:
521 self.add_header().TryMerge(d)
522 continue
523 if tt == 50:
524 self.set_payload(d.getPrefixedString())
525 continue
526 if tt == 56:
527 self.set_followredirects(d.getBoolean())
528 continue
529 if tt == 65:
530 self.set_deadline(d.getDouble())
531 continue
532 if tt == 72:
533 self.set_mustvalidateservercertificate(d.getBoolean())
534 continue
537 if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
538 d.skipData(tt)
541 def __str__(self, prefix="", printElemNumber=0):
542 res=""
543 if self.has_method_: res+=prefix+("Method: %s\n" % self.DebugFormatInt32(self.method_))
544 if self.has_url_: res+=prefix+("Url: %s\n" % self.DebugFormatString(self.url_))
545 cnt=0
546 for e in self.header_:
547 elm=""
548 if printElemNumber: elm="(%d)" % cnt
549 res+=prefix+("Header%s {\n" % elm)
550 res+=e.__str__(prefix + " ", printElemNumber)
551 res+=prefix+"}\n"
552 cnt+=1
553 if self.has_payload_: res+=prefix+("Payload: %s\n" % self.DebugFormatString(self.payload_))
554 if self.has_followredirects_: res+=prefix+("FollowRedirects: %s\n" % self.DebugFormatBool(self.followredirects_))
555 if self.has_deadline_: res+=prefix+("Deadline: %s\n" % self.DebugFormat(self.deadline_))
556 if self.has_mustvalidateservercertificate_: res+=prefix+("MustValidateServerCertificate: %s\n" % self.DebugFormatBool(self.mustvalidateservercertificate_))
557 return res
560 def _BuildTagLookupTable(sparse, maxtag, default=None):
561 return tuple([sparse.get(i, default) for i in xrange(0, 1+maxtag)])
563 kMethod = 1
564 kUrl = 2
565 kHeaderGroup = 3
566 kHeaderKey = 4
567 kHeaderValue = 5
568 kPayload = 6
569 kFollowRedirects = 7
570 kDeadline = 8
571 kMustValidateServerCertificate = 9
573 _TEXT = _BuildTagLookupTable({
574 0: "ErrorCode",
575 1: "Method",
576 2: "Url",
577 3: "Header",
578 4: "Key",
579 5: "Value",
580 6: "Payload",
581 7: "FollowRedirects",
582 8: "Deadline",
583 9: "MustValidateServerCertificate",
584 }, 9)
586 _TYPES = _BuildTagLookupTable({
587 0: ProtocolBuffer.Encoder.NUMERIC,
588 1: ProtocolBuffer.Encoder.NUMERIC,
589 2: ProtocolBuffer.Encoder.STRING,
590 3: ProtocolBuffer.Encoder.STARTGROUP,
591 4: ProtocolBuffer.Encoder.STRING,
592 5: ProtocolBuffer.Encoder.STRING,
593 6: ProtocolBuffer.Encoder.STRING,
594 7: ProtocolBuffer.Encoder.NUMERIC,
595 8: ProtocolBuffer.Encoder.DOUBLE,
596 9: ProtocolBuffer.Encoder.NUMERIC,
597 }, 9, ProtocolBuffer.Encoder.MAX_TYPE)
600 _STYLE = """"""
601 _STYLE_CONTENT_TYPE = """"""
602 _PROTO_DESCRIPTOR_NAME = 'apphosting.URLFetchRequest'
603 class URLFetchResponse_Header(ProtocolBuffer.ProtocolMessage):
604 has_key_ = 0
605 key_ = ""
606 has_value_ = 0
607 value_ = ""
609 def __init__(self, contents=None):
610 if contents is not None: self.MergeFromString(contents)
612 def key(self): return self.key_
614 def set_key(self, x):
615 self.has_key_ = 1
616 self.key_ = x
618 def clear_key(self):
619 if self.has_key_:
620 self.has_key_ = 0
621 self.key_ = ""
623 def has_key(self): return self.has_key_
625 def value(self): return self.value_
627 def set_value(self, x):
628 self.has_value_ = 1
629 self.value_ = x
631 def clear_value(self):
632 if self.has_value_:
633 self.has_value_ = 0
634 self.value_ = ""
636 def has_value(self): return self.has_value_
639 def MergeFrom(self, x):
640 assert x is not self
641 if (x.has_key()): self.set_key(x.key())
642 if (x.has_value()): self.set_value(x.value())
644 def Equals(self, x):
645 if x is self: return 1
646 if self.has_key_ != x.has_key_: return 0
647 if self.has_key_ and self.key_ != x.key_: return 0
648 if self.has_value_ != x.has_value_: return 0
649 if self.has_value_ and self.value_ != x.value_: return 0
650 return 1
652 def IsInitialized(self, debug_strs=None):
653 initialized = 1
654 if (not self.has_key_):
655 initialized = 0
656 if debug_strs is not None:
657 debug_strs.append('Required field: key not set.')
658 if (not self.has_value_):
659 initialized = 0
660 if debug_strs is not None:
661 debug_strs.append('Required field: value not set.')
662 return initialized
664 def ByteSize(self):
665 n = 0
666 n += self.lengthString(len(self.key_))
667 n += self.lengthString(len(self.value_))
668 return n + 2
670 def ByteSizePartial(self):
671 n = 0
672 if (self.has_key_):
673 n += 1
674 n += self.lengthString(len(self.key_))
675 if (self.has_value_):
676 n += 1
677 n += self.lengthString(len(self.value_))
678 return n
680 def Clear(self):
681 self.clear_key()
682 self.clear_value()
684 def OutputUnchecked(self, out):
685 out.putVarInt32(34)
686 out.putPrefixedString(self.key_)
687 out.putVarInt32(42)
688 out.putPrefixedString(self.value_)
690 def OutputPartial(self, out):
691 if (self.has_key_):
692 out.putVarInt32(34)
693 out.putPrefixedString(self.key_)
694 if (self.has_value_):
695 out.putVarInt32(42)
696 out.putPrefixedString(self.value_)
698 def TryMerge(self, d):
699 while 1:
700 tt = d.getVarInt32()
701 if tt == 28: break
702 if tt == 34:
703 self.set_key(d.getPrefixedString())
704 continue
705 if tt == 42:
706 self.set_value(d.getPrefixedString())
707 continue
710 if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
711 d.skipData(tt)
714 def __str__(self, prefix="", printElemNumber=0):
715 res=""
716 if self.has_key_: res+=prefix+("Key: %s\n" % self.DebugFormatString(self.key_))
717 if self.has_value_: res+=prefix+("Value: %s\n" % self.DebugFormatString(self.value_))
718 return res
720 class URLFetchResponse(ProtocolBuffer.ProtocolMessage):
721 has_content_ = 0
722 content_ = ""
723 has_statuscode_ = 0
724 statuscode_ = 0
725 has_contentwastruncated_ = 0
726 contentwastruncated_ = 0
727 has_externalbytessent_ = 0
728 externalbytessent_ = 0
729 has_externalbytesreceived_ = 0
730 externalbytesreceived_ = 0
731 has_finalurl_ = 0
732 finalurl_ = ""
733 has_apicpumilliseconds_ = 0
734 apicpumilliseconds_ = 0
735 has_apibytessent_ = 0
736 apibytessent_ = 0
737 has_apibytesreceived_ = 0
738 apibytesreceived_ = 0
740 def __init__(self, contents=None):
741 self.header_ = []
742 if contents is not None: self.MergeFromString(contents)
744 def content(self): return self.content_
746 def set_content(self, x):
747 self.has_content_ = 1
748 self.content_ = x
750 def clear_content(self):
751 if self.has_content_:
752 self.has_content_ = 0
753 self.content_ = ""
755 def has_content(self): return self.has_content_
757 def statuscode(self): return self.statuscode_
759 def set_statuscode(self, x):
760 self.has_statuscode_ = 1
761 self.statuscode_ = x
763 def clear_statuscode(self):
764 if self.has_statuscode_:
765 self.has_statuscode_ = 0
766 self.statuscode_ = 0
768 def has_statuscode(self): return self.has_statuscode_
770 def header_size(self): return len(self.header_)
771 def header_list(self): return self.header_
773 def header(self, i):
774 return self.header_[i]
776 def mutable_header(self, i):
777 return self.header_[i]
779 def add_header(self):
780 x = URLFetchResponse_Header()
781 self.header_.append(x)
782 return x
784 def clear_header(self):
785 self.header_ = []
786 def contentwastruncated(self): return self.contentwastruncated_
788 def set_contentwastruncated(self, x):
789 self.has_contentwastruncated_ = 1
790 self.contentwastruncated_ = x
792 def clear_contentwastruncated(self):
793 if self.has_contentwastruncated_:
794 self.has_contentwastruncated_ = 0
795 self.contentwastruncated_ = 0
797 def has_contentwastruncated(self): return self.has_contentwastruncated_
799 def externalbytessent(self): return self.externalbytessent_
801 def set_externalbytessent(self, x):
802 self.has_externalbytessent_ = 1
803 self.externalbytessent_ = x
805 def clear_externalbytessent(self):
806 if self.has_externalbytessent_:
807 self.has_externalbytessent_ = 0
808 self.externalbytessent_ = 0
810 def has_externalbytessent(self): return self.has_externalbytessent_
812 def externalbytesreceived(self): return self.externalbytesreceived_
814 def set_externalbytesreceived(self, x):
815 self.has_externalbytesreceived_ = 1
816 self.externalbytesreceived_ = x
818 def clear_externalbytesreceived(self):
819 if self.has_externalbytesreceived_:
820 self.has_externalbytesreceived_ = 0
821 self.externalbytesreceived_ = 0
823 def has_externalbytesreceived(self): return self.has_externalbytesreceived_
825 def finalurl(self): return self.finalurl_
827 def set_finalurl(self, x):
828 self.has_finalurl_ = 1
829 self.finalurl_ = x
831 def clear_finalurl(self):
832 if self.has_finalurl_:
833 self.has_finalurl_ = 0
834 self.finalurl_ = ""
836 def has_finalurl(self): return self.has_finalurl_
838 def apicpumilliseconds(self): return self.apicpumilliseconds_
840 def set_apicpumilliseconds(self, x):
841 self.has_apicpumilliseconds_ = 1
842 self.apicpumilliseconds_ = x
844 def clear_apicpumilliseconds(self):
845 if self.has_apicpumilliseconds_:
846 self.has_apicpumilliseconds_ = 0
847 self.apicpumilliseconds_ = 0
849 def has_apicpumilliseconds(self): return self.has_apicpumilliseconds_
851 def apibytessent(self): return self.apibytessent_
853 def set_apibytessent(self, x):
854 self.has_apibytessent_ = 1
855 self.apibytessent_ = x
857 def clear_apibytessent(self):
858 if self.has_apibytessent_:
859 self.has_apibytessent_ = 0
860 self.apibytessent_ = 0
862 def has_apibytessent(self): return self.has_apibytessent_
864 def apibytesreceived(self): return self.apibytesreceived_
866 def set_apibytesreceived(self, x):
867 self.has_apibytesreceived_ = 1
868 self.apibytesreceived_ = x
870 def clear_apibytesreceived(self):
871 if self.has_apibytesreceived_:
872 self.has_apibytesreceived_ = 0
873 self.apibytesreceived_ = 0
875 def has_apibytesreceived(self): return self.has_apibytesreceived_
878 def MergeFrom(self, x):
879 assert x is not self
880 if (x.has_content()): self.set_content(x.content())
881 if (x.has_statuscode()): self.set_statuscode(x.statuscode())
882 for i in xrange(x.header_size()): self.add_header().CopyFrom(x.header(i))
883 if (x.has_contentwastruncated()): self.set_contentwastruncated(x.contentwastruncated())
884 if (x.has_externalbytessent()): self.set_externalbytessent(x.externalbytessent())
885 if (x.has_externalbytesreceived()): self.set_externalbytesreceived(x.externalbytesreceived())
886 if (x.has_finalurl()): self.set_finalurl(x.finalurl())
887 if (x.has_apicpumilliseconds()): self.set_apicpumilliseconds(x.apicpumilliseconds())
888 if (x.has_apibytessent()): self.set_apibytessent(x.apibytessent())
889 if (x.has_apibytesreceived()): self.set_apibytesreceived(x.apibytesreceived())
891 def Equals(self, x):
892 if x is self: return 1
893 if self.has_content_ != x.has_content_: return 0
894 if self.has_content_ and self.content_ != x.content_: return 0
895 if self.has_statuscode_ != x.has_statuscode_: return 0
896 if self.has_statuscode_ and self.statuscode_ != x.statuscode_: return 0
897 if len(self.header_) != len(x.header_): return 0
898 for e1, e2 in zip(self.header_, x.header_):
899 if e1 != e2: return 0
900 if self.has_contentwastruncated_ != x.has_contentwastruncated_: return 0
901 if self.has_contentwastruncated_ and self.contentwastruncated_ != x.contentwastruncated_: return 0
902 if self.has_externalbytessent_ != x.has_externalbytessent_: return 0
903 if self.has_externalbytessent_ and self.externalbytessent_ != x.externalbytessent_: return 0
904 if self.has_externalbytesreceived_ != x.has_externalbytesreceived_: return 0
905 if self.has_externalbytesreceived_ and self.externalbytesreceived_ != x.externalbytesreceived_: return 0
906 if self.has_finalurl_ != x.has_finalurl_: return 0
907 if self.has_finalurl_ and self.finalurl_ != x.finalurl_: return 0
908 if self.has_apicpumilliseconds_ != x.has_apicpumilliseconds_: return 0
909 if self.has_apicpumilliseconds_ and self.apicpumilliseconds_ != x.apicpumilliseconds_: return 0
910 if self.has_apibytessent_ != x.has_apibytessent_: return 0
911 if self.has_apibytessent_ and self.apibytessent_ != x.apibytessent_: return 0
912 if self.has_apibytesreceived_ != x.has_apibytesreceived_: return 0
913 if self.has_apibytesreceived_ and self.apibytesreceived_ != x.apibytesreceived_: return 0
914 return 1
916 def IsInitialized(self, debug_strs=None):
917 initialized = 1
918 if (not self.has_statuscode_):
919 initialized = 0
920 if debug_strs is not None:
921 debug_strs.append('Required field: statuscode not set.')
922 for p in self.header_:
923 if not p.IsInitialized(debug_strs): initialized=0
924 return initialized
926 def ByteSize(self):
927 n = 0
928 if (self.has_content_): n += 1 + self.lengthString(len(self.content_))
929 n += self.lengthVarInt64(self.statuscode_)
930 n += 2 * len(self.header_)
931 for i in xrange(len(self.header_)): n += self.header_[i].ByteSize()
932 if (self.has_contentwastruncated_): n += 2
933 if (self.has_externalbytessent_): n += 1 + self.lengthVarInt64(self.externalbytessent_)
934 if (self.has_externalbytesreceived_): n += 1 + self.lengthVarInt64(self.externalbytesreceived_)
935 if (self.has_finalurl_): n += 1 + self.lengthString(len(self.finalurl_))
936 if (self.has_apicpumilliseconds_): n += 1 + self.lengthVarInt64(self.apicpumilliseconds_)
937 if (self.has_apibytessent_): n += 1 + self.lengthVarInt64(self.apibytessent_)
938 if (self.has_apibytesreceived_): n += 1 + self.lengthVarInt64(self.apibytesreceived_)
939 return n + 1
941 def ByteSizePartial(self):
942 n = 0
943 if (self.has_content_): n += 1 + self.lengthString(len(self.content_))
944 if (self.has_statuscode_):
945 n += 1
946 n += self.lengthVarInt64(self.statuscode_)
947 n += 2 * len(self.header_)
948 for i in xrange(len(self.header_)): n += self.header_[i].ByteSizePartial()
949 if (self.has_contentwastruncated_): n += 2
950 if (self.has_externalbytessent_): n += 1 + self.lengthVarInt64(self.externalbytessent_)
951 if (self.has_externalbytesreceived_): n += 1 + self.lengthVarInt64(self.externalbytesreceived_)
952 if (self.has_finalurl_): n += 1 + self.lengthString(len(self.finalurl_))
953 if (self.has_apicpumilliseconds_): n += 1 + self.lengthVarInt64(self.apicpumilliseconds_)
954 if (self.has_apibytessent_): n += 1 + self.lengthVarInt64(self.apibytessent_)
955 if (self.has_apibytesreceived_): n += 1 + self.lengthVarInt64(self.apibytesreceived_)
956 return n
958 def Clear(self):
959 self.clear_content()
960 self.clear_statuscode()
961 self.clear_header()
962 self.clear_contentwastruncated()
963 self.clear_externalbytessent()
964 self.clear_externalbytesreceived()
965 self.clear_finalurl()
966 self.clear_apicpumilliseconds()
967 self.clear_apibytessent()
968 self.clear_apibytesreceived()
970 def OutputUnchecked(self, out):
971 if (self.has_content_):
972 out.putVarInt32(10)
973 out.putPrefixedString(self.content_)
974 out.putVarInt32(16)
975 out.putVarInt32(self.statuscode_)
976 for i in xrange(len(self.header_)):
977 out.putVarInt32(27)
978 self.header_[i].OutputUnchecked(out)
979 out.putVarInt32(28)
980 if (self.has_contentwastruncated_):
981 out.putVarInt32(48)
982 out.putBoolean(self.contentwastruncated_)
983 if (self.has_externalbytessent_):
984 out.putVarInt32(56)
985 out.putVarInt64(self.externalbytessent_)
986 if (self.has_externalbytesreceived_):
987 out.putVarInt32(64)
988 out.putVarInt64(self.externalbytesreceived_)
989 if (self.has_finalurl_):
990 out.putVarInt32(74)
991 out.putPrefixedString(self.finalurl_)
992 if (self.has_apicpumilliseconds_):
993 out.putVarInt32(80)
994 out.putVarInt64(self.apicpumilliseconds_)
995 if (self.has_apibytessent_):
996 out.putVarInt32(88)
997 out.putVarInt64(self.apibytessent_)
998 if (self.has_apibytesreceived_):
999 out.putVarInt32(96)
1000 out.putVarInt64(self.apibytesreceived_)
1002 def OutputPartial(self, out):
1003 if (self.has_content_):
1004 out.putVarInt32(10)
1005 out.putPrefixedString(self.content_)
1006 if (self.has_statuscode_):
1007 out.putVarInt32(16)
1008 out.putVarInt32(self.statuscode_)
1009 for i in xrange(len(self.header_)):
1010 out.putVarInt32(27)
1011 self.header_[i].OutputPartial(out)
1012 out.putVarInt32(28)
1013 if (self.has_contentwastruncated_):
1014 out.putVarInt32(48)
1015 out.putBoolean(self.contentwastruncated_)
1016 if (self.has_externalbytessent_):
1017 out.putVarInt32(56)
1018 out.putVarInt64(self.externalbytessent_)
1019 if (self.has_externalbytesreceived_):
1020 out.putVarInt32(64)
1021 out.putVarInt64(self.externalbytesreceived_)
1022 if (self.has_finalurl_):
1023 out.putVarInt32(74)
1024 out.putPrefixedString(self.finalurl_)
1025 if (self.has_apicpumilliseconds_):
1026 out.putVarInt32(80)
1027 out.putVarInt64(self.apicpumilliseconds_)
1028 if (self.has_apibytessent_):
1029 out.putVarInt32(88)
1030 out.putVarInt64(self.apibytessent_)
1031 if (self.has_apibytesreceived_):
1032 out.putVarInt32(96)
1033 out.putVarInt64(self.apibytesreceived_)
1035 def TryMerge(self, d):
1036 while d.avail() > 0:
1037 tt = d.getVarInt32()
1038 if tt == 10:
1039 self.set_content(d.getPrefixedString())
1040 continue
1041 if tt == 16:
1042 self.set_statuscode(d.getVarInt32())
1043 continue
1044 if tt == 27:
1045 self.add_header().TryMerge(d)
1046 continue
1047 if tt == 48:
1048 self.set_contentwastruncated(d.getBoolean())
1049 continue
1050 if tt == 56:
1051 self.set_externalbytessent(d.getVarInt64())
1052 continue
1053 if tt == 64:
1054 self.set_externalbytesreceived(d.getVarInt64())
1055 continue
1056 if tt == 74:
1057 self.set_finalurl(d.getPrefixedString())
1058 continue
1059 if tt == 80:
1060 self.set_apicpumilliseconds(d.getVarInt64())
1061 continue
1062 if tt == 88:
1063 self.set_apibytessent(d.getVarInt64())
1064 continue
1065 if tt == 96:
1066 self.set_apibytesreceived(d.getVarInt64())
1067 continue
1070 if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
1071 d.skipData(tt)
1074 def __str__(self, prefix="", printElemNumber=0):
1075 res=""
1076 if self.has_content_: res+=prefix+("Content: %s\n" % self.DebugFormatString(self.content_))
1077 if self.has_statuscode_: res+=prefix+("StatusCode: %s\n" % self.DebugFormatInt32(self.statuscode_))
1078 cnt=0
1079 for e in self.header_:
1080 elm=""
1081 if printElemNumber: elm="(%d)" % cnt
1082 res+=prefix+("Header%s {\n" % elm)
1083 res+=e.__str__(prefix + " ", printElemNumber)
1084 res+=prefix+"}\n"
1085 cnt+=1
1086 if self.has_contentwastruncated_: res+=prefix+("ContentWasTruncated: %s\n" % self.DebugFormatBool(self.contentwastruncated_))
1087 if self.has_externalbytessent_: res+=prefix+("ExternalBytesSent: %s\n" % self.DebugFormatInt64(self.externalbytessent_))
1088 if self.has_externalbytesreceived_: res+=prefix+("ExternalBytesReceived: %s\n" % self.DebugFormatInt64(self.externalbytesreceived_))
1089 if self.has_finalurl_: res+=prefix+("FinalUrl: %s\n" % self.DebugFormatString(self.finalurl_))
1090 if self.has_apicpumilliseconds_: res+=prefix+("ApiCpuMilliseconds: %s\n" % self.DebugFormatInt64(self.apicpumilliseconds_))
1091 if self.has_apibytessent_: res+=prefix+("ApiBytesSent: %s\n" % self.DebugFormatInt64(self.apibytessent_))
1092 if self.has_apibytesreceived_: res+=prefix+("ApiBytesReceived: %s\n" % self.DebugFormatInt64(self.apibytesreceived_))
1093 return res
1096 def _BuildTagLookupTable(sparse, maxtag, default=None):
1097 return tuple([sparse.get(i, default) for i in xrange(0, 1+maxtag)])
1099 kContent = 1
1100 kStatusCode = 2
1101 kHeaderGroup = 3
1102 kHeaderKey = 4
1103 kHeaderValue = 5
1104 kContentWasTruncated = 6
1105 kExternalBytesSent = 7
1106 kExternalBytesReceived = 8
1107 kFinalUrl = 9
1108 kApiCpuMilliseconds = 10
1109 kApiBytesSent = 11
1110 kApiBytesReceived = 12
1112 _TEXT = _BuildTagLookupTable({
1113 0: "ErrorCode",
1114 1: "Content",
1115 2: "StatusCode",
1116 3: "Header",
1117 4: "Key",
1118 5: "Value",
1119 6: "ContentWasTruncated",
1120 7: "ExternalBytesSent",
1121 8: "ExternalBytesReceived",
1122 9: "FinalUrl",
1123 10: "ApiCpuMilliseconds",
1124 11: "ApiBytesSent",
1125 12: "ApiBytesReceived",
1126 }, 12)
1128 _TYPES = _BuildTagLookupTable({
1129 0: ProtocolBuffer.Encoder.NUMERIC,
1130 1: ProtocolBuffer.Encoder.STRING,
1131 2: ProtocolBuffer.Encoder.NUMERIC,
1132 3: ProtocolBuffer.Encoder.STARTGROUP,
1133 4: ProtocolBuffer.Encoder.STRING,
1134 5: ProtocolBuffer.Encoder.STRING,
1135 6: ProtocolBuffer.Encoder.NUMERIC,
1136 7: ProtocolBuffer.Encoder.NUMERIC,
1137 8: ProtocolBuffer.Encoder.NUMERIC,
1138 9: ProtocolBuffer.Encoder.STRING,
1139 10: ProtocolBuffer.Encoder.NUMERIC,
1140 11: ProtocolBuffer.Encoder.NUMERIC,
1141 12: ProtocolBuffer.Encoder.NUMERIC,
1142 }, 12, ProtocolBuffer.Encoder.MAX_TYPE)
1145 _STYLE = """"""
1146 _STYLE_CONTENT_TYPE = """"""
1147 _PROTO_DESCRIPTOR_NAME = 'apphosting.URLFetchResponse'
1148 if _extension_runtime:
1149 pass
1151 __all__ = ['URLFetchServiceError','URLFetchRequest','URLFetchRequest_Header','URLFetchResponse','URLFetchResponse_Header']