#
# Autogenerated by Thrift Compiler (0.9.3)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
#  options string: py
#

from thrift.Thrift import TType, TMessageType, TException, TApplicationException

from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol, TProtocol
try:
  from thrift.protocol import fastbinary
except:
  fastbinary = None



class Filter:
  """
  Attributes:
   - attr
   - op
   - val
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRING, 'attr', None, None, ), # 1
    (2, TType.STRING, 'op', None, None, ), # 2
    (3, TType.STRING, 'val', None, None, ), # 3
  )

  def __init__(self, attr=None, op=None, val=None,):
    self.attr = attr
    self.op = op
    self.val = val

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRING:
          self.attr = iprot.readString()
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRING:
          self.op = iprot.readString()
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.STRING:
          self.val = iprot.readString()
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('Filter')
    if self.attr is not None:
      oprot.writeFieldBegin('attr', TType.STRING, 1)
      oprot.writeString(self.attr)
      oprot.writeFieldEnd()
    if self.op is not None:
      oprot.writeFieldBegin('op', TType.STRING, 2)
      oprot.writeString(self.op)
      oprot.writeFieldEnd()
    if self.val is not None:
      oprot.writeFieldBegin('val', TType.STRING, 3)
      oprot.writeString(self.val)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    if self.attr is None:
      raise TProtocol.TProtocolException(message='Required field attr is unset!')
    if self.op is None:
      raise TProtocol.TProtocolException(message='Required field op is unset!')
    if self.val is None:
      raise TProtocol.TProtocolException(message='Required field val is unset!')
    return


  def __hash__(self):
    value = 17
    value = (value * 31) ^ hash(self.attr)
    value = (value * 31) ^ hash(self.op)
    value = (value * 31) ^ hash(self.val)
    return value

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class Flag:
  """
  Attributes:
   - name
   - weight
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRING, 'name', None, None, ), # 1
    (2, TType.I32, 'weight', None, None, ), # 2
  )

  def __init__(self, name=None, weight=None,):
    self.name = name
    self.weight = weight

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRING:
          self.name = iprot.readString()
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.I32:
          self.weight = iprot.readI32()
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('Flag')
    if self.name is not None:
      oprot.writeFieldBegin('name', TType.STRING, 1)
      oprot.writeString(self.name)
      oprot.writeFieldEnd()
    if self.weight is not None:
      oprot.writeFieldBegin('weight', TType.I32, 2)
      oprot.writeI32(self.weight)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    if self.name is None:
      raise TProtocol.TProtocolException(message='Required field name is unset!')
    if self.weight is None:
      raise TProtocol.TProtocolException(message='Required field weight is unset!')
    return


  def __hash__(self):
    value = 17
    value = (value * 31) ^ hash(self.name)
    value = (value * 31) ^ hash(self.weight)
    return value

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class Branch:
  """
  Attributes:
   - path
   - volume
   - leaf
  """

  thrift_spec = (
    None, # 0
    (1, TType.LIST, 'path', (TType.STRUCT,(Filter, Filter.thrift_spec)), None, ), # 1
    (2, TType.I32, 'volume', None, None, ), # 2
    (3, TType.LIST, 'leaf', (TType.STRUCT,(Flag, Flag.thrift_spec)), None, ), # 3
  )

  def __init__(self, path=None, volume=None, leaf=None,):
    self.path = path
    self.volume = volume
    self.leaf = leaf

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.LIST:
          self.path = []
          (_etype3, _size0) = iprot.readListBegin()
          for _i4 in xrange(_size0):
            _elem5 = Filter()
            _elem5.read(iprot)
            self.path.append(_elem5)
          iprot.readListEnd()
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.I32:
          self.volume = iprot.readI32()
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.LIST:
          self.leaf = []
          (_etype9, _size6) = iprot.readListBegin()
          for _i10 in xrange(_size6):
            _elem11 = Flag()
            _elem11.read(iprot)
            self.leaf.append(_elem11)
          iprot.readListEnd()
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('Branch')
    if self.path is not None:
      oprot.writeFieldBegin('path', TType.LIST, 1)
      oprot.writeListBegin(TType.STRUCT, len(self.path))
      for iter12 in self.path:
        iter12.write(oprot)
      oprot.writeListEnd()
      oprot.writeFieldEnd()
    if self.volume is not None:
      oprot.writeFieldBegin('volume', TType.I32, 2)
      oprot.writeI32(self.volume)
      oprot.writeFieldEnd()
    if self.leaf is not None:
      oprot.writeFieldBegin('leaf', TType.LIST, 3)
      oprot.writeListBegin(TType.STRUCT, len(self.leaf))
      for iter13 in self.leaf:
        iter13.write(oprot)
      oprot.writeListEnd()
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    if self.path is None:
      raise TProtocol.TProtocolException(message='Required field path is unset!')
    if self.volume is None:
      raise TProtocol.TProtocolException(message='Required field volume is unset!')
    if self.leaf is None:
      raise TProtocol.TProtocolException(message='Required field leaf is unset!')
    return


  def __hash__(self):
    value = 17
    value = (value * 31) ^ hash(self.path)
    value = (value * 31) ^ hash(self.volume)
    value = (value * 31) ^ hash(self.leaf)
    return value

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class Feature:
  """
  Attributes:
   - name
   - key
   - on
   - expired_at
   - tree
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRING, 'name', None, None, ), # 1
    (2, TType.STRING, 'key', None, None, ), # 2
    (3, TType.BOOL, 'on', None, None, ), # 3
    (4, TType.I64, 'expired_at', None, None, ), # 4
    (5, TType.LIST, 'tree', (TType.STRUCT,(Branch, Branch.thrift_spec)), None, ), # 5
  )

  def __init__(self, name=None, key=None, on=None, expired_at=None, tree=None,):
    self.name = name
    self.key = key
    self.on = on
    self.expired_at = expired_at
    self.tree = tree

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRING:
          self.name = iprot.readString()
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRING:
          self.key = iprot.readString()
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.BOOL:
          self.on = iprot.readBool()
        else:
          iprot.skip(ftype)
      elif fid == 4:
        if ftype == TType.I64:
          self.expired_at = iprot.readI64()
        else:
          iprot.skip(ftype)
      elif fid == 5:
        if ftype == TType.LIST:
          self.tree = []
          (_etype17, _size14) = iprot.readListBegin()
          for _i18 in xrange(_size14):
            _elem19 = Branch()
            _elem19.read(iprot)
            self.tree.append(_elem19)
          iprot.readListEnd()
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('Feature')
    if self.name is not None:
      oprot.writeFieldBegin('name', TType.STRING, 1)
      oprot.writeString(self.name)
      oprot.writeFieldEnd()
    if self.key is not None:
      oprot.writeFieldBegin('key', TType.STRING, 2)
      oprot.writeString(self.key)
      oprot.writeFieldEnd()
    if self.on is not None:
      oprot.writeFieldBegin('on', TType.BOOL, 3)
      oprot.writeBool(self.on)
      oprot.writeFieldEnd()
    if self.expired_at is not None:
      oprot.writeFieldBegin('expired_at', TType.I64, 4)
      oprot.writeI64(self.expired_at)
      oprot.writeFieldEnd()
    if self.tree is not None:
      oprot.writeFieldBegin('tree', TType.LIST, 5)
      oprot.writeListBegin(TType.STRUCT, len(self.tree))
      for iter20 in self.tree:
        iter20.write(oprot)
      oprot.writeListEnd()
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    if self.name is None:
      raise TProtocol.TProtocolException(message='Required field name is unset!')
    if self.key is None:
      raise TProtocol.TProtocolException(message='Required field key is unset!')
    if self.on is None:
      raise TProtocol.TProtocolException(message='Required field on is unset!')
    if self.expired_at is None:
      raise TProtocol.TProtocolException(message='Required field expired_at is unset!')
    if self.tree is None:
      raise TProtocol.TProtocolException(message='Required field tree is unset!')
    return


  def __hash__(self):
    value = 17
    value = (value * 31) ^ hash(self.name)
    value = (value * 31) ^ hash(self.key)
    value = (value * 31) ^ hash(self.on)
    value = (value * 31) ^ hash(self.expired_at)
    value = (value * 31) ^ hash(self.tree)
    return value

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)
