#
# Autogenerated by Thrift Compiler (0.13.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

from thrift.transport import TTransport
all_structs = []


class FooRequest(object):
    """
    Attributes:
     - mystring

    """


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

    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 and ftype == TType.STRING:
                self.mystring = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
            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("FooRequest")
        if self.mystring is not None:
            oprot.writeFieldBegin("mystring", TType.STRING, 1)
            oprot.writeString(self.mystring.encode("utf-8") if sys.version_info[0] == 2 else self.mystring)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.mystring is None:
            raise TProtocolException(message="Required field mystring is unset!")
        return

    def __repr__(self):
        L = [f"{key}={value}"
             for key, value in self.__dict__.items()]
        return f"{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 FooResponse(object):
    """
    Attributes:
     - responsestring

    """


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

    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 and ftype == TType.STRING:
                self.responsestring = iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString()
            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("FooResponse")
        if self.responsestring is not None:
            oprot.writeFieldBegin("responsestring", TType.STRING, 1)
            oprot.writeString(self.responsestring.encode("utf-8") if sys.version_info[0] == 2 else self.responsestring)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.responsestring is None:
            raise TProtocolException(message="Required field responsestring is unset!")
        return

    def __repr__(self):
        L = [f"{key}={value}"
             for key, value in self.__dict__.items()]
        return f"{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(FooRequest)
FooRequest.thrift_spec = (
    None,  # 0
    (1, TType.STRING, "mystring", "UTF8", None, ),  # 1
)
all_structs.append(FooResponse)
FooResponse.thrift_spec = (
    None,  # 0
    (1, TType.STRING, "responsestring", "UTF8", None, ),  # 1
)
fix_spec(all_structs)
del all_structs
