1# Copyright 2016 Google LLC. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# Generated by the protocol buffer compiler.  DO NOT EDIT!
15# source: apphosting/datastore/datastore_v4.proto
16
17from __future__ import absolute_import
18from googlecloudsdk.third_party.appengine.proto import ProtocolBuffer
19import abc
20import array
21
22
23try:
24  from six.moves._thread import allocate_lock as _Lock
25except ImportError:
26  from threading import Lock as _Lock
27
28if hasattr(__builtins__, 'xrange'): range = xrange
29
30if hasattr(ProtocolBuffer, 'ExtendableProtocolMessage'):
31  _extension_runtime = True
32  _ExtendableProtocolMessage = ProtocolBuffer.ExtendableProtocolMessage
33else:
34  _extension_runtime = False
35  _ExtendableProtocolMessage = ProtocolBuffer.ProtocolMessage
36
37from googlecloudsdk.third_party.appengine.datastore.entity_v4_pb import *
38import googlecloudsdk.third_party.appengine.datastore.entity_v4_pb
39googlecloudsdk_dot_third_party_dot_appengine_dot_datastore_dot_entity__v4__pb = __import__('googlecloudsdk.third_party.appengine.datastore.entity_v4_pb', {}, {}, [''])
40class Error(ProtocolBuffer.ProtocolMessage):
41
42  # ErrorCode values
43  BAD_REQUEST  =    1
44  CONCURRENT_TRANSACTION =    2
45  INTERNAL_ERROR =    3
46  NEED_INDEX   =    4
47  TIMEOUT      =    5
48  PERMISSION_DENIED =    6
49  BIGTABLE_ERROR =    7
50  COMMITTED_BUT_STILL_APPLYING =    8
51  CAPABILITY_DISABLED =    9
52  TRY_ALTERNATE_BACKEND =   10
53  SAFE_TIME_TOO_OLD =   11
54  RESOURCE_EXHAUSTED =   12
55  NOT_FOUND    =   13
56  ALREADY_EXISTS =   14
57  FAILED_PRECONDITION =   15
58  UNAUTHENTICATED =   16
59  ABORTED      =   17
60
61  _ErrorCode_NAMES = {
62    1: "BAD_REQUEST",
63    2: "CONCURRENT_TRANSACTION",
64    3: "INTERNAL_ERROR",
65    4: "NEED_INDEX",
66    5: "TIMEOUT",
67    6: "PERMISSION_DENIED",
68    7: "BIGTABLE_ERROR",
69    8: "COMMITTED_BUT_STILL_APPLYING",
70    9: "CAPABILITY_DISABLED",
71    10: "TRY_ALTERNATE_BACKEND",
72    11: "SAFE_TIME_TOO_OLD",
73    12: "RESOURCE_EXHAUSTED",
74    13: "NOT_FOUND",
75    14: "ALREADY_EXISTS",
76    15: "FAILED_PRECONDITION",
77    16: "UNAUTHENTICATED",
78    17: "ABORTED",
79  }
80
81  def ErrorCode_Name(cls, x): return cls._ErrorCode_NAMES.get(x, "")
82  ErrorCode_Name = classmethod(ErrorCode_Name)
83
84
85  def __init__(self, contents=None):
86    pass
87    if contents is not None: self.MergeFromString(contents)
88
89
90  def MergeFrom(self, x):
91    assert x is not self
92
93  def Equals(self, x):
94    if x is self: return 1
95    return 1
96
97  def IsInitialized(self, debug_strs=None):
98    initialized = 1
99    return initialized
100
101  def ByteSize(self):
102    n = 0
103    return n
104
105  def ByteSizePartial(self):
106    n = 0
107    return n
108
109  def Clear(self):
110    pass
111
112  def OutputUnchecked(self, out):
113    pass
114
115  def OutputPartial(self, out):
116    pass
117
118  def TryMerge(self, d):
119    while d.avail() > 0:
120      tt = d.getVarInt32()
121      # tag 0 is special: it's used to indicate an error.
122      # so if we see it we raise an exception.
123      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
124      d.skipData(tt)
125
126
127  def __str__(self, prefix="", printElemNumber=0):
128    res=""
129    return res
130
131
132  def _BuildTagLookupTable(sparse, maxtag, default=None):
133    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
134
135
136  _TEXT = _BuildTagLookupTable({
137    0: "ErrorCode",
138  }, 0)
139
140  _TYPES = _BuildTagLookupTable({
141    0: ProtocolBuffer.Encoder.NUMERIC,
142  }, 0, ProtocolBuffer.Encoder.MAX_TYPE)
143
144  # stylesheet for XML output
145  _STYLE = \
146   """"""
147  _STYLE_CONTENT_TYPE = \
148   """"""
149  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.Error'
150class EntityResult(ProtocolBuffer.ProtocolMessage):
151
152  # ResultType values
153  FULL         =    1
154  PROJECTION   =    2
155  KEY_ONLY     =    3
156
157  _ResultType_NAMES = {
158    1: "FULL",
159    2: "PROJECTION",
160    3: "KEY_ONLY",
161  }
162
163  def ResultType_Name(cls, x): return cls._ResultType_NAMES.get(x, "")
164  ResultType_Name = classmethod(ResultType_Name)
165
166  has_entity_ = 0
167  has_version_ = 0
168  version_ = 0
169  has_cursor_ = 0
170  cursor_ = ""
171
172  def __init__(self, contents=None):
173    self.entity_ = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Entity()
174    if contents is not None: self.MergeFromString(contents)
175
176  def entity(self): return self.entity_
177
178  def mutable_entity(self): self.has_entity_ = 1; return self.entity_
179
180  def clear_entity(self):self.has_entity_ = 0; self.entity_.Clear()
181
182  def has_entity(self): return self.has_entity_
183
184  def version(self): return self.version_
185
186  def set_version(self, x):
187    self.has_version_ = 1
188    self.version_ = x
189
190  def clear_version(self):
191    if self.has_version_:
192      self.has_version_ = 0
193      self.version_ = 0
194
195  def has_version(self): return self.has_version_
196
197  def cursor(self): return self.cursor_
198
199  def set_cursor(self, x):
200    self.has_cursor_ = 1
201    self.cursor_ = x
202
203  def clear_cursor(self):
204    if self.has_cursor_:
205      self.has_cursor_ = 0
206      self.cursor_ = ""
207
208  def has_cursor(self): return self.has_cursor_
209
210
211  def MergeFrom(self, x):
212    assert x is not self
213    if (x.has_entity()): self.mutable_entity().MergeFrom(x.entity())
214    if (x.has_version()): self.set_version(x.version())
215    if (x.has_cursor()): self.set_cursor(x.cursor())
216
217  def Equals(self, x):
218    if x is self: return 1
219    if self.has_entity_ != x.has_entity_: return 0
220    if self.has_entity_ and self.entity_ != x.entity_: return 0
221    if self.has_version_ != x.has_version_: return 0
222    if self.has_version_ and self.version_ != x.version_: return 0
223    if self.has_cursor_ != x.has_cursor_: return 0
224    if self.has_cursor_ and self.cursor_ != x.cursor_: return 0
225    return 1
226
227  def IsInitialized(self, debug_strs=None):
228    initialized = 1
229    if (not self.has_entity_):
230      initialized = 0
231      if debug_strs is not None:
232        debug_strs.append('Required field: entity not set.')
233    elif not self.entity_.IsInitialized(debug_strs): initialized = 0
234    return initialized
235
236  def ByteSize(self):
237    n = 0
238    n += self.lengthString(self.entity_.ByteSize())
239    if (self.has_version_): n += 1 + self.lengthVarInt64(self.version_)
240    if (self.has_cursor_): n += 1 + self.lengthString(len(self.cursor_))
241    return n + 1
242
243  def ByteSizePartial(self):
244    n = 0
245    if (self.has_entity_):
246      n += 1
247      n += self.lengthString(self.entity_.ByteSizePartial())
248    if (self.has_version_): n += 1 + self.lengthVarInt64(self.version_)
249    if (self.has_cursor_): n += 1 + self.lengthString(len(self.cursor_))
250    return n
251
252  def Clear(self):
253    self.clear_entity()
254    self.clear_version()
255    self.clear_cursor()
256
257  def OutputUnchecked(self, out):
258    out.putVarInt32(10)
259    out.putVarInt32(self.entity_.ByteSize())
260    self.entity_.OutputUnchecked(out)
261    if (self.has_version_):
262      out.putVarInt32(16)
263      out.putVarInt64(self.version_)
264    if (self.has_cursor_):
265      out.putVarInt32(26)
266      out.putPrefixedString(self.cursor_)
267
268  def OutputPartial(self, out):
269    if (self.has_entity_):
270      out.putVarInt32(10)
271      out.putVarInt32(self.entity_.ByteSizePartial())
272      self.entity_.OutputPartial(out)
273    if (self.has_version_):
274      out.putVarInt32(16)
275      out.putVarInt64(self.version_)
276    if (self.has_cursor_):
277      out.putVarInt32(26)
278      out.putPrefixedString(self.cursor_)
279
280  def TryMerge(self, d):
281    while d.avail() > 0:
282      tt = d.getVarInt32()
283      if tt == 10:
284        length = d.getVarInt32()
285        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
286        d.skip(length)
287        self.mutable_entity().TryMerge(tmp)
288        continue
289      if tt == 16:
290        self.set_version(d.getVarInt64())
291        continue
292      if tt == 26:
293        self.set_cursor(d.getPrefixedString())
294        continue
295      # tag 0 is special: it's used to indicate an error.
296      # so if we see it we raise an exception.
297      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
298      d.skipData(tt)
299
300
301  def __str__(self, prefix="", printElemNumber=0):
302    res=""
303    if self.has_entity_:
304      res+=prefix+"entity <\n"
305      res+=self.entity_.__str__(prefix + "  ", printElemNumber)
306      res+=prefix+">\n"
307    if self.has_version_: res+=prefix+("version: %s\n" % self.DebugFormatInt64(self.version_))
308    if self.has_cursor_: res+=prefix+("cursor: %s\n" % self.DebugFormatString(self.cursor_))
309    return res
310
311
312  def _BuildTagLookupTable(sparse, maxtag, default=None):
313    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
314
315  kentity = 1
316  kversion = 2
317  kcursor = 3
318
319  _TEXT = _BuildTagLookupTable({
320    0: "ErrorCode",
321    1: "entity",
322    2: "version",
323    3: "cursor",
324  }, 3)
325
326  _TYPES = _BuildTagLookupTable({
327    0: ProtocolBuffer.Encoder.NUMERIC,
328    1: ProtocolBuffer.Encoder.STRING,
329    2: ProtocolBuffer.Encoder.NUMERIC,
330    3: ProtocolBuffer.Encoder.STRING,
331  }, 3, ProtocolBuffer.Encoder.MAX_TYPE)
332
333  # stylesheet for XML output
334  _STYLE = \
335   """"""
336  _STYLE_CONTENT_TYPE = \
337   """"""
338  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.EntityResult'
339class Query(ProtocolBuffer.ProtocolMessage):
340  has_filter_ = 0
341  filter_ = None
342  has_start_cursor_ = 0
343  start_cursor_ = ""
344  has_end_cursor_ = 0
345  end_cursor_ = ""
346  has_offset_ = 0
347  offset_ = 0
348  has_limit_ = 0
349  limit_ = 0
350
351  def __init__(self, contents=None):
352    self.projection_ = []
353    self.kind_ = []
354    self.order_ = []
355    self.group_by_ = []
356    self.lazy_init_lock_ = _Lock()
357    if contents is not None: self.MergeFromString(contents)
358
359  def projection_size(self): return len(self.projection_)
360  def projection_list(self): return self.projection_
361
362  def projection(self, i):
363    return self.projection_[i]
364
365  def mutable_projection(self, i):
366    return self.projection_[i]
367
368  def add_projection(self):
369    x = PropertyExpression()
370    self.projection_.append(x)
371    return x
372
373  def clear_projection(self):
374    self.projection_ = []
375  def kind_size(self): return len(self.kind_)
376  def kind_list(self): return self.kind_
377
378  def kind(self, i):
379    return self.kind_[i]
380
381  def mutable_kind(self, i):
382    return self.kind_[i]
383
384  def add_kind(self):
385    x = KindExpression()
386    self.kind_.append(x)
387    return x
388
389  def clear_kind(self):
390    self.kind_ = []
391  def filter(self):
392    if self.filter_ is None:
393      self.lazy_init_lock_.acquire()
394      try:
395        if self.filter_ is None: self.filter_ = Filter()
396      finally:
397        self.lazy_init_lock_.release()
398    return self.filter_
399
400  def mutable_filter(self): self.has_filter_ = 1; return self.filter()
401
402  def clear_filter(self):
403    # Warning: this method does not acquire the lock.
404    if self.has_filter_:
405      self.has_filter_ = 0;
406      if self.filter_ is not None: self.filter_.Clear()
407
408  def has_filter(self): return self.has_filter_
409
410  def order_size(self): return len(self.order_)
411  def order_list(self): return self.order_
412
413  def order(self, i):
414    return self.order_[i]
415
416  def mutable_order(self, i):
417    return self.order_[i]
418
419  def add_order(self):
420    x = PropertyOrder()
421    self.order_.append(x)
422    return x
423
424  def clear_order(self):
425    self.order_ = []
426  def group_by_size(self): return len(self.group_by_)
427  def group_by_list(self): return self.group_by_
428
429  def group_by(self, i):
430    return self.group_by_[i]
431
432  def mutable_group_by(self, i):
433    return self.group_by_[i]
434
435  def add_group_by(self):
436    x = PropertyReference()
437    self.group_by_.append(x)
438    return x
439
440  def clear_group_by(self):
441    self.group_by_ = []
442  def start_cursor(self): return self.start_cursor_
443
444  def set_start_cursor(self, x):
445    self.has_start_cursor_ = 1
446    self.start_cursor_ = x
447
448  def clear_start_cursor(self):
449    if self.has_start_cursor_:
450      self.has_start_cursor_ = 0
451      self.start_cursor_ = ""
452
453  def has_start_cursor(self): return self.has_start_cursor_
454
455  def end_cursor(self): return self.end_cursor_
456
457  def set_end_cursor(self, x):
458    self.has_end_cursor_ = 1
459    self.end_cursor_ = x
460
461  def clear_end_cursor(self):
462    if self.has_end_cursor_:
463      self.has_end_cursor_ = 0
464      self.end_cursor_ = ""
465
466  def has_end_cursor(self): return self.has_end_cursor_
467
468  def offset(self): return self.offset_
469
470  def set_offset(self, x):
471    self.has_offset_ = 1
472    self.offset_ = x
473
474  def clear_offset(self):
475    if self.has_offset_:
476      self.has_offset_ = 0
477      self.offset_ = 0
478
479  def has_offset(self): return self.has_offset_
480
481  def limit(self): return self.limit_
482
483  def set_limit(self, x):
484    self.has_limit_ = 1
485    self.limit_ = x
486
487  def clear_limit(self):
488    if self.has_limit_:
489      self.has_limit_ = 0
490      self.limit_ = 0
491
492  def has_limit(self): return self.has_limit_
493
494
495  def MergeFrom(self, x):
496    assert x is not self
497    for i in range(x.projection_size()): self.add_projection().CopyFrom(x.projection(i))
498    for i in range(x.kind_size()): self.add_kind().CopyFrom(x.kind(i))
499    if (x.has_filter()): self.mutable_filter().MergeFrom(x.filter())
500    for i in range(x.order_size()): self.add_order().CopyFrom(x.order(i))
501    for i in range(x.group_by_size()): self.add_group_by().CopyFrom(x.group_by(i))
502    if (x.has_start_cursor()): self.set_start_cursor(x.start_cursor())
503    if (x.has_end_cursor()): self.set_end_cursor(x.end_cursor())
504    if (x.has_offset()): self.set_offset(x.offset())
505    if (x.has_limit()): self.set_limit(x.limit())
506
507  def Equals(self, x):
508    if x is self: return 1
509    if len(self.projection_) != len(x.projection_): return 0
510    for e1, e2 in zip(self.projection_, x.projection_):
511      if e1 != e2: return 0
512    if len(self.kind_) != len(x.kind_): return 0
513    for e1, e2 in zip(self.kind_, x.kind_):
514      if e1 != e2: return 0
515    if self.has_filter_ != x.has_filter_: return 0
516    if self.has_filter_ and self.filter_ != x.filter_: return 0
517    if len(self.order_) != len(x.order_): return 0
518    for e1, e2 in zip(self.order_, x.order_):
519      if e1 != e2: return 0
520    if len(self.group_by_) != len(x.group_by_): return 0
521    for e1, e2 in zip(self.group_by_, x.group_by_):
522      if e1 != e2: return 0
523    if self.has_start_cursor_ != x.has_start_cursor_: return 0
524    if self.has_start_cursor_ and self.start_cursor_ != x.start_cursor_: return 0
525    if self.has_end_cursor_ != x.has_end_cursor_: return 0
526    if self.has_end_cursor_ and self.end_cursor_ != x.end_cursor_: return 0
527    if self.has_offset_ != x.has_offset_: return 0
528    if self.has_offset_ and self.offset_ != x.offset_: return 0
529    if self.has_limit_ != x.has_limit_: return 0
530    if self.has_limit_ and self.limit_ != x.limit_: return 0
531    return 1
532
533  def IsInitialized(self, debug_strs=None):
534    initialized = 1
535    for p in self.projection_:
536      if not p.IsInitialized(debug_strs): initialized=0
537    for p in self.kind_:
538      if not p.IsInitialized(debug_strs): initialized=0
539    if (self.has_filter_ and not self.filter_.IsInitialized(debug_strs)): initialized = 0
540    for p in self.order_:
541      if not p.IsInitialized(debug_strs): initialized=0
542    for p in self.group_by_:
543      if not p.IsInitialized(debug_strs): initialized=0
544    return initialized
545
546  def ByteSize(self):
547    n = 0
548    n += 1 * len(self.projection_)
549    for i in range(len(self.projection_)): n += self.lengthString(self.projection_[i].ByteSize())
550    n += 1 * len(self.kind_)
551    for i in range(len(self.kind_)): n += self.lengthString(self.kind_[i].ByteSize())
552    if (self.has_filter_): n += 1 + self.lengthString(self.filter_.ByteSize())
553    n += 1 * len(self.order_)
554    for i in range(len(self.order_)): n += self.lengthString(self.order_[i].ByteSize())
555    n += 1 * len(self.group_by_)
556    for i in range(len(self.group_by_)): n += self.lengthString(self.group_by_[i].ByteSize())
557    if (self.has_start_cursor_): n += 1 + self.lengthString(len(self.start_cursor_))
558    if (self.has_end_cursor_): n += 1 + self.lengthString(len(self.end_cursor_))
559    if (self.has_offset_): n += 1 + self.lengthVarInt64(self.offset_)
560    if (self.has_limit_): n += 1 + self.lengthVarInt64(self.limit_)
561    return n
562
563  def ByteSizePartial(self):
564    n = 0
565    n += 1 * len(self.projection_)
566    for i in range(len(self.projection_)): n += self.lengthString(self.projection_[i].ByteSizePartial())
567    n += 1 * len(self.kind_)
568    for i in range(len(self.kind_)): n += self.lengthString(self.kind_[i].ByteSizePartial())
569    if (self.has_filter_): n += 1 + self.lengthString(self.filter_.ByteSizePartial())
570    n += 1 * len(self.order_)
571    for i in range(len(self.order_)): n += self.lengthString(self.order_[i].ByteSizePartial())
572    n += 1 * len(self.group_by_)
573    for i in range(len(self.group_by_)): n += self.lengthString(self.group_by_[i].ByteSizePartial())
574    if (self.has_start_cursor_): n += 1 + self.lengthString(len(self.start_cursor_))
575    if (self.has_end_cursor_): n += 1 + self.lengthString(len(self.end_cursor_))
576    if (self.has_offset_): n += 1 + self.lengthVarInt64(self.offset_)
577    if (self.has_limit_): n += 1 + self.lengthVarInt64(self.limit_)
578    return n
579
580  def Clear(self):
581    self.clear_projection()
582    self.clear_kind()
583    self.clear_filter()
584    self.clear_order()
585    self.clear_group_by()
586    self.clear_start_cursor()
587    self.clear_end_cursor()
588    self.clear_offset()
589    self.clear_limit()
590
591  def OutputUnchecked(self, out):
592    for i in range(len(self.projection_)):
593      out.putVarInt32(18)
594      out.putVarInt32(self.projection_[i].ByteSize())
595      self.projection_[i].OutputUnchecked(out)
596    for i in range(len(self.kind_)):
597      out.putVarInt32(26)
598      out.putVarInt32(self.kind_[i].ByteSize())
599      self.kind_[i].OutputUnchecked(out)
600    if (self.has_filter_):
601      out.putVarInt32(34)
602      out.putVarInt32(self.filter_.ByteSize())
603      self.filter_.OutputUnchecked(out)
604    for i in range(len(self.order_)):
605      out.putVarInt32(42)
606      out.putVarInt32(self.order_[i].ByteSize())
607      self.order_[i].OutputUnchecked(out)
608    for i in range(len(self.group_by_)):
609      out.putVarInt32(50)
610      out.putVarInt32(self.group_by_[i].ByteSize())
611      self.group_by_[i].OutputUnchecked(out)
612    if (self.has_start_cursor_):
613      out.putVarInt32(58)
614      out.putPrefixedString(self.start_cursor_)
615    if (self.has_end_cursor_):
616      out.putVarInt32(66)
617      out.putPrefixedString(self.end_cursor_)
618    if (self.has_offset_):
619      out.putVarInt32(80)
620      out.putVarInt32(self.offset_)
621    if (self.has_limit_):
622      out.putVarInt32(88)
623      out.putVarInt32(self.limit_)
624
625  def OutputPartial(self, out):
626    for i in range(len(self.projection_)):
627      out.putVarInt32(18)
628      out.putVarInt32(self.projection_[i].ByteSizePartial())
629      self.projection_[i].OutputPartial(out)
630    for i in range(len(self.kind_)):
631      out.putVarInt32(26)
632      out.putVarInt32(self.kind_[i].ByteSizePartial())
633      self.kind_[i].OutputPartial(out)
634    if (self.has_filter_):
635      out.putVarInt32(34)
636      out.putVarInt32(self.filter_.ByteSizePartial())
637      self.filter_.OutputPartial(out)
638    for i in range(len(self.order_)):
639      out.putVarInt32(42)
640      out.putVarInt32(self.order_[i].ByteSizePartial())
641      self.order_[i].OutputPartial(out)
642    for i in range(len(self.group_by_)):
643      out.putVarInt32(50)
644      out.putVarInt32(self.group_by_[i].ByteSizePartial())
645      self.group_by_[i].OutputPartial(out)
646    if (self.has_start_cursor_):
647      out.putVarInt32(58)
648      out.putPrefixedString(self.start_cursor_)
649    if (self.has_end_cursor_):
650      out.putVarInt32(66)
651      out.putPrefixedString(self.end_cursor_)
652    if (self.has_offset_):
653      out.putVarInt32(80)
654      out.putVarInt32(self.offset_)
655    if (self.has_limit_):
656      out.putVarInt32(88)
657      out.putVarInt32(self.limit_)
658
659  def TryMerge(self, d):
660    while d.avail() > 0:
661      tt = d.getVarInt32()
662      if tt == 18:
663        length = d.getVarInt32()
664        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
665        d.skip(length)
666        self.add_projection().TryMerge(tmp)
667        continue
668      if tt == 26:
669        length = d.getVarInt32()
670        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
671        d.skip(length)
672        self.add_kind().TryMerge(tmp)
673        continue
674      if tt == 34:
675        length = d.getVarInt32()
676        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
677        d.skip(length)
678        self.mutable_filter().TryMerge(tmp)
679        continue
680      if tt == 42:
681        length = d.getVarInt32()
682        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
683        d.skip(length)
684        self.add_order().TryMerge(tmp)
685        continue
686      if tt == 50:
687        length = d.getVarInt32()
688        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
689        d.skip(length)
690        self.add_group_by().TryMerge(tmp)
691        continue
692      if tt == 58:
693        self.set_start_cursor(d.getPrefixedString())
694        continue
695      if tt == 66:
696        self.set_end_cursor(d.getPrefixedString())
697        continue
698      if tt == 80:
699        self.set_offset(d.getVarInt32())
700        continue
701      if tt == 88:
702        self.set_limit(d.getVarInt32())
703        continue
704      # tag 0 is special: it's used to indicate an error.
705      # so if we see it we raise an exception.
706      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
707      d.skipData(tt)
708
709
710  def __str__(self, prefix="", printElemNumber=0):
711    res=""
712    cnt=0
713    for e in self.projection_:
714      elm=""
715      if printElemNumber: elm="(%d)" % cnt
716      res+=prefix+("projection%s <\n" % elm)
717      res+=e.__str__(prefix + "  ", printElemNumber)
718      res+=prefix+">\n"
719      cnt+=1
720    cnt=0
721    for e in self.kind_:
722      elm=""
723      if printElemNumber: elm="(%d)" % cnt
724      res+=prefix+("kind%s <\n" % elm)
725      res+=e.__str__(prefix + "  ", printElemNumber)
726      res+=prefix+">\n"
727      cnt+=1
728    if self.has_filter_:
729      res+=prefix+"filter <\n"
730      res+=self.filter_.__str__(prefix + "  ", printElemNumber)
731      res+=prefix+">\n"
732    cnt=0
733    for e in self.order_:
734      elm=""
735      if printElemNumber: elm="(%d)" % cnt
736      res+=prefix+("order%s <\n" % elm)
737      res+=e.__str__(prefix + "  ", printElemNumber)
738      res+=prefix+">\n"
739      cnt+=1
740    cnt=0
741    for e in self.group_by_:
742      elm=""
743      if printElemNumber: elm="(%d)" % cnt
744      res+=prefix+("group_by%s <\n" % elm)
745      res+=e.__str__(prefix + "  ", printElemNumber)
746      res+=prefix+">\n"
747      cnt+=1
748    if self.has_start_cursor_: res+=prefix+("start_cursor: %s\n" % self.DebugFormatString(self.start_cursor_))
749    if self.has_end_cursor_: res+=prefix+("end_cursor: %s\n" % self.DebugFormatString(self.end_cursor_))
750    if self.has_offset_: res+=prefix+("offset: %s\n" % self.DebugFormatInt32(self.offset_))
751    if self.has_limit_: res+=prefix+("limit: %s\n" % self.DebugFormatInt32(self.limit_))
752    return res
753
754
755  def _BuildTagLookupTable(sparse, maxtag, default=None):
756    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
757
758  kprojection = 2
759  kkind = 3
760  kfilter = 4
761  korder = 5
762  kgroup_by = 6
763  kstart_cursor = 7
764  kend_cursor = 8
765  koffset = 10
766  klimit = 11
767
768  _TEXT = _BuildTagLookupTable({
769    0: "ErrorCode",
770    2: "projection",
771    3: "kind",
772    4: "filter",
773    5: "order",
774    6: "group_by",
775    7: "start_cursor",
776    8: "end_cursor",
777    10: "offset",
778    11: "limit",
779  }, 11)
780
781  _TYPES = _BuildTagLookupTable({
782    0: ProtocolBuffer.Encoder.NUMERIC,
783    2: ProtocolBuffer.Encoder.STRING,
784    3: ProtocolBuffer.Encoder.STRING,
785    4: ProtocolBuffer.Encoder.STRING,
786    5: ProtocolBuffer.Encoder.STRING,
787    6: ProtocolBuffer.Encoder.STRING,
788    7: ProtocolBuffer.Encoder.STRING,
789    8: ProtocolBuffer.Encoder.STRING,
790    10: ProtocolBuffer.Encoder.NUMERIC,
791    11: ProtocolBuffer.Encoder.NUMERIC,
792  }, 11, ProtocolBuffer.Encoder.MAX_TYPE)
793
794  # stylesheet for XML output
795  _STYLE = \
796   """"""
797  _STYLE_CONTENT_TYPE = \
798   """"""
799  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.Query'
800class KindExpression(ProtocolBuffer.ProtocolMessage):
801  has_name_ = 0
802  name_ = ""
803
804  def __init__(self, contents=None):
805    if contents is not None: self.MergeFromString(contents)
806
807  def name(self): return self.name_
808
809  def set_name(self, x):
810    self.has_name_ = 1
811    self.name_ = x
812
813  def clear_name(self):
814    if self.has_name_:
815      self.has_name_ = 0
816      self.name_ = ""
817
818  def has_name(self): return self.has_name_
819
820
821  def MergeFrom(self, x):
822    assert x is not self
823    if (x.has_name()): self.set_name(x.name())
824
825  def Equals(self, x):
826    if x is self: return 1
827    if self.has_name_ != x.has_name_: return 0
828    if self.has_name_ and self.name_ != x.name_: return 0
829    return 1
830
831  def IsInitialized(self, debug_strs=None):
832    initialized = 1
833    if (not self.has_name_):
834      initialized = 0
835      if debug_strs is not None:
836        debug_strs.append('Required field: name not set.')
837    return initialized
838
839  def ByteSize(self):
840    n = 0
841    n += self.lengthString(len(self.name_))
842    return n + 1
843
844  def ByteSizePartial(self):
845    n = 0
846    if (self.has_name_):
847      n += 1
848      n += self.lengthString(len(self.name_))
849    return n
850
851  def Clear(self):
852    self.clear_name()
853
854  def OutputUnchecked(self, out):
855    out.putVarInt32(10)
856    out.putPrefixedString(self.name_)
857
858  def OutputPartial(self, out):
859    if (self.has_name_):
860      out.putVarInt32(10)
861      out.putPrefixedString(self.name_)
862
863  def TryMerge(self, d):
864    while d.avail() > 0:
865      tt = d.getVarInt32()
866      if tt == 10:
867        self.set_name(d.getPrefixedString())
868        continue
869      # tag 0 is special: it's used to indicate an error.
870      # so if we see it we raise an exception.
871      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
872      d.skipData(tt)
873
874
875  def __str__(self, prefix="", printElemNumber=0):
876    res=""
877    if self.has_name_: res+=prefix+("name: %s\n" % self.DebugFormatString(self.name_))
878    return res
879
880
881  def _BuildTagLookupTable(sparse, maxtag, default=None):
882    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
883
884  kname = 1
885
886  _TEXT = _BuildTagLookupTable({
887    0: "ErrorCode",
888    1: "name",
889  }, 1)
890
891  _TYPES = _BuildTagLookupTable({
892    0: ProtocolBuffer.Encoder.NUMERIC,
893    1: ProtocolBuffer.Encoder.STRING,
894  }, 1, ProtocolBuffer.Encoder.MAX_TYPE)
895
896  # stylesheet for XML output
897  _STYLE = \
898   """"""
899  _STYLE_CONTENT_TYPE = \
900   """"""
901  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.KindExpression'
902class PropertyReference(ProtocolBuffer.ProtocolMessage):
903  has_name_ = 0
904  name_ = ""
905
906  def __init__(self, contents=None):
907    if contents is not None: self.MergeFromString(contents)
908
909  def name(self): return self.name_
910
911  def set_name(self, x):
912    self.has_name_ = 1
913    self.name_ = x
914
915  def clear_name(self):
916    if self.has_name_:
917      self.has_name_ = 0
918      self.name_ = ""
919
920  def has_name(self): return self.has_name_
921
922
923  def MergeFrom(self, x):
924    assert x is not self
925    if (x.has_name()): self.set_name(x.name())
926
927  def Equals(self, x):
928    if x is self: return 1
929    if self.has_name_ != x.has_name_: return 0
930    if self.has_name_ and self.name_ != x.name_: return 0
931    return 1
932
933  def IsInitialized(self, debug_strs=None):
934    initialized = 1
935    if (not self.has_name_):
936      initialized = 0
937      if debug_strs is not None:
938        debug_strs.append('Required field: name not set.')
939    return initialized
940
941  def ByteSize(self):
942    n = 0
943    n += self.lengthString(len(self.name_))
944    return n + 1
945
946  def ByteSizePartial(self):
947    n = 0
948    if (self.has_name_):
949      n += 1
950      n += self.lengthString(len(self.name_))
951    return n
952
953  def Clear(self):
954    self.clear_name()
955
956  def OutputUnchecked(self, out):
957    out.putVarInt32(18)
958    out.putPrefixedString(self.name_)
959
960  def OutputPartial(self, out):
961    if (self.has_name_):
962      out.putVarInt32(18)
963      out.putPrefixedString(self.name_)
964
965  def TryMerge(self, d):
966    while d.avail() > 0:
967      tt = d.getVarInt32()
968      if tt == 18:
969        self.set_name(d.getPrefixedString())
970        continue
971      # tag 0 is special: it's used to indicate an error.
972      # so if we see it we raise an exception.
973      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
974      d.skipData(tt)
975
976
977  def __str__(self, prefix="", printElemNumber=0):
978    res=""
979    if self.has_name_: res+=prefix+("name: %s\n" % self.DebugFormatString(self.name_))
980    return res
981
982
983  def _BuildTagLookupTable(sparse, maxtag, default=None):
984    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
985
986  kname = 2
987
988  _TEXT = _BuildTagLookupTable({
989    0: "ErrorCode",
990    2: "name",
991  }, 2)
992
993  _TYPES = _BuildTagLookupTable({
994    0: ProtocolBuffer.Encoder.NUMERIC,
995    2: ProtocolBuffer.Encoder.STRING,
996  }, 2, ProtocolBuffer.Encoder.MAX_TYPE)
997
998  # stylesheet for XML output
999  _STYLE = \
1000   """"""
1001  _STYLE_CONTENT_TYPE = \
1002   """"""
1003  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.PropertyReference'
1004class PropertyExpression(ProtocolBuffer.ProtocolMessage):
1005
1006  # AggregationFunction values
1007  FIRST        =    1
1008
1009  _AggregationFunction_NAMES = {
1010    1: "FIRST",
1011  }
1012
1013  def AggregationFunction_Name(cls, x): return cls._AggregationFunction_NAMES.get(x, "")
1014  AggregationFunction_Name = classmethod(AggregationFunction_Name)
1015
1016  has_property_ = 0
1017  has_aggregation_function_ = 0
1018  aggregation_function_ = 0
1019
1020  def __init__(self, contents=None):
1021    self.property_ = PropertyReference()
1022    if contents is not None: self.MergeFromString(contents)
1023
1024  def property(self): return self.property_
1025
1026  def mutable_property(self): self.has_property_ = 1; return self.property_
1027
1028  def clear_property(self):self.has_property_ = 0; self.property_.Clear()
1029
1030  def has_property(self): return self.has_property_
1031
1032  def aggregation_function(self): return self.aggregation_function_
1033
1034  def set_aggregation_function(self, x):
1035    self.has_aggregation_function_ = 1
1036    self.aggregation_function_ = x
1037
1038  def clear_aggregation_function(self):
1039    if self.has_aggregation_function_:
1040      self.has_aggregation_function_ = 0
1041      self.aggregation_function_ = 0
1042
1043  def has_aggregation_function(self): return self.has_aggregation_function_
1044
1045
1046  def MergeFrom(self, x):
1047    assert x is not self
1048    if (x.has_property()): self.mutable_property().MergeFrom(x.property())
1049    if (x.has_aggregation_function()): self.set_aggregation_function(x.aggregation_function())
1050
1051  def Equals(self, x):
1052    if x is self: return 1
1053    if self.has_property_ != x.has_property_: return 0
1054    if self.has_property_ and self.property_ != x.property_: return 0
1055    if self.has_aggregation_function_ != x.has_aggregation_function_: return 0
1056    if self.has_aggregation_function_ and self.aggregation_function_ != x.aggregation_function_: return 0
1057    return 1
1058
1059  def IsInitialized(self, debug_strs=None):
1060    initialized = 1
1061    if (not self.has_property_):
1062      initialized = 0
1063      if debug_strs is not None:
1064        debug_strs.append('Required field: property not set.')
1065    elif not self.property_.IsInitialized(debug_strs): initialized = 0
1066    return initialized
1067
1068  def ByteSize(self):
1069    n = 0
1070    n += self.lengthString(self.property_.ByteSize())
1071    if (self.has_aggregation_function_): n += 1 + self.lengthVarInt64(self.aggregation_function_)
1072    return n + 1
1073
1074  def ByteSizePartial(self):
1075    n = 0
1076    if (self.has_property_):
1077      n += 1
1078      n += self.lengthString(self.property_.ByteSizePartial())
1079    if (self.has_aggregation_function_): n += 1 + self.lengthVarInt64(self.aggregation_function_)
1080    return n
1081
1082  def Clear(self):
1083    self.clear_property()
1084    self.clear_aggregation_function()
1085
1086  def OutputUnchecked(self, out):
1087    out.putVarInt32(10)
1088    out.putVarInt32(self.property_.ByteSize())
1089    self.property_.OutputUnchecked(out)
1090    if (self.has_aggregation_function_):
1091      out.putVarInt32(16)
1092      out.putVarInt32(self.aggregation_function_)
1093
1094  def OutputPartial(self, out):
1095    if (self.has_property_):
1096      out.putVarInt32(10)
1097      out.putVarInt32(self.property_.ByteSizePartial())
1098      self.property_.OutputPartial(out)
1099    if (self.has_aggregation_function_):
1100      out.putVarInt32(16)
1101      out.putVarInt32(self.aggregation_function_)
1102
1103  def TryMerge(self, d):
1104    while d.avail() > 0:
1105      tt = d.getVarInt32()
1106      if tt == 10:
1107        length = d.getVarInt32()
1108        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
1109        d.skip(length)
1110        self.mutable_property().TryMerge(tmp)
1111        continue
1112      if tt == 16:
1113        self.set_aggregation_function(d.getVarInt32())
1114        continue
1115      # tag 0 is special: it's used to indicate an error.
1116      # so if we see it we raise an exception.
1117      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
1118      d.skipData(tt)
1119
1120
1121  def __str__(self, prefix="", printElemNumber=0):
1122    res=""
1123    if self.has_property_:
1124      res+=prefix+"property <\n"
1125      res+=self.property_.__str__(prefix + "  ", printElemNumber)
1126      res+=prefix+">\n"
1127    if self.has_aggregation_function_: res+=prefix+("aggregation_function: %s\n" % self.DebugFormatInt32(self.aggregation_function_))
1128    return res
1129
1130
1131  def _BuildTagLookupTable(sparse, maxtag, default=None):
1132    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
1133
1134  kproperty = 1
1135  kaggregation_function = 2
1136
1137  _TEXT = _BuildTagLookupTable({
1138    0: "ErrorCode",
1139    1: "property",
1140    2: "aggregation_function",
1141  }, 2)
1142
1143  _TYPES = _BuildTagLookupTable({
1144    0: ProtocolBuffer.Encoder.NUMERIC,
1145    1: ProtocolBuffer.Encoder.STRING,
1146    2: ProtocolBuffer.Encoder.NUMERIC,
1147  }, 2, ProtocolBuffer.Encoder.MAX_TYPE)
1148
1149  # stylesheet for XML output
1150  _STYLE = \
1151   """"""
1152  _STYLE_CONTENT_TYPE = \
1153   """"""
1154  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.PropertyExpression'
1155class PropertyOrder(ProtocolBuffer.ProtocolMessage):
1156
1157  # Direction values
1158  ASCENDING    =    1
1159  DESCENDING   =    2
1160
1161  _Direction_NAMES = {
1162    1: "ASCENDING",
1163    2: "DESCENDING",
1164  }
1165
1166  def Direction_Name(cls, x): return cls._Direction_NAMES.get(x, "")
1167  Direction_Name = classmethod(Direction_Name)
1168
1169  has_property_ = 0
1170  has_direction_ = 0
1171  direction_ = 1
1172
1173  def __init__(self, contents=None):
1174    self.property_ = PropertyReference()
1175    if contents is not None: self.MergeFromString(contents)
1176
1177  def property(self): return self.property_
1178
1179  def mutable_property(self): self.has_property_ = 1; return self.property_
1180
1181  def clear_property(self):self.has_property_ = 0; self.property_.Clear()
1182
1183  def has_property(self): return self.has_property_
1184
1185  def direction(self): return self.direction_
1186
1187  def set_direction(self, x):
1188    self.has_direction_ = 1
1189    self.direction_ = x
1190
1191  def clear_direction(self):
1192    if self.has_direction_:
1193      self.has_direction_ = 0
1194      self.direction_ = 1
1195
1196  def has_direction(self): return self.has_direction_
1197
1198
1199  def MergeFrom(self, x):
1200    assert x is not self
1201    if (x.has_property()): self.mutable_property().MergeFrom(x.property())
1202    if (x.has_direction()): self.set_direction(x.direction())
1203
1204  def Equals(self, x):
1205    if x is self: return 1
1206    if self.has_property_ != x.has_property_: return 0
1207    if self.has_property_ and self.property_ != x.property_: return 0
1208    if self.has_direction_ != x.has_direction_: return 0
1209    if self.has_direction_ and self.direction_ != x.direction_: return 0
1210    return 1
1211
1212  def IsInitialized(self, debug_strs=None):
1213    initialized = 1
1214    if (not self.has_property_):
1215      initialized = 0
1216      if debug_strs is not None:
1217        debug_strs.append('Required field: property not set.')
1218    elif not self.property_.IsInitialized(debug_strs): initialized = 0
1219    return initialized
1220
1221  def ByteSize(self):
1222    n = 0
1223    n += self.lengthString(self.property_.ByteSize())
1224    if (self.has_direction_): n += 1 + self.lengthVarInt64(self.direction_)
1225    return n + 1
1226
1227  def ByteSizePartial(self):
1228    n = 0
1229    if (self.has_property_):
1230      n += 1
1231      n += self.lengthString(self.property_.ByteSizePartial())
1232    if (self.has_direction_): n += 1 + self.lengthVarInt64(self.direction_)
1233    return n
1234
1235  def Clear(self):
1236    self.clear_property()
1237    self.clear_direction()
1238
1239  def OutputUnchecked(self, out):
1240    out.putVarInt32(10)
1241    out.putVarInt32(self.property_.ByteSize())
1242    self.property_.OutputUnchecked(out)
1243    if (self.has_direction_):
1244      out.putVarInt32(16)
1245      out.putVarInt32(self.direction_)
1246
1247  def OutputPartial(self, out):
1248    if (self.has_property_):
1249      out.putVarInt32(10)
1250      out.putVarInt32(self.property_.ByteSizePartial())
1251      self.property_.OutputPartial(out)
1252    if (self.has_direction_):
1253      out.putVarInt32(16)
1254      out.putVarInt32(self.direction_)
1255
1256  def TryMerge(self, d):
1257    while d.avail() > 0:
1258      tt = d.getVarInt32()
1259      if tt == 10:
1260        length = d.getVarInt32()
1261        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
1262        d.skip(length)
1263        self.mutable_property().TryMerge(tmp)
1264        continue
1265      if tt == 16:
1266        self.set_direction(d.getVarInt32())
1267        continue
1268      # tag 0 is special: it's used to indicate an error.
1269      # so if we see it we raise an exception.
1270      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
1271      d.skipData(tt)
1272
1273
1274  def __str__(self, prefix="", printElemNumber=0):
1275    res=""
1276    if self.has_property_:
1277      res+=prefix+"property <\n"
1278      res+=self.property_.__str__(prefix + "  ", printElemNumber)
1279      res+=prefix+">\n"
1280    if self.has_direction_: res+=prefix+("direction: %s\n" % self.DebugFormatInt32(self.direction_))
1281    return res
1282
1283
1284  def _BuildTagLookupTable(sparse, maxtag, default=None):
1285    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
1286
1287  kproperty = 1
1288  kdirection = 2
1289
1290  _TEXT = _BuildTagLookupTable({
1291    0: "ErrorCode",
1292    1: "property",
1293    2: "direction",
1294  }, 2)
1295
1296  _TYPES = _BuildTagLookupTable({
1297    0: ProtocolBuffer.Encoder.NUMERIC,
1298    1: ProtocolBuffer.Encoder.STRING,
1299    2: ProtocolBuffer.Encoder.NUMERIC,
1300  }, 2, ProtocolBuffer.Encoder.MAX_TYPE)
1301
1302  # stylesheet for XML output
1303  _STYLE = \
1304   """"""
1305  _STYLE_CONTENT_TYPE = \
1306   """"""
1307  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.PropertyOrder'
1308class Filter(ProtocolBuffer.ProtocolMessage):
1309  has_composite_filter_ = 0
1310  composite_filter_ = None
1311  has_property_filter_ = 0
1312  property_filter_ = None
1313
1314  def __init__(self, contents=None):
1315    self.lazy_init_lock_ = _Lock()
1316    if contents is not None: self.MergeFromString(contents)
1317
1318  def composite_filter(self):
1319    if self.composite_filter_ is None:
1320      self.lazy_init_lock_.acquire()
1321      try:
1322        if self.composite_filter_ is None: self.composite_filter_ = CompositeFilter()
1323      finally:
1324        self.lazy_init_lock_.release()
1325    return self.composite_filter_
1326
1327  def mutable_composite_filter(self): self.has_composite_filter_ = 1; return self.composite_filter()
1328
1329  def clear_composite_filter(self):
1330    # Warning: this method does not acquire the lock.
1331    if self.has_composite_filter_:
1332      self.has_composite_filter_ = 0;
1333      if self.composite_filter_ is not None: self.composite_filter_.Clear()
1334
1335  def has_composite_filter(self): return self.has_composite_filter_
1336
1337  def property_filter(self):
1338    if self.property_filter_ is None:
1339      self.lazy_init_lock_.acquire()
1340      try:
1341        if self.property_filter_ is None: self.property_filter_ = PropertyFilter()
1342      finally:
1343        self.lazy_init_lock_.release()
1344    return self.property_filter_
1345
1346  def mutable_property_filter(self): self.has_property_filter_ = 1; return self.property_filter()
1347
1348  def clear_property_filter(self):
1349    # Warning: this method does not acquire the lock.
1350    if self.has_property_filter_:
1351      self.has_property_filter_ = 0;
1352      if self.property_filter_ is not None: self.property_filter_.Clear()
1353
1354  def has_property_filter(self): return self.has_property_filter_
1355
1356
1357  def MergeFrom(self, x):
1358    assert x is not self
1359    if (x.has_composite_filter()): self.mutable_composite_filter().MergeFrom(x.composite_filter())
1360    if (x.has_property_filter()): self.mutable_property_filter().MergeFrom(x.property_filter())
1361
1362  def Equals(self, x):
1363    if x is self: return 1
1364    if self.has_composite_filter_ != x.has_composite_filter_: return 0
1365    if self.has_composite_filter_ and self.composite_filter_ != x.composite_filter_: return 0
1366    if self.has_property_filter_ != x.has_property_filter_: return 0
1367    if self.has_property_filter_ and self.property_filter_ != x.property_filter_: return 0
1368    return 1
1369
1370  def IsInitialized(self, debug_strs=None):
1371    initialized = 1
1372    if (self.has_composite_filter_ and not self.composite_filter_.IsInitialized(debug_strs)): initialized = 0
1373    if (self.has_property_filter_ and not self.property_filter_.IsInitialized(debug_strs)): initialized = 0
1374    return initialized
1375
1376  def ByteSize(self):
1377    n = 0
1378    if (self.has_composite_filter_): n += 1 + self.lengthString(self.composite_filter_.ByteSize())
1379    if (self.has_property_filter_): n += 1 + self.lengthString(self.property_filter_.ByteSize())
1380    return n
1381
1382  def ByteSizePartial(self):
1383    n = 0
1384    if (self.has_composite_filter_): n += 1 + self.lengthString(self.composite_filter_.ByteSizePartial())
1385    if (self.has_property_filter_): n += 1 + self.lengthString(self.property_filter_.ByteSizePartial())
1386    return n
1387
1388  def Clear(self):
1389    self.clear_composite_filter()
1390    self.clear_property_filter()
1391
1392  def OutputUnchecked(self, out):
1393    if (self.has_composite_filter_):
1394      out.putVarInt32(10)
1395      out.putVarInt32(self.composite_filter_.ByteSize())
1396      self.composite_filter_.OutputUnchecked(out)
1397    if (self.has_property_filter_):
1398      out.putVarInt32(18)
1399      out.putVarInt32(self.property_filter_.ByteSize())
1400      self.property_filter_.OutputUnchecked(out)
1401
1402  def OutputPartial(self, out):
1403    if (self.has_composite_filter_):
1404      out.putVarInt32(10)
1405      out.putVarInt32(self.composite_filter_.ByteSizePartial())
1406      self.composite_filter_.OutputPartial(out)
1407    if (self.has_property_filter_):
1408      out.putVarInt32(18)
1409      out.putVarInt32(self.property_filter_.ByteSizePartial())
1410      self.property_filter_.OutputPartial(out)
1411
1412  def TryMerge(self, d):
1413    while d.avail() > 0:
1414      tt = d.getVarInt32()
1415      if tt == 10:
1416        length = d.getVarInt32()
1417        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
1418        d.skip(length)
1419        self.mutable_composite_filter().TryMerge(tmp)
1420        continue
1421      if tt == 18:
1422        length = d.getVarInt32()
1423        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
1424        d.skip(length)
1425        self.mutable_property_filter().TryMerge(tmp)
1426        continue
1427      # tag 0 is special: it's used to indicate an error.
1428      # so if we see it we raise an exception.
1429      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
1430      d.skipData(tt)
1431
1432
1433  def __str__(self, prefix="", printElemNumber=0):
1434    res=""
1435    if self.has_composite_filter_:
1436      res+=prefix+"composite_filter <\n"
1437      res+=self.composite_filter_.__str__(prefix + "  ", printElemNumber)
1438      res+=prefix+">\n"
1439    if self.has_property_filter_:
1440      res+=prefix+"property_filter <\n"
1441      res+=self.property_filter_.__str__(prefix + "  ", printElemNumber)
1442      res+=prefix+">\n"
1443    return res
1444
1445
1446  def _BuildTagLookupTable(sparse, maxtag, default=None):
1447    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
1448
1449  kcomposite_filter = 1
1450  kproperty_filter = 2
1451
1452  _TEXT = _BuildTagLookupTable({
1453    0: "ErrorCode",
1454    1: "composite_filter",
1455    2: "property_filter",
1456  }, 2)
1457
1458  _TYPES = _BuildTagLookupTable({
1459    0: ProtocolBuffer.Encoder.NUMERIC,
1460    1: ProtocolBuffer.Encoder.STRING,
1461    2: ProtocolBuffer.Encoder.STRING,
1462  }, 2, ProtocolBuffer.Encoder.MAX_TYPE)
1463
1464  # stylesheet for XML output
1465  _STYLE = \
1466   """"""
1467  _STYLE_CONTENT_TYPE = \
1468   """"""
1469  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.Filter'
1470class CompositeFilter(ProtocolBuffer.ProtocolMessage):
1471
1472  # Operator values
1473  AND          =    1
1474
1475  _Operator_NAMES = {
1476    1: "AND",
1477  }
1478
1479  def Operator_Name(cls, x): return cls._Operator_NAMES.get(x, "")
1480  Operator_Name = classmethod(Operator_Name)
1481
1482  has_operator_ = 0
1483  operator_ = 0
1484
1485  def __init__(self, contents=None):
1486    self.filter_ = []
1487    if contents is not None: self.MergeFromString(contents)
1488
1489  def operator(self): return self.operator_
1490
1491  def set_operator(self, x):
1492    self.has_operator_ = 1
1493    self.operator_ = x
1494
1495  def clear_operator(self):
1496    if self.has_operator_:
1497      self.has_operator_ = 0
1498      self.operator_ = 0
1499
1500  def has_operator(self): return self.has_operator_
1501
1502  def filter_size(self): return len(self.filter_)
1503  def filter_list(self): return self.filter_
1504
1505  def filter(self, i):
1506    return self.filter_[i]
1507
1508  def mutable_filter(self, i):
1509    return self.filter_[i]
1510
1511  def add_filter(self):
1512    x = Filter()
1513    self.filter_.append(x)
1514    return x
1515
1516  def clear_filter(self):
1517    self.filter_ = []
1518
1519  def MergeFrom(self, x):
1520    assert x is not self
1521    if (x.has_operator()): self.set_operator(x.operator())
1522    for i in range(x.filter_size()): self.add_filter().CopyFrom(x.filter(i))
1523
1524  def Equals(self, x):
1525    if x is self: return 1
1526    if self.has_operator_ != x.has_operator_: return 0
1527    if self.has_operator_ and self.operator_ != x.operator_: return 0
1528    if len(self.filter_) != len(x.filter_): return 0
1529    for e1, e2 in zip(self.filter_, x.filter_):
1530      if e1 != e2: return 0
1531    return 1
1532
1533  def IsInitialized(self, debug_strs=None):
1534    initialized = 1
1535    if (not self.has_operator_):
1536      initialized = 0
1537      if debug_strs is not None:
1538        debug_strs.append('Required field: operator not set.')
1539    for p in self.filter_:
1540      if not p.IsInitialized(debug_strs): initialized=0
1541    return initialized
1542
1543  def ByteSize(self):
1544    n = 0
1545    n += self.lengthVarInt64(self.operator_)
1546    n += 1 * len(self.filter_)
1547    for i in range(len(self.filter_)): n += self.lengthString(self.filter_[i].ByteSize())
1548    return n + 1
1549
1550  def ByteSizePartial(self):
1551    n = 0
1552    if (self.has_operator_):
1553      n += 1
1554      n += self.lengthVarInt64(self.operator_)
1555    n += 1 * len(self.filter_)
1556    for i in range(len(self.filter_)): n += self.lengthString(self.filter_[i].ByteSizePartial())
1557    return n
1558
1559  def Clear(self):
1560    self.clear_operator()
1561    self.clear_filter()
1562
1563  def OutputUnchecked(self, out):
1564    out.putVarInt32(8)
1565    out.putVarInt32(self.operator_)
1566    for i in range(len(self.filter_)):
1567      out.putVarInt32(18)
1568      out.putVarInt32(self.filter_[i].ByteSize())
1569      self.filter_[i].OutputUnchecked(out)
1570
1571  def OutputPartial(self, out):
1572    if (self.has_operator_):
1573      out.putVarInt32(8)
1574      out.putVarInt32(self.operator_)
1575    for i in range(len(self.filter_)):
1576      out.putVarInt32(18)
1577      out.putVarInt32(self.filter_[i].ByteSizePartial())
1578      self.filter_[i].OutputPartial(out)
1579
1580  def TryMerge(self, d):
1581    while d.avail() > 0:
1582      tt = d.getVarInt32()
1583      if tt == 8:
1584        self.set_operator(d.getVarInt32())
1585        continue
1586      if tt == 18:
1587        length = d.getVarInt32()
1588        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
1589        d.skip(length)
1590        self.add_filter().TryMerge(tmp)
1591        continue
1592      # tag 0 is special: it's used to indicate an error.
1593      # so if we see it we raise an exception.
1594      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
1595      d.skipData(tt)
1596
1597
1598  def __str__(self, prefix="", printElemNumber=0):
1599    res=""
1600    if self.has_operator_: res+=prefix+("operator: %s\n" % self.DebugFormatInt32(self.operator_))
1601    cnt=0
1602    for e in self.filter_:
1603      elm=""
1604      if printElemNumber: elm="(%d)" % cnt
1605      res+=prefix+("filter%s <\n" % elm)
1606      res+=e.__str__(prefix + "  ", printElemNumber)
1607      res+=prefix+">\n"
1608      cnt+=1
1609    return res
1610
1611
1612  def _BuildTagLookupTable(sparse, maxtag, default=None):
1613    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
1614
1615  koperator = 1
1616  kfilter = 2
1617
1618  _TEXT = _BuildTagLookupTable({
1619    0: "ErrorCode",
1620    1: "operator",
1621    2: "filter",
1622  }, 2)
1623
1624  _TYPES = _BuildTagLookupTable({
1625    0: ProtocolBuffer.Encoder.NUMERIC,
1626    1: ProtocolBuffer.Encoder.NUMERIC,
1627    2: ProtocolBuffer.Encoder.STRING,
1628  }, 2, ProtocolBuffer.Encoder.MAX_TYPE)
1629
1630  # stylesheet for XML output
1631  _STYLE = \
1632   """"""
1633  _STYLE_CONTENT_TYPE = \
1634   """"""
1635  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.CompositeFilter'
1636class PropertyFilter(ProtocolBuffer.ProtocolMessage):
1637
1638  # Operator values
1639  LESS_THAN    =    1
1640  LESS_THAN_OR_EQUAL =    2
1641  GREATER_THAN =    3
1642  GREATER_THAN_OR_EQUAL =    4
1643  EQUAL        =    5
1644  HAS_ANCESTOR =   11
1645
1646  _Operator_NAMES = {
1647    1: "LESS_THAN",
1648    2: "LESS_THAN_OR_EQUAL",
1649    3: "GREATER_THAN",
1650    4: "GREATER_THAN_OR_EQUAL",
1651    5: "EQUAL",
1652    11: "HAS_ANCESTOR",
1653  }
1654
1655  def Operator_Name(cls, x): return cls._Operator_NAMES.get(x, "")
1656  Operator_Name = classmethod(Operator_Name)
1657
1658  has_property_ = 0
1659  has_operator_ = 0
1660  operator_ = 0
1661  has_value_ = 0
1662
1663  def __init__(self, contents=None):
1664    self.property_ = PropertyReference()
1665    self.value_ = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Value()
1666    if contents is not None: self.MergeFromString(contents)
1667
1668  def property(self): return self.property_
1669
1670  def mutable_property(self): self.has_property_ = 1; return self.property_
1671
1672  def clear_property(self):self.has_property_ = 0; self.property_.Clear()
1673
1674  def has_property(self): return self.has_property_
1675
1676  def operator(self): return self.operator_
1677
1678  def set_operator(self, x):
1679    self.has_operator_ = 1
1680    self.operator_ = x
1681
1682  def clear_operator(self):
1683    if self.has_operator_:
1684      self.has_operator_ = 0
1685      self.operator_ = 0
1686
1687  def has_operator(self): return self.has_operator_
1688
1689  def value(self): return self.value_
1690
1691  def mutable_value(self): self.has_value_ = 1; return self.value_
1692
1693  def clear_value(self):self.has_value_ = 0; self.value_.Clear()
1694
1695  def has_value(self): return self.has_value_
1696
1697
1698  def MergeFrom(self, x):
1699    assert x is not self
1700    if (x.has_property()): self.mutable_property().MergeFrom(x.property())
1701    if (x.has_operator()): self.set_operator(x.operator())
1702    if (x.has_value()): self.mutable_value().MergeFrom(x.value())
1703
1704  def Equals(self, x):
1705    if x is self: return 1
1706    if self.has_property_ != x.has_property_: return 0
1707    if self.has_property_ and self.property_ != x.property_: return 0
1708    if self.has_operator_ != x.has_operator_: return 0
1709    if self.has_operator_ and self.operator_ != x.operator_: return 0
1710    if self.has_value_ != x.has_value_: return 0
1711    if self.has_value_ and self.value_ != x.value_: return 0
1712    return 1
1713
1714  def IsInitialized(self, debug_strs=None):
1715    initialized = 1
1716    if (not self.has_property_):
1717      initialized = 0
1718      if debug_strs is not None:
1719        debug_strs.append('Required field: property not set.')
1720    elif not self.property_.IsInitialized(debug_strs): initialized = 0
1721    if (not self.has_operator_):
1722      initialized = 0
1723      if debug_strs is not None:
1724        debug_strs.append('Required field: operator not set.')
1725    if (not self.has_value_):
1726      initialized = 0
1727      if debug_strs is not None:
1728        debug_strs.append('Required field: value not set.')
1729    elif not self.value_.IsInitialized(debug_strs): initialized = 0
1730    return initialized
1731
1732  def ByteSize(self):
1733    n = 0
1734    n += self.lengthString(self.property_.ByteSize())
1735    n += self.lengthVarInt64(self.operator_)
1736    n += self.lengthString(self.value_.ByteSize())
1737    return n + 3
1738
1739  def ByteSizePartial(self):
1740    n = 0
1741    if (self.has_property_):
1742      n += 1
1743      n += self.lengthString(self.property_.ByteSizePartial())
1744    if (self.has_operator_):
1745      n += 1
1746      n += self.lengthVarInt64(self.operator_)
1747    if (self.has_value_):
1748      n += 1
1749      n += self.lengthString(self.value_.ByteSizePartial())
1750    return n
1751
1752  def Clear(self):
1753    self.clear_property()
1754    self.clear_operator()
1755    self.clear_value()
1756
1757  def OutputUnchecked(self, out):
1758    out.putVarInt32(10)
1759    out.putVarInt32(self.property_.ByteSize())
1760    self.property_.OutputUnchecked(out)
1761    out.putVarInt32(16)
1762    out.putVarInt32(self.operator_)
1763    out.putVarInt32(26)
1764    out.putVarInt32(self.value_.ByteSize())
1765    self.value_.OutputUnchecked(out)
1766
1767  def OutputPartial(self, out):
1768    if (self.has_property_):
1769      out.putVarInt32(10)
1770      out.putVarInt32(self.property_.ByteSizePartial())
1771      self.property_.OutputPartial(out)
1772    if (self.has_operator_):
1773      out.putVarInt32(16)
1774      out.putVarInt32(self.operator_)
1775    if (self.has_value_):
1776      out.putVarInt32(26)
1777      out.putVarInt32(self.value_.ByteSizePartial())
1778      self.value_.OutputPartial(out)
1779
1780  def TryMerge(self, d):
1781    while d.avail() > 0:
1782      tt = d.getVarInt32()
1783      if tt == 10:
1784        length = d.getVarInt32()
1785        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
1786        d.skip(length)
1787        self.mutable_property().TryMerge(tmp)
1788        continue
1789      if tt == 16:
1790        self.set_operator(d.getVarInt32())
1791        continue
1792      if tt == 26:
1793        length = d.getVarInt32()
1794        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
1795        d.skip(length)
1796        self.mutable_value().TryMerge(tmp)
1797        continue
1798      # tag 0 is special: it's used to indicate an error.
1799      # so if we see it we raise an exception.
1800      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
1801      d.skipData(tt)
1802
1803
1804  def __str__(self, prefix="", printElemNumber=0):
1805    res=""
1806    if self.has_property_:
1807      res+=prefix+"property <\n"
1808      res+=self.property_.__str__(prefix + "  ", printElemNumber)
1809      res+=prefix+">\n"
1810    if self.has_operator_: res+=prefix+("operator: %s\n" % self.DebugFormatInt32(self.operator_))
1811    if self.has_value_:
1812      res+=prefix+"value <\n"
1813      res+=self.value_.__str__(prefix + "  ", printElemNumber)
1814      res+=prefix+">\n"
1815    return res
1816
1817
1818  def _BuildTagLookupTable(sparse, maxtag, default=None):
1819    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
1820
1821  kproperty = 1
1822  koperator = 2
1823  kvalue = 3
1824
1825  _TEXT = _BuildTagLookupTable({
1826    0: "ErrorCode",
1827    1: "property",
1828    2: "operator",
1829    3: "value",
1830  }, 3)
1831
1832  _TYPES = _BuildTagLookupTable({
1833    0: ProtocolBuffer.Encoder.NUMERIC,
1834    1: ProtocolBuffer.Encoder.STRING,
1835    2: ProtocolBuffer.Encoder.NUMERIC,
1836    3: ProtocolBuffer.Encoder.STRING,
1837  }, 3, ProtocolBuffer.Encoder.MAX_TYPE)
1838
1839  # stylesheet for XML output
1840  _STYLE = \
1841   """"""
1842  _STYLE_CONTENT_TYPE = \
1843   """"""
1844  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.PropertyFilter'
1845class GqlQuery(ProtocolBuffer.ProtocolMessage):
1846  has_query_string_ = 0
1847  query_string_ = ""
1848  has_allow_literal_ = 0
1849  allow_literal_ = 0
1850
1851  def __init__(self, contents=None):
1852    self.name_arg_ = []
1853    self.number_arg_ = []
1854    if contents is not None: self.MergeFromString(contents)
1855
1856  def query_string(self): return self.query_string_
1857
1858  def set_query_string(self, x):
1859    self.has_query_string_ = 1
1860    self.query_string_ = x
1861
1862  def clear_query_string(self):
1863    if self.has_query_string_:
1864      self.has_query_string_ = 0
1865      self.query_string_ = ""
1866
1867  def has_query_string(self): return self.has_query_string_
1868
1869  def allow_literal(self): return self.allow_literal_
1870
1871  def set_allow_literal(self, x):
1872    self.has_allow_literal_ = 1
1873    self.allow_literal_ = x
1874
1875  def clear_allow_literal(self):
1876    if self.has_allow_literal_:
1877      self.has_allow_literal_ = 0
1878      self.allow_literal_ = 0
1879
1880  def has_allow_literal(self): return self.has_allow_literal_
1881
1882  def name_arg_size(self): return len(self.name_arg_)
1883  def name_arg_list(self): return self.name_arg_
1884
1885  def name_arg(self, i):
1886    return self.name_arg_[i]
1887
1888  def mutable_name_arg(self, i):
1889    return self.name_arg_[i]
1890
1891  def add_name_arg(self):
1892    x = GqlQueryArg()
1893    self.name_arg_.append(x)
1894    return x
1895
1896  def clear_name_arg(self):
1897    self.name_arg_ = []
1898  def number_arg_size(self): return len(self.number_arg_)
1899  def number_arg_list(self): return self.number_arg_
1900
1901  def number_arg(self, i):
1902    return self.number_arg_[i]
1903
1904  def mutable_number_arg(self, i):
1905    return self.number_arg_[i]
1906
1907  def add_number_arg(self):
1908    x = GqlQueryArg()
1909    self.number_arg_.append(x)
1910    return x
1911
1912  def clear_number_arg(self):
1913    self.number_arg_ = []
1914
1915  def MergeFrom(self, x):
1916    assert x is not self
1917    if (x.has_query_string()): self.set_query_string(x.query_string())
1918    if (x.has_allow_literal()): self.set_allow_literal(x.allow_literal())
1919    for i in range(x.name_arg_size()): self.add_name_arg().CopyFrom(x.name_arg(i))
1920    for i in range(x.number_arg_size()): self.add_number_arg().CopyFrom(x.number_arg(i))
1921
1922  def Equals(self, x):
1923    if x is self: return 1
1924    if self.has_query_string_ != x.has_query_string_: return 0
1925    if self.has_query_string_ and self.query_string_ != x.query_string_: return 0
1926    if self.has_allow_literal_ != x.has_allow_literal_: return 0
1927    if self.has_allow_literal_ and self.allow_literal_ != x.allow_literal_: return 0
1928    if len(self.name_arg_) != len(x.name_arg_): return 0
1929    for e1, e2 in zip(self.name_arg_, x.name_arg_):
1930      if e1 != e2: return 0
1931    if len(self.number_arg_) != len(x.number_arg_): return 0
1932    for e1, e2 in zip(self.number_arg_, x.number_arg_):
1933      if e1 != e2: return 0
1934    return 1
1935
1936  def IsInitialized(self, debug_strs=None):
1937    initialized = 1
1938    if (not self.has_query_string_):
1939      initialized = 0
1940      if debug_strs is not None:
1941        debug_strs.append('Required field: query_string not set.')
1942    for p in self.name_arg_:
1943      if not p.IsInitialized(debug_strs): initialized=0
1944    for p in self.number_arg_:
1945      if not p.IsInitialized(debug_strs): initialized=0
1946    return initialized
1947
1948  def ByteSize(self):
1949    n = 0
1950    n += self.lengthString(len(self.query_string_))
1951    if (self.has_allow_literal_): n += 2
1952    n += 1 * len(self.name_arg_)
1953    for i in range(len(self.name_arg_)): n += self.lengthString(self.name_arg_[i].ByteSize())
1954    n += 1 * len(self.number_arg_)
1955    for i in range(len(self.number_arg_)): n += self.lengthString(self.number_arg_[i].ByteSize())
1956    return n + 1
1957
1958  def ByteSizePartial(self):
1959    n = 0
1960    if (self.has_query_string_):
1961      n += 1
1962      n += self.lengthString(len(self.query_string_))
1963    if (self.has_allow_literal_): n += 2
1964    n += 1 * len(self.name_arg_)
1965    for i in range(len(self.name_arg_)): n += self.lengthString(self.name_arg_[i].ByteSizePartial())
1966    n += 1 * len(self.number_arg_)
1967    for i in range(len(self.number_arg_)): n += self.lengthString(self.number_arg_[i].ByteSizePartial())
1968    return n
1969
1970  def Clear(self):
1971    self.clear_query_string()
1972    self.clear_allow_literal()
1973    self.clear_name_arg()
1974    self.clear_number_arg()
1975
1976  def OutputUnchecked(self, out):
1977    out.putVarInt32(10)
1978    out.putPrefixedString(self.query_string_)
1979    if (self.has_allow_literal_):
1980      out.putVarInt32(16)
1981      out.putBoolean(self.allow_literal_)
1982    for i in range(len(self.name_arg_)):
1983      out.putVarInt32(26)
1984      out.putVarInt32(self.name_arg_[i].ByteSize())
1985      self.name_arg_[i].OutputUnchecked(out)
1986    for i in range(len(self.number_arg_)):
1987      out.putVarInt32(34)
1988      out.putVarInt32(self.number_arg_[i].ByteSize())
1989      self.number_arg_[i].OutputUnchecked(out)
1990
1991  def OutputPartial(self, out):
1992    if (self.has_query_string_):
1993      out.putVarInt32(10)
1994      out.putPrefixedString(self.query_string_)
1995    if (self.has_allow_literal_):
1996      out.putVarInt32(16)
1997      out.putBoolean(self.allow_literal_)
1998    for i in range(len(self.name_arg_)):
1999      out.putVarInt32(26)
2000      out.putVarInt32(self.name_arg_[i].ByteSizePartial())
2001      self.name_arg_[i].OutputPartial(out)
2002    for i in range(len(self.number_arg_)):
2003      out.putVarInt32(34)
2004      out.putVarInt32(self.number_arg_[i].ByteSizePartial())
2005      self.number_arg_[i].OutputPartial(out)
2006
2007  def TryMerge(self, d):
2008    while d.avail() > 0:
2009      tt = d.getVarInt32()
2010      if tt == 10:
2011        self.set_query_string(d.getPrefixedString())
2012        continue
2013      if tt == 16:
2014        self.set_allow_literal(d.getBoolean())
2015        continue
2016      if tt == 26:
2017        length = d.getVarInt32()
2018        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
2019        d.skip(length)
2020        self.add_name_arg().TryMerge(tmp)
2021        continue
2022      if tt == 34:
2023        length = d.getVarInt32()
2024        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
2025        d.skip(length)
2026        self.add_number_arg().TryMerge(tmp)
2027        continue
2028      # tag 0 is special: it's used to indicate an error.
2029      # so if we see it we raise an exception.
2030      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
2031      d.skipData(tt)
2032
2033
2034  def __str__(self, prefix="", printElemNumber=0):
2035    res=""
2036    if self.has_query_string_: res+=prefix+("query_string: %s\n" % self.DebugFormatString(self.query_string_))
2037    if self.has_allow_literal_: res+=prefix+("allow_literal: %s\n" % self.DebugFormatBool(self.allow_literal_))
2038    cnt=0
2039    for e in self.name_arg_:
2040      elm=""
2041      if printElemNumber: elm="(%d)" % cnt
2042      res+=prefix+("name_arg%s <\n" % elm)
2043      res+=e.__str__(prefix + "  ", printElemNumber)
2044      res+=prefix+">\n"
2045      cnt+=1
2046    cnt=0
2047    for e in self.number_arg_:
2048      elm=""
2049      if printElemNumber: elm="(%d)" % cnt
2050      res+=prefix+("number_arg%s <\n" % elm)
2051      res+=e.__str__(prefix + "  ", printElemNumber)
2052      res+=prefix+">\n"
2053      cnt+=1
2054    return res
2055
2056
2057  def _BuildTagLookupTable(sparse, maxtag, default=None):
2058    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
2059
2060  kquery_string = 1
2061  kallow_literal = 2
2062  kname_arg = 3
2063  knumber_arg = 4
2064
2065  _TEXT = _BuildTagLookupTable({
2066    0: "ErrorCode",
2067    1: "query_string",
2068    2: "allow_literal",
2069    3: "name_arg",
2070    4: "number_arg",
2071  }, 4)
2072
2073  _TYPES = _BuildTagLookupTable({
2074    0: ProtocolBuffer.Encoder.NUMERIC,
2075    1: ProtocolBuffer.Encoder.STRING,
2076    2: ProtocolBuffer.Encoder.NUMERIC,
2077    3: ProtocolBuffer.Encoder.STRING,
2078    4: ProtocolBuffer.Encoder.STRING,
2079  }, 4, ProtocolBuffer.Encoder.MAX_TYPE)
2080
2081  # stylesheet for XML output
2082  _STYLE = \
2083   """"""
2084  _STYLE_CONTENT_TYPE = \
2085   """"""
2086  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.GqlQuery'
2087class GqlQueryArg(ProtocolBuffer.ProtocolMessage):
2088  has_name_ = 0
2089  name_ = ""
2090  has_value_ = 0
2091  value_ = None
2092  has_cursor_ = 0
2093  cursor_ = ""
2094
2095  def __init__(self, contents=None):
2096    self.lazy_init_lock_ = _Lock()
2097    if contents is not None: self.MergeFromString(contents)
2098
2099  def name(self): return self.name_
2100
2101  def set_name(self, x):
2102    self.has_name_ = 1
2103    self.name_ = x
2104
2105  def clear_name(self):
2106    if self.has_name_:
2107      self.has_name_ = 0
2108      self.name_ = ""
2109
2110  def has_name(self): return self.has_name_
2111
2112  def value(self):
2113    if self.value_ is None:
2114      self.lazy_init_lock_.acquire()
2115      try:
2116        if self.value_ is None: self.value_ = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Value()
2117      finally:
2118        self.lazy_init_lock_.release()
2119    return self.value_
2120
2121  def mutable_value(self): self.has_value_ = 1; return self.value()
2122
2123  def clear_value(self):
2124    # Warning: this method does not acquire the lock.
2125    if self.has_value_:
2126      self.has_value_ = 0;
2127      if self.value_ is not None: self.value_.Clear()
2128
2129  def has_value(self): return self.has_value_
2130
2131  def cursor(self): return self.cursor_
2132
2133  def set_cursor(self, x):
2134    self.has_cursor_ = 1
2135    self.cursor_ = x
2136
2137  def clear_cursor(self):
2138    if self.has_cursor_:
2139      self.has_cursor_ = 0
2140      self.cursor_ = ""
2141
2142  def has_cursor(self): return self.has_cursor_
2143
2144
2145  def MergeFrom(self, x):
2146    assert x is not self
2147    if (x.has_name()): self.set_name(x.name())
2148    if (x.has_value()): self.mutable_value().MergeFrom(x.value())
2149    if (x.has_cursor()): self.set_cursor(x.cursor())
2150
2151  def Equals(self, x):
2152    if x is self: return 1
2153    if self.has_name_ != x.has_name_: return 0
2154    if self.has_name_ and self.name_ != x.name_: return 0
2155    if self.has_value_ != x.has_value_: return 0
2156    if self.has_value_ and self.value_ != x.value_: return 0
2157    if self.has_cursor_ != x.has_cursor_: return 0
2158    if self.has_cursor_ and self.cursor_ != x.cursor_: return 0
2159    return 1
2160
2161  def IsInitialized(self, debug_strs=None):
2162    initialized = 1
2163    if (self.has_value_ and not self.value_.IsInitialized(debug_strs)): initialized = 0
2164    return initialized
2165
2166  def ByteSize(self):
2167    n = 0
2168    if (self.has_name_): n += 1 + self.lengthString(len(self.name_))
2169    if (self.has_value_): n += 1 + self.lengthString(self.value_.ByteSize())
2170    if (self.has_cursor_): n += 1 + self.lengthString(len(self.cursor_))
2171    return n
2172
2173  def ByteSizePartial(self):
2174    n = 0
2175    if (self.has_name_): n += 1 + self.lengthString(len(self.name_))
2176    if (self.has_value_): n += 1 + self.lengthString(self.value_.ByteSizePartial())
2177    if (self.has_cursor_): n += 1 + self.lengthString(len(self.cursor_))
2178    return n
2179
2180  def Clear(self):
2181    self.clear_name()
2182    self.clear_value()
2183    self.clear_cursor()
2184
2185  def OutputUnchecked(self, out):
2186    if (self.has_name_):
2187      out.putVarInt32(10)
2188      out.putPrefixedString(self.name_)
2189    if (self.has_value_):
2190      out.putVarInt32(18)
2191      out.putVarInt32(self.value_.ByteSize())
2192      self.value_.OutputUnchecked(out)
2193    if (self.has_cursor_):
2194      out.putVarInt32(26)
2195      out.putPrefixedString(self.cursor_)
2196
2197  def OutputPartial(self, out):
2198    if (self.has_name_):
2199      out.putVarInt32(10)
2200      out.putPrefixedString(self.name_)
2201    if (self.has_value_):
2202      out.putVarInt32(18)
2203      out.putVarInt32(self.value_.ByteSizePartial())
2204      self.value_.OutputPartial(out)
2205    if (self.has_cursor_):
2206      out.putVarInt32(26)
2207      out.putPrefixedString(self.cursor_)
2208
2209  def TryMerge(self, d):
2210    while d.avail() > 0:
2211      tt = d.getVarInt32()
2212      if tt == 10:
2213        self.set_name(d.getPrefixedString())
2214        continue
2215      if tt == 18:
2216        length = d.getVarInt32()
2217        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
2218        d.skip(length)
2219        self.mutable_value().TryMerge(tmp)
2220        continue
2221      if tt == 26:
2222        self.set_cursor(d.getPrefixedString())
2223        continue
2224      # tag 0 is special: it's used to indicate an error.
2225      # so if we see it we raise an exception.
2226      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
2227      d.skipData(tt)
2228
2229
2230  def __str__(self, prefix="", printElemNumber=0):
2231    res=""
2232    if self.has_name_: res+=prefix+("name: %s\n" % self.DebugFormatString(self.name_))
2233    if self.has_value_:
2234      res+=prefix+"value <\n"
2235      res+=self.value_.__str__(prefix + "  ", printElemNumber)
2236      res+=prefix+">\n"
2237    if self.has_cursor_: res+=prefix+("cursor: %s\n" % self.DebugFormatString(self.cursor_))
2238    return res
2239
2240
2241  def _BuildTagLookupTable(sparse, maxtag, default=None):
2242    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
2243
2244  kname = 1
2245  kvalue = 2
2246  kcursor = 3
2247
2248  _TEXT = _BuildTagLookupTable({
2249    0: "ErrorCode",
2250    1: "name",
2251    2: "value",
2252    3: "cursor",
2253  }, 3)
2254
2255  _TYPES = _BuildTagLookupTable({
2256    0: ProtocolBuffer.Encoder.NUMERIC,
2257    1: ProtocolBuffer.Encoder.STRING,
2258    2: ProtocolBuffer.Encoder.STRING,
2259    3: ProtocolBuffer.Encoder.STRING,
2260  }, 3, ProtocolBuffer.Encoder.MAX_TYPE)
2261
2262  # stylesheet for XML output
2263  _STYLE = \
2264   """"""
2265  _STYLE_CONTENT_TYPE = \
2266   """"""
2267  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.GqlQueryArg'
2268class QueryResultBatch(ProtocolBuffer.ProtocolMessage):
2269
2270  # MoreResultsType values
2271  NOT_FINISHED =    1
2272  MORE_RESULTS_AFTER_LIMIT =    2
2273  NO_MORE_RESULTS =    3
2274
2275  _MoreResultsType_NAMES = {
2276    1: "NOT_FINISHED",
2277    2: "MORE_RESULTS_AFTER_LIMIT",
2278    3: "NO_MORE_RESULTS",
2279  }
2280
2281  def MoreResultsType_Name(cls, x): return cls._MoreResultsType_NAMES.get(x, "")
2282  MoreResultsType_Name = classmethod(MoreResultsType_Name)
2283
2284  has_entity_result_type_ = 0
2285  entity_result_type_ = 0
2286  has_skipped_cursor_ = 0
2287  skipped_cursor_ = ""
2288  has_end_cursor_ = 0
2289  end_cursor_ = ""
2290  has_more_results_ = 0
2291  more_results_ = 0
2292  has_skipped_results_ = 0
2293  skipped_results_ = 0
2294  has_snapshot_version_ = 0
2295  snapshot_version_ = 0
2296
2297  def __init__(self, contents=None):
2298    self.entity_result_ = []
2299    if contents is not None: self.MergeFromString(contents)
2300
2301  def entity_result_type(self): return self.entity_result_type_
2302
2303  def set_entity_result_type(self, x):
2304    self.has_entity_result_type_ = 1
2305    self.entity_result_type_ = x
2306
2307  def clear_entity_result_type(self):
2308    if self.has_entity_result_type_:
2309      self.has_entity_result_type_ = 0
2310      self.entity_result_type_ = 0
2311
2312  def has_entity_result_type(self): return self.has_entity_result_type_
2313
2314  def entity_result_size(self): return len(self.entity_result_)
2315  def entity_result_list(self): return self.entity_result_
2316
2317  def entity_result(self, i):
2318    return self.entity_result_[i]
2319
2320  def mutable_entity_result(self, i):
2321    return self.entity_result_[i]
2322
2323  def add_entity_result(self):
2324    x = EntityResult()
2325    self.entity_result_.append(x)
2326    return x
2327
2328  def clear_entity_result(self):
2329    self.entity_result_ = []
2330  def skipped_cursor(self): return self.skipped_cursor_
2331
2332  def set_skipped_cursor(self, x):
2333    self.has_skipped_cursor_ = 1
2334    self.skipped_cursor_ = x
2335
2336  def clear_skipped_cursor(self):
2337    if self.has_skipped_cursor_:
2338      self.has_skipped_cursor_ = 0
2339      self.skipped_cursor_ = ""
2340
2341  def has_skipped_cursor(self): return self.has_skipped_cursor_
2342
2343  def end_cursor(self): return self.end_cursor_
2344
2345  def set_end_cursor(self, x):
2346    self.has_end_cursor_ = 1
2347    self.end_cursor_ = x
2348
2349  def clear_end_cursor(self):
2350    if self.has_end_cursor_:
2351      self.has_end_cursor_ = 0
2352      self.end_cursor_ = ""
2353
2354  def has_end_cursor(self): return self.has_end_cursor_
2355
2356  def more_results(self): return self.more_results_
2357
2358  def set_more_results(self, x):
2359    self.has_more_results_ = 1
2360    self.more_results_ = x
2361
2362  def clear_more_results(self):
2363    if self.has_more_results_:
2364      self.has_more_results_ = 0
2365      self.more_results_ = 0
2366
2367  def has_more_results(self): return self.has_more_results_
2368
2369  def skipped_results(self): return self.skipped_results_
2370
2371  def set_skipped_results(self, x):
2372    self.has_skipped_results_ = 1
2373    self.skipped_results_ = x
2374
2375  def clear_skipped_results(self):
2376    if self.has_skipped_results_:
2377      self.has_skipped_results_ = 0
2378      self.skipped_results_ = 0
2379
2380  def has_skipped_results(self): return self.has_skipped_results_
2381
2382  def snapshot_version(self): return self.snapshot_version_
2383
2384  def set_snapshot_version(self, x):
2385    self.has_snapshot_version_ = 1
2386    self.snapshot_version_ = x
2387
2388  def clear_snapshot_version(self):
2389    if self.has_snapshot_version_:
2390      self.has_snapshot_version_ = 0
2391      self.snapshot_version_ = 0
2392
2393  def has_snapshot_version(self): return self.has_snapshot_version_
2394
2395
2396  def MergeFrom(self, x):
2397    assert x is not self
2398    if (x.has_entity_result_type()): self.set_entity_result_type(x.entity_result_type())
2399    for i in range(x.entity_result_size()): self.add_entity_result().CopyFrom(x.entity_result(i))
2400    if (x.has_skipped_cursor()): self.set_skipped_cursor(x.skipped_cursor())
2401    if (x.has_end_cursor()): self.set_end_cursor(x.end_cursor())
2402    if (x.has_more_results()): self.set_more_results(x.more_results())
2403    if (x.has_skipped_results()): self.set_skipped_results(x.skipped_results())
2404    if (x.has_snapshot_version()): self.set_snapshot_version(x.snapshot_version())
2405
2406  def Equals(self, x):
2407    if x is self: return 1
2408    if self.has_entity_result_type_ != x.has_entity_result_type_: return 0
2409    if self.has_entity_result_type_ and self.entity_result_type_ != x.entity_result_type_: return 0
2410    if len(self.entity_result_) != len(x.entity_result_): return 0
2411    for e1, e2 in zip(self.entity_result_, x.entity_result_):
2412      if e1 != e2: return 0
2413    if self.has_skipped_cursor_ != x.has_skipped_cursor_: return 0
2414    if self.has_skipped_cursor_ and self.skipped_cursor_ != x.skipped_cursor_: return 0
2415    if self.has_end_cursor_ != x.has_end_cursor_: return 0
2416    if self.has_end_cursor_ and self.end_cursor_ != x.end_cursor_: return 0
2417    if self.has_more_results_ != x.has_more_results_: return 0
2418    if self.has_more_results_ and self.more_results_ != x.more_results_: return 0
2419    if self.has_skipped_results_ != x.has_skipped_results_: return 0
2420    if self.has_skipped_results_ and self.skipped_results_ != x.skipped_results_: return 0
2421    if self.has_snapshot_version_ != x.has_snapshot_version_: return 0
2422    if self.has_snapshot_version_ and self.snapshot_version_ != x.snapshot_version_: return 0
2423    return 1
2424
2425  def IsInitialized(self, debug_strs=None):
2426    initialized = 1
2427    if (not self.has_entity_result_type_):
2428      initialized = 0
2429      if debug_strs is not None:
2430        debug_strs.append('Required field: entity_result_type not set.')
2431    for p in self.entity_result_:
2432      if not p.IsInitialized(debug_strs): initialized=0
2433    if (not self.has_more_results_):
2434      initialized = 0
2435      if debug_strs is not None:
2436        debug_strs.append('Required field: more_results not set.')
2437    return initialized
2438
2439  def ByteSize(self):
2440    n = 0
2441    n += self.lengthVarInt64(self.entity_result_type_)
2442    n += 1 * len(self.entity_result_)
2443    for i in range(len(self.entity_result_)): n += self.lengthString(self.entity_result_[i].ByteSize())
2444    if (self.has_skipped_cursor_): n += 1 + self.lengthString(len(self.skipped_cursor_))
2445    if (self.has_end_cursor_): n += 1 + self.lengthString(len(self.end_cursor_))
2446    n += self.lengthVarInt64(self.more_results_)
2447    if (self.has_skipped_results_): n += 1 + self.lengthVarInt64(self.skipped_results_)
2448    if (self.has_snapshot_version_): n += 1 + self.lengthVarInt64(self.snapshot_version_)
2449    return n + 2
2450
2451  def ByteSizePartial(self):
2452    n = 0
2453    if (self.has_entity_result_type_):
2454      n += 1
2455      n += self.lengthVarInt64(self.entity_result_type_)
2456    n += 1 * len(self.entity_result_)
2457    for i in range(len(self.entity_result_)): n += self.lengthString(self.entity_result_[i].ByteSizePartial())
2458    if (self.has_skipped_cursor_): n += 1 + self.lengthString(len(self.skipped_cursor_))
2459    if (self.has_end_cursor_): n += 1 + self.lengthString(len(self.end_cursor_))
2460    if (self.has_more_results_):
2461      n += 1
2462      n += self.lengthVarInt64(self.more_results_)
2463    if (self.has_skipped_results_): n += 1 + self.lengthVarInt64(self.skipped_results_)
2464    if (self.has_snapshot_version_): n += 1 + self.lengthVarInt64(self.snapshot_version_)
2465    return n
2466
2467  def Clear(self):
2468    self.clear_entity_result_type()
2469    self.clear_entity_result()
2470    self.clear_skipped_cursor()
2471    self.clear_end_cursor()
2472    self.clear_more_results()
2473    self.clear_skipped_results()
2474    self.clear_snapshot_version()
2475
2476  def OutputUnchecked(self, out):
2477    out.putVarInt32(8)
2478    out.putVarInt32(self.entity_result_type_)
2479    for i in range(len(self.entity_result_)):
2480      out.putVarInt32(18)
2481      out.putVarInt32(self.entity_result_[i].ByteSize())
2482      self.entity_result_[i].OutputUnchecked(out)
2483    if (self.has_skipped_cursor_):
2484      out.putVarInt32(26)
2485      out.putPrefixedString(self.skipped_cursor_)
2486    if (self.has_end_cursor_):
2487      out.putVarInt32(34)
2488      out.putPrefixedString(self.end_cursor_)
2489    out.putVarInt32(40)
2490    out.putVarInt32(self.more_results_)
2491    if (self.has_skipped_results_):
2492      out.putVarInt32(48)
2493      out.putVarInt32(self.skipped_results_)
2494    if (self.has_snapshot_version_):
2495      out.putVarInt32(56)
2496      out.putVarInt64(self.snapshot_version_)
2497
2498  def OutputPartial(self, out):
2499    if (self.has_entity_result_type_):
2500      out.putVarInt32(8)
2501      out.putVarInt32(self.entity_result_type_)
2502    for i in range(len(self.entity_result_)):
2503      out.putVarInt32(18)
2504      out.putVarInt32(self.entity_result_[i].ByteSizePartial())
2505      self.entity_result_[i].OutputPartial(out)
2506    if (self.has_skipped_cursor_):
2507      out.putVarInt32(26)
2508      out.putPrefixedString(self.skipped_cursor_)
2509    if (self.has_end_cursor_):
2510      out.putVarInt32(34)
2511      out.putPrefixedString(self.end_cursor_)
2512    if (self.has_more_results_):
2513      out.putVarInt32(40)
2514      out.putVarInt32(self.more_results_)
2515    if (self.has_skipped_results_):
2516      out.putVarInt32(48)
2517      out.putVarInt32(self.skipped_results_)
2518    if (self.has_snapshot_version_):
2519      out.putVarInt32(56)
2520      out.putVarInt64(self.snapshot_version_)
2521
2522  def TryMerge(self, d):
2523    while d.avail() > 0:
2524      tt = d.getVarInt32()
2525      if tt == 8:
2526        self.set_entity_result_type(d.getVarInt32())
2527        continue
2528      if tt == 18:
2529        length = d.getVarInt32()
2530        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
2531        d.skip(length)
2532        self.add_entity_result().TryMerge(tmp)
2533        continue
2534      if tt == 26:
2535        self.set_skipped_cursor(d.getPrefixedString())
2536        continue
2537      if tt == 34:
2538        self.set_end_cursor(d.getPrefixedString())
2539        continue
2540      if tt == 40:
2541        self.set_more_results(d.getVarInt32())
2542        continue
2543      if tt == 48:
2544        self.set_skipped_results(d.getVarInt32())
2545        continue
2546      if tt == 56:
2547        self.set_snapshot_version(d.getVarInt64())
2548        continue
2549      # tag 0 is special: it's used to indicate an error.
2550      # so if we see it we raise an exception.
2551      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
2552      d.skipData(tt)
2553
2554
2555  def __str__(self, prefix="", printElemNumber=0):
2556    res=""
2557    if self.has_entity_result_type_: res+=prefix+("entity_result_type: %s\n" % self.DebugFormatInt32(self.entity_result_type_))
2558    cnt=0
2559    for e in self.entity_result_:
2560      elm=""
2561      if printElemNumber: elm="(%d)" % cnt
2562      res+=prefix+("entity_result%s <\n" % elm)
2563      res+=e.__str__(prefix + "  ", printElemNumber)
2564      res+=prefix+">\n"
2565      cnt+=1
2566    if self.has_skipped_cursor_: res+=prefix+("skipped_cursor: %s\n" % self.DebugFormatString(self.skipped_cursor_))
2567    if self.has_end_cursor_: res+=prefix+("end_cursor: %s\n" % self.DebugFormatString(self.end_cursor_))
2568    if self.has_more_results_: res+=prefix+("more_results: %s\n" % self.DebugFormatInt32(self.more_results_))
2569    if self.has_skipped_results_: res+=prefix+("skipped_results: %s\n" % self.DebugFormatInt32(self.skipped_results_))
2570    if self.has_snapshot_version_: res+=prefix+("snapshot_version: %s\n" % self.DebugFormatInt64(self.snapshot_version_))
2571    return res
2572
2573
2574  def _BuildTagLookupTable(sparse, maxtag, default=None):
2575    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
2576
2577  kentity_result_type = 1
2578  kentity_result = 2
2579  kskipped_cursor = 3
2580  kend_cursor = 4
2581  kmore_results = 5
2582  kskipped_results = 6
2583  ksnapshot_version = 7
2584
2585  _TEXT = _BuildTagLookupTable({
2586    0: "ErrorCode",
2587    1: "entity_result_type",
2588    2: "entity_result",
2589    3: "skipped_cursor",
2590    4: "end_cursor",
2591    5: "more_results",
2592    6: "skipped_results",
2593    7: "snapshot_version",
2594  }, 7)
2595
2596  _TYPES = _BuildTagLookupTable({
2597    0: ProtocolBuffer.Encoder.NUMERIC,
2598    1: ProtocolBuffer.Encoder.NUMERIC,
2599    2: ProtocolBuffer.Encoder.STRING,
2600    3: ProtocolBuffer.Encoder.STRING,
2601    4: ProtocolBuffer.Encoder.STRING,
2602    5: ProtocolBuffer.Encoder.NUMERIC,
2603    6: ProtocolBuffer.Encoder.NUMERIC,
2604    7: ProtocolBuffer.Encoder.NUMERIC,
2605  }, 7, ProtocolBuffer.Encoder.MAX_TYPE)
2606
2607  # stylesheet for XML output
2608  _STYLE = \
2609   """"""
2610  _STYLE_CONTENT_TYPE = \
2611   """"""
2612  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.QueryResultBatch'
2613class Mutation(ProtocolBuffer.ProtocolMessage):
2614
2615  # Operation values
2616  UNKNOWN      =    0
2617  INSERT       =    1
2618  UPDATE       =    2
2619  UPSERT       =    3
2620  DELETE       =    4
2621
2622  _Operation_NAMES = {
2623    0: "UNKNOWN",
2624    1: "INSERT",
2625    2: "UPDATE",
2626    3: "UPSERT",
2627    4: "DELETE",
2628  }
2629
2630  def Operation_Name(cls, x): return cls._Operation_NAMES.get(x, "")
2631  Operation_Name = classmethod(Operation_Name)
2632
2633  has_op_ = 0
2634  op_ = 0
2635  has_key_ = 0
2636  key_ = None
2637  has_entity_ = 0
2638  entity_ = None
2639
2640  def __init__(self, contents=None):
2641    self.lazy_init_lock_ = _Lock()
2642    if contents is not None: self.MergeFromString(contents)
2643
2644  def op(self): return self.op_
2645
2646  def set_op(self, x):
2647    self.has_op_ = 1
2648    self.op_ = x
2649
2650  def clear_op(self):
2651    if self.has_op_:
2652      self.has_op_ = 0
2653      self.op_ = 0
2654
2655  def has_op(self): return self.has_op_
2656
2657  def key(self):
2658    if self.key_ is None:
2659      self.lazy_init_lock_.acquire()
2660      try:
2661        if self.key_ is None: self.key_ = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Key()
2662      finally:
2663        self.lazy_init_lock_.release()
2664    return self.key_
2665
2666  def mutable_key(self): self.has_key_ = 1; return self.key()
2667
2668  def clear_key(self):
2669    # Warning: this method does not acquire the lock.
2670    if self.has_key_:
2671      self.has_key_ = 0;
2672      if self.key_ is not None: self.key_.Clear()
2673
2674  def has_key(self): return self.has_key_
2675
2676  def entity(self):
2677    if self.entity_ is None:
2678      self.lazy_init_lock_.acquire()
2679      try:
2680        if self.entity_ is None: self.entity_ = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Entity()
2681      finally:
2682        self.lazy_init_lock_.release()
2683    return self.entity_
2684
2685  def mutable_entity(self): self.has_entity_ = 1; return self.entity()
2686
2687  def clear_entity(self):
2688    # Warning: this method does not acquire the lock.
2689    if self.has_entity_:
2690      self.has_entity_ = 0;
2691      if self.entity_ is not None: self.entity_.Clear()
2692
2693  def has_entity(self): return self.has_entity_
2694
2695
2696  def MergeFrom(self, x):
2697    assert x is not self
2698    if (x.has_op()): self.set_op(x.op())
2699    if (x.has_key()): self.mutable_key().MergeFrom(x.key())
2700    if (x.has_entity()): self.mutable_entity().MergeFrom(x.entity())
2701
2702  def Equals(self, x):
2703    if x is self: return 1
2704    if self.has_op_ != x.has_op_: return 0
2705    if self.has_op_ and self.op_ != x.op_: return 0
2706    if self.has_key_ != x.has_key_: return 0
2707    if self.has_key_ and self.key_ != x.key_: return 0
2708    if self.has_entity_ != x.has_entity_: return 0
2709    if self.has_entity_ and self.entity_ != x.entity_: return 0
2710    return 1
2711
2712  def IsInitialized(self, debug_strs=None):
2713    initialized = 1
2714    if (self.has_key_ and not self.key_.IsInitialized(debug_strs)): initialized = 0
2715    if (self.has_entity_ and not self.entity_.IsInitialized(debug_strs)): initialized = 0
2716    return initialized
2717
2718  def ByteSize(self):
2719    n = 0
2720    if (self.has_op_): n += 1 + self.lengthVarInt64(self.op_)
2721    if (self.has_key_): n += 1 + self.lengthString(self.key_.ByteSize())
2722    if (self.has_entity_): n += 1 + self.lengthString(self.entity_.ByteSize())
2723    return n
2724
2725  def ByteSizePartial(self):
2726    n = 0
2727    if (self.has_op_): n += 1 + self.lengthVarInt64(self.op_)
2728    if (self.has_key_): n += 1 + self.lengthString(self.key_.ByteSizePartial())
2729    if (self.has_entity_): n += 1 + self.lengthString(self.entity_.ByteSizePartial())
2730    return n
2731
2732  def Clear(self):
2733    self.clear_op()
2734    self.clear_key()
2735    self.clear_entity()
2736
2737  def OutputUnchecked(self, out):
2738    if (self.has_op_):
2739      out.putVarInt32(8)
2740      out.putVarInt32(self.op_)
2741    if (self.has_key_):
2742      out.putVarInt32(18)
2743      out.putVarInt32(self.key_.ByteSize())
2744      self.key_.OutputUnchecked(out)
2745    if (self.has_entity_):
2746      out.putVarInt32(26)
2747      out.putVarInt32(self.entity_.ByteSize())
2748      self.entity_.OutputUnchecked(out)
2749
2750  def OutputPartial(self, out):
2751    if (self.has_op_):
2752      out.putVarInt32(8)
2753      out.putVarInt32(self.op_)
2754    if (self.has_key_):
2755      out.putVarInt32(18)
2756      out.putVarInt32(self.key_.ByteSizePartial())
2757      self.key_.OutputPartial(out)
2758    if (self.has_entity_):
2759      out.putVarInt32(26)
2760      out.putVarInt32(self.entity_.ByteSizePartial())
2761      self.entity_.OutputPartial(out)
2762
2763  def TryMerge(self, d):
2764    while d.avail() > 0:
2765      tt = d.getVarInt32()
2766      if tt == 8:
2767        self.set_op(d.getVarInt32())
2768        continue
2769      if tt == 18:
2770        length = d.getVarInt32()
2771        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
2772        d.skip(length)
2773        self.mutable_key().TryMerge(tmp)
2774        continue
2775      if tt == 26:
2776        length = d.getVarInt32()
2777        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
2778        d.skip(length)
2779        self.mutable_entity().TryMerge(tmp)
2780        continue
2781      # tag 0 is special: it's used to indicate an error.
2782      # so if we see it we raise an exception.
2783      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
2784      d.skipData(tt)
2785
2786
2787  def __str__(self, prefix="", printElemNumber=0):
2788    res=""
2789    if self.has_op_: res+=prefix+("op: %s\n" % self.DebugFormatInt32(self.op_))
2790    if self.has_key_:
2791      res+=prefix+"key <\n"
2792      res+=self.key_.__str__(prefix + "  ", printElemNumber)
2793      res+=prefix+">\n"
2794    if self.has_entity_:
2795      res+=prefix+"entity <\n"
2796      res+=self.entity_.__str__(prefix + "  ", printElemNumber)
2797      res+=prefix+">\n"
2798    return res
2799
2800
2801  def _BuildTagLookupTable(sparse, maxtag, default=None):
2802    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
2803
2804  kop = 1
2805  kkey = 2
2806  kentity = 3
2807
2808  _TEXT = _BuildTagLookupTable({
2809    0: "ErrorCode",
2810    1: "op",
2811    2: "key",
2812    3: "entity",
2813  }, 3)
2814
2815  _TYPES = _BuildTagLookupTable({
2816    0: ProtocolBuffer.Encoder.NUMERIC,
2817    1: ProtocolBuffer.Encoder.NUMERIC,
2818    2: ProtocolBuffer.Encoder.STRING,
2819    3: ProtocolBuffer.Encoder.STRING,
2820  }, 3, ProtocolBuffer.Encoder.MAX_TYPE)
2821
2822  # stylesheet for XML output
2823  _STYLE = \
2824   """"""
2825  _STYLE_CONTENT_TYPE = \
2826   """"""
2827  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.Mutation'
2828class MutationResult(ProtocolBuffer.ProtocolMessage):
2829  has_key_ = 0
2830  key_ = None
2831  has_new_version_ = 0
2832  new_version_ = 0
2833
2834  def __init__(self, contents=None):
2835    self.lazy_init_lock_ = _Lock()
2836    if contents is not None: self.MergeFromString(contents)
2837
2838  def key(self):
2839    if self.key_ is None:
2840      self.lazy_init_lock_.acquire()
2841      try:
2842        if self.key_ is None: self.key_ = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Key()
2843      finally:
2844        self.lazy_init_lock_.release()
2845    return self.key_
2846
2847  def mutable_key(self): self.has_key_ = 1; return self.key()
2848
2849  def clear_key(self):
2850    # Warning: this method does not acquire the lock.
2851    if self.has_key_:
2852      self.has_key_ = 0;
2853      if self.key_ is not None: self.key_.Clear()
2854
2855  def has_key(self): return self.has_key_
2856
2857  def new_version(self): return self.new_version_
2858
2859  def set_new_version(self, x):
2860    self.has_new_version_ = 1
2861    self.new_version_ = x
2862
2863  def clear_new_version(self):
2864    if self.has_new_version_:
2865      self.has_new_version_ = 0
2866      self.new_version_ = 0
2867
2868  def has_new_version(self): return self.has_new_version_
2869
2870
2871  def MergeFrom(self, x):
2872    assert x is not self
2873    if (x.has_key()): self.mutable_key().MergeFrom(x.key())
2874    if (x.has_new_version()): self.set_new_version(x.new_version())
2875
2876  def Equals(self, x):
2877    if x is self: return 1
2878    if self.has_key_ != x.has_key_: return 0
2879    if self.has_key_ and self.key_ != x.key_: return 0
2880    if self.has_new_version_ != x.has_new_version_: return 0
2881    if self.has_new_version_ and self.new_version_ != x.new_version_: return 0
2882    return 1
2883
2884  def IsInitialized(self, debug_strs=None):
2885    initialized = 1
2886    if (self.has_key_ and not self.key_.IsInitialized(debug_strs)): initialized = 0
2887    return initialized
2888
2889  def ByteSize(self):
2890    n = 0
2891    if (self.has_key_): n += 1 + self.lengthString(self.key_.ByteSize())
2892    if (self.has_new_version_): n += 1 + self.lengthVarInt64(self.new_version_)
2893    return n
2894
2895  def ByteSizePartial(self):
2896    n = 0
2897    if (self.has_key_): n += 1 + self.lengthString(self.key_.ByteSizePartial())
2898    if (self.has_new_version_): n += 1 + self.lengthVarInt64(self.new_version_)
2899    return n
2900
2901  def Clear(self):
2902    self.clear_key()
2903    self.clear_new_version()
2904
2905  def OutputUnchecked(self, out):
2906    if (self.has_key_):
2907      out.putVarInt32(26)
2908      out.putVarInt32(self.key_.ByteSize())
2909      self.key_.OutputUnchecked(out)
2910    if (self.has_new_version_):
2911      out.putVarInt32(32)
2912      out.putVarInt64(self.new_version_)
2913
2914  def OutputPartial(self, out):
2915    if (self.has_key_):
2916      out.putVarInt32(26)
2917      out.putVarInt32(self.key_.ByteSizePartial())
2918      self.key_.OutputPartial(out)
2919    if (self.has_new_version_):
2920      out.putVarInt32(32)
2921      out.putVarInt64(self.new_version_)
2922
2923  def TryMerge(self, d):
2924    while d.avail() > 0:
2925      tt = d.getVarInt32()
2926      if tt == 26:
2927        length = d.getVarInt32()
2928        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
2929        d.skip(length)
2930        self.mutable_key().TryMerge(tmp)
2931        continue
2932      if tt == 32:
2933        self.set_new_version(d.getVarInt64())
2934        continue
2935      # tag 0 is special: it's used to indicate an error.
2936      # so if we see it we raise an exception.
2937      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
2938      d.skipData(tt)
2939
2940
2941  def __str__(self, prefix="", printElemNumber=0):
2942    res=""
2943    if self.has_key_:
2944      res+=prefix+"key <\n"
2945      res+=self.key_.__str__(prefix + "  ", printElemNumber)
2946      res+=prefix+">\n"
2947    if self.has_new_version_: res+=prefix+("new_version: %s\n" % self.DebugFormatInt64(self.new_version_))
2948    return res
2949
2950
2951  def _BuildTagLookupTable(sparse, maxtag, default=None):
2952    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
2953
2954  kkey = 3
2955  knew_version = 4
2956
2957  _TEXT = _BuildTagLookupTable({
2958    0: "ErrorCode",
2959    3: "key",
2960    4: "new_version",
2961  }, 4)
2962
2963  _TYPES = _BuildTagLookupTable({
2964    0: ProtocolBuffer.Encoder.NUMERIC,
2965    3: ProtocolBuffer.Encoder.STRING,
2966    4: ProtocolBuffer.Encoder.NUMERIC,
2967  }, 4, ProtocolBuffer.Encoder.MAX_TYPE)
2968
2969  # stylesheet for XML output
2970  _STYLE = \
2971   """"""
2972  _STYLE_CONTENT_TYPE = \
2973   """"""
2974  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.MutationResult'
2975class DeprecatedMutation(ProtocolBuffer.ProtocolMessage):
2976  has_force_ = 0
2977  force_ = 0
2978
2979  def __init__(self, contents=None):
2980    self.upsert_ = []
2981    self.update_ = []
2982    self.insert_ = []
2983    self.insert_auto_id_ = []
2984    self.delete_ = []
2985    if contents is not None: self.MergeFromString(contents)
2986
2987  def upsert_size(self): return len(self.upsert_)
2988  def upsert_list(self): return self.upsert_
2989
2990  def upsert(self, i):
2991    return self.upsert_[i]
2992
2993  def mutable_upsert(self, i):
2994    return self.upsert_[i]
2995
2996  def add_upsert(self):
2997    x = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Entity()
2998    self.upsert_.append(x)
2999    return x
3000
3001  def clear_upsert(self):
3002    self.upsert_ = []
3003  def update_size(self): return len(self.update_)
3004  def update_list(self): return self.update_
3005
3006  def update(self, i):
3007    return self.update_[i]
3008
3009  def mutable_update(self, i):
3010    return self.update_[i]
3011
3012  def add_update(self):
3013    x = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Entity()
3014    self.update_.append(x)
3015    return x
3016
3017  def clear_update(self):
3018    self.update_ = []
3019  def insert_size(self): return len(self.insert_)
3020  def insert_list(self): return self.insert_
3021
3022  def insert(self, i):
3023    return self.insert_[i]
3024
3025  def mutable_insert(self, i):
3026    return self.insert_[i]
3027
3028  def add_insert(self):
3029    x = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Entity()
3030    self.insert_.append(x)
3031    return x
3032
3033  def clear_insert(self):
3034    self.insert_ = []
3035  def insert_auto_id_size(self): return len(self.insert_auto_id_)
3036  def insert_auto_id_list(self): return self.insert_auto_id_
3037
3038  def insert_auto_id(self, i):
3039    return self.insert_auto_id_[i]
3040
3041  def mutable_insert_auto_id(self, i):
3042    return self.insert_auto_id_[i]
3043
3044  def add_insert_auto_id(self):
3045    x = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Entity()
3046    self.insert_auto_id_.append(x)
3047    return x
3048
3049  def clear_insert_auto_id(self):
3050    self.insert_auto_id_ = []
3051  def delete_size(self): return len(self.delete_)
3052  def delete_list(self): return self.delete_
3053
3054  def delete(self, i):
3055    return self.delete_[i]
3056
3057  def mutable_delete(self, i):
3058    return self.delete_[i]
3059
3060  def add_delete(self):
3061    x = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Key()
3062    self.delete_.append(x)
3063    return x
3064
3065  def clear_delete(self):
3066    self.delete_ = []
3067  def force(self): return self.force_
3068
3069  def set_force(self, x):
3070    self.has_force_ = 1
3071    self.force_ = x
3072
3073  def clear_force(self):
3074    if self.has_force_:
3075      self.has_force_ = 0
3076      self.force_ = 0
3077
3078  def has_force(self): return self.has_force_
3079
3080
3081  def MergeFrom(self, x):
3082    assert x is not self
3083    for i in range(x.upsert_size()): self.add_upsert().CopyFrom(x.upsert(i))
3084    for i in range(x.update_size()): self.add_update().CopyFrom(x.update(i))
3085    for i in range(x.insert_size()): self.add_insert().CopyFrom(x.insert(i))
3086    for i in range(x.insert_auto_id_size()): self.add_insert_auto_id().CopyFrom(x.insert_auto_id(i))
3087    for i in range(x.delete_size()): self.add_delete().CopyFrom(x.delete(i))
3088    if (x.has_force()): self.set_force(x.force())
3089
3090  def Equals(self, x):
3091    if x is self: return 1
3092    if len(self.upsert_) != len(x.upsert_): return 0
3093    for e1, e2 in zip(self.upsert_, x.upsert_):
3094      if e1 != e2: return 0
3095    if len(self.update_) != len(x.update_): return 0
3096    for e1, e2 in zip(self.update_, x.update_):
3097      if e1 != e2: return 0
3098    if len(self.insert_) != len(x.insert_): return 0
3099    for e1, e2 in zip(self.insert_, x.insert_):
3100      if e1 != e2: return 0
3101    if len(self.insert_auto_id_) != len(x.insert_auto_id_): return 0
3102    for e1, e2 in zip(self.insert_auto_id_, x.insert_auto_id_):
3103      if e1 != e2: return 0
3104    if len(self.delete_) != len(x.delete_): return 0
3105    for e1, e2 in zip(self.delete_, x.delete_):
3106      if e1 != e2: return 0
3107    if self.has_force_ != x.has_force_: return 0
3108    if self.has_force_ and self.force_ != x.force_: return 0
3109    return 1
3110
3111  def IsInitialized(self, debug_strs=None):
3112    initialized = 1
3113    for p in self.upsert_:
3114      if not p.IsInitialized(debug_strs): initialized=0
3115    for p in self.update_:
3116      if not p.IsInitialized(debug_strs): initialized=0
3117    for p in self.insert_:
3118      if not p.IsInitialized(debug_strs): initialized=0
3119    for p in self.insert_auto_id_:
3120      if not p.IsInitialized(debug_strs): initialized=0
3121    for p in self.delete_:
3122      if not p.IsInitialized(debug_strs): initialized=0
3123    return initialized
3124
3125  def ByteSize(self):
3126    n = 0
3127    n += 1 * len(self.upsert_)
3128    for i in range(len(self.upsert_)): n += self.lengthString(self.upsert_[i].ByteSize())
3129    n += 1 * len(self.update_)
3130    for i in range(len(self.update_)): n += self.lengthString(self.update_[i].ByteSize())
3131    n += 1 * len(self.insert_)
3132    for i in range(len(self.insert_)): n += self.lengthString(self.insert_[i].ByteSize())
3133    n += 1 * len(self.insert_auto_id_)
3134    for i in range(len(self.insert_auto_id_)): n += self.lengthString(self.insert_auto_id_[i].ByteSize())
3135    n += 1 * len(self.delete_)
3136    for i in range(len(self.delete_)): n += self.lengthString(self.delete_[i].ByteSize())
3137    if (self.has_force_): n += 2
3138    return n
3139
3140  def ByteSizePartial(self):
3141    n = 0
3142    n += 1 * len(self.upsert_)
3143    for i in range(len(self.upsert_)): n += self.lengthString(self.upsert_[i].ByteSizePartial())
3144    n += 1 * len(self.update_)
3145    for i in range(len(self.update_)): n += self.lengthString(self.update_[i].ByteSizePartial())
3146    n += 1 * len(self.insert_)
3147    for i in range(len(self.insert_)): n += self.lengthString(self.insert_[i].ByteSizePartial())
3148    n += 1 * len(self.insert_auto_id_)
3149    for i in range(len(self.insert_auto_id_)): n += self.lengthString(self.insert_auto_id_[i].ByteSizePartial())
3150    n += 1 * len(self.delete_)
3151    for i in range(len(self.delete_)): n += self.lengthString(self.delete_[i].ByteSizePartial())
3152    if (self.has_force_): n += 2
3153    return n
3154
3155  def Clear(self):
3156    self.clear_upsert()
3157    self.clear_update()
3158    self.clear_insert()
3159    self.clear_insert_auto_id()
3160    self.clear_delete()
3161    self.clear_force()
3162
3163  def OutputUnchecked(self, out):
3164    for i in range(len(self.upsert_)):
3165      out.putVarInt32(10)
3166      out.putVarInt32(self.upsert_[i].ByteSize())
3167      self.upsert_[i].OutputUnchecked(out)
3168    for i in range(len(self.update_)):
3169      out.putVarInt32(18)
3170      out.putVarInt32(self.update_[i].ByteSize())
3171      self.update_[i].OutputUnchecked(out)
3172    for i in range(len(self.insert_)):
3173      out.putVarInt32(26)
3174      out.putVarInt32(self.insert_[i].ByteSize())
3175      self.insert_[i].OutputUnchecked(out)
3176    for i in range(len(self.insert_auto_id_)):
3177      out.putVarInt32(34)
3178      out.putVarInt32(self.insert_auto_id_[i].ByteSize())
3179      self.insert_auto_id_[i].OutputUnchecked(out)
3180    for i in range(len(self.delete_)):
3181      out.putVarInt32(42)
3182      out.putVarInt32(self.delete_[i].ByteSize())
3183      self.delete_[i].OutputUnchecked(out)
3184    if (self.has_force_):
3185      out.putVarInt32(48)
3186      out.putBoolean(self.force_)
3187
3188  def OutputPartial(self, out):
3189    for i in range(len(self.upsert_)):
3190      out.putVarInt32(10)
3191      out.putVarInt32(self.upsert_[i].ByteSizePartial())
3192      self.upsert_[i].OutputPartial(out)
3193    for i in range(len(self.update_)):
3194      out.putVarInt32(18)
3195      out.putVarInt32(self.update_[i].ByteSizePartial())
3196      self.update_[i].OutputPartial(out)
3197    for i in range(len(self.insert_)):
3198      out.putVarInt32(26)
3199      out.putVarInt32(self.insert_[i].ByteSizePartial())
3200      self.insert_[i].OutputPartial(out)
3201    for i in range(len(self.insert_auto_id_)):
3202      out.putVarInt32(34)
3203      out.putVarInt32(self.insert_auto_id_[i].ByteSizePartial())
3204      self.insert_auto_id_[i].OutputPartial(out)
3205    for i in range(len(self.delete_)):
3206      out.putVarInt32(42)
3207      out.putVarInt32(self.delete_[i].ByteSizePartial())
3208      self.delete_[i].OutputPartial(out)
3209    if (self.has_force_):
3210      out.putVarInt32(48)
3211      out.putBoolean(self.force_)
3212
3213  def TryMerge(self, d):
3214    while d.avail() > 0:
3215      tt = d.getVarInt32()
3216      if tt == 10:
3217        length = d.getVarInt32()
3218        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
3219        d.skip(length)
3220        self.add_upsert().TryMerge(tmp)
3221        continue
3222      if tt == 18:
3223        length = d.getVarInt32()
3224        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
3225        d.skip(length)
3226        self.add_update().TryMerge(tmp)
3227        continue
3228      if tt == 26:
3229        length = d.getVarInt32()
3230        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
3231        d.skip(length)
3232        self.add_insert().TryMerge(tmp)
3233        continue
3234      if tt == 34:
3235        length = d.getVarInt32()
3236        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
3237        d.skip(length)
3238        self.add_insert_auto_id().TryMerge(tmp)
3239        continue
3240      if tt == 42:
3241        length = d.getVarInt32()
3242        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
3243        d.skip(length)
3244        self.add_delete().TryMerge(tmp)
3245        continue
3246      if tt == 48:
3247        self.set_force(d.getBoolean())
3248        continue
3249      # tag 0 is special: it's used to indicate an error.
3250      # so if we see it we raise an exception.
3251      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
3252      d.skipData(tt)
3253
3254
3255  def __str__(self, prefix="", printElemNumber=0):
3256    res=""
3257    cnt=0
3258    for e in self.upsert_:
3259      elm=""
3260      if printElemNumber: elm="(%d)" % cnt
3261      res+=prefix+("upsert%s <\n" % elm)
3262      res+=e.__str__(prefix + "  ", printElemNumber)
3263      res+=prefix+">\n"
3264      cnt+=1
3265    cnt=0
3266    for e in self.update_:
3267      elm=""
3268      if printElemNumber: elm="(%d)" % cnt
3269      res+=prefix+("update%s <\n" % elm)
3270      res+=e.__str__(prefix + "  ", printElemNumber)
3271      res+=prefix+">\n"
3272      cnt+=1
3273    cnt=0
3274    for e in self.insert_:
3275      elm=""
3276      if printElemNumber: elm="(%d)" % cnt
3277      res+=prefix+("insert%s <\n" % elm)
3278      res+=e.__str__(prefix + "  ", printElemNumber)
3279      res+=prefix+">\n"
3280      cnt+=1
3281    cnt=0
3282    for e in self.insert_auto_id_:
3283      elm=""
3284      if printElemNumber: elm="(%d)" % cnt
3285      res+=prefix+("insert_auto_id%s <\n" % elm)
3286      res+=e.__str__(prefix + "  ", printElemNumber)
3287      res+=prefix+">\n"
3288      cnt+=1
3289    cnt=0
3290    for e in self.delete_:
3291      elm=""
3292      if printElemNumber: elm="(%d)" % cnt
3293      res+=prefix+("delete%s <\n" % elm)
3294      res+=e.__str__(prefix + "  ", printElemNumber)
3295      res+=prefix+">\n"
3296      cnt+=1
3297    if self.has_force_: res+=prefix+("force: %s\n" % self.DebugFormatBool(self.force_))
3298    return res
3299
3300
3301  def _BuildTagLookupTable(sparse, maxtag, default=None):
3302    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
3303
3304  kupsert = 1
3305  kupdate = 2
3306  kinsert = 3
3307  kinsert_auto_id = 4
3308  kdelete = 5
3309  kforce = 6
3310
3311  _TEXT = _BuildTagLookupTable({
3312    0: "ErrorCode",
3313    1: "upsert",
3314    2: "update",
3315    3: "insert",
3316    4: "insert_auto_id",
3317    5: "delete",
3318    6: "force",
3319  }, 6)
3320
3321  _TYPES = _BuildTagLookupTable({
3322    0: ProtocolBuffer.Encoder.NUMERIC,
3323    1: ProtocolBuffer.Encoder.STRING,
3324    2: ProtocolBuffer.Encoder.STRING,
3325    3: ProtocolBuffer.Encoder.STRING,
3326    4: ProtocolBuffer.Encoder.STRING,
3327    5: ProtocolBuffer.Encoder.STRING,
3328    6: ProtocolBuffer.Encoder.NUMERIC,
3329  }, 6, ProtocolBuffer.Encoder.MAX_TYPE)
3330
3331  # stylesheet for XML output
3332  _STYLE = \
3333   """"""
3334  _STYLE_CONTENT_TYPE = \
3335   """"""
3336  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.DeprecatedMutation'
3337class DeprecatedMutationResult(ProtocolBuffer.ProtocolMessage):
3338  has_index_updates_ = 0
3339  index_updates_ = 0
3340
3341  def __init__(self, contents=None):
3342    self.insert_auto_id_key_ = []
3343    self.upsert_version_ = []
3344    self.update_version_ = []
3345    self.insert_version_ = []
3346    self.insert_auto_id_version_ = []
3347    self.delete_version_ = []
3348    if contents is not None: self.MergeFromString(contents)
3349
3350  def index_updates(self): return self.index_updates_
3351
3352  def set_index_updates(self, x):
3353    self.has_index_updates_ = 1
3354    self.index_updates_ = x
3355
3356  def clear_index_updates(self):
3357    if self.has_index_updates_:
3358      self.has_index_updates_ = 0
3359      self.index_updates_ = 0
3360
3361  def has_index_updates(self): return self.has_index_updates_
3362
3363  def insert_auto_id_key_size(self): return len(self.insert_auto_id_key_)
3364  def insert_auto_id_key_list(self): return self.insert_auto_id_key_
3365
3366  def insert_auto_id_key(self, i):
3367    return self.insert_auto_id_key_[i]
3368
3369  def mutable_insert_auto_id_key(self, i):
3370    return self.insert_auto_id_key_[i]
3371
3372  def add_insert_auto_id_key(self):
3373    x = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Key()
3374    self.insert_auto_id_key_.append(x)
3375    return x
3376
3377  def clear_insert_auto_id_key(self):
3378    self.insert_auto_id_key_ = []
3379  def upsert_version_size(self): return len(self.upsert_version_)
3380  def upsert_version_list(self): return self.upsert_version_
3381
3382  def upsert_version(self, i):
3383    return self.upsert_version_[i]
3384
3385  def set_upsert_version(self, i, x):
3386    self.upsert_version_[i] = x
3387
3388  def add_upsert_version(self, x):
3389    self.upsert_version_.append(x)
3390
3391  def clear_upsert_version(self):
3392    self.upsert_version_ = []
3393
3394  def update_version_size(self): return len(self.update_version_)
3395  def update_version_list(self): return self.update_version_
3396
3397  def update_version(self, i):
3398    return self.update_version_[i]
3399
3400  def set_update_version(self, i, x):
3401    self.update_version_[i] = x
3402
3403  def add_update_version(self, x):
3404    self.update_version_.append(x)
3405
3406  def clear_update_version(self):
3407    self.update_version_ = []
3408
3409  def insert_version_size(self): return len(self.insert_version_)
3410  def insert_version_list(self): return self.insert_version_
3411
3412  def insert_version(self, i):
3413    return self.insert_version_[i]
3414
3415  def set_insert_version(self, i, x):
3416    self.insert_version_[i] = x
3417
3418  def add_insert_version(self, x):
3419    self.insert_version_.append(x)
3420
3421  def clear_insert_version(self):
3422    self.insert_version_ = []
3423
3424  def insert_auto_id_version_size(self): return len(self.insert_auto_id_version_)
3425  def insert_auto_id_version_list(self): return self.insert_auto_id_version_
3426
3427  def insert_auto_id_version(self, i):
3428    return self.insert_auto_id_version_[i]
3429
3430  def set_insert_auto_id_version(self, i, x):
3431    self.insert_auto_id_version_[i] = x
3432
3433  def add_insert_auto_id_version(self, x):
3434    self.insert_auto_id_version_.append(x)
3435
3436  def clear_insert_auto_id_version(self):
3437    self.insert_auto_id_version_ = []
3438
3439  def delete_version_size(self): return len(self.delete_version_)
3440  def delete_version_list(self): return self.delete_version_
3441
3442  def delete_version(self, i):
3443    return self.delete_version_[i]
3444
3445  def set_delete_version(self, i, x):
3446    self.delete_version_[i] = x
3447
3448  def add_delete_version(self, x):
3449    self.delete_version_.append(x)
3450
3451  def clear_delete_version(self):
3452    self.delete_version_ = []
3453
3454
3455  def MergeFrom(self, x):
3456    assert x is not self
3457    if (x.has_index_updates()): self.set_index_updates(x.index_updates())
3458    for i in range(x.insert_auto_id_key_size()): self.add_insert_auto_id_key().CopyFrom(x.insert_auto_id_key(i))
3459    for i in range(x.upsert_version_size()): self.add_upsert_version(x.upsert_version(i))
3460    for i in range(x.update_version_size()): self.add_update_version(x.update_version(i))
3461    for i in range(x.insert_version_size()): self.add_insert_version(x.insert_version(i))
3462    for i in range(x.insert_auto_id_version_size()): self.add_insert_auto_id_version(x.insert_auto_id_version(i))
3463    for i in range(x.delete_version_size()): self.add_delete_version(x.delete_version(i))
3464
3465  def Equals(self, x):
3466    if x is self: return 1
3467    if self.has_index_updates_ != x.has_index_updates_: return 0
3468    if self.has_index_updates_ and self.index_updates_ != x.index_updates_: return 0
3469    if len(self.insert_auto_id_key_) != len(x.insert_auto_id_key_): return 0
3470    for e1, e2 in zip(self.insert_auto_id_key_, x.insert_auto_id_key_):
3471      if e1 != e2: return 0
3472    if len(self.upsert_version_) != len(x.upsert_version_): return 0
3473    for e1, e2 in zip(self.upsert_version_, x.upsert_version_):
3474      if e1 != e2: return 0
3475    if len(self.update_version_) != len(x.update_version_): return 0
3476    for e1, e2 in zip(self.update_version_, x.update_version_):
3477      if e1 != e2: return 0
3478    if len(self.insert_version_) != len(x.insert_version_): return 0
3479    for e1, e2 in zip(self.insert_version_, x.insert_version_):
3480      if e1 != e2: return 0
3481    if len(self.insert_auto_id_version_) != len(x.insert_auto_id_version_): return 0
3482    for e1, e2 in zip(self.insert_auto_id_version_, x.insert_auto_id_version_):
3483      if e1 != e2: return 0
3484    if len(self.delete_version_) != len(x.delete_version_): return 0
3485    for e1, e2 in zip(self.delete_version_, x.delete_version_):
3486      if e1 != e2: return 0
3487    return 1
3488
3489  def IsInitialized(self, debug_strs=None):
3490    initialized = 1
3491    if (not self.has_index_updates_):
3492      initialized = 0
3493      if debug_strs is not None:
3494        debug_strs.append('Required field: index_updates not set.')
3495    for p in self.insert_auto_id_key_:
3496      if not p.IsInitialized(debug_strs): initialized=0
3497    return initialized
3498
3499  def ByteSize(self):
3500    n = 0
3501    n += self.lengthVarInt64(self.index_updates_)
3502    n += 1 * len(self.insert_auto_id_key_)
3503    for i in range(len(self.insert_auto_id_key_)): n += self.lengthString(self.insert_auto_id_key_[i].ByteSize())
3504    n += 1 * len(self.upsert_version_)
3505    for i in range(len(self.upsert_version_)): n += self.lengthVarInt64(self.upsert_version_[i])
3506    n += 1 * len(self.update_version_)
3507    for i in range(len(self.update_version_)): n += self.lengthVarInt64(self.update_version_[i])
3508    n += 1 * len(self.insert_version_)
3509    for i in range(len(self.insert_version_)): n += self.lengthVarInt64(self.insert_version_[i])
3510    n += 1 * len(self.insert_auto_id_version_)
3511    for i in range(len(self.insert_auto_id_version_)): n += self.lengthVarInt64(self.insert_auto_id_version_[i])
3512    n += 1 * len(self.delete_version_)
3513    for i in range(len(self.delete_version_)): n += self.lengthVarInt64(self.delete_version_[i])
3514    return n + 1
3515
3516  def ByteSizePartial(self):
3517    n = 0
3518    if (self.has_index_updates_):
3519      n += 1
3520      n += self.lengthVarInt64(self.index_updates_)
3521    n += 1 * len(self.insert_auto_id_key_)
3522    for i in range(len(self.insert_auto_id_key_)): n += self.lengthString(self.insert_auto_id_key_[i].ByteSizePartial())
3523    n += 1 * len(self.upsert_version_)
3524    for i in range(len(self.upsert_version_)): n += self.lengthVarInt64(self.upsert_version_[i])
3525    n += 1 * len(self.update_version_)
3526    for i in range(len(self.update_version_)): n += self.lengthVarInt64(self.update_version_[i])
3527    n += 1 * len(self.insert_version_)
3528    for i in range(len(self.insert_version_)): n += self.lengthVarInt64(self.insert_version_[i])
3529    n += 1 * len(self.insert_auto_id_version_)
3530    for i in range(len(self.insert_auto_id_version_)): n += self.lengthVarInt64(self.insert_auto_id_version_[i])
3531    n += 1 * len(self.delete_version_)
3532    for i in range(len(self.delete_version_)): n += self.lengthVarInt64(self.delete_version_[i])
3533    return n
3534
3535  def Clear(self):
3536    self.clear_index_updates()
3537    self.clear_insert_auto_id_key()
3538    self.clear_upsert_version()
3539    self.clear_update_version()
3540    self.clear_insert_version()
3541    self.clear_insert_auto_id_version()
3542    self.clear_delete_version()
3543
3544  def OutputUnchecked(self, out):
3545    out.putVarInt32(8)
3546    out.putVarInt32(self.index_updates_)
3547    for i in range(len(self.insert_auto_id_key_)):
3548      out.putVarInt32(18)
3549      out.putVarInt32(self.insert_auto_id_key_[i].ByteSize())
3550      self.insert_auto_id_key_[i].OutputUnchecked(out)
3551    for i in range(len(self.upsert_version_)):
3552      out.putVarInt32(24)
3553      out.putVarInt64(self.upsert_version_[i])
3554    for i in range(len(self.update_version_)):
3555      out.putVarInt32(32)
3556      out.putVarInt64(self.update_version_[i])
3557    for i in range(len(self.insert_version_)):
3558      out.putVarInt32(40)
3559      out.putVarInt64(self.insert_version_[i])
3560    for i in range(len(self.insert_auto_id_version_)):
3561      out.putVarInt32(48)
3562      out.putVarInt64(self.insert_auto_id_version_[i])
3563    for i in range(len(self.delete_version_)):
3564      out.putVarInt32(56)
3565      out.putVarInt64(self.delete_version_[i])
3566
3567  def OutputPartial(self, out):
3568    if (self.has_index_updates_):
3569      out.putVarInt32(8)
3570      out.putVarInt32(self.index_updates_)
3571    for i in range(len(self.insert_auto_id_key_)):
3572      out.putVarInt32(18)
3573      out.putVarInt32(self.insert_auto_id_key_[i].ByteSizePartial())
3574      self.insert_auto_id_key_[i].OutputPartial(out)
3575    for i in range(len(self.upsert_version_)):
3576      out.putVarInt32(24)
3577      out.putVarInt64(self.upsert_version_[i])
3578    for i in range(len(self.update_version_)):
3579      out.putVarInt32(32)
3580      out.putVarInt64(self.update_version_[i])
3581    for i in range(len(self.insert_version_)):
3582      out.putVarInt32(40)
3583      out.putVarInt64(self.insert_version_[i])
3584    for i in range(len(self.insert_auto_id_version_)):
3585      out.putVarInt32(48)
3586      out.putVarInt64(self.insert_auto_id_version_[i])
3587    for i in range(len(self.delete_version_)):
3588      out.putVarInt32(56)
3589      out.putVarInt64(self.delete_version_[i])
3590
3591  def TryMerge(self, d):
3592    while d.avail() > 0:
3593      tt = d.getVarInt32()
3594      if tt == 8:
3595        self.set_index_updates(d.getVarInt32())
3596        continue
3597      if tt == 18:
3598        length = d.getVarInt32()
3599        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
3600        d.skip(length)
3601        self.add_insert_auto_id_key().TryMerge(tmp)
3602        continue
3603      if tt == 24:
3604        self.add_upsert_version(d.getVarInt64())
3605        continue
3606      if tt == 32:
3607        self.add_update_version(d.getVarInt64())
3608        continue
3609      if tt == 40:
3610        self.add_insert_version(d.getVarInt64())
3611        continue
3612      if tt == 48:
3613        self.add_insert_auto_id_version(d.getVarInt64())
3614        continue
3615      if tt == 56:
3616        self.add_delete_version(d.getVarInt64())
3617        continue
3618      # tag 0 is special: it's used to indicate an error.
3619      # so if we see it we raise an exception.
3620      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
3621      d.skipData(tt)
3622
3623
3624  def __str__(self, prefix="", printElemNumber=0):
3625    res=""
3626    if self.has_index_updates_: res+=prefix+("index_updates: %s\n" % self.DebugFormatInt32(self.index_updates_))
3627    cnt=0
3628    for e in self.insert_auto_id_key_:
3629      elm=""
3630      if printElemNumber: elm="(%d)" % cnt
3631      res+=prefix+("insert_auto_id_key%s <\n" % elm)
3632      res+=e.__str__(prefix + "  ", printElemNumber)
3633      res+=prefix+">\n"
3634      cnt+=1
3635    cnt=0
3636    for e in self.upsert_version_:
3637      elm=""
3638      if printElemNumber: elm="(%d)" % cnt
3639      res+=prefix+("upsert_version%s: %s\n" % (elm, self.DebugFormatInt64(e)))
3640      cnt+=1
3641    cnt=0
3642    for e in self.update_version_:
3643      elm=""
3644      if printElemNumber: elm="(%d)" % cnt
3645      res+=prefix+("update_version%s: %s\n" % (elm, self.DebugFormatInt64(e)))
3646      cnt+=1
3647    cnt=0
3648    for e in self.insert_version_:
3649      elm=""
3650      if printElemNumber: elm="(%d)" % cnt
3651      res+=prefix+("insert_version%s: %s\n" % (elm, self.DebugFormatInt64(e)))
3652      cnt+=1
3653    cnt=0
3654    for e in self.insert_auto_id_version_:
3655      elm=""
3656      if printElemNumber: elm="(%d)" % cnt
3657      res+=prefix+("insert_auto_id_version%s: %s\n" % (elm, self.DebugFormatInt64(e)))
3658      cnt+=1
3659    cnt=0
3660    for e in self.delete_version_:
3661      elm=""
3662      if printElemNumber: elm="(%d)" % cnt
3663      res+=prefix+("delete_version%s: %s\n" % (elm, self.DebugFormatInt64(e)))
3664      cnt+=1
3665    return res
3666
3667
3668  def _BuildTagLookupTable(sparse, maxtag, default=None):
3669    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
3670
3671  kindex_updates = 1
3672  kinsert_auto_id_key = 2
3673  kupsert_version = 3
3674  kupdate_version = 4
3675  kinsert_version = 5
3676  kinsert_auto_id_version = 6
3677  kdelete_version = 7
3678
3679  _TEXT = _BuildTagLookupTable({
3680    0: "ErrorCode",
3681    1: "index_updates",
3682    2: "insert_auto_id_key",
3683    3: "upsert_version",
3684    4: "update_version",
3685    5: "insert_version",
3686    6: "insert_auto_id_version",
3687    7: "delete_version",
3688  }, 7)
3689
3690  _TYPES = _BuildTagLookupTable({
3691    0: ProtocolBuffer.Encoder.NUMERIC,
3692    1: ProtocolBuffer.Encoder.NUMERIC,
3693    2: ProtocolBuffer.Encoder.STRING,
3694    3: ProtocolBuffer.Encoder.NUMERIC,
3695    4: ProtocolBuffer.Encoder.NUMERIC,
3696    5: ProtocolBuffer.Encoder.NUMERIC,
3697    6: ProtocolBuffer.Encoder.NUMERIC,
3698    7: ProtocolBuffer.Encoder.NUMERIC,
3699  }, 7, ProtocolBuffer.Encoder.MAX_TYPE)
3700
3701  # stylesheet for XML output
3702  _STYLE = \
3703   """"""
3704  _STYLE_CONTENT_TYPE = \
3705   """"""
3706  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.DeprecatedMutationResult'
3707class ReadOptions(ProtocolBuffer.ProtocolMessage):
3708
3709  # ReadConsistency values
3710  DEFAULT      =    0
3711  STRONG       =    1
3712  EVENTUAL     =    2
3713
3714  _ReadConsistency_NAMES = {
3715    0: "DEFAULT",
3716    1: "STRONG",
3717    2: "EVENTUAL",
3718  }
3719
3720  def ReadConsistency_Name(cls, x): return cls._ReadConsistency_NAMES.get(x, "")
3721  ReadConsistency_Name = classmethod(ReadConsistency_Name)
3722
3723  has_read_consistency_ = 0
3724  read_consistency_ = 0
3725  has_transaction_ = 0
3726  transaction_ = ""
3727
3728  def __init__(self, contents=None):
3729    if contents is not None: self.MergeFromString(contents)
3730
3731  def read_consistency(self): return self.read_consistency_
3732
3733  def set_read_consistency(self, x):
3734    self.has_read_consistency_ = 1
3735    self.read_consistency_ = x
3736
3737  def clear_read_consistency(self):
3738    if self.has_read_consistency_:
3739      self.has_read_consistency_ = 0
3740      self.read_consistency_ = 0
3741
3742  def has_read_consistency(self): return self.has_read_consistency_
3743
3744  def transaction(self): return self.transaction_
3745
3746  def set_transaction(self, x):
3747    self.has_transaction_ = 1
3748    self.transaction_ = x
3749
3750  def clear_transaction(self):
3751    if self.has_transaction_:
3752      self.has_transaction_ = 0
3753      self.transaction_ = ""
3754
3755  def has_transaction(self): return self.has_transaction_
3756
3757
3758  def MergeFrom(self, x):
3759    assert x is not self
3760    if (x.has_read_consistency()): self.set_read_consistency(x.read_consistency())
3761    if (x.has_transaction()): self.set_transaction(x.transaction())
3762
3763  def Equals(self, x):
3764    if x is self: return 1
3765    if self.has_read_consistency_ != x.has_read_consistency_: return 0
3766    if self.has_read_consistency_ and self.read_consistency_ != x.read_consistency_: return 0
3767    if self.has_transaction_ != x.has_transaction_: return 0
3768    if self.has_transaction_ and self.transaction_ != x.transaction_: return 0
3769    return 1
3770
3771  def IsInitialized(self, debug_strs=None):
3772    initialized = 1
3773    return initialized
3774
3775  def ByteSize(self):
3776    n = 0
3777    if (self.has_read_consistency_): n += 1 + self.lengthVarInt64(self.read_consistency_)
3778    if (self.has_transaction_): n += 1 + self.lengthString(len(self.transaction_))
3779    return n
3780
3781  def ByteSizePartial(self):
3782    n = 0
3783    if (self.has_read_consistency_): n += 1 + self.lengthVarInt64(self.read_consistency_)
3784    if (self.has_transaction_): n += 1 + self.lengthString(len(self.transaction_))
3785    return n
3786
3787  def Clear(self):
3788    self.clear_read_consistency()
3789    self.clear_transaction()
3790
3791  def OutputUnchecked(self, out):
3792    if (self.has_read_consistency_):
3793      out.putVarInt32(8)
3794      out.putVarInt32(self.read_consistency_)
3795    if (self.has_transaction_):
3796      out.putVarInt32(18)
3797      out.putPrefixedString(self.transaction_)
3798
3799  def OutputPartial(self, out):
3800    if (self.has_read_consistency_):
3801      out.putVarInt32(8)
3802      out.putVarInt32(self.read_consistency_)
3803    if (self.has_transaction_):
3804      out.putVarInt32(18)
3805      out.putPrefixedString(self.transaction_)
3806
3807  def TryMerge(self, d):
3808    while d.avail() > 0:
3809      tt = d.getVarInt32()
3810      if tt == 8:
3811        self.set_read_consistency(d.getVarInt32())
3812        continue
3813      if tt == 18:
3814        self.set_transaction(d.getPrefixedString())
3815        continue
3816      # tag 0 is special: it's used to indicate an error.
3817      # so if we see it we raise an exception.
3818      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
3819      d.skipData(tt)
3820
3821
3822  def __str__(self, prefix="", printElemNumber=0):
3823    res=""
3824    if self.has_read_consistency_: res+=prefix+("read_consistency: %s\n" % self.DebugFormatInt32(self.read_consistency_))
3825    if self.has_transaction_: res+=prefix+("transaction: %s\n" % self.DebugFormatString(self.transaction_))
3826    return res
3827
3828
3829  def _BuildTagLookupTable(sparse, maxtag, default=None):
3830    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
3831
3832  kread_consistency = 1
3833  ktransaction = 2
3834
3835  _TEXT = _BuildTagLookupTable({
3836    0: "ErrorCode",
3837    1: "read_consistency",
3838    2: "transaction",
3839  }, 2)
3840
3841  _TYPES = _BuildTagLookupTable({
3842    0: ProtocolBuffer.Encoder.NUMERIC,
3843    1: ProtocolBuffer.Encoder.NUMERIC,
3844    2: ProtocolBuffer.Encoder.STRING,
3845  }, 2, ProtocolBuffer.Encoder.MAX_TYPE)
3846
3847  # stylesheet for XML output
3848  _STYLE = \
3849   """"""
3850  _STYLE_CONTENT_TYPE = \
3851   """"""
3852  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.ReadOptions'
3853class LookupRequest(ProtocolBuffer.ProtocolMessage):
3854  has_read_options_ = 0
3855  read_options_ = None
3856
3857  def __init__(self, contents=None):
3858    self.key_ = []
3859    self.lazy_init_lock_ = _Lock()
3860    if contents is not None: self.MergeFromString(contents)
3861
3862  def read_options(self):
3863    if self.read_options_ is None:
3864      self.lazy_init_lock_.acquire()
3865      try:
3866        if self.read_options_ is None: self.read_options_ = ReadOptions()
3867      finally:
3868        self.lazy_init_lock_.release()
3869    return self.read_options_
3870
3871  def mutable_read_options(self): self.has_read_options_ = 1; return self.read_options()
3872
3873  def clear_read_options(self):
3874    # Warning: this method does not acquire the lock.
3875    if self.has_read_options_:
3876      self.has_read_options_ = 0;
3877      if self.read_options_ is not None: self.read_options_.Clear()
3878
3879  def has_read_options(self): return self.has_read_options_
3880
3881  def key_size(self): return len(self.key_)
3882  def key_list(self): return self.key_
3883
3884  def key(self, i):
3885    return self.key_[i]
3886
3887  def mutable_key(self, i):
3888    return self.key_[i]
3889
3890  def add_key(self):
3891    x = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Key()
3892    self.key_.append(x)
3893    return x
3894
3895  def clear_key(self):
3896    self.key_ = []
3897
3898  def MergeFrom(self, x):
3899    assert x is not self
3900    if (x.has_read_options()): self.mutable_read_options().MergeFrom(x.read_options())
3901    for i in range(x.key_size()): self.add_key().CopyFrom(x.key(i))
3902
3903  def Equals(self, x):
3904    if x is self: return 1
3905    if self.has_read_options_ != x.has_read_options_: return 0
3906    if self.has_read_options_ and self.read_options_ != x.read_options_: return 0
3907    if len(self.key_) != len(x.key_): return 0
3908    for e1, e2 in zip(self.key_, x.key_):
3909      if e1 != e2: return 0
3910    return 1
3911
3912  def IsInitialized(self, debug_strs=None):
3913    initialized = 1
3914    if (self.has_read_options_ and not self.read_options_.IsInitialized(debug_strs)): initialized = 0
3915    for p in self.key_:
3916      if not p.IsInitialized(debug_strs): initialized=0
3917    return initialized
3918
3919  def ByteSize(self):
3920    n = 0
3921    if (self.has_read_options_): n += 1 + self.lengthString(self.read_options_.ByteSize())
3922    n += 1 * len(self.key_)
3923    for i in range(len(self.key_)): n += self.lengthString(self.key_[i].ByteSize())
3924    return n
3925
3926  def ByteSizePartial(self):
3927    n = 0
3928    if (self.has_read_options_): n += 1 + self.lengthString(self.read_options_.ByteSizePartial())
3929    n += 1 * len(self.key_)
3930    for i in range(len(self.key_)): n += self.lengthString(self.key_[i].ByteSizePartial())
3931    return n
3932
3933  def Clear(self):
3934    self.clear_read_options()
3935    self.clear_key()
3936
3937  def OutputUnchecked(self, out):
3938    if (self.has_read_options_):
3939      out.putVarInt32(10)
3940      out.putVarInt32(self.read_options_.ByteSize())
3941      self.read_options_.OutputUnchecked(out)
3942    for i in range(len(self.key_)):
3943      out.putVarInt32(26)
3944      out.putVarInt32(self.key_[i].ByteSize())
3945      self.key_[i].OutputUnchecked(out)
3946
3947  def OutputPartial(self, out):
3948    if (self.has_read_options_):
3949      out.putVarInt32(10)
3950      out.putVarInt32(self.read_options_.ByteSizePartial())
3951      self.read_options_.OutputPartial(out)
3952    for i in range(len(self.key_)):
3953      out.putVarInt32(26)
3954      out.putVarInt32(self.key_[i].ByteSizePartial())
3955      self.key_[i].OutputPartial(out)
3956
3957  def TryMerge(self, d):
3958    while d.avail() > 0:
3959      tt = d.getVarInt32()
3960      if tt == 10:
3961        length = d.getVarInt32()
3962        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
3963        d.skip(length)
3964        self.mutable_read_options().TryMerge(tmp)
3965        continue
3966      if tt == 26:
3967        length = d.getVarInt32()
3968        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
3969        d.skip(length)
3970        self.add_key().TryMerge(tmp)
3971        continue
3972      # tag 0 is special: it's used to indicate an error.
3973      # so if we see it we raise an exception.
3974      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
3975      d.skipData(tt)
3976
3977
3978  def __str__(self, prefix="", printElemNumber=0):
3979    res=""
3980    if self.has_read_options_:
3981      res+=prefix+"read_options <\n"
3982      res+=self.read_options_.__str__(prefix + "  ", printElemNumber)
3983      res+=prefix+">\n"
3984    cnt=0
3985    for e in self.key_:
3986      elm=""
3987      if printElemNumber: elm="(%d)" % cnt
3988      res+=prefix+("key%s <\n" % elm)
3989      res+=e.__str__(prefix + "  ", printElemNumber)
3990      res+=prefix+">\n"
3991      cnt+=1
3992    return res
3993
3994
3995  def _BuildTagLookupTable(sparse, maxtag, default=None):
3996    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
3997
3998  kread_options = 1
3999  kkey = 3
4000
4001  _TEXT = _BuildTagLookupTable({
4002    0: "ErrorCode",
4003    1: "read_options",
4004    3: "key",
4005  }, 3)
4006
4007  _TYPES = _BuildTagLookupTable({
4008    0: ProtocolBuffer.Encoder.NUMERIC,
4009    1: ProtocolBuffer.Encoder.STRING,
4010    3: ProtocolBuffer.Encoder.STRING,
4011  }, 3, ProtocolBuffer.Encoder.MAX_TYPE)
4012
4013  # stylesheet for XML output
4014  _STYLE = \
4015   """"""
4016  _STYLE_CONTENT_TYPE = \
4017   """"""
4018  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.LookupRequest'
4019class LookupResponse(ProtocolBuffer.ProtocolMessage):
4020
4021  def __init__(self, contents=None):
4022    self.found_ = []
4023    self.missing_ = []
4024    self.deferred_ = []
4025    if contents is not None: self.MergeFromString(contents)
4026
4027  def found_size(self): return len(self.found_)
4028  def found_list(self): return self.found_
4029
4030  def found(self, i):
4031    return self.found_[i]
4032
4033  def mutable_found(self, i):
4034    return self.found_[i]
4035
4036  def add_found(self):
4037    x = EntityResult()
4038    self.found_.append(x)
4039    return x
4040
4041  def clear_found(self):
4042    self.found_ = []
4043  def missing_size(self): return len(self.missing_)
4044  def missing_list(self): return self.missing_
4045
4046  def missing(self, i):
4047    return self.missing_[i]
4048
4049  def mutable_missing(self, i):
4050    return self.missing_[i]
4051
4052  def add_missing(self):
4053    x = EntityResult()
4054    self.missing_.append(x)
4055    return x
4056
4057  def clear_missing(self):
4058    self.missing_ = []
4059  def deferred_size(self): return len(self.deferred_)
4060  def deferred_list(self): return self.deferred_
4061
4062  def deferred(self, i):
4063    return self.deferred_[i]
4064
4065  def mutable_deferred(self, i):
4066    return self.deferred_[i]
4067
4068  def add_deferred(self):
4069    x = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Key()
4070    self.deferred_.append(x)
4071    return x
4072
4073  def clear_deferred(self):
4074    self.deferred_ = []
4075
4076  def MergeFrom(self, x):
4077    assert x is not self
4078    for i in range(x.found_size()): self.add_found().CopyFrom(x.found(i))
4079    for i in range(x.missing_size()): self.add_missing().CopyFrom(x.missing(i))
4080    for i in range(x.deferred_size()): self.add_deferred().CopyFrom(x.deferred(i))
4081
4082  def Equals(self, x):
4083    if x is self: return 1
4084    if len(self.found_) != len(x.found_): return 0
4085    for e1, e2 in zip(self.found_, x.found_):
4086      if e1 != e2: return 0
4087    if len(self.missing_) != len(x.missing_): return 0
4088    for e1, e2 in zip(self.missing_, x.missing_):
4089      if e1 != e2: return 0
4090    if len(self.deferred_) != len(x.deferred_): return 0
4091    for e1, e2 in zip(self.deferred_, x.deferred_):
4092      if e1 != e2: return 0
4093    return 1
4094
4095  def IsInitialized(self, debug_strs=None):
4096    initialized = 1
4097    for p in self.found_:
4098      if not p.IsInitialized(debug_strs): initialized=0
4099    for p in self.missing_:
4100      if not p.IsInitialized(debug_strs): initialized=0
4101    for p in self.deferred_:
4102      if not p.IsInitialized(debug_strs): initialized=0
4103    return initialized
4104
4105  def ByteSize(self):
4106    n = 0
4107    n += 1 * len(self.found_)
4108    for i in range(len(self.found_)): n += self.lengthString(self.found_[i].ByteSize())
4109    n += 1 * len(self.missing_)
4110    for i in range(len(self.missing_)): n += self.lengthString(self.missing_[i].ByteSize())
4111    n += 1 * len(self.deferred_)
4112    for i in range(len(self.deferred_)): n += self.lengthString(self.deferred_[i].ByteSize())
4113    return n
4114
4115  def ByteSizePartial(self):
4116    n = 0
4117    n += 1 * len(self.found_)
4118    for i in range(len(self.found_)): n += self.lengthString(self.found_[i].ByteSizePartial())
4119    n += 1 * len(self.missing_)
4120    for i in range(len(self.missing_)): n += self.lengthString(self.missing_[i].ByteSizePartial())
4121    n += 1 * len(self.deferred_)
4122    for i in range(len(self.deferred_)): n += self.lengthString(self.deferred_[i].ByteSizePartial())
4123    return n
4124
4125  def Clear(self):
4126    self.clear_found()
4127    self.clear_missing()
4128    self.clear_deferred()
4129
4130  def OutputUnchecked(self, out):
4131    for i in range(len(self.found_)):
4132      out.putVarInt32(10)
4133      out.putVarInt32(self.found_[i].ByteSize())
4134      self.found_[i].OutputUnchecked(out)
4135    for i in range(len(self.missing_)):
4136      out.putVarInt32(18)
4137      out.putVarInt32(self.missing_[i].ByteSize())
4138      self.missing_[i].OutputUnchecked(out)
4139    for i in range(len(self.deferred_)):
4140      out.putVarInt32(26)
4141      out.putVarInt32(self.deferred_[i].ByteSize())
4142      self.deferred_[i].OutputUnchecked(out)
4143
4144  def OutputPartial(self, out):
4145    for i in range(len(self.found_)):
4146      out.putVarInt32(10)
4147      out.putVarInt32(self.found_[i].ByteSizePartial())
4148      self.found_[i].OutputPartial(out)
4149    for i in range(len(self.missing_)):
4150      out.putVarInt32(18)
4151      out.putVarInt32(self.missing_[i].ByteSizePartial())
4152      self.missing_[i].OutputPartial(out)
4153    for i in range(len(self.deferred_)):
4154      out.putVarInt32(26)
4155      out.putVarInt32(self.deferred_[i].ByteSizePartial())
4156      self.deferred_[i].OutputPartial(out)
4157
4158  def TryMerge(self, d):
4159    while d.avail() > 0:
4160      tt = d.getVarInt32()
4161      if tt == 10:
4162        length = d.getVarInt32()
4163        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
4164        d.skip(length)
4165        self.add_found().TryMerge(tmp)
4166        continue
4167      if tt == 18:
4168        length = d.getVarInt32()
4169        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
4170        d.skip(length)
4171        self.add_missing().TryMerge(tmp)
4172        continue
4173      if tt == 26:
4174        length = d.getVarInt32()
4175        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
4176        d.skip(length)
4177        self.add_deferred().TryMerge(tmp)
4178        continue
4179      # tag 0 is special: it's used to indicate an error.
4180      # so if we see it we raise an exception.
4181      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
4182      d.skipData(tt)
4183
4184
4185  def __str__(self, prefix="", printElemNumber=0):
4186    res=""
4187    cnt=0
4188    for e in self.found_:
4189      elm=""
4190      if printElemNumber: elm="(%d)" % cnt
4191      res+=prefix+("found%s <\n" % elm)
4192      res+=e.__str__(prefix + "  ", printElemNumber)
4193      res+=prefix+">\n"
4194      cnt+=1
4195    cnt=0
4196    for e in self.missing_:
4197      elm=""
4198      if printElemNumber: elm="(%d)" % cnt
4199      res+=prefix+("missing%s <\n" % elm)
4200      res+=e.__str__(prefix + "  ", printElemNumber)
4201      res+=prefix+">\n"
4202      cnt+=1
4203    cnt=0
4204    for e in self.deferred_:
4205      elm=""
4206      if printElemNumber: elm="(%d)" % cnt
4207      res+=prefix+("deferred%s <\n" % elm)
4208      res+=e.__str__(prefix + "  ", printElemNumber)
4209      res+=prefix+">\n"
4210      cnt+=1
4211    return res
4212
4213
4214  def _BuildTagLookupTable(sparse, maxtag, default=None):
4215    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
4216
4217  kfound = 1
4218  kmissing = 2
4219  kdeferred = 3
4220
4221  _TEXT = _BuildTagLookupTable({
4222    0: "ErrorCode",
4223    1: "found",
4224    2: "missing",
4225    3: "deferred",
4226  }, 3)
4227
4228  _TYPES = _BuildTagLookupTable({
4229    0: ProtocolBuffer.Encoder.NUMERIC,
4230    1: ProtocolBuffer.Encoder.STRING,
4231    2: ProtocolBuffer.Encoder.STRING,
4232    3: ProtocolBuffer.Encoder.STRING,
4233  }, 3, ProtocolBuffer.Encoder.MAX_TYPE)
4234
4235  # stylesheet for XML output
4236  _STYLE = \
4237   """"""
4238  _STYLE_CONTENT_TYPE = \
4239   """"""
4240  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.LookupResponse'
4241class RunQueryRequest(ProtocolBuffer.ProtocolMessage):
4242  has_read_options_ = 0
4243  read_options_ = None
4244  has_partition_id_ = 0
4245  partition_id_ = None
4246  has_query_ = 0
4247  query_ = None
4248  has_gql_query_ = 0
4249  gql_query_ = None
4250  has_min_safe_time_seconds_ = 0
4251  min_safe_time_seconds_ = 0
4252  has_suggested_batch_size_ = 0
4253  suggested_batch_size_ = 0
4254
4255  def __init__(self, contents=None):
4256    self.lazy_init_lock_ = _Lock()
4257    if contents is not None: self.MergeFromString(contents)
4258
4259  def read_options(self):
4260    if self.read_options_ is None:
4261      self.lazy_init_lock_.acquire()
4262      try:
4263        if self.read_options_ is None: self.read_options_ = ReadOptions()
4264      finally:
4265        self.lazy_init_lock_.release()
4266    return self.read_options_
4267
4268  def mutable_read_options(self): self.has_read_options_ = 1; return self.read_options()
4269
4270  def clear_read_options(self):
4271    # Warning: this method does not acquire the lock.
4272    if self.has_read_options_:
4273      self.has_read_options_ = 0;
4274      if self.read_options_ is not None: self.read_options_.Clear()
4275
4276  def has_read_options(self): return self.has_read_options_
4277
4278  def partition_id(self):
4279    if self.partition_id_ is None:
4280      self.lazy_init_lock_.acquire()
4281      try:
4282        if self.partition_id_ is None: self.partition_id_ = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.PartitionId()
4283      finally:
4284        self.lazy_init_lock_.release()
4285    return self.partition_id_
4286
4287  def mutable_partition_id(self): self.has_partition_id_ = 1; return self.partition_id()
4288
4289  def clear_partition_id(self):
4290    # Warning: this method does not acquire the lock.
4291    if self.has_partition_id_:
4292      self.has_partition_id_ = 0;
4293      if self.partition_id_ is not None: self.partition_id_.Clear()
4294
4295  def has_partition_id(self): return self.has_partition_id_
4296
4297  def query(self):
4298    if self.query_ is None:
4299      self.lazy_init_lock_.acquire()
4300      try:
4301        if self.query_ is None: self.query_ = Query()
4302      finally:
4303        self.lazy_init_lock_.release()
4304    return self.query_
4305
4306  def mutable_query(self): self.has_query_ = 1; return self.query()
4307
4308  def clear_query(self):
4309    # Warning: this method does not acquire the lock.
4310    if self.has_query_:
4311      self.has_query_ = 0;
4312      if self.query_ is not None: self.query_.Clear()
4313
4314  def has_query(self): return self.has_query_
4315
4316  def gql_query(self):
4317    if self.gql_query_ is None:
4318      self.lazy_init_lock_.acquire()
4319      try:
4320        if self.gql_query_ is None: self.gql_query_ = GqlQuery()
4321      finally:
4322        self.lazy_init_lock_.release()
4323    return self.gql_query_
4324
4325  def mutable_gql_query(self): self.has_gql_query_ = 1; return self.gql_query()
4326
4327  def clear_gql_query(self):
4328    # Warning: this method does not acquire the lock.
4329    if self.has_gql_query_:
4330      self.has_gql_query_ = 0;
4331      if self.gql_query_ is not None: self.gql_query_.Clear()
4332
4333  def has_gql_query(self): return self.has_gql_query_
4334
4335  def min_safe_time_seconds(self): return self.min_safe_time_seconds_
4336
4337  def set_min_safe_time_seconds(self, x):
4338    self.has_min_safe_time_seconds_ = 1
4339    self.min_safe_time_seconds_ = x
4340
4341  def clear_min_safe_time_seconds(self):
4342    if self.has_min_safe_time_seconds_:
4343      self.has_min_safe_time_seconds_ = 0
4344      self.min_safe_time_seconds_ = 0
4345
4346  def has_min_safe_time_seconds(self): return self.has_min_safe_time_seconds_
4347
4348  def suggested_batch_size(self): return self.suggested_batch_size_
4349
4350  def set_suggested_batch_size(self, x):
4351    self.has_suggested_batch_size_ = 1
4352    self.suggested_batch_size_ = x
4353
4354  def clear_suggested_batch_size(self):
4355    if self.has_suggested_batch_size_:
4356      self.has_suggested_batch_size_ = 0
4357      self.suggested_batch_size_ = 0
4358
4359  def has_suggested_batch_size(self): return self.has_suggested_batch_size_
4360
4361
4362  def MergeFrom(self, x):
4363    assert x is not self
4364    if (x.has_read_options()): self.mutable_read_options().MergeFrom(x.read_options())
4365    if (x.has_partition_id()): self.mutable_partition_id().MergeFrom(x.partition_id())
4366    if (x.has_query()): self.mutable_query().MergeFrom(x.query())
4367    if (x.has_gql_query()): self.mutable_gql_query().MergeFrom(x.gql_query())
4368    if (x.has_min_safe_time_seconds()): self.set_min_safe_time_seconds(x.min_safe_time_seconds())
4369    if (x.has_suggested_batch_size()): self.set_suggested_batch_size(x.suggested_batch_size())
4370
4371  def Equals(self, x):
4372    if x is self: return 1
4373    if self.has_read_options_ != x.has_read_options_: return 0
4374    if self.has_read_options_ and self.read_options_ != x.read_options_: return 0
4375    if self.has_partition_id_ != x.has_partition_id_: return 0
4376    if self.has_partition_id_ and self.partition_id_ != x.partition_id_: return 0
4377    if self.has_query_ != x.has_query_: return 0
4378    if self.has_query_ and self.query_ != x.query_: return 0
4379    if self.has_gql_query_ != x.has_gql_query_: return 0
4380    if self.has_gql_query_ and self.gql_query_ != x.gql_query_: return 0
4381    if self.has_min_safe_time_seconds_ != x.has_min_safe_time_seconds_: return 0
4382    if self.has_min_safe_time_seconds_ and self.min_safe_time_seconds_ != x.min_safe_time_seconds_: return 0
4383    if self.has_suggested_batch_size_ != x.has_suggested_batch_size_: return 0
4384    if self.has_suggested_batch_size_ and self.suggested_batch_size_ != x.suggested_batch_size_: return 0
4385    return 1
4386
4387  def IsInitialized(self, debug_strs=None):
4388    initialized = 1
4389    if (self.has_read_options_ and not self.read_options_.IsInitialized(debug_strs)): initialized = 0
4390    if (self.has_partition_id_ and not self.partition_id_.IsInitialized(debug_strs)): initialized = 0
4391    if (self.has_query_ and not self.query_.IsInitialized(debug_strs)): initialized = 0
4392    if (self.has_gql_query_ and not self.gql_query_.IsInitialized(debug_strs)): initialized = 0
4393    return initialized
4394
4395  def ByteSize(self):
4396    n = 0
4397    if (self.has_read_options_): n += 1 + self.lengthString(self.read_options_.ByteSize())
4398    if (self.has_partition_id_): n += 1 + self.lengthString(self.partition_id_.ByteSize())
4399    if (self.has_query_): n += 1 + self.lengthString(self.query_.ByteSize())
4400    if (self.has_gql_query_): n += 1 + self.lengthString(self.gql_query_.ByteSize())
4401    if (self.has_min_safe_time_seconds_): n += 1 + self.lengthVarInt64(self.min_safe_time_seconds_)
4402    if (self.has_suggested_batch_size_): n += 1 + self.lengthVarInt64(self.suggested_batch_size_)
4403    return n
4404
4405  def ByteSizePartial(self):
4406    n = 0
4407    if (self.has_read_options_): n += 1 + self.lengthString(self.read_options_.ByteSizePartial())
4408    if (self.has_partition_id_): n += 1 + self.lengthString(self.partition_id_.ByteSizePartial())
4409    if (self.has_query_): n += 1 + self.lengthString(self.query_.ByteSizePartial())
4410    if (self.has_gql_query_): n += 1 + self.lengthString(self.gql_query_.ByteSizePartial())
4411    if (self.has_min_safe_time_seconds_): n += 1 + self.lengthVarInt64(self.min_safe_time_seconds_)
4412    if (self.has_suggested_batch_size_): n += 1 + self.lengthVarInt64(self.suggested_batch_size_)
4413    return n
4414
4415  def Clear(self):
4416    self.clear_read_options()
4417    self.clear_partition_id()
4418    self.clear_query()
4419    self.clear_gql_query()
4420    self.clear_min_safe_time_seconds()
4421    self.clear_suggested_batch_size()
4422
4423  def OutputUnchecked(self, out):
4424    if (self.has_read_options_):
4425      out.putVarInt32(10)
4426      out.putVarInt32(self.read_options_.ByteSize())
4427      self.read_options_.OutputUnchecked(out)
4428    if (self.has_partition_id_):
4429      out.putVarInt32(18)
4430      out.putVarInt32(self.partition_id_.ByteSize())
4431      self.partition_id_.OutputUnchecked(out)
4432    if (self.has_query_):
4433      out.putVarInt32(26)
4434      out.putVarInt32(self.query_.ByteSize())
4435      self.query_.OutputUnchecked(out)
4436    if (self.has_min_safe_time_seconds_):
4437      out.putVarInt32(32)
4438      out.putVarInt64(self.min_safe_time_seconds_)
4439    if (self.has_suggested_batch_size_):
4440      out.putVarInt32(40)
4441      out.putVarInt32(self.suggested_batch_size_)
4442    if (self.has_gql_query_):
4443      out.putVarInt32(58)
4444      out.putVarInt32(self.gql_query_.ByteSize())
4445      self.gql_query_.OutputUnchecked(out)
4446
4447  def OutputPartial(self, out):
4448    if (self.has_read_options_):
4449      out.putVarInt32(10)
4450      out.putVarInt32(self.read_options_.ByteSizePartial())
4451      self.read_options_.OutputPartial(out)
4452    if (self.has_partition_id_):
4453      out.putVarInt32(18)
4454      out.putVarInt32(self.partition_id_.ByteSizePartial())
4455      self.partition_id_.OutputPartial(out)
4456    if (self.has_query_):
4457      out.putVarInt32(26)
4458      out.putVarInt32(self.query_.ByteSizePartial())
4459      self.query_.OutputPartial(out)
4460    if (self.has_min_safe_time_seconds_):
4461      out.putVarInt32(32)
4462      out.putVarInt64(self.min_safe_time_seconds_)
4463    if (self.has_suggested_batch_size_):
4464      out.putVarInt32(40)
4465      out.putVarInt32(self.suggested_batch_size_)
4466    if (self.has_gql_query_):
4467      out.putVarInt32(58)
4468      out.putVarInt32(self.gql_query_.ByteSizePartial())
4469      self.gql_query_.OutputPartial(out)
4470
4471  def TryMerge(self, d):
4472    while d.avail() > 0:
4473      tt = d.getVarInt32()
4474      if tt == 10:
4475        length = d.getVarInt32()
4476        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
4477        d.skip(length)
4478        self.mutable_read_options().TryMerge(tmp)
4479        continue
4480      if tt == 18:
4481        length = d.getVarInt32()
4482        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
4483        d.skip(length)
4484        self.mutable_partition_id().TryMerge(tmp)
4485        continue
4486      if tt == 26:
4487        length = d.getVarInt32()
4488        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
4489        d.skip(length)
4490        self.mutable_query().TryMerge(tmp)
4491        continue
4492      if tt == 32:
4493        self.set_min_safe_time_seconds(d.getVarInt64())
4494        continue
4495      if tt == 40:
4496        self.set_suggested_batch_size(d.getVarInt32())
4497        continue
4498      if tt == 58:
4499        length = d.getVarInt32()
4500        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
4501        d.skip(length)
4502        self.mutable_gql_query().TryMerge(tmp)
4503        continue
4504      # tag 0 is special: it's used to indicate an error.
4505      # so if we see it we raise an exception.
4506      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
4507      d.skipData(tt)
4508
4509
4510  def __str__(self, prefix="", printElemNumber=0):
4511    res=""
4512    if self.has_read_options_:
4513      res+=prefix+"read_options <\n"
4514      res+=self.read_options_.__str__(prefix + "  ", printElemNumber)
4515      res+=prefix+">\n"
4516    if self.has_partition_id_:
4517      res+=prefix+"partition_id <\n"
4518      res+=self.partition_id_.__str__(prefix + "  ", printElemNumber)
4519      res+=prefix+">\n"
4520    if self.has_query_:
4521      res+=prefix+"query <\n"
4522      res+=self.query_.__str__(prefix + "  ", printElemNumber)
4523      res+=prefix+">\n"
4524    if self.has_gql_query_:
4525      res+=prefix+"gql_query <\n"
4526      res+=self.gql_query_.__str__(prefix + "  ", printElemNumber)
4527      res+=prefix+">\n"
4528    if self.has_min_safe_time_seconds_: res+=prefix+("min_safe_time_seconds: %s\n" % self.DebugFormatInt64(self.min_safe_time_seconds_))
4529    if self.has_suggested_batch_size_: res+=prefix+("suggested_batch_size: %s\n" % self.DebugFormatInt32(self.suggested_batch_size_))
4530    return res
4531
4532
4533  def _BuildTagLookupTable(sparse, maxtag, default=None):
4534    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
4535
4536  kread_options = 1
4537  kpartition_id = 2
4538  kquery = 3
4539  kgql_query = 7
4540  kmin_safe_time_seconds = 4
4541  ksuggested_batch_size = 5
4542
4543  _TEXT = _BuildTagLookupTable({
4544    0: "ErrorCode",
4545    1: "read_options",
4546    2: "partition_id",
4547    3: "query",
4548    4: "min_safe_time_seconds",
4549    5: "suggested_batch_size",
4550    7: "gql_query",
4551  }, 7)
4552
4553  _TYPES = _BuildTagLookupTable({
4554    0: ProtocolBuffer.Encoder.NUMERIC,
4555    1: ProtocolBuffer.Encoder.STRING,
4556    2: ProtocolBuffer.Encoder.STRING,
4557    3: ProtocolBuffer.Encoder.STRING,
4558    4: ProtocolBuffer.Encoder.NUMERIC,
4559    5: ProtocolBuffer.Encoder.NUMERIC,
4560    7: ProtocolBuffer.Encoder.STRING,
4561  }, 7, ProtocolBuffer.Encoder.MAX_TYPE)
4562
4563  # stylesheet for XML output
4564  _STYLE = \
4565   """"""
4566  _STYLE_CONTENT_TYPE = \
4567   """"""
4568  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.RunQueryRequest'
4569class RunQueryResponse(ProtocolBuffer.ProtocolMessage):
4570  has_batch_ = 0
4571  has_query_handle_ = 0
4572  query_handle_ = ""
4573
4574  def __init__(self, contents=None):
4575    self.batch_ = QueryResultBatch()
4576    if contents is not None: self.MergeFromString(contents)
4577
4578  def batch(self): return self.batch_
4579
4580  def mutable_batch(self): self.has_batch_ = 1; return self.batch_
4581
4582  def clear_batch(self):self.has_batch_ = 0; self.batch_.Clear()
4583
4584  def has_batch(self): return self.has_batch_
4585
4586  def query_handle(self): return self.query_handle_
4587
4588  def set_query_handle(self, x):
4589    self.has_query_handle_ = 1
4590    self.query_handle_ = x
4591
4592  def clear_query_handle(self):
4593    if self.has_query_handle_:
4594      self.has_query_handle_ = 0
4595      self.query_handle_ = ""
4596
4597  def has_query_handle(self): return self.has_query_handle_
4598
4599
4600  def MergeFrom(self, x):
4601    assert x is not self
4602    if (x.has_batch()): self.mutable_batch().MergeFrom(x.batch())
4603    if (x.has_query_handle()): self.set_query_handle(x.query_handle())
4604
4605  def Equals(self, x):
4606    if x is self: return 1
4607    if self.has_batch_ != x.has_batch_: return 0
4608    if self.has_batch_ and self.batch_ != x.batch_: return 0
4609    if self.has_query_handle_ != x.has_query_handle_: return 0
4610    if self.has_query_handle_ and self.query_handle_ != x.query_handle_: return 0
4611    return 1
4612
4613  def IsInitialized(self, debug_strs=None):
4614    initialized = 1
4615    if (not self.has_batch_):
4616      initialized = 0
4617      if debug_strs is not None:
4618        debug_strs.append('Required field: batch not set.')
4619    elif not self.batch_.IsInitialized(debug_strs): initialized = 0
4620    return initialized
4621
4622  def ByteSize(self):
4623    n = 0
4624    n += self.lengthString(self.batch_.ByteSize())
4625    if (self.has_query_handle_): n += 1 + self.lengthString(len(self.query_handle_))
4626    return n + 1
4627
4628  def ByteSizePartial(self):
4629    n = 0
4630    if (self.has_batch_):
4631      n += 1
4632      n += self.lengthString(self.batch_.ByteSizePartial())
4633    if (self.has_query_handle_): n += 1 + self.lengthString(len(self.query_handle_))
4634    return n
4635
4636  def Clear(self):
4637    self.clear_batch()
4638    self.clear_query_handle()
4639
4640  def OutputUnchecked(self, out):
4641    out.putVarInt32(10)
4642    out.putVarInt32(self.batch_.ByteSize())
4643    self.batch_.OutputUnchecked(out)
4644    if (self.has_query_handle_):
4645      out.putVarInt32(18)
4646      out.putPrefixedString(self.query_handle_)
4647
4648  def OutputPartial(self, out):
4649    if (self.has_batch_):
4650      out.putVarInt32(10)
4651      out.putVarInt32(self.batch_.ByteSizePartial())
4652      self.batch_.OutputPartial(out)
4653    if (self.has_query_handle_):
4654      out.putVarInt32(18)
4655      out.putPrefixedString(self.query_handle_)
4656
4657  def TryMerge(self, d):
4658    while d.avail() > 0:
4659      tt = d.getVarInt32()
4660      if tt == 10:
4661        length = d.getVarInt32()
4662        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
4663        d.skip(length)
4664        self.mutable_batch().TryMerge(tmp)
4665        continue
4666      if tt == 18:
4667        self.set_query_handle(d.getPrefixedString())
4668        continue
4669      # tag 0 is special: it's used to indicate an error.
4670      # so if we see it we raise an exception.
4671      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
4672      d.skipData(tt)
4673
4674
4675  def __str__(self, prefix="", printElemNumber=0):
4676    res=""
4677    if self.has_batch_:
4678      res+=prefix+"batch <\n"
4679      res+=self.batch_.__str__(prefix + "  ", printElemNumber)
4680      res+=prefix+">\n"
4681    if self.has_query_handle_: res+=prefix+("query_handle: %s\n" % self.DebugFormatString(self.query_handle_))
4682    return res
4683
4684
4685  def _BuildTagLookupTable(sparse, maxtag, default=None):
4686    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
4687
4688  kbatch = 1
4689  kquery_handle = 2
4690
4691  _TEXT = _BuildTagLookupTable({
4692    0: "ErrorCode",
4693    1: "batch",
4694    2: "query_handle",
4695  }, 2)
4696
4697  _TYPES = _BuildTagLookupTable({
4698    0: ProtocolBuffer.Encoder.NUMERIC,
4699    1: ProtocolBuffer.Encoder.STRING,
4700    2: ProtocolBuffer.Encoder.STRING,
4701  }, 2, ProtocolBuffer.Encoder.MAX_TYPE)
4702
4703  # stylesheet for XML output
4704  _STYLE = \
4705   """"""
4706  _STYLE_CONTENT_TYPE = \
4707   """"""
4708  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.RunQueryResponse'
4709class ContinueQueryRequest(ProtocolBuffer.ProtocolMessage):
4710  has_query_handle_ = 0
4711  query_handle_ = ""
4712
4713  def __init__(self, contents=None):
4714    if contents is not None: self.MergeFromString(contents)
4715
4716  def query_handle(self): return self.query_handle_
4717
4718  def set_query_handle(self, x):
4719    self.has_query_handle_ = 1
4720    self.query_handle_ = x
4721
4722  def clear_query_handle(self):
4723    if self.has_query_handle_:
4724      self.has_query_handle_ = 0
4725      self.query_handle_ = ""
4726
4727  def has_query_handle(self): return self.has_query_handle_
4728
4729
4730  def MergeFrom(self, x):
4731    assert x is not self
4732    if (x.has_query_handle()): self.set_query_handle(x.query_handle())
4733
4734  def Equals(self, x):
4735    if x is self: return 1
4736    if self.has_query_handle_ != x.has_query_handle_: return 0
4737    if self.has_query_handle_ and self.query_handle_ != x.query_handle_: return 0
4738    return 1
4739
4740  def IsInitialized(self, debug_strs=None):
4741    initialized = 1
4742    if (not self.has_query_handle_):
4743      initialized = 0
4744      if debug_strs is not None:
4745        debug_strs.append('Required field: query_handle not set.')
4746    return initialized
4747
4748  def ByteSize(self):
4749    n = 0
4750    n += self.lengthString(len(self.query_handle_))
4751    return n + 1
4752
4753  def ByteSizePartial(self):
4754    n = 0
4755    if (self.has_query_handle_):
4756      n += 1
4757      n += self.lengthString(len(self.query_handle_))
4758    return n
4759
4760  def Clear(self):
4761    self.clear_query_handle()
4762
4763  def OutputUnchecked(self, out):
4764    out.putVarInt32(10)
4765    out.putPrefixedString(self.query_handle_)
4766
4767  def OutputPartial(self, out):
4768    if (self.has_query_handle_):
4769      out.putVarInt32(10)
4770      out.putPrefixedString(self.query_handle_)
4771
4772  def TryMerge(self, d):
4773    while d.avail() > 0:
4774      tt = d.getVarInt32()
4775      if tt == 10:
4776        self.set_query_handle(d.getPrefixedString())
4777        continue
4778      # tag 0 is special: it's used to indicate an error.
4779      # so if we see it we raise an exception.
4780      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
4781      d.skipData(tt)
4782
4783
4784  def __str__(self, prefix="", printElemNumber=0):
4785    res=""
4786    if self.has_query_handle_: res+=prefix+("query_handle: %s\n" % self.DebugFormatString(self.query_handle_))
4787    return res
4788
4789
4790  def _BuildTagLookupTable(sparse, maxtag, default=None):
4791    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
4792
4793  kquery_handle = 1
4794
4795  _TEXT = _BuildTagLookupTable({
4796    0: "ErrorCode",
4797    1: "query_handle",
4798  }, 1)
4799
4800  _TYPES = _BuildTagLookupTable({
4801    0: ProtocolBuffer.Encoder.NUMERIC,
4802    1: ProtocolBuffer.Encoder.STRING,
4803  }, 1, ProtocolBuffer.Encoder.MAX_TYPE)
4804
4805  # stylesheet for XML output
4806  _STYLE = \
4807   """"""
4808  _STYLE_CONTENT_TYPE = \
4809   """"""
4810  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.ContinueQueryRequest'
4811class ContinueQueryResponse(ProtocolBuffer.ProtocolMessage):
4812  has_batch_ = 0
4813
4814  def __init__(self, contents=None):
4815    self.batch_ = QueryResultBatch()
4816    if contents is not None: self.MergeFromString(contents)
4817
4818  def batch(self): return self.batch_
4819
4820  def mutable_batch(self): self.has_batch_ = 1; return self.batch_
4821
4822  def clear_batch(self):self.has_batch_ = 0; self.batch_.Clear()
4823
4824  def has_batch(self): return self.has_batch_
4825
4826
4827  def MergeFrom(self, x):
4828    assert x is not self
4829    if (x.has_batch()): self.mutable_batch().MergeFrom(x.batch())
4830
4831  def Equals(self, x):
4832    if x is self: return 1
4833    if self.has_batch_ != x.has_batch_: return 0
4834    if self.has_batch_ and self.batch_ != x.batch_: return 0
4835    return 1
4836
4837  def IsInitialized(self, debug_strs=None):
4838    initialized = 1
4839    if (not self.has_batch_):
4840      initialized = 0
4841      if debug_strs is not None:
4842        debug_strs.append('Required field: batch not set.')
4843    elif not self.batch_.IsInitialized(debug_strs): initialized = 0
4844    return initialized
4845
4846  def ByteSize(self):
4847    n = 0
4848    n += self.lengthString(self.batch_.ByteSize())
4849    return n + 1
4850
4851  def ByteSizePartial(self):
4852    n = 0
4853    if (self.has_batch_):
4854      n += 1
4855      n += self.lengthString(self.batch_.ByteSizePartial())
4856    return n
4857
4858  def Clear(self):
4859    self.clear_batch()
4860
4861  def OutputUnchecked(self, out):
4862    out.putVarInt32(10)
4863    out.putVarInt32(self.batch_.ByteSize())
4864    self.batch_.OutputUnchecked(out)
4865
4866  def OutputPartial(self, out):
4867    if (self.has_batch_):
4868      out.putVarInt32(10)
4869      out.putVarInt32(self.batch_.ByteSizePartial())
4870      self.batch_.OutputPartial(out)
4871
4872  def TryMerge(self, d):
4873    while d.avail() > 0:
4874      tt = d.getVarInt32()
4875      if tt == 10:
4876        length = d.getVarInt32()
4877        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
4878        d.skip(length)
4879        self.mutable_batch().TryMerge(tmp)
4880        continue
4881      # tag 0 is special: it's used to indicate an error.
4882      # so if we see it we raise an exception.
4883      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
4884      d.skipData(tt)
4885
4886
4887  def __str__(self, prefix="", printElemNumber=0):
4888    res=""
4889    if self.has_batch_:
4890      res+=prefix+"batch <\n"
4891      res+=self.batch_.__str__(prefix + "  ", printElemNumber)
4892      res+=prefix+">\n"
4893    return res
4894
4895
4896  def _BuildTagLookupTable(sparse, maxtag, default=None):
4897    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
4898
4899  kbatch = 1
4900
4901  _TEXT = _BuildTagLookupTable({
4902    0: "ErrorCode",
4903    1: "batch",
4904  }, 1)
4905
4906  _TYPES = _BuildTagLookupTable({
4907    0: ProtocolBuffer.Encoder.NUMERIC,
4908    1: ProtocolBuffer.Encoder.STRING,
4909  }, 1, ProtocolBuffer.Encoder.MAX_TYPE)
4910
4911  # stylesheet for XML output
4912  _STYLE = \
4913   """"""
4914  _STYLE_CONTENT_TYPE = \
4915   """"""
4916  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.ContinueQueryResponse'
4917class BeginTransactionRequest(ProtocolBuffer.ProtocolMessage):
4918  has_cross_group_ = 0
4919  cross_group_ = 0
4920  has_cross_request_ = 0
4921  cross_request_ = 0
4922
4923  def __init__(self, contents=None):
4924    if contents is not None: self.MergeFromString(contents)
4925
4926  def cross_group(self): return self.cross_group_
4927
4928  def set_cross_group(self, x):
4929    self.has_cross_group_ = 1
4930    self.cross_group_ = x
4931
4932  def clear_cross_group(self):
4933    if self.has_cross_group_:
4934      self.has_cross_group_ = 0
4935      self.cross_group_ = 0
4936
4937  def has_cross_group(self): return self.has_cross_group_
4938
4939  def cross_request(self): return self.cross_request_
4940
4941  def set_cross_request(self, x):
4942    self.has_cross_request_ = 1
4943    self.cross_request_ = x
4944
4945  def clear_cross_request(self):
4946    if self.has_cross_request_:
4947      self.has_cross_request_ = 0
4948      self.cross_request_ = 0
4949
4950  def has_cross_request(self): return self.has_cross_request_
4951
4952
4953  def MergeFrom(self, x):
4954    assert x is not self
4955    if (x.has_cross_group()): self.set_cross_group(x.cross_group())
4956    if (x.has_cross_request()): self.set_cross_request(x.cross_request())
4957
4958  def Equals(self, x):
4959    if x is self: return 1
4960    if self.has_cross_group_ != x.has_cross_group_: return 0
4961    if self.has_cross_group_ and self.cross_group_ != x.cross_group_: return 0
4962    if self.has_cross_request_ != x.has_cross_request_: return 0
4963    if self.has_cross_request_ and self.cross_request_ != x.cross_request_: return 0
4964    return 1
4965
4966  def IsInitialized(self, debug_strs=None):
4967    initialized = 1
4968    return initialized
4969
4970  def ByteSize(self):
4971    n = 0
4972    if (self.has_cross_group_): n += 2
4973    if (self.has_cross_request_): n += 2
4974    return n
4975
4976  def ByteSizePartial(self):
4977    n = 0
4978    if (self.has_cross_group_): n += 2
4979    if (self.has_cross_request_): n += 2
4980    return n
4981
4982  def Clear(self):
4983    self.clear_cross_group()
4984    self.clear_cross_request()
4985
4986  def OutputUnchecked(self, out):
4987    if (self.has_cross_group_):
4988      out.putVarInt32(8)
4989      out.putBoolean(self.cross_group_)
4990    if (self.has_cross_request_):
4991      out.putVarInt32(16)
4992      out.putBoolean(self.cross_request_)
4993
4994  def OutputPartial(self, out):
4995    if (self.has_cross_group_):
4996      out.putVarInt32(8)
4997      out.putBoolean(self.cross_group_)
4998    if (self.has_cross_request_):
4999      out.putVarInt32(16)
5000      out.putBoolean(self.cross_request_)
5001
5002  def TryMerge(self, d):
5003    while d.avail() > 0:
5004      tt = d.getVarInt32()
5005      if tt == 8:
5006        self.set_cross_group(d.getBoolean())
5007        continue
5008      if tt == 16:
5009        self.set_cross_request(d.getBoolean())
5010        continue
5011      # tag 0 is special: it's used to indicate an error.
5012      # so if we see it we raise an exception.
5013      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
5014      d.skipData(tt)
5015
5016
5017  def __str__(self, prefix="", printElemNumber=0):
5018    res=""
5019    if self.has_cross_group_: res+=prefix+("cross_group: %s\n" % self.DebugFormatBool(self.cross_group_))
5020    if self.has_cross_request_: res+=prefix+("cross_request: %s\n" % self.DebugFormatBool(self.cross_request_))
5021    return res
5022
5023
5024  def _BuildTagLookupTable(sparse, maxtag, default=None):
5025    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
5026
5027  kcross_group = 1
5028  kcross_request = 2
5029
5030  _TEXT = _BuildTagLookupTable({
5031    0: "ErrorCode",
5032    1: "cross_group",
5033    2: "cross_request",
5034  }, 2)
5035
5036  _TYPES = _BuildTagLookupTable({
5037    0: ProtocolBuffer.Encoder.NUMERIC,
5038    1: ProtocolBuffer.Encoder.NUMERIC,
5039    2: ProtocolBuffer.Encoder.NUMERIC,
5040  }, 2, ProtocolBuffer.Encoder.MAX_TYPE)
5041
5042  # stylesheet for XML output
5043  _STYLE = \
5044   """"""
5045  _STYLE_CONTENT_TYPE = \
5046   """"""
5047  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.BeginTransactionRequest'
5048class BeginTransactionResponse(ProtocolBuffer.ProtocolMessage):
5049  has_transaction_ = 0
5050  transaction_ = ""
5051
5052  def __init__(self, contents=None):
5053    if contents is not None: self.MergeFromString(contents)
5054
5055  def transaction(self): return self.transaction_
5056
5057  def set_transaction(self, x):
5058    self.has_transaction_ = 1
5059    self.transaction_ = x
5060
5061  def clear_transaction(self):
5062    if self.has_transaction_:
5063      self.has_transaction_ = 0
5064      self.transaction_ = ""
5065
5066  def has_transaction(self): return self.has_transaction_
5067
5068
5069  def MergeFrom(self, x):
5070    assert x is not self
5071    if (x.has_transaction()): self.set_transaction(x.transaction())
5072
5073  def Equals(self, x):
5074    if x is self: return 1
5075    if self.has_transaction_ != x.has_transaction_: return 0
5076    if self.has_transaction_ and self.transaction_ != x.transaction_: return 0
5077    return 1
5078
5079  def IsInitialized(self, debug_strs=None):
5080    initialized = 1
5081    if (not self.has_transaction_):
5082      initialized = 0
5083      if debug_strs is not None:
5084        debug_strs.append('Required field: transaction not set.')
5085    return initialized
5086
5087  def ByteSize(self):
5088    n = 0
5089    n += self.lengthString(len(self.transaction_))
5090    return n + 1
5091
5092  def ByteSizePartial(self):
5093    n = 0
5094    if (self.has_transaction_):
5095      n += 1
5096      n += self.lengthString(len(self.transaction_))
5097    return n
5098
5099  def Clear(self):
5100    self.clear_transaction()
5101
5102  def OutputUnchecked(self, out):
5103    out.putVarInt32(10)
5104    out.putPrefixedString(self.transaction_)
5105
5106  def OutputPartial(self, out):
5107    if (self.has_transaction_):
5108      out.putVarInt32(10)
5109      out.putPrefixedString(self.transaction_)
5110
5111  def TryMerge(self, d):
5112    while d.avail() > 0:
5113      tt = d.getVarInt32()
5114      if tt == 10:
5115        self.set_transaction(d.getPrefixedString())
5116        continue
5117      # tag 0 is special: it's used to indicate an error.
5118      # so if we see it we raise an exception.
5119      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
5120      d.skipData(tt)
5121
5122
5123  def __str__(self, prefix="", printElemNumber=0):
5124    res=""
5125    if self.has_transaction_: res+=prefix+("transaction: %s\n" % self.DebugFormatString(self.transaction_))
5126    return res
5127
5128
5129  def _BuildTagLookupTable(sparse, maxtag, default=None):
5130    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
5131
5132  ktransaction = 1
5133
5134  _TEXT = _BuildTagLookupTable({
5135    0: "ErrorCode",
5136    1: "transaction",
5137  }, 1)
5138
5139  _TYPES = _BuildTagLookupTable({
5140    0: ProtocolBuffer.Encoder.NUMERIC,
5141    1: ProtocolBuffer.Encoder.STRING,
5142  }, 1, ProtocolBuffer.Encoder.MAX_TYPE)
5143
5144  # stylesheet for XML output
5145  _STYLE = \
5146   """"""
5147  _STYLE_CONTENT_TYPE = \
5148   """"""
5149  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.BeginTransactionResponse'
5150class RollbackRequest(ProtocolBuffer.ProtocolMessage):
5151  has_transaction_ = 0
5152  transaction_ = ""
5153
5154  def __init__(self, contents=None):
5155    if contents is not None: self.MergeFromString(contents)
5156
5157  def transaction(self): return self.transaction_
5158
5159  def set_transaction(self, x):
5160    self.has_transaction_ = 1
5161    self.transaction_ = x
5162
5163  def clear_transaction(self):
5164    if self.has_transaction_:
5165      self.has_transaction_ = 0
5166      self.transaction_ = ""
5167
5168  def has_transaction(self): return self.has_transaction_
5169
5170
5171  def MergeFrom(self, x):
5172    assert x is not self
5173    if (x.has_transaction()): self.set_transaction(x.transaction())
5174
5175  def Equals(self, x):
5176    if x is self: return 1
5177    if self.has_transaction_ != x.has_transaction_: return 0
5178    if self.has_transaction_ and self.transaction_ != x.transaction_: return 0
5179    return 1
5180
5181  def IsInitialized(self, debug_strs=None):
5182    initialized = 1
5183    if (not self.has_transaction_):
5184      initialized = 0
5185      if debug_strs is not None:
5186        debug_strs.append('Required field: transaction not set.')
5187    return initialized
5188
5189  def ByteSize(self):
5190    n = 0
5191    n += self.lengthString(len(self.transaction_))
5192    return n + 1
5193
5194  def ByteSizePartial(self):
5195    n = 0
5196    if (self.has_transaction_):
5197      n += 1
5198      n += self.lengthString(len(self.transaction_))
5199    return n
5200
5201  def Clear(self):
5202    self.clear_transaction()
5203
5204  def OutputUnchecked(self, out):
5205    out.putVarInt32(10)
5206    out.putPrefixedString(self.transaction_)
5207
5208  def OutputPartial(self, out):
5209    if (self.has_transaction_):
5210      out.putVarInt32(10)
5211      out.putPrefixedString(self.transaction_)
5212
5213  def TryMerge(self, d):
5214    while d.avail() > 0:
5215      tt = d.getVarInt32()
5216      if tt == 10:
5217        self.set_transaction(d.getPrefixedString())
5218        continue
5219      # tag 0 is special: it's used to indicate an error.
5220      # so if we see it we raise an exception.
5221      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
5222      d.skipData(tt)
5223
5224
5225  def __str__(self, prefix="", printElemNumber=0):
5226    res=""
5227    if self.has_transaction_: res+=prefix+("transaction: %s\n" % self.DebugFormatString(self.transaction_))
5228    return res
5229
5230
5231  def _BuildTagLookupTable(sparse, maxtag, default=None):
5232    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
5233
5234  ktransaction = 1
5235
5236  _TEXT = _BuildTagLookupTable({
5237    0: "ErrorCode",
5238    1: "transaction",
5239  }, 1)
5240
5241  _TYPES = _BuildTagLookupTable({
5242    0: ProtocolBuffer.Encoder.NUMERIC,
5243    1: ProtocolBuffer.Encoder.STRING,
5244  }, 1, ProtocolBuffer.Encoder.MAX_TYPE)
5245
5246  # stylesheet for XML output
5247  _STYLE = \
5248   """"""
5249  _STYLE_CONTENT_TYPE = \
5250   """"""
5251  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.RollbackRequest'
5252class RollbackResponse(ProtocolBuffer.ProtocolMessage):
5253
5254  def __init__(self, contents=None):
5255    pass
5256    if contents is not None: self.MergeFromString(contents)
5257
5258
5259  def MergeFrom(self, x):
5260    assert x is not self
5261
5262  def Equals(self, x):
5263    if x is self: return 1
5264    return 1
5265
5266  def IsInitialized(self, debug_strs=None):
5267    initialized = 1
5268    return initialized
5269
5270  def ByteSize(self):
5271    n = 0
5272    return n
5273
5274  def ByteSizePartial(self):
5275    n = 0
5276    return n
5277
5278  def Clear(self):
5279    pass
5280
5281  def OutputUnchecked(self, out):
5282    pass
5283
5284  def OutputPartial(self, out):
5285    pass
5286
5287  def TryMerge(self, d):
5288    while d.avail() > 0:
5289      tt = d.getVarInt32()
5290      # tag 0 is special: it's used to indicate an error.
5291      # so if we see it we raise an exception.
5292      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
5293      d.skipData(tt)
5294
5295
5296  def __str__(self, prefix="", printElemNumber=0):
5297    res=""
5298    return res
5299
5300
5301  def _BuildTagLookupTable(sparse, maxtag, default=None):
5302    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
5303
5304
5305  _TEXT = _BuildTagLookupTable({
5306    0: "ErrorCode",
5307  }, 0)
5308
5309  _TYPES = _BuildTagLookupTable({
5310    0: ProtocolBuffer.Encoder.NUMERIC,
5311  }, 0, ProtocolBuffer.Encoder.MAX_TYPE)
5312
5313  # stylesheet for XML output
5314  _STYLE = \
5315   """"""
5316  _STYLE_CONTENT_TYPE = \
5317   """"""
5318  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.RollbackResponse'
5319class CommitRequest(ProtocolBuffer.ProtocolMessage):
5320
5321  # Mode values
5322  TRANSACTIONAL =    1
5323  NON_TRANSACTIONAL =    2
5324
5325  _Mode_NAMES = {
5326    1: "TRANSACTIONAL",
5327    2: "NON_TRANSACTIONAL",
5328  }
5329
5330  def Mode_Name(cls, x): return cls._Mode_NAMES.get(x, "")
5331  Mode_Name = classmethod(Mode_Name)
5332
5333  has_transaction_ = 0
5334  transaction_ = ""
5335  has_deprecated_mutation_ = 0
5336  deprecated_mutation_ = None
5337  has_mode_ = 0
5338  mode_ = 1
5339  has_ignore_read_only_ = 0
5340  ignore_read_only_ = 0
5341
5342  def __init__(self, contents=None):
5343    self.mutation_ = []
5344    self.lazy_init_lock_ = _Lock()
5345    if contents is not None: self.MergeFromString(contents)
5346
5347  def transaction(self): return self.transaction_
5348
5349  def set_transaction(self, x):
5350    self.has_transaction_ = 1
5351    self.transaction_ = x
5352
5353  def clear_transaction(self):
5354    if self.has_transaction_:
5355      self.has_transaction_ = 0
5356      self.transaction_ = ""
5357
5358  def has_transaction(self): return self.has_transaction_
5359
5360  def mutation_size(self): return len(self.mutation_)
5361  def mutation_list(self): return self.mutation_
5362
5363  def mutation(self, i):
5364    return self.mutation_[i]
5365
5366  def mutable_mutation(self, i):
5367    return self.mutation_[i]
5368
5369  def add_mutation(self):
5370    x = Mutation()
5371    self.mutation_.append(x)
5372    return x
5373
5374  def clear_mutation(self):
5375    self.mutation_ = []
5376  def deprecated_mutation(self):
5377    if self.deprecated_mutation_ is None:
5378      self.lazy_init_lock_.acquire()
5379      try:
5380        if self.deprecated_mutation_ is None: self.deprecated_mutation_ = DeprecatedMutation()
5381      finally:
5382        self.lazy_init_lock_.release()
5383    return self.deprecated_mutation_
5384
5385  def mutable_deprecated_mutation(self): self.has_deprecated_mutation_ = 1; return self.deprecated_mutation()
5386
5387  def clear_deprecated_mutation(self):
5388    # Warning: this method does not acquire the lock.
5389    if self.has_deprecated_mutation_:
5390      self.has_deprecated_mutation_ = 0;
5391      if self.deprecated_mutation_ is not None: self.deprecated_mutation_.Clear()
5392
5393  def has_deprecated_mutation(self): return self.has_deprecated_mutation_
5394
5395  def mode(self): return self.mode_
5396
5397  def set_mode(self, x):
5398    self.has_mode_ = 1
5399    self.mode_ = x
5400
5401  def clear_mode(self):
5402    if self.has_mode_:
5403      self.has_mode_ = 0
5404      self.mode_ = 1
5405
5406  def has_mode(self): return self.has_mode_
5407
5408  def ignore_read_only(self): return self.ignore_read_only_
5409
5410  def set_ignore_read_only(self, x):
5411    self.has_ignore_read_only_ = 1
5412    self.ignore_read_only_ = x
5413
5414  def clear_ignore_read_only(self):
5415    if self.has_ignore_read_only_:
5416      self.has_ignore_read_only_ = 0
5417      self.ignore_read_only_ = 0
5418
5419  def has_ignore_read_only(self): return self.has_ignore_read_only_
5420
5421
5422  def MergeFrom(self, x):
5423    assert x is not self
5424    if (x.has_transaction()): self.set_transaction(x.transaction())
5425    for i in range(x.mutation_size()): self.add_mutation().CopyFrom(x.mutation(i))
5426    if (x.has_deprecated_mutation()): self.mutable_deprecated_mutation().MergeFrom(x.deprecated_mutation())
5427    if (x.has_mode()): self.set_mode(x.mode())
5428    if (x.has_ignore_read_only()): self.set_ignore_read_only(x.ignore_read_only())
5429
5430  def Equals(self, x):
5431    if x is self: return 1
5432    if self.has_transaction_ != x.has_transaction_: return 0
5433    if self.has_transaction_ and self.transaction_ != x.transaction_: return 0
5434    if len(self.mutation_) != len(x.mutation_): return 0
5435    for e1, e2 in zip(self.mutation_, x.mutation_):
5436      if e1 != e2: return 0
5437    if self.has_deprecated_mutation_ != x.has_deprecated_mutation_: return 0
5438    if self.has_deprecated_mutation_ and self.deprecated_mutation_ != x.deprecated_mutation_: return 0
5439    if self.has_mode_ != x.has_mode_: return 0
5440    if self.has_mode_ and self.mode_ != x.mode_: return 0
5441    if self.has_ignore_read_only_ != x.has_ignore_read_only_: return 0
5442    if self.has_ignore_read_only_ and self.ignore_read_only_ != x.ignore_read_only_: return 0
5443    return 1
5444
5445  def IsInitialized(self, debug_strs=None):
5446    initialized = 1
5447    for p in self.mutation_:
5448      if not p.IsInitialized(debug_strs): initialized=0
5449    if (self.has_deprecated_mutation_ and not self.deprecated_mutation_.IsInitialized(debug_strs)): initialized = 0
5450    return initialized
5451
5452  def ByteSize(self):
5453    n = 0
5454    if (self.has_transaction_): n += 1 + self.lengthString(len(self.transaction_))
5455    n += 1 * len(self.mutation_)
5456    for i in range(len(self.mutation_)): n += self.lengthString(self.mutation_[i].ByteSize())
5457    if (self.has_deprecated_mutation_): n += 1 + self.lengthString(self.deprecated_mutation_.ByteSize())
5458    if (self.has_mode_): n += 1 + self.lengthVarInt64(self.mode_)
5459    if (self.has_ignore_read_only_): n += 2
5460    return n
5461
5462  def ByteSizePartial(self):
5463    n = 0
5464    if (self.has_transaction_): n += 1 + self.lengthString(len(self.transaction_))
5465    n += 1 * len(self.mutation_)
5466    for i in range(len(self.mutation_)): n += self.lengthString(self.mutation_[i].ByteSizePartial())
5467    if (self.has_deprecated_mutation_): n += 1 + self.lengthString(self.deprecated_mutation_.ByteSizePartial())
5468    if (self.has_mode_): n += 1 + self.lengthVarInt64(self.mode_)
5469    if (self.has_ignore_read_only_): n += 2
5470    return n
5471
5472  def Clear(self):
5473    self.clear_transaction()
5474    self.clear_mutation()
5475    self.clear_deprecated_mutation()
5476    self.clear_mode()
5477    self.clear_ignore_read_only()
5478
5479  def OutputUnchecked(self, out):
5480    if (self.has_transaction_):
5481      out.putVarInt32(10)
5482      out.putPrefixedString(self.transaction_)
5483    if (self.has_deprecated_mutation_):
5484      out.putVarInt32(18)
5485      out.putVarInt32(self.deprecated_mutation_.ByteSize())
5486      self.deprecated_mutation_.OutputUnchecked(out)
5487    if (self.has_mode_):
5488      out.putVarInt32(32)
5489      out.putVarInt32(self.mode_)
5490    for i in range(len(self.mutation_)):
5491      out.putVarInt32(42)
5492      out.putVarInt32(self.mutation_[i].ByteSize())
5493      self.mutation_[i].OutputUnchecked(out)
5494    if (self.has_ignore_read_only_):
5495      out.putVarInt32(48)
5496      out.putBoolean(self.ignore_read_only_)
5497
5498  def OutputPartial(self, out):
5499    if (self.has_transaction_):
5500      out.putVarInt32(10)
5501      out.putPrefixedString(self.transaction_)
5502    if (self.has_deprecated_mutation_):
5503      out.putVarInt32(18)
5504      out.putVarInt32(self.deprecated_mutation_.ByteSizePartial())
5505      self.deprecated_mutation_.OutputPartial(out)
5506    if (self.has_mode_):
5507      out.putVarInt32(32)
5508      out.putVarInt32(self.mode_)
5509    for i in range(len(self.mutation_)):
5510      out.putVarInt32(42)
5511      out.putVarInt32(self.mutation_[i].ByteSizePartial())
5512      self.mutation_[i].OutputPartial(out)
5513    if (self.has_ignore_read_only_):
5514      out.putVarInt32(48)
5515      out.putBoolean(self.ignore_read_only_)
5516
5517  def TryMerge(self, d):
5518    while d.avail() > 0:
5519      tt = d.getVarInt32()
5520      if tt == 10:
5521        self.set_transaction(d.getPrefixedString())
5522        continue
5523      if tt == 18:
5524        length = d.getVarInt32()
5525        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
5526        d.skip(length)
5527        self.mutable_deprecated_mutation().TryMerge(tmp)
5528        continue
5529      if tt == 32:
5530        self.set_mode(d.getVarInt32())
5531        continue
5532      if tt == 42:
5533        length = d.getVarInt32()
5534        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
5535        d.skip(length)
5536        self.add_mutation().TryMerge(tmp)
5537        continue
5538      if tt == 48:
5539        self.set_ignore_read_only(d.getBoolean())
5540        continue
5541      # tag 0 is special: it's used to indicate an error.
5542      # so if we see it we raise an exception.
5543      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
5544      d.skipData(tt)
5545
5546
5547  def __str__(self, prefix="", printElemNumber=0):
5548    res=""
5549    if self.has_transaction_: res+=prefix+("transaction: %s\n" % self.DebugFormatString(self.transaction_))
5550    cnt=0
5551    for e in self.mutation_:
5552      elm=""
5553      if printElemNumber: elm="(%d)" % cnt
5554      res+=prefix+("mutation%s <\n" % elm)
5555      res+=e.__str__(prefix + "  ", printElemNumber)
5556      res+=prefix+">\n"
5557      cnt+=1
5558    if self.has_deprecated_mutation_:
5559      res+=prefix+"deprecated_mutation <\n"
5560      res+=self.deprecated_mutation_.__str__(prefix + "  ", printElemNumber)
5561      res+=prefix+">\n"
5562    if self.has_mode_: res+=prefix+("mode: %s\n" % self.DebugFormatInt32(self.mode_))
5563    if self.has_ignore_read_only_: res+=prefix+("ignore_read_only: %s\n" % self.DebugFormatBool(self.ignore_read_only_))
5564    return res
5565
5566
5567  def _BuildTagLookupTable(sparse, maxtag, default=None):
5568    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
5569
5570  ktransaction = 1
5571  kmutation = 5
5572  kdeprecated_mutation = 2
5573  kmode = 4
5574  kignore_read_only = 6
5575
5576  _TEXT = _BuildTagLookupTable({
5577    0: "ErrorCode",
5578    1: "transaction",
5579    2: "deprecated_mutation",
5580    4: "mode",
5581    5: "mutation",
5582    6: "ignore_read_only",
5583  }, 6)
5584
5585  _TYPES = _BuildTagLookupTable({
5586    0: ProtocolBuffer.Encoder.NUMERIC,
5587    1: ProtocolBuffer.Encoder.STRING,
5588    2: ProtocolBuffer.Encoder.STRING,
5589    4: ProtocolBuffer.Encoder.NUMERIC,
5590    5: ProtocolBuffer.Encoder.STRING,
5591    6: ProtocolBuffer.Encoder.NUMERIC,
5592  }, 6, ProtocolBuffer.Encoder.MAX_TYPE)
5593
5594  # stylesheet for XML output
5595  _STYLE = \
5596   """"""
5597  _STYLE_CONTENT_TYPE = \
5598   """"""
5599  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.CommitRequest'
5600class CommitResponse(ProtocolBuffer.ProtocolMessage):
5601  has_deprecated_mutation_result_ = 0
5602  deprecated_mutation_result_ = None
5603  has_index_updates_ = 0
5604  index_updates_ = 0
5605
5606  def __init__(self, contents=None):
5607    self.mutation_result_ = []
5608    self.lazy_init_lock_ = _Lock()
5609    if contents is not None: self.MergeFromString(contents)
5610
5611  def mutation_result_size(self): return len(self.mutation_result_)
5612  def mutation_result_list(self): return self.mutation_result_
5613
5614  def mutation_result(self, i):
5615    return self.mutation_result_[i]
5616
5617  def mutable_mutation_result(self, i):
5618    return self.mutation_result_[i]
5619
5620  def add_mutation_result(self):
5621    x = MutationResult()
5622    self.mutation_result_.append(x)
5623    return x
5624
5625  def clear_mutation_result(self):
5626    self.mutation_result_ = []
5627  def deprecated_mutation_result(self):
5628    if self.deprecated_mutation_result_ is None:
5629      self.lazy_init_lock_.acquire()
5630      try:
5631        if self.deprecated_mutation_result_ is None: self.deprecated_mutation_result_ = DeprecatedMutationResult()
5632      finally:
5633        self.lazy_init_lock_.release()
5634    return self.deprecated_mutation_result_
5635
5636  def mutable_deprecated_mutation_result(self): self.has_deprecated_mutation_result_ = 1; return self.deprecated_mutation_result()
5637
5638  def clear_deprecated_mutation_result(self):
5639    # Warning: this method does not acquire the lock.
5640    if self.has_deprecated_mutation_result_:
5641      self.has_deprecated_mutation_result_ = 0;
5642      if self.deprecated_mutation_result_ is not None: self.deprecated_mutation_result_.Clear()
5643
5644  def has_deprecated_mutation_result(self): return self.has_deprecated_mutation_result_
5645
5646  def index_updates(self): return self.index_updates_
5647
5648  def set_index_updates(self, x):
5649    self.has_index_updates_ = 1
5650    self.index_updates_ = x
5651
5652  def clear_index_updates(self):
5653    if self.has_index_updates_:
5654      self.has_index_updates_ = 0
5655      self.index_updates_ = 0
5656
5657  def has_index_updates(self): return self.has_index_updates_
5658
5659
5660  def MergeFrom(self, x):
5661    assert x is not self
5662    for i in range(x.mutation_result_size()): self.add_mutation_result().CopyFrom(x.mutation_result(i))
5663    if (x.has_deprecated_mutation_result()): self.mutable_deprecated_mutation_result().MergeFrom(x.deprecated_mutation_result())
5664    if (x.has_index_updates()): self.set_index_updates(x.index_updates())
5665
5666  def Equals(self, x):
5667    if x is self: return 1
5668    if len(self.mutation_result_) != len(x.mutation_result_): return 0
5669    for e1, e2 in zip(self.mutation_result_, x.mutation_result_):
5670      if e1 != e2: return 0
5671    if self.has_deprecated_mutation_result_ != x.has_deprecated_mutation_result_: return 0
5672    if self.has_deprecated_mutation_result_ and self.deprecated_mutation_result_ != x.deprecated_mutation_result_: return 0
5673    if self.has_index_updates_ != x.has_index_updates_: return 0
5674    if self.has_index_updates_ and self.index_updates_ != x.index_updates_: return 0
5675    return 1
5676
5677  def IsInitialized(self, debug_strs=None):
5678    initialized = 1
5679    for p in self.mutation_result_:
5680      if not p.IsInitialized(debug_strs): initialized=0
5681    if (self.has_deprecated_mutation_result_ and not self.deprecated_mutation_result_.IsInitialized(debug_strs)): initialized = 0
5682    return initialized
5683
5684  def ByteSize(self):
5685    n = 0
5686    n += 1 * len(self.mutation_result_)
5687    for i in range(len(self.mutation_result_)): n += self.lengthString(self.mutation_result_[i].ByteSize())
5688    if (self.has_deprecated_mutation_result_): n += 1 + self.lengthString(self.deprecated_mutation_result_.ByteSize())
5689    if (self.has_index_updates_): n += 1 + self.lengthVarInt64(self.index_updates_)
5690    return n
5691
5692  def ByteSizePartial(self):
5693    n = 0
5694    n += 1 * len(self.mutation_result_)
5695    for i in range(len(self.mutation_result_)): n += self.lengthString(self.mutation_result_[i].ByteSizePartial())
5696    if (self.has_deprecated_mutation_result_): n += 1 + self.lengthString(self.deprecated_mutation_result_.ByteSizePartial())
5697    if (self.has_index_updates_): n += 1 + self.lengthVarInt64(self.index_updates_)
5698    return n
5699
5700  def Clear(self):
5701    self.clear_mutation_result()
5702    self.clear_deprecated_mutation_result()
5703    self.clear_index_updates()
5704
5705  def OutputUnchecked(self, out):
5706    if (self.has_deprecated_mutation_result_):
5707      out.putVarInt32(10)
5708      out.putVarInt32(self.deprecated_mutation_result_.ByteSize())
5709      self.deprecated_mutation_result_.OutputUnchecked(out)
5710    for i in range(len(self.mutation_result_)):
5711      out.putVarInt32(26)
5712      out.putVarInt32(self.mutation_result_[i].ByteSize())
5713      self.mutation_result_[i].OutputUnchecked(out)
5714    if (self.has_index_updates_):
5715      out.putVarInt32(32)
5716      out.putVarInt32(self.index_updates_)
5717
5718  def OutputPartial(self, out):
5719    if (self.has_deprecated_mutation_result_):
5720      out.putVarInt32(10)
5721      out.putVarInt32(self.deprecated_mutation_result_.ByteSizePartial())
5722      self.deprecated_mutation_result_.OutputPartial(out)
5723    for i in range(len(self.mutation_result_)):
5724      out.putVarInt32(26)
5725      out.putVarInt32(self.mutation_result_[i].ByteSizePartial())
5726      self.mutation_result_[i].OutputPartial(out)
5727    if (self.has_index_updates_):
5728      out.putVarInt32(32)
5729      out.putVarInt32(self.index_updates_)
5730
5731  def TryMerge(self, d):
5732    while d.avail() > 0:
5733      tt = d.getVarInt32()
5734      if tt == 10:
5735        length = d.getVarInt32()
5736        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
5737        d.skip(length)
5738        self.mutable_deprecated_mutation_result().TryMerge(tmp)
5739        continue
5740      if tt == 26:
5741        length = d.getVarInt32()
5742        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
5743        d.skip(length)
5744        self.add_mutation_result().TryMerge(tmp)
5745        continue
5746      if tt == 32:
5747        self.set_index_updates(d.getVarInt32())
5748        continue
5749      # tag 0 is special: it's used to indicate an error.
5750      # so if we see it we raise an exception.
5751      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
5752      d.skipData(tt)
5753
5754
5755  def __str__(self, prefix="", printElemNumber=0):
5756    res=""
5757    cnt=0
5758    for e in self.mutation_result_:
5759      elm=""
5760      if printElemNumber: elm="(%d)" % cnt
5761      res+=prefix+("mutation_result%s <\n" % elm)
5762      res+=e.__str__(prefix + "  ", printElemNumber)
5763      res+=prefix+">\n"
5764      cnt+=1
5765    if self.has_deprecated_mutation_result_:
5766      res+=prefix+"deprecated_mutation_result <\n"
5767      res+=self.deprecated_mutation_result_.__str__(prefix + "  ", printElemNumber)
5768      res+=prefix+">\n"
5769    if self.has_index_updates_: res+=prefix+("index_updates: %s\n" % self.DebugFormatInt32(self.index_updates_))
5770    return res
5771
5772
5773  def _BuildTagLookupTable(sparse, maxtag, default=None):
5774    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
5775
5776  kmutation_result = 3
5777  kdeprecated_mutation_result = 1
5778  kindex_updates = 4
5779
5780  _TEXT = _BuildTagLookupTable({
5781    0: "ErrorCode",
5782    1: "deprecated_mutation_result",
5783    3: "mutation_result",
5784    4: "index_updates",
5785  }, 4)
5786
5787  _TYPES = _BuildTagLookupTable({
5788    0: ProtocolBuffer.Encoder.NUMERIC,
5789    1: ProtocolBuffer.Encoder.STRING,
5790    3: ProtocolBuffer.Encoder.STRING,
5791    4: ProtocolBuffer.Encoder.NUMERIC,
5792  }, 4, ProtocolBuffer.Encoder.MAX_TYPE)
5793
5794  # stylesheet for XML output
5795  _STYLE = \
5796   """"""
5797  _STYLE_CONTENT_TYPE = \
5798   """"""
5799  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.CommitResponse'
5800class AllocateIdsRequest(ProtocolBuffer.ProtocolMessage):
5801
5802  def __init__(self, contents=None):
5803    self.allocate_ = []
5804    self.reserve_ = []
5805    if contents is not None: self.MergeFromString(contents)
5806
5807  def allocate_size(self): return len(self.allocate_)
5808  def allocate_list(self): return self.allocate_
5809
5810  def allocate(self, i):
5811    return self.allocate_[i]
5812
5813  def mutable_allocate(self, i):
5814    return self.allocate_[i]
5815
5816  def add_allocate(self):
5817    x = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Key()
5818    self.allocate_.append(x)
5819    return x
5820
5821  def clear_allocate(self):
5822    self.allocate_ = []
5823  def reserve_size(self): return len(self.reserve_)
5824  def reserve_list(self): return self.reserve_
5825
5826  def reserve(self, i):
5827    return self.reserve_[i]
5828
5829  def mutable_reserve(self, i):
5830    return self.reserve_[i]
5831
5832  def add_reserve(self):
5833    x = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Key()
5834    self.reserve_.append(x)
5835    return x
5836
5837  def clear_reserve(self):
5838    self.reserve_ = []
5839
5840  def MergeFrom(self, x):
5841    assert x is not self
5842    for i in range(x.allocate_size()): self.add_allocate().CopyFrom(x.allocate(i))
5843    for i in range(x.reserve_size()): self.add_reserve().CopyFrom(x.reserve(i))
5844
5845  def Equals(self, x):
5846    if x is self: return 1
5847    if len(self.allocate_) != len(x.allocate_): return 0
5848    for e1, e2 in zip(self.allocate_, x.allocate_):
5849      if e1 != e2: return 0
5850    if len(self.reserve_) != len(x.reserve_): return 0
5851    for e1, e2 in zip(self.reserve_, x.reserve_):
5852      if e1 != e2: return 0
5853    return 1
5854
5855  def IsInitialized(self, debug_strs=None):
5856    initialized = 1
5857    for p in self.allocate_:
5858      if not p.IsInitialized(debug_strs): initialized=0
5859    for p in self.reserve_:
5860      if not p.IsInitialized(debug_strs): initialized=0
5861    return initialized
5862
5863  def ByteSize(self):
5864    n = 0
5865    n += 1 * len(self.allocate_)
5866    for i in range(len(self.allocate_)): n += self.lengthString(self.allocate_[i].ByteSize())
5867    n += 1 * len(self.reserve_)
5868    for i in range(len(self.reserve_)): n += self.lengthString(self.reserve_[i].ByteSize())
5869    return n
5870
5871  def ByteSizePartial(self):
5872    n = 0
5873    n += 1 * len(self.allocate_)
5874    for i in range(len(self.allocate_)): n += self.lengthString(self.allocate_[i].ByteSizePartial())
5875    n += 1 * len(self.reserve_)
5876    for i in range(len(self.reserve_)): n += self.lengthString(self.reserve_[i].ByteSizePartial())
5877    return n
5878
5879  def Clear(self):
5880    self.clear_allocate()
5881    self.clear_reserve()
5882
5883  def OutputUnchecked(self, out):
5884    for i in range(len(self.allocate_)):
5885      out.putVarInt32(10)
5886      out.putVarInt32(self.allocate_[i].ByteSize())
5887      self.allocate_[i].OutputUnchecked(out)
5888    for i in range(len(self.reserve_)):
5889      out.putVarInt32(18)
5890      out.putVarInt32(self.reserve_[i].ByteSize())
5891      self.reserve_[i].OutputUnchecked(out)
5892
5893  def OutputPartial(self, out):
5894    for i in range(len(self.allocate_)):
5895      out.putVarInt32(10)
5896      out.putVarInt32(self.allocate_[i].ByteSizePartial())
5897      self.allocate_[i].OutputPartial(out)
5898    for i in range(len(self.reserve_)):
5899      out.putVarInt32(18)
5900      out.putVarInt32(self.reserve_[i].ByteSizePartial())
5901      self.reserve_[i].OutputPartial(out)
5902
5903  def TryMerge(self, d):
5904    while d.avail() > 0:
5905      tt = d.getVarInt32()
5906      if tt == 10:
5907        length = d.getVarInt32()
5908        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
5909        d.skip(length)
5910        self.add_allocate().TryMerge(tmp)
5911        continue
5912      if tt == 18:
5913        length = d.getVarInt32()
5914        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
5915        d.skip(length)
5916        self.add_reserve().TryMerge(tmp)
5917        continue
5918      # tag 0 is special: it's used to indicate an error.
5919      # so if we see it we raise an exception.
5920      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
5921      d.skipData(tt)
5922
5923
5924  def __str__(self, prefix="", printElemNumber=0):
5925    res=""
5926    cnt=0
5927    for e in self.allocate_:
5928      elm=""
5929      if printElemNumber: elm="(%d)" % cnt
5930      res+=prefix+("allocate%s <\n" % elm)
5931      res+=e.__str__(prefix + "  ", printElemNumber)
5932      res+=prefix+">\n"
5933      cnt+=1
5934    cnt=0
5935    for e in self.reserve_:
5936      elm=""
5937      if printElemNumber: elm="(%d)" % cnt
5938      res+=prefix+("reserve%s <\n" % elm)
5939      res+=e.__str__(prefix + "  ", printElemNumber)
5940      res+=prefix+">\n"
5941      cnt+=1
5942    return res
5943
5944
5945  def _BuildTagLookupTable(sparse, maxtag, default=None):
5946    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
5947
5948  kallocate = 1
5949  kreserve = 2
5950
5951  _TEXT = _BuildTagLookupTable({
5952    0: "ErrorCode",
5953    1: "allocate",
5954    2: "reserve",
5955  }, 2)
5956
5957  _TYPES = _BuildTagLookupTable({
5958    0: ProtocolBuffer.Encoder.NUMERIC,
5959    1: ProtocolBuffer.Encoder.STRING,
5960    2: ProtocolBuffer.Encoder.STRING,
5961  }, 2, ProtocolBuffer.Encoder.MAX_TYPE)
5962
5963  # stylesheet for XML output
5964  _STYLE = \
5965   """"""
5966  _STYLE_CONTENT_TYPE = \
5967   """"""
5968  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.AllocateIdsRequest'
5969class AllocateIdsResponse(ProtocolBuffer.ProtocolMessage):
5970
5971  def __init__(self, contents=None):
5972    self.allocated_ = []
5973    if contents is not None: self.MergeFromString(contents)
5974
5975  def allocated_size(self): return len(self.allocated_)
5976  def allocated_list(self): return self.allocated_
5977
5978  def allocated(self, i):
5979    return self.allocated_[i]
5980
5981  def mutable_allocated(self, i):
5982    return self.allocated_[i]
5983
5984  def add_allocated(self):
5985    x = googlecloudsdk.third_party.appengine.datastore.entity_v4_pb.Key()
5986    self.allocated_.append(x)
5987    return x
5988
5989  def clear_allocated(self):
5990    self.allocated_ = []
5991
5992  def MergeFrom(self, x):
5993    assert x is not self
5994    for i in range(x.allocated_size()): self.add_allocated().CopyFrom(x.allocated(i))
5995
5996  def Equals(self, x):
5997    if x is self: return 1
5998    if len(self.allocated_) != len(x.allocated_): return 0
5999    for e1, e2 in zip(self.allocated_, x.allocated_):
6000      if e1 != e2: return 0
6001    return 1
6002
6003  def IsInitialized(self, debug_strs=None):
6004    initialized = 1
6005    for p in self.allocated_:
6006      if not p.IsInitialized(debug_strs): initialized=0
6007    return initialized
6008
6009  def ByteSize(self):
6010    n = 0
6011    n += 1 * len(self.allocated_)
6012    for i in range(len(self.allocated_)): n += self.lengthString(self.allocated_[i].ByteSize())
6013    return n
6014
6015  def ByteSizePartial(self):
6016    n = 0
6017    n += 1 * len(self.allocated_)
6018    for i in range(len(self.allocated_)): n += self.lengthString(self.allocated_[i].ByteSizePartial())
6019    return n
6020
6021  def Clear(self):
6022    self.clear_allocated()
6023
6024  def OutputUnchecked(self, out):
6025    for i in range(len(self.allocated_)):
6026      out.putVarInt32(10)
6027      out.putVarInt32(self.allocated_[i].ByteSize())
6028      self.allocated_[i].OutputUnchecked(out)
6029
6030  def OutputPartial(self, out):
6031    for i in range(len(self.allocated_)):
6032      out.putVarInt32(10)
6033      out.putVarInt32(self.allocated_[i].ByteSizePartial())
6034      self.allocated_[i].OutputPartial(out)
6035
6036  def TryMerge(self, d):
6037    while d.avail() > 0:
6038      tt = d.getVarInt32()
6039      if tt == 10:
6040        length = d.getVarInt32()
6041        tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
6042        d.skip(length)
6043        self.add_allocated().TryMerge(tmp)
6044        continue
6045      # tag 0 is special: it's used to indicate an error.
6046      # so if we see it we raise an exception.
6047      if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError()
6048      d.skipData(tt)
6049
6050
6051  def __str__(self, prefix="", printElemNumber=0):
6052    res=""
6053    cnt=0
6054    for e in self.allocated_:
6055      elm=""
6056      if printElemNumber: elm="(%d)" % cnt
6057      res+=prefix+("allocated%s <\n" % elm)
6058      res+=e.__str__(prefix + "  ", printElemNumber)
6059      res+=prefix+">\n"
6060      cnt+=1
6061    return res
6062
6063
6064  def _BuildTagLookupTable(sparse, maxtag, default=None):
6065    return tuple([sparse.get(i, default) for i in range(0, 1+maxtag)])
6066
6067  kallocated = 1
6068
6069  _TEXT = _BuildTagLookupTable({
6070    0: "ErrorCode",
6071    1: "allocated",
6072  }, 1)
6073
6074  _TYPES = _BuildTagLookupTable({
6075    0: ProtocolBuffer.Encoder.NUMERIC,
6076    1: ProtocolBuffer.Encoder.STRING,
6077  }, 1, ProtocolBuffer.Encoder.MAX_TYPE)
6078
6079  # stylesheet for XML output
6080  _STYLE = \
6081   """"""
6082  _STYLE_CONTENT_TYPE = \
6083   """"""
6084  _PROTO_DESCRIPTOR_NAME = 'apphosting.datastore.v4.AllocateIdsResponse'
6085if _extension_runtime:
6086  pass
6087
6088__all__ = ['Error','EntityResult','Query','KindExpression','PropertyReference','PropertyExpression','PropertyOrder','Filter','CompositeFilter','PropertyFilter','GqlQuery','GqlQueryArg','QueryResultBatch','Mutation','MutationResult','DeprecatedMutation','DeprecatedMutationResult','ReadOptions','LookupRequest','LookupResponse','RunQueryRequest','RunQueryResponse','ContinueQueryRequest','ContinueQueryResponse','BeginTransactionRequest','BeginTransactionResponse','RollbackRequest','RollbackResponse','CommitRequest','CommitResponse','AllocateIdsRequest','AllocateIdsResponse']
6089