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

from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException
from thrift.protocol.TProtocol import TProtocolException
from thrift.TRecursive import fix_spec

import sys
import koverse.thriftgen.ttypes

from thrift.transport import TTransport
all_structs = []


class TProducer(object):
    """
    Attributes:
     - name
     - relation
    """


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

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [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().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRING:
                    self.relation = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(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.encode('utf-8') if sys.version_info[0] == 2 else self.name)
            oprot.writeFieldEnd()
        if self.relation is not None:
            oprot.writeFieldBegin('relation', TType.STRING, 2)
            oprot.writeString(self.relation.encode('utf-8') if sys.version_info[0] == 2 else 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__.items()]
        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(object):
    """
    Attributes:
     - id
     - definition
     - dimensions
     - producers
     - displayName
     - tags
     - dataCollectionId
     - configurationOptions
     - lastExecutedTimestamp
    """


    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._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [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().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.LIST:
                    self.dimensions = []
                    (_etype3, _size0) = iprot.readListBegin()
                    for _i4 in range(_size0):
                        _elem5 = []
                        (_etype9, _size6) = iprot.readListBegin()
                        for _i10 in range(_size6):
                            _elem11 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else 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 range(_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().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 6:
                if ftype == TType.LIST:
                    self.tags = []
                    (_etype21, _size18) = iprot.readListBegin()
                    for _i22 in range(_size18):
                        _elem23 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                        self.tags.append(_elem23)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 7:
                if ftype == TType.STRING:
                    self.dataCollectionId = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 8:
                if ftype == TType.MAP:
                    self.configurationOptions = {}
                    (_ktype25, _vtype26, _size24) = iprot.readMapBegin()
                    for _i28 in range(_size24):
                        _key29 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else 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._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(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.encode('utf-8') if sys.version_info[0] == 2 else 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.encode('utf-8') if sys.version_info[0] == 2 else 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.encode('utf-8') if sys.version_info[0] == 2 else 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.encode('utf-8') if sys.version_info[0] == 2 else iter34)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.dataCollectionId is not None:
            oprot.writeFieldBegin('dataCollectionId', TType.STRING, 7)
            oprot.writeString(self.dataCollectionId.encode('utf-8') if sys.version_info[0] == 2 else 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.encode('utf-8') if sys.version_info[0] == 2 else 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__.items()]
        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)
all_structs.append(TProducer)
TProducer.thrift_spec = (
    None,  # 0
    (1, TType.STRING, 'name', 'UTF8', None, ),  # 1
    (2, TType.STRING, 'relation', 'UTF8', None, ),  # 2
)
all_structs.append(TAggregate)
TAggregate.thrift_spec = (
    None,  # 0
    (1, TType.I64, 'id', None, None, ),  # 1
    (2, TType.STRING, 'definition', 'UTF8', None, ),  # 2
    (3, TType.LIST, 'dimensions', (TType.LIST, (TType.STRING, 'UTF8', False), False), None, ),  # 3
    (4, TType.LIST, 'producers', (TType.STRUCT, [TProducer, None], False), None, ),  # 4
    (5, TType.STRING, 'displayName', 'UTF8', None, ),  # 5
    (6, TType.LIST, 'tags', (TType.STRING, 'UTF8', False), None, ),  # 6
    (7, TType.STRING, 'dataCollectionId', 'UTF8', None, ),  # 7
    (8, TType.MAP, 'configurationOptions', (TType.STRING, 'UTF8', TType.STRUCT, [koverse.thriftgen.ttypes.TConfigValue, None], False), None, ),  # 8
    (9, TType.I64, 'lastExecutedTimestamp', None, None, ),  # 9
)
fix_spec(all_structs)
del all_structs
