#
# 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 logging
from .ttypes import *
from thrift.Thrift import TProcessor
from thrift.transport import TTransport
all_structs = []


class Iface(object):
    def installAddOn(self, authInfo, fileName, data):
        """
        Parameters:
         - authInfo
         - fileName
         - data
        """
        pass

    def listAddons(self, authInfo):
        """
        Parameters:
         - authInfo
        """
        pass

    def getAddOnById(self, authInfo, id):
        """
        Parameters:
         - authInfo
         - id
        """
        pass

    def deleteAddOn(self, authInfo, addOn):
        """
        Parameters:
         - authInfo
         - addOn
        """
        pass

    def getAddOnBytes(self, authInfo, addOn):
        """
        Parameters:
         - authInfo
         - addOn
        """
        pass


class Client(Iface):
    def __init__(self, iprot, oprot=None):
        self._iprot = self._oprot = iprot
        if oprot is not None:
            self._oprot = oprot
        self._seqid = 0

    def installAddOn(self, authInfo, fileName, data):
        """
        Parameters:
         - authInfo
         - fileName
         - data
        """
        self.send_installAddOn(authInfo, fileName, data)
        return self.recv_installAddOn()

    def send_installAddOn(self, authInfo, fileName, data):
        self._oprot.writeMessageBegin('installAddOn', TMessageType.CALL, self._seqid)
        args = installAddOn_args()
        args.authInfo = authInfo
        args.fileName = fileName
        args.data = data
        args.write(self._oprot)
        self._oprot.writeMessageEnd()
        self._oprot.trans.flush()

    def recv_installAddOn(self):
        iprot = self._iprot
        (fname, mtype, rseqid) = iprot.readMessageBegin()
        if mtype == TMessageType.EXCEPTION:
            x = TApplicationException()
            x.read(iprot)
            iprot.readMessageEnd()
            raise x
        result = installAddOn_result()
        result.read(iprot)
        iprot.readMessageEnd()
        if result.success is not None:
            return result.success
        if result.ke is not None:
            raise result.ke
        if result.ae is not None:
            raise result.ae
        if result.ce is not None:
            raise result.ce
        raise TApplicationException(TApplicationException.MISSING_RESULT, "installAddOn failed: unknown result")

    def listAddons(self, authInfo):
        """
        Parameters:
         - authInfo
        """
        self.send_listAddons(authInfo)
        return self.recv_listAddons()

    def send_listAddons(self, authInfo):
        self._oprot.writeMessageBegin('listAddons', TMessageType.CALL, self._seqid)
        args = listAddons_args()
        args.authInfo = authInfo
        args.write(self._oprot)
        self._oprot.writeMessageEnd()
        self._oprot.trans.flush()

    def recv_listAddons(self):
        iprot = self._iprot
        (fname, mtype, rseqid) = iprot.readMessageBegin()
        if mtype == TMessageType.EXCEPTION:
            x = TApplicationException()
            x.read(iprot)
            iprot.readMessageEnd()
            raise x
        result = listAddons_result()
        result.read(iprot)
        iprot.readMessageEnd()
        if result.success is not None:
            return result.success
        if result.ke is not None:
            raise result.ke
        if result.ae is not None:
            raise result.ae
        if result.ce is not None:
            raise result.ce
        raise TApplicationException(TApplicationException.MISSING_RESULT, "listAddons failed: unknown result")

    def getAddOnById(self, authInfo, id):
        """
        Parameters:
         - authInfo
         - id
        """
        self.send_getAddOnById(authInfo, id)
        return self.recv_getAddOnById()

    def send_getAddOnById(self, authInfo, id):
        self._oprot.writeMessageBegin('getAddOnById', TMessageType.CALL, self._seqid)
        args = getAddOnById_args()
        args.authInfo = authInfo
        args.id = id
        args.write(self._oprot)
        self._oprot.writeMessageEnd()
        self._oprot.trans.flush()

    def recv_getAddOnById(self):
        iprot = self._iprot
        (fname, mtype, rseqid) = iprot.readMessageBegin()
        if mtype == TMessageType.EXCEPTION:
            x = TApplicationException()
            x.read(iprot)
            iprot.readMessageEnd()
            raise x
        result = getAddOnById_result()
        result.read(iprot)
        iprot.readMessageEnd()
        if result.success is not None:
            return result.success
        if result.ke is not None:
            raise result.ke
        if result.ae is not None:
            raise result.ae
        if result.nfe is not None:
            raise result.nfe
        if result.ce is not None:
            raise result.ce
        raise TApplicationException(TApplicationException.MISSING_RESULT, "getAddOnById failed: unknown result")

    def deleteAddOn(self, authInfo, addOn):
        """
        Parameters:
         - authInfo
         - addOn
        """
        self.send_deleteAddOn(authInfo, addOn)
        self.recv_deleteAddOn()

    def send_deleteAddOn(self, authInfo, addOn):
        self._oprot.writeMessageBegin('deleteAddOn', TMessageType.CALL, self._seqid)
        args = deleteAddOn_args()
        args.authInfo = authInfo
        args.addOn = addOn
        args.write(self._oprot)
        self._oprot.writeMessageEnd()
        self._oprot.trans.flush()

    def recv_deleteAddOn(self):
        iprot = self._iprot
        (fname, mtype, rseqid) = iprot.readMessageBegin()
        if mtype == TMessageType.EXCEPTION:
            x = TApplicationException()
            x.read(iprot)
            iprot.readMessageEnd()
            raise x
        result = deleteAddOn_result()
        result.read(iprot)
        iprot.readMessageEnd()
        if result.ke is not None:
            raise result.ke
        if result.ae is not None:
            raise result.ae
        if result.ce is not None:
            raise result.ce
        return

    def getAddOnBytes(self, authInfo, addOn):
        """
        Parameters:
         - authInfo
         - addOn
        """
        self.send_getAddOnBytes(authInfo, addOn)
        return self.recv_getAddOnBytes()

    def send_getAddOnBytes(self, authInfo, addOn):
        self._oprot.writeMessageBegin('getAddOnBytes', TMessageType.CALL, self._seqid)
        args = getAddOnBytes_args()
        args.authInfo = authInfo
        args.addOn = addOn
        args.write(self._oprot)
        self._oprot.writeMessageEnd()
        self._oprot.trans.flush()

    def recv_getAddOnBytes(self):
        iprot = self._iprot
        (fname, mtype, rseqid) = iprot.readMessageBegin()
        if mtype == TMessageType.EXCEPTION:
            x = TApplicationException()
            x.read(iprot)
            iprot.readMessageEnd()
            raise x
        result = getAddOnBytes_result()
        result.read(iprot)
        iprot.readMessageEnd()
        if result.success is not None:
            return result.success
        if result.ke is not None:
            raise result.ke
        if result.ae is not None:
            raise result.ae
        if result.ce is not None:
            raise result.ce
        raise TApplicationException(TApplicationException.MISSING_RESULT, "getAddOnBytes failed: unknown result")


class Processor(Iface, TProcessor):
    def __init__(self, handler):
        self._handler = handler
        self._processMap = {}
        self._processMap["installAddOn"] = Processor.process_installAddOn
        self._processMap["listAddons"] = Processor.process_listAddons
        self._processMap["getAddOnById"] = Processor.process_getAddOnById
        self._processMap["deleteAddOn"] = Processor.process_deleteAddOn
        self._processMap["getAddOnBytes"] = Processor.process_getAddOnBytes

    def process(self, iprot, oprot):
        (name, type, seqid) = iprot.readMessageBegin()
        if name not in self._processMap:
            iprot.skip(TType.STRUCT)
            iprot.readMessageEnd()
            x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name))
            oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)
            x.write(oprot)
            oprot.writeMessageEnd()
            oprot.trans.flush()
            return
        else:
            self._processMap[name](self, seqid, iprot, oprot)
        return True

    def process_installAddOn(self, seqid, iprot, oprot):
        args = installAddOn_args()
        args.read(iprot)
        iprot.readMessageEnd()
        result = installAddOn_result()
        try:
            result.success = self._handler.installAddOn(args.authInfo, args.fileName, args.data)
            msg_type = TMessageType.REPLY
        except TTransport.TTransportException:
            raise
        except koverse.thriftgen.ttypes.TKoverseException as ke:
            msg_type = TMessageType.REPLY
            result.ke = ke
        except koverse.thriftgen.security.ttypes.TAuthorizationException as ae:
            msg_type = TMessageType.REPLY
            result.ae = ae
        except koverse.thriftgen.security.ttypes.TCannotUseKoverseException as ce:
            msg_type = TMessageType.REPLY
            result.ce = ce
        except TApplicationException as ex:
            logging.exception('TApplication exception in handler')
            msg_type = TMessageType.EXCEPTION
            result = ex
        except Exception:
            logging.exception('Unexpected exception in handler')
            msg_type = TMessageType.EXCEPTION
            result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
        oprot.writeMessageBegin("installAddOn", msg_type, seqid)
        result.write(oprot)
        oprot.writeMessageEnd()
        oprot.trans.flush()

    def process_listAddons(self, seqid, iprot, oprot):
        args = listAddons_args()
        args.read(iprot)
        iprot.readMessageEnd()
        result = listAddons_result()
        try:
            result.success = self._handler.listAddons(args.authInfo)
            msg_type = TMessageType.REPLY
        except TTransport.TTransportException:
            raise
        except koverse.thriftgen.ttypes.TKoverseException as ke:
            msg_type = TMessageType.REPLY
            result.ke = ke
        except koverse.thriftgen.security.ttypes.TAuthorizationException as ae:
            msg_type = TMessageType.REPLY
            result.ae = ae
        except koverse.thriftgen.security.ttypes.TCannotUseKoverseException as ce:
            msg_type = TMessageType.REPLY
            result.ce = ce
        except TApplicationException as ex:
            logging.exception('TApplication exception in handler')
            msg_type = TMessageType.EXCEPTION
            result = ex
        except Exception:
            logging.exception('Unexpected exception in handler')
            msg_type = TMessageType.EXCEPTION
            result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
        oprot.writeMessageBegin("listAddons", msg_type, seqid)
        result.write(oprot)
        oprot.writeMessageEnd()
        oprot.trans.flush()

    def process_getAddOnById(self, seqid, iprot, oprot):
        args = getAddOnById_args()
        args.read(iprot)
        iprot.readMessageEnd()
        result = getAddOnById_result()
        try:
            result.success = self._handler.getAddOnById(args.authInfo, args.id)
            msg_type = TMessageType.REPLY
        except TTransport.TTransportException:
            raise
        except koverse.thriftgen.ttypes.TKoverseException as ke:
            msg_type = TMessageType.REPLY
            result.ke = ke
        except koverse.thriftgen.security.ttypes.TAuthorizationException as ae:
            msg_type = TMessageType.REPLY
            result.ae = ae
        except koverse.thriftgen.ttypes.TNotFoundException as nfe:
            msg_type = TMessageType.REPLY
            result.nfe = nfe
        except koverse.thriftgen.security.ttypes.TCannotUseKoverseException as ce:
            msg_type = TMessageType.REPLY
            result.ce = ce
        except TApplicationException as ex:
            logging.exception('TApplication exception in handler')
            msg_type = TMessageType.EXCEPTION
            result = ex
        except Exception:
            logging.exception('Unexpected exception in handler')
            msg_type = TMessageType.EXCEPTION
            result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
        oprot.writeMessageBegin("getAddOnById", msg_type, seqid)
        result.write(oprot)
        oprot.writeMessageEnd()
        oprot.trans.flush()

    def process_deleteAddOn(self, seqid, iprot, oprot):
        args = deleteAddOn_args()
        args.read(iprot)
        iprot.readMessageEnd()
        result = deleteAddOn_result()
        try:
            self._handler.deleteAddOn(args.authInfo, args.addOn)
            msg_type = TMessageType.REPLY
        except TTransport.TTransportException:
            raise
        except koverse.thriftgen.ttypes.TKoverseException as ke:
            msg_type = TMessageType.REPLY
            result.ke = ke
        except koverse.thriftgen.security.ttypes.TAuthorizationException as ae:
            msg_type = TMessageType.REPLY
            result.ae = ae
        except koverse.thriftgen.security.ttypes.TCannotUseKoverseException as ce:
            msg_type = TMessageType.REPLY
            result.ce = ce
        except TApplicationException as ex:
            logging.exception('TApplication exception in handler')
            msg_type = TMessageType.EXCEPTION
            result = ex
        except Exception:
            logging.exception('Unexpected exception in handler')
            msg_type = TMessageType.EXCEPTION
            result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
        oprot.writeMessageBegin("deleteAddOn", msg_type, seqid)
        result.write(oprot)
        oprot.writeMessageEnd()
        oprot.trans.flush()

    def process_getAddOnBytes(self, seqid, iprot, oprot):
        args = getAddOnBytes_args()
        args.read(iprot)
        iprot.readMessageEnd()
        result = getAddOnBytes_result()
        try:
            result.success = self._handler.getAddOnBytes(args.authInfo, args.addOn)
            msg_type = TMessageType.REPLY
        except TTransport.TTransportException:
            raise
        except koverse.thriftgen.ttypes.TKoverseException as ke:
            msg_type = TMessageType.REPLY
            result.ke = ke
        except koverse.thriftgen.security.ttypes.TAuthorizationException as ae:
            msg_type = TMessageType.REPLY
            result.ae = ae
        except koverse.thriftgen.security.ttypes.TCannotUseKoverseException as ce:
            msg_type = TMessageType.REPLY
            result.ce = ce
        except TApplicationException as ex:
            logging.exception('TApplication exception in handler')
            msg_type = TMessageType.EXCEPTION
            result = ex
        except Exception:
            logging.exception('Unexpected exception in handler')
            msg_type = TMessageType.EXCEPTION
            result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
        oprot.writeMessageBegin("getAddOnBytes", msg_type, seqid)
        result.write(oprot)
        oprot.writeMessageEnd()
        oprot.trans.flush()

# HELPER FUNCTIONS AND STRUCTURES


class installAddOn_args(object):
    """
    Attributes:
     - authInfo
     - fileName
     - data
    """


    def __init__(self, authInfo=None, fileName=None, data=None,):
        self.authInfo = authInfo
        self.fileName = fileName
        self.data = data

    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.STRUCT:
                    self.authInfo = koverse.thriftgen.security.ttypes.TAuthInfo()
                    self.authInfo.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.STRING:
                    self.fileName = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 4:
                if ftype == TType.STRING:
                    self.data = iprot.readBinary()
                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('installAddOn_args')
        if self.authInfo is not None:
            oprot.writeFieldBegin('authInfo', TType.STRUCT, 1)
            self.authInfo.write(oprot)
            oprot.writeFieldEnd()
        if self.fileName is not None:
            oprot.writeFieldBegin('fileName', TType.STRING, 3)
            oprot.writeString(self.fileName.encode('utf-8') if sys.version_info[0] == 2 else self.fileName)
            oprot.writeFieldEnd()
        if self.data is not None:
            oprot.writeFieldBegin('data', TType.STRING, 4)
            oprot.writeBinary(self.data)
            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(installAddOn_args)
installAddOn_args.thrift_spec = (
    None,  # 0
    (1, TType.STRUCT, 'authInfo', [koverse.thriftgen.security.ttypes.TAuthInfo, None], None, ),  # 1
    None,  # 2
    (3, TType.STRING, 'fileName', 'UTF8', None, ),  # 3
    (4, TType.STRING, 'data', 'BINARY', None, ),  # 4
)


class installAddOn_result(object):
    """
    Attributes:
     - success
     - ke
     - ae
     - ce
    """


    def __init__(self, success=None, ke=None, ae=None, ce=None,):
        self.success = success
        self.ke = ke
        self.ae = ae
        self.ce = ce

    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 == 0:
                if ftype == TType.STRUCT:
                    self.success = TAddOn()
                    self.success.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 1:
                if ftype == TType.STRUCT:
                    self.ke = koverse.thriftgen.ttypes.TKoverseException()
                    self.ke.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRUCT:
                    self.ae = koverse.thriftgen.security.ttypes.TAuthorizationException()
                    self.ae.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.STRUCT:
                    self.ce = koverse.thriftgen.security.ttypes.TCannotUseKoverseException()
                    self.ce.read(iprot)
                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('installAddOn_result')
        if self.success is not None:
            oprot.writeFieldBegin('success', TType.STRUCT, 0)
            self.success.write(oprot)
            oprot.writeFieldEnd()
        if self.ke is not None:
            oprot.writeFieldBegin('ke', TType.STRUCT, 1)
            self.ke.write(oprot)
            oprot.writeFieldEnd()
        if self.ae is not None:
            oprot.writeFieldBegin('ae', TType.STRUCT, 2)
            self.ae.write(oprot)
            oprot.writeFieldEnd()
        if self.ce is not None:
            oprot.writeFieldBegin('ce', TType.STRUCT, 3)
            self.ce.write(oprot)
            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(installAddOn_result)
installAddOn_result.thrift_spec = (
    (0, TType.STRUCT, 'success', [TAddOn, None], None, ),  # 0
    (1, TType.STRUCT, 'ke', [koverse.thriftgen.ttypes.TKoverseException, None], None, ),  # 1
    (2, TType.STRUCT, 'ae', [koverse.thriftgen.security.ttypes.TAuthorizationException, None], None, ),  # 2
    (3, TType.STRUCT, 'ce', [koverse.thriftgen.security.ttypes.TCannotUseKoverseException, None], None, ),  # 3
)


class listAddons_args(object):
    """
    Attributes:
     - authInfo
    """


    def __init__(self, authInfo=None,):
        self.authInfo = authInfo

    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.STRUCT:
                    self.authInfo = koverse.thriftgen.security.ttypes.TAuthInfo()
                    self.authInfo.read(iprot)
                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('listAddons_args')
        if self.authInfo is not None:
            oprot.writeFieldBegin('authInfo', TType.STRUCT, 1)
            self.authInfo.write(oprot)
            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(listAddons_args)
listAddons_args.thrift_spec = (
    None,  # 0
    (1, TType.STRUCT, 'authInfo', [koverse.thriftgen.security.ttypes.TAuthInfo, None], None, ),  # 1
)


class listAddons_result(object):
    """
    Attributes:
     - success
     - ke
     - ae
     - ce
    """


    def __init__(self, success=None, ke=None, ae=None, ce=None,):
        self.success = success
        self.ke = ke
        self.ae = ae
        self.ce = ce

    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 == 0:
                if ftype == TType.LIST:
                    self.success = []
                    (_etype59, _size56) = iprot.readListBegin()
                    for _i60 in range(_size56):
                        _elem61 = TAddOn()
                        _elem61.read(iprot)
                        self.success.append(_elem61)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 1:
                if ftype == TType.STRUCT:
                    self.ke = koverse.thriftgen.ttypes.TKoverseException()
                    self.ke.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRUCT:
                    self.ae = koverse.thriftgen.security.ttypes.TAuthorizationException()
                    self.ae.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.STRUCT:
                    self.ce = koverse.thriftgen.security.ttypes.TCannotUseKoverseException()
                    self.ce.read(iprot)
                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('listAddons_result')
        if self.success is not None:
            oprot.writeFieldBegin('success', TType.LIST, 0)
            oprot.writeListBegin(TType.STRUCT, len(self.success))
            for iter62 in self.success:
                iter62.write(oprot)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.ke is not None:
            oprot.writeFieldBegin('ke', TType.STRUCT, 1)
            self.ke.write(oprot)
            oprot.writeFieldEnd()
        if self.ae is not None:
            oprot.writeFieldBegin('ae', TType.STRUCT, 2)
            self.ae.write(oprot)
            oprot.writeFieldEnd()
        if self.ce is not None:
            oprot.writeFieldBegin('ce', TType.STRUCT, 3)
            self.ce.write(oprot)
            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(listAddons_result)
listAddons_result.thrift_spec = (
    (0, TType.LIST, 'success', (TType.STRUCT, [TAddOn, None], False), None, ),  # 0
    (1, TType.STRUCT, 'ke', [koverse.thriftgen.ttypes.TKoverseException, None], None, ),  # 1
    (2, TType.STRUCT, 'ae', [koverse.thriftgen.security.ttypes.TAuthorizationException, None], None, ),  # 2
    (3, TType.STRUCT, 'ce', [koverse.thriftgen.security.ttypes.TCannotUseKoverseException, None], None, ),  # 3
)


class getAddOnById_args(object):
    """
    Attributes:
     - authInfo
     - id
    """


    def __init__(self, authInfo=None, id=None,):
        self.authInfo = authInfo
        self.id = id

    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.STRUCT:
                    self.authInfo = koverse.thriftgen.security.ttypes.TAuthInfo()
                    self.authInfo.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.I64:
                    self.id = 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('getAddOnById_args')
        if self.authInfo is not None:
            oprot.writeFieldBegin('authInfo', TType.STRUCT, 1)
            self.authInfo.write(oprot)
            oprot.writeFieldEnd()
        if self.id is not None:
            oprot.writeFieldBegin('id', TType.I64, 2)
            oprot.writeI64(self.id)
            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(getAddOnById_args)
getAddOnById_args.thrift_spec = (
    None,  # 0
    (1, TType.STRUCT, 'authInfo', [koverse.thriftgen.security.ttypes.TAuthInfo, None], None, ),  # 1
    (2, TType.I64, 'id', None, None, ),  # 2
)


class getAddOnById_result(object):
    """
    Attributes:
     - success
     - ke
     - ae
     - nfe
     - ce
    """


    def __init__(self, success=None, ke=None, ae=None, nfe=None, ce=None,):
        self.success = success
        self.ke = ke
        self.ae = ae
        self.nfe = nfe
        self.ce = ce

    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 == 0:
                if ftype == TType.STRUCT:
                    self.success = TAddOn()
                    self.success.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 1:
                if ftype == TType.STRUCT:
                    self.ke = koverse.thriftgen.ttypes.TKoverseException()
                    self.ke.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRUCT:
                    self.ae = koverse.thriftgen.security.ttypes.TAuthorizationException()
                    self.ae.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.STRUCT:
                    self.nfe = koverse.thriftgen.ttypes.TNotFoundException()
                    self.nfe.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 4:
                if ftype == TType.STRUCT:
                    self.ce = koverse.thriftgen.security.ttypes.TCannotUseKoverseException()
                    self.ce.read(iprot)
                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('getAddOnById_result')
        if self.success is not None:
            oprot.writeFieldBegin('success', TType.STRUCT, 0)
            self.success.write(oprot)
            oprot.writeFieldEnd()
        if self.ke is not None:
            oprot.writeFieldBegin('ke', TType.STRUCT, 1)
            self.ke.write(oprot)
            oprot.writeFieldEnd()
        if self.ae is not None:
            oprot.writeFieldBegin('ae', TType.STRUCT, 2)
            self.ae.write(oprot)
            oprot.writeFieldEnd()
        if self.nfe is not None:
            oprot.writeFieldBegin('nfe', TType.STRUCT, 3)
            self.nfe.write(oprot)
            oprot.writeFieldEnd()
        if self.ce is not None:
            oprot.writeFieldBegin('ce', TType.STRUCT, 4)
            self.ce.write(oprot)
            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(getAddOnById_result)
getAddOnById_result.thrift_spec = (
    (0, TType.STRUCT, 'success', [TAddOn, None], None, ),  # 0
    (1, TType.STRUCT, 'ke', [koverse.thriftgen.ttypes.TKoverseException, None], None, ),  # 1
    (2, TType.STRUCT, 'ae', [koverse.thriftgen.security.ttypes.TAuthorizationException, None], None, ),  # 2
    (3, TType.STRUCT, 'nfe', [koverse.thriftgen.ttypes.TNotFoundException, None], None, ),  # 3
    (4, TType.STRUCT, 'ce', [koverse.thriftgen.security.ttypes.TCannotUseKoverseException, None], None, ),  # 4
)


class deleteAddOn_args(object):
    """
    Attributes:
     - authInfo
     - addOn
    """


    def __init__(self, authInfo=None, addOn=None,):
        self.authInfo = authInfo
        self.addOn = addOn

    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.STRUCT:
                    self.authInfo = koverse.thriftgen.security.ttypes.TAuthInfo()
                    self.authInfo.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRUCT:
                    self.addOn = TAddOn()
                    self.addOn.read(iprot)
                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('deleteAddOn_args')
        if self.authInfo is not None:
            oprot.writeFieldBegin('authInfo', TType.STRUCT, 1)
            self.authInfo.write(oprot)
            oprot.writeFieldEnd()
        if self.addOn is not None:
            oprot.writeFieldBegin('addOn', TType.STRUCT, 2)
            self.addOn.write(oprot)
            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(deleteAddOn_args)
deleteAddOn_args.thrift_spec = (
    None,  # 0
    (1, TType.STRUCT, 'authInfo', [koverse.thriftgen.security.ttypes.TAuthInfo, None], None, ),  # 1
    (2, TType.STRUCT, 'addOn', [TAddOn, None], None, ),  # 2
)


class deleteAddOn_result(object):
    """
    Attributes:
     - ke
     - ae
     - ce
    """


    def __init__(self, ke=None, ae=None, ce=None,):
        self.ke = ke
        self.ae = ae
        self.ce = ce

    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.STRUCT:
                    self.ke = koverse.thriftgen.ttypes.TKoverseException()
                    self.ke.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRUCT:
                    self.ae = koverse.thriftgen.security.ttypes.TAuthorizationException()
                    self.ae.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.STRUCT:
                    self.ce = koverse.thriftgen.security.ttypes.TCannotUseKoverseException()
                    self.ce.read(iprot)
                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('deleteAddOn_result')
        if self.ke is not None:
            oprot.writeFieldBegin('ke', TType.STRUCT, 1)
            self.ke.write(oprot)
            oprot.writeFieldEnd()
        if self.ae is not None:
            oprot.writeFieldBegin('ae', TType.STRUCT, 2)
            self.ae.write(oprot)
            oprot.writeFieldEnd()
        if self.ce is not None:
            oprot.writeFieldBegin('ce', TType.STRUCT, 3)
            self.ce.write(oprot)
            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(deleteAddOn_result)
deleteAddOn_result.thrift_spec = (
    None,  # 0
    (1, TType.STRUCT, 'ke', [koverse.thriftgen.ttypes.TKoverseException, None], None, ),  # 1
    (2, TType.STRUCT, 'ae', [koverse.thriftgen.security.ttypes.TAuthorizationException, None], None, ),  # 2
    (3, TType.STRUCT, 'ce', [koverse.thriftgen.security.ttypes.TCannotUseKoverseException, None], None, ),  # 3
)


class getAddOnBytes_args(object):
    """
    Attributes:
     - authInfo
     - addOn
    """


    def __init__(self, authInfo=None, addOn=None,):
        self.authInfo = authInfo
        self.addOn = addOn

    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.STRUCT:
                    self.authInfo = koverse.thriftgen.security.ttypes.TAuthInfo()
                    self.authInfo.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRUCT:
                    self.addOn = TAddOn()
                    self.addOn.read(iprot)
                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('getAddOnBytes_args')
        if self.authInfo is not None:
            oprot.writeFieldBegin('authInfo', TType.STRUCT, 1)
            self.authInfo.write(oprot)
            oprot.writeFieldEnd()
        if self.addOn is not None:
            oprot.writeFieldBegin('addOn', TType.STRUCT, 2)
            self.addOn.write(oprot)
            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(getAddOnBytes_args)
getAddOnBytes_args.thrift_spec = (
    None,  # 0
    (1, TType.STRUCT, 'authInfo', [koverse.thriftgen.security.ttypes.TAuthInfo, None], None, ),  # 1
    (2, TType.STRUCT, 'addOn', [TAddOn, None], None, ),  # 2
)


class getAddOnBytes_result(object):
    """
    Attributes:
     - success
     - ke
     - ae
     - ce
    """


    def __init__(self, success=None, ke=None, ae=None, ce=None,):
        self.success = success
        self.ke = ke
        self.ae = ae
        self.ce = ce

    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 == 0:
                if ftype == TType.STRING:
                    self.success = iprot.readBinary()
                else:
                    iprot.skip(ftype)
            elif fid == 1:
                if ftype == TType.STRUCT:
                    self.ke = koverse.thriftgen.ttypes.TKoverseException()
                    self.ke.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRUCT:
                    self.ae = koverse.thriftgen.security.ttypes.TAuthorizationException()
                    self.ae.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.STRUCT:
                    self.ce = koverse.thriftgen.security.ttypes.TCannotUseKoverseException()
                    self.ce.read(iprot)
                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('getAddOnBytes_result')
        if self.success is not None:
            oprot.writeFieldBegin('success', TType.STRING, 0)
            oprot.writeBinary(self.success)
            oprot.writeFieldEnd()
        if self.ke is not None:
            oprot.writeFieldBegin('ke', TType.STRUCT, 1)
            self.ke.write(oprot)
            oprot.writeFieldEnd()
        if self.ae is not None:
            oprot.writeFieldBegin('ae', TType.STRUCT, 2)
            self.ae.write(oprot)
            oprot.writeFieldEnd()
        if self.ce is not None:
            oprot.writeFieldBegin('ce', TType.STRUCT, 3)
            self.ce.write(oprot)
            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(getAddOnBytes_result)
getAddOnBytes_result.thrift_spec = (
    (0, TType.STRING, 'success', 'BINARY', None, ),  # 0
    (1, TType.STRUCT, 'ke', [koverse.thriftgen.ttypes.TKoverseException, None], None, ),  # 1
    (2, TType.STRUCT, 'ae', [koverse.thriftgen.security.ttypes.TAuthorizationException, None], None, ),  # 2
    (3, TType.STRUCT, 'ce', [koverse.thriftgen.security.ttypes.TCannotUseKoverseException, None], None, ),  # 3
)
fix_spec(all_structs)
del all_structs

