#
# 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

from thrift.transport import TTransport
all_structs = []


class ForsunPlanError(TException):
    """
    Attributes:
     - code
     - message
    """


    def __init__(self, code=None, message=None,):
        self.code = code
        self.message = message

    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.I16:
                    self.code = iprot.readI16()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRING:
                    self.message = 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('ForsunPlanError')
        if self.code is not None:
            oprot.writeFieldBegin('code', TType.I16, 1)
            oprot.writeI16(self.code)
            oprot.writeFieldEnd()
        if self.message is not None:
            oprot.writeFieldBegin('message', TType.STRING, 2)
            oprot.writeString(self.message.encode('utf-8') if sys.version_info[0] == 2 else self.message)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        return

    def __str__(self):
        return repr(self)

    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 ForsunPlan(object):
    """
    Attributes:
     - is_time_out
     - key
     - second
     - minute
     - hour
     - day
     - month
     - week
     - next_time
     - status
     - count
     - current_count
     - last_timeout
     - action
     - params
    """


    def __init__(self, is_time_out=None, key=None, second=None, minute=-1, hour=-1, day=-1, month=-1, week=-1, next_time=None, status=0, count=0, current_count=0, last_timeout=0, action="shell", params={
    },):
        self.is_time_out = is_time_out
        self.key = key
        self.second = second
        self.minute = minute
        self.hour = hour
        self.day = day
        self.month = month
        self.week = week
        self.next_time = next_time
        self.status = status
        self.count = count
        self.current_count = current_count
        self.last_timeout = last_timeout
        self.action = action
        if params is self.thrift_spec[15][4]:
            params = {
            }
        self.params = params

    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.BOOL:
                    self.is_time_out = iprot.readBool()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRING:
                    self.key = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.I16:
                    self.second = iprot.readI16()
                else:
                    iprot.skip(ftype)
            elif fid == 4:
                if ftype == TType.I16:
                    self.minute = iprot.readI16()
                else:
                    iprot.skip(ftype)
            elif fid == 5:
                if ftype == TType.I16:
                    self.hour = iprot.readI16()
                else:
                    iprot.skip(ftype)
            elif fid == 6:
                if ftype == TType.I16:
                    self.day = iprot.readI16()
                else:
                    iprot.skip(ftype)
            elif fid == 7:
                if ftype == TType.I16:
                    self.month = iprot.readI16()
                else:
                    iprot.skip(ftype)
            elif fid == 8:
                if ftype == TType.I16:
                    self.week = iprot.readI16()
                else:
                    iprot.skip(ftype)
            elif fid == 9:
                if ftype == TType.I32:
                    self.next_time = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 10:
                if ftype == TType.I16:
                    self.status = iprot.readI16()
                else:
                    iprot.skip(ftype)
            elif fid == 11:
                if ftype == TType.I16:
                    self.count = iprot.readI16()
                else:
                    iprot.skip(ftype)
            elif fid == 12:
                if ftype == TType.I16:
                    self.current_count = iprot.readI16()
                else:
                    iprot.skip(ftype)
            elif fid == 13:
                if ftype == TType.I32:
                    self.last_timeout = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 14:
                if ftype == TType.STRING:
                    self.action = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 15:
                if ftype == TType.MAP:
                    self.params = {}
                    (_ktype1, _vtype2, _size0) = iprot.readMapBegin()
                    for _i4 in range(_size0):
                        _key5 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                        _val6 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                        self.params[_key5] = _val6
                    iprot.readMapEnd()
                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('ForsunPlan')
        if self.is_time_out is not None:
            oprot.writeFieldBegin('is_time_out', TType.BOOL, 1)
            oprot.writeBool(self.is_time_out)
            oprot.writeFieldEnd()
        if self.key is not None:
            oprot.writeFieldBegin('key', TType.STRING, 2)
            oprot.writeString(self.key.encode('utf-8') if sys.version_info[0] == 2 else self.key)
            oprot.writeFieldEnd()
        if self.second is not None:
            oprot.writeFieldBegin('second', TType.I16, 3)
            oprot.writeI16(self.second)
            oprot.writeFieldEnd()
        if self.minute is not None:
            oprot.writeFieldBegin('minute', TType.I16, 4)
            oprot.writeI16(self.minute)
            oprot.writeFieldEnd()
        if self.hour is not None:
            oprot.writeFieldBegin('hour', TType.I16, 5)
            oprot.writeI16(self.hour)
            oprot.writeFieldEnd()
        if self.day is not None:
            oprot.writeFieldBegin('day', TType.I16, 6)
            oprot.writeI16(self.day)
            oprot.writeFieldEnd()
        if self.month is not None:
            oprot.writeFieldBegin('month', TType.I16, 7)
            oprot.writeI16(self.month)
            oprot.writeFieldEnd()
        if self.week is not None:
            oprot.writeFieldBegin('week', TType.I16, 8)
            oprot.writeI16(self.week)
            oprot.writeFieldEnd()
        if self.next_time is not None:
            oprot.writeFieldBegin('next_time', TType.I32, 9)
            oprot.writeI32(self.next_time)
            oprot.writeFieldEnd()
        if self.status is not None:
            oprot.writeFieldBegin('status', TType.I16, 10)
            oprot.writeI16(self.status)
            oprot.writeFieldEnd()
        if self.count is not None:
            oprot.writeFieldBegin('count', TType.I16, 11)
            oprot.writeI16(self.count)
            oprot.writeFieldEnd()
        if self.current_count is not None:
            oprot.writeFieldBegin('current_count', TType.I16, 12)
            oprot.writeI16(self.current_count)
            oprot.writeFieldEnd()
        if self.last_timeout is not None:
            oprot.writeFieldBegin('last_timeout', TType.I32, 13)
            oprot.writeI32(self.last_timeout)
            oprot.writeFieldEnd()
        if self.action is not None:
            oprot.writeFieldBegin('action', TType.STRING, 14)
            oprot.writeString(self.action.encode('utf-8') if sys.version_info[0] == 2 else self.action)
            oprot.writeFieldEnd()
        if self.params is not None:
            oprot.writeFieldBegin('params', TType.MAP, 15)
            oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.params))
            for kiter7, viter8 in self.params.items():
                oprot.writeString(kiter7.encode('utf-8') if sys.version_info[0] == 2 else kiter7)
                oprot.writeString(viter8.encode('utf-8') if sys.version_info[0] == 2 else viter8)
            oprot.writeMapEnd()
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.is_time_out is None:
            raise TProtocolException(message='Required field is_time_out is unset!')
        if self.key is None:
            raise TProtocolException(message='Required field key is unset!')
        if self.second is None:
            raise TProtocolException(message='Required field second is unset!')
        if self.next_time is None:
            raise TProtocolException(message='Required field next_time is unset!')
        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(ForsunPlanError)
ForsunPlanError.thrift_spec = (
    None,  # 0
    (1, TType.I16, 'code', None, None, ),  # 1
    (2, TType.STRING, 'message', 'UTF8', None, ),  # 2
)
all_structs.append(ForsunPlan)
ForsunPlan.thrift_spec = (
    None,  # 0
    (1, TType.BOOL, 'is_time_out', None, None, ),  # 1
    (2, TType.STRING, 'key', 'UTF8', None, ),  # 2
    (3, TType.I16, 'second', None, None, ),  # 3
    (4, TType.I16, 'minute', None, -1, ),  # 4
    (5, TType.I16, 'hour', None, -1, ),  # 5
    (6, TType.I16, 'day', None, -1, ),  # 6
    (7, TType.I16, 'month', None, -1, ),  # 7
    (8, TType.I16, 'week', None, -1, ),  # 8
    (9, TType.I32, 'next_time', None, None, ),  # 9
    (10, TType.I16, 'status', None, 0, ),  # 10
    (11, TType.I16, 'count', None, 0, ),  # 11
    (12, TType.I16, 'current_count', None, 0, ),  # 12
    (13, TType.I32, 'last_timeout', None, 0, ),  # 13
    (14, TType.STRING, 'action', 'UTF8', "shell", ),  # 14
    (15, TType.MAP, 'params', (TType.STRING, 'UTF8', TType.STRING, 'UTF8', False), {
    }, ),  # 15
)
fix_spec(all_structs)
del all_structs
