#
# Autogenerated by Thrift Compiler (0.9.1)
#
# 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
import koverse.thriftgen.ttypes


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



class TProducer:
  """
  Attributes:
   - name
   - relation
  """

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

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

  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.relation = 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('TProducer')
    if self.name is not None:
      oprot.writeFieldBegin('name', TType.STRING, 1)
      oprot.writeString(self.name)
      oprot.writeFieldEnd()
    if self.relation is not None:
      oprot.writeFieldBegin('relation', TType.STRING, 2)
      oprot.writeString(self.relation)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  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 TAggregate:
  """
  Attributes:
   - id
   - definition
   - dimensions
   - producers
   - displayName
   - tags
   - dataCollectionId
   - configurationOptions
   - lastExecutedTimestamp
  """

  thrift_spec = (
    None, # 0
    (1, TType.I64, 'id', None, None, ), # 1
    (2, TType.STRING, 'definition', None, None, ), # 2
    (3, TType.LIST, 'dimensions', (TType.LIST,(TType.STRING,None)), None, ), # 3
    (4, TType.LIST, 'producers', (TType.STRUCT,(TProducer, TProducer.thrift_spec)), None, ), # 4
    (5, TType.STRING, 'displayName', None, None, ), # 5
    (6, TType.LIST, 'tags', (TType.STRING,None), None, ), # 6
    (7, TType.STRING, 'dataCollectionId', None, None, ), # 7
    (8, TType.MAP, 'configurationOptions', (TType.STRING,None,TType.STRUCT,(koverse.thriftgen.ttypes.TConfigValue, koverse.thriftgen.ttypes.TConfigValue.thrift_spec)), None, ), # 8
    (9, TType.I64, 'lastExecutedTimestamp', None, None, ), # 9
  )

  def __init__(self, id=None, definition=None, dimensions=None, producers=None, displayName=None, tags=None, dataCollectionId=None, configurationOptions=None, lastExecutedTimestamp=None,):
    self.id = id
    self.definition = definition
    self.dimensions = dimensions
    self.producers = producers
    self.displayName = displayName
    self.tags = tags
    self.dataCollectionId = dataCollectionId
    self.configurationOptions = configurationOptions
    self.lastExecutedTimestamp = lastExecutedTimestamp

  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.I64:
          self.id = iprot.readI64();
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRING:
          self.definition = iprot.readString();
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.LIST:
          self.dimensions = []
          (_etype3, _size0) = iprot.readListBegin()
          for _i4 in xrange(_size0):
            _elem5 = []
            (_etype9, _size6) = iprot.readListBegin()
            for _i10 in xrange(_size6):
              _elem11 = iprot.readString();
              _elem5.append(_elem11)
            iprot.readListEnd()
            self.dimensions.append(_elem5)
          iprot.readListEnd()
        else:
          iprot.skip(ftype)
      elif fid == 4:
        if ftype == TType.LIST:
          self.producers = []
          (_etype15, _size12) = iprot.readListBegin()
          for _i16 in xrange(_size12):
            _elem17 = TProducer()
            _elem17.read(iprot)
            self.producers.append(_elem17)
          iprot.readListEnd()
        else:
          iprot.skip(ftype)
      elif fid == 5:
        if ftype == TType.STRING:
          self.displayName = iprot.readString();
        else:
          iprot.skip(ftype)
      elif fid == 6:
        if ftype == TType.LIST:
          self.tags = []
          (_etype21, _size18) = iprot.readListBegin()
          for _i22 in xrange(_size18):
            _elem23 = iprot.readString();
            self.tags.append(_elem23)
          iprot.readListEnd()
        else:
          iprot.skip(ftype)
      elif fid == 7:
        if ftype == TType.STRING:
          self.dataCollectionId = iprot.readString();
        else:
          iprot.skip(ftype)
      elif fid == 8:
        if ftype == TType.MAP:
          self.configurationOptions = {}
          (_ktype25, _vtype26, _size24 ) = iprot.readMapBegin()
          for _i28 in xrange(_size24):
            _key29 = iprot.readString();
            _val30 = koverse.thriftgen.ttypes.TConfigValue()
            _val30.read(iprot)
            self.configurationOptions[_key29] = _val30
          iprot.readMapEnd()
        else:
          iprot.skip(ftype)
      elif fid == 9:
        if ftype == TType.I64:
          self.lastExecutedTimestamp = iprot.readI64();
        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('TAggregate')
    if self.id is not None:
      oprot.writeFieldBegin('id', TType.I64, 1)
      oprot.writeI64(self.id)
      oprot.writeFieldEnd()
    if self.definition is not None:
      oprot.writeFieldBegin('definition', TType.STRING, 2)
      oprot.writeString(self.definition)
      oprot.writeFieldEnd()
    if self.dimensions is not None:
      oprot.writeFieldBegin('dimensions', TType.LIST, 3)
      oprot.writeListBegin(TType.LIST, len(self.dimensions))
      for iter31 in self.dimensions:
        oprot.writeListBegin(TType.STRING, len(iter31))
        for iter32 in iter31:
          oprot.writeString(iter32)
        oprot.writeListEnd()
      oprot.writeListEnd()
      oprot.writeFieldEnd()
    if self.producers is not None:
      oprot.writeFieldBegin('producers', TType.LIST, 4)
      oprot.writeListBegin(TType.STRUCT, len(self.producers))
      for iter33 in self.producers:
        iter33.write(oprot)
      oprot.writeListEnd()
      oprot.writeFieldEnd()
    if self.displayName is not None:
      oprot.writeFieldBegin('displayName', TType.STRING, 5)
      oprot.writeString(self.displayName)
      oprot.writeFieldEnd()
    if self.tags is not None:
      oprot.writeFieldBegin('tags', TType.LIST, 6)
      oprot.writeListBegin(TType.STRING, len(self.tags))
      for iter34 in self.tags:
        oprot.writeString(iter34)
      oprot.writeListEnd()
      oprot.writeFieldEnd()
    if self.dataCollectionId is not None:
      oprot.writeFieldBegin('dataCollectionId', TType.STRING, 7)
      oprot.writeString(self.dataCollectionId)
      oprot.writeFieldEnd()
    if self.configurationOptions is not None:
      oprot.writeFieldBegin('configurationOptions', TType.MAP, 8)
      oprot.writeMapBegin(TType.STRING, TType.STRUCT, len(self.configurationOptions))
      for kiter35,viter36 in self.configurationOptions.items():
        oprot.writeString(kiter35)
        viter36.write(oprot)
      oprot.writeMapEnd()
      oprot.writeFieldEnd()
    if self.lastExecutedTimestamp is not None:
      oprot.writeFieldBegin('lastExecutedTimestamp', TType.I64, 9)
      oprot.writeI64(self.lastExecutedTimestamp)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def validate(self):
    return


  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)
