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

from thrift.Thrift import TType, TMessageType, TException, TApplicationException
import impala._thrift_gen.ErrorCodes.ttypes


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



class TStatus(object):
  """
  Attributes:
   - status_code
   - error_msgs
  """

  thrift_spec = (
    None, # 0
    (1, TType.I32, 'status_code', None, None, ), # 1
    (2, TType.LIST, 'error_msgs', (TType.STRING,None), None, ), # 2
  )

  def __init__(self, status_code=None, error_msgs=None,):
    self.status_code = status_code
    self.error_msgs = error_msgs

  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.I32:
          self.status_code = iprot.readI32()
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.LIST:
          self.error_msgs = []
          (_etype3, _size0) = iprot.readListBegin()
          for _i4 in xrange(_size0):
            _elem5 = iprot.readString()
            self.error_msgs.append(_elem5)
          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('TStatus')
    if self.status_code is not None:
      oprot.writeFieldBegin('status_code', TType.I32, 1)
      oprot.writeI32(self.status_code)
      oprot.writeFieldEnd()
    if self.error_msgs is not None:
      oprot.writeFieldBegin('error_msgs', TType.LIST, 2)
      oprot.writeListBegin(TType.STRING, len(self.error_msgs))
      for iter6 in self.error_msgs:
        oprot.writeString(iter6)
      oprot.writeListEnd()
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

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


  def __hash__(self):
    value = 17
    value = (value * 31) ^ hash(self.status_code)
    value = (value * 31) ^ hash(self.error_msgs)
    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)
