#
# Autogenerated by Thrift
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#

from thrift.Thrift import *

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


class Status(object):
  DEAD = 0
  STARTING = 1
  ALIVE = 2
  STOPPING = 3
  STOPPED = 4
  WARNING = 5

  _VALUES_TO_NAMES = {
    0: "DEAD",
    1: "STARTING",
    2: "ALIVE",
    3: "STOPPING",
    4: "STOPPED",
    5: "WARNING",
  }

  _NAMES_TO_VALUES = {
    "DEAD": 0,
    "STARTING": 1,
    "ALIVE": 2,
    "STOPPING": 3,
    "STOPPED": 4,
    "WARNING": 5,
  }


class Endpoint(object):
  """
  Attributes:
   - host
   - port
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRING, 'host', None, None, ), # 1
    (2, TType.I32, 'port', None, None, ), # 2
  )

  def __init__(self, host=None, port=None,):
    self.host = host
    self.port = port

  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.host = iprot.readString();
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.I32:
          self.port = iprot.readI32();
        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('Endpoint')
    if self.host != None:
      oprot.writeFieldBegin('host', TType.STRING, 1)
      oprot.writeString(self.host)
      oprot.writeFieldEnd()
    if self.port != None:
      oprot.writeFieldBegin('port', TType.I32, 2)
      oprot.writeI32(self.port)
      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 ServiceInstance(object):
  """
  Attributes:
   - serviceEndpoint
   - additionalEndpoints
   - status
   - shard
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'serviceEndpoint', (Endpoint, Endpoint.thrift_spec), None, ), # 1
    (2, TType.MAP, 'additionalEndpoints', (TType.STRING,None,TType.STRUCT,(Endpoint, Endpoint.thrift_spec)), None, ), # 2
    (3, TType.I32, 'status', None, None, ), # 3
    (4, TType.I32, 'shard', None, None, ), # 4
  )

  def __init__(self, serviceEndpoint=None, additionalEndpoints=None, status=None, shard=None,):
    self.serviceEndpoint = serviceEndpoint
    self.additionalEndpoints = additionalEndpoints
    self.status = status
    self.shard = shard

  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.STRUCT:
          self.serviceEndpoint = Endpoint()
          self.serviceEndpoint.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.MAP:
          self.additionalEndpoints = {}
          (_ktype1, _vtype2, _size0 ) = iprot.readMapBegin() 
          for _i4 in xrange(_size0):
            _key5 = iprot.readString();
            _val6 = Endpoint()
            _val6.read(iprot)
            self.additionalEndpoints[_key5] = _val6
          iprot.readMapEnd()
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.I32:
          self.status = iprot.readI32();
        else:
          iprot.skip(ftype)
      elif fid == 4:
        if ftype == TType.I32:
          self.shard = iprot.readI32();
        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('ServiceInstance')
    if self.serviceEndpoint != None:
      oprot.writeFieldBegin('serviceEndpoint', TType.STRUCT, 1)
      self.serviceEndpoint.write(oprot)
      oprot.writeFieldEnd()
    if self.additionalEndpoints != None:
      oprot.writeFieldBegin('additionalEndpoints', TType.MAP, 2)
      oprot.writeMapBegin(TType.STRING, TType.STRUCT, len(self.additionalEndpoints))
      for kiter7,viter8 in self.additionalEndpoints.items():
        oprot.writeString(kiter7)
        viter8.write(oprot)
      oprot.writeMapEnd()
      oprot.writeFieldEnd()
    if self.status != None:
      oprot.writeFieldBegin('status', TType.I32, 3)
      oprot.writeI32(self.status)
      oprot.writeFieldEnd()
    if self.shard != None:
      oprot.writeFieldBegin('shard', TType.I32, 4)
      oprot.writeI32(self.shard)
      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)
