#
# Autogenerated by Thrift Compiler (0.9.1)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#

require 'thrift'
require 'reair_types'

module TReplicationService
  class Client
    include ::Thrift::Client

    def getActiveJobs(afterId, maxJobs)
      send_getActiveJobs(afterId, maxJobs)
      return recv_getActiveJobs()
    end

    def send_getActiveJobs(afterId, maxJobs)
      send_message('getActiveJobs', GetActiveJobs_args, :afterId => afterId, :maxJobs => maxJobs)
    end

    def recv_getActiveJobs()
      result = receive_message(GetActiveJobs_result)
      return result.success unless result.success.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getActiveJobs failed: unknown result')
    end

    def getRetiredJobs(afterId, maxJobs)
      send_getRetiredJobs(afterId, maxJobs)
      return recv_getRetiredJobs()
    end

    def send_getRetiredJobs(afterId, maxJobs)
      send_message('getRetiredJobs', GetRetiredJobs_args, :afterId => afterId, :maxJobs => maxJobs)
    end

    def recv_getRetiredJobs()
      result = receive_message(GetRetiredJobs_result)
      return result.success unless result.success.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getRetiredJobs failed: unknown result')
    end

    def getJobs(ids)
      send_getJobs(ids)
      return recv_getJobs()
    end

    def send_getJobs(ids)
      send_message('getJobs', GetJobs_args, :ids => ids)
    end

    def recv_getJobs()
      result = receive_message(GetJobs_result)
      return result.success unless result.success.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getJobs failed: unknown result')
    end

    def pause()
      send_pause()
      recv_pause()
    end

    def send_pause()
      send_message('pause', Pause_args)
    end

    def recv_pause()
      result = receive_message(Pause_result)
      return
    end

    def resume()
      send_resume()
      recv_resume()
    end

    def send_resume()
      send_message('resume', Resume_args)
    end

    def recv_resume()
      result = receive_message(Resume_result)
      return
    end

    def getLag()
      send_getLag()
      return recv_getLag()
    end

    def send_getLag()
      send_message('getLag', GetLag_args)
    end

    def recv_getLag()
      result = receive_message(GetLag_result)
      return result.success unless result.success.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getLag failed: unknown result')
    end

  end

  class Processor
    include ::Thrift::Processor

    def process_getActiveJobs(seqid, iprot, oprot)
      args = read_args(iprot, GetActiveJobs_args)
      result = GetActiveJobs_result.new()
      result.success = @handler.getActiveJobs(args.afterId, args.maxJobs)
      write_result(result, oprot, 'getActiveJobs', seqid)
    end

    def process_getRetiredJobs(seqid, iprot, oprot)
      args = read_args(iprot, GetRetiredJobs_args)
      result = GetRetiredJobs_result.new()
      result.success = @handler.getRetiredJobs(args.afterId, args.maxJobs)
      write_result(result, oprot, 'getRetiredJobs', seqid)
    end

    def process_getJobs(seqid, iprot, oprot)
      args = read_args(iprot, GetJobs_args)
      result = GetJobs_result.new()
      result.success = @handler.getJobs(args.ids)
      write_result(result, oprot, 'getJobs', seqid)
    end

    def process_pause(seqid, iprot, oprot)
      args = read_args(iprot, Pause_args)
      result = Pause_result.new()
      @handler.pause()
      write_result(result, oprot, 'pause', seqid)
    end

    def process_resume(seqid, iprot, oprot)
      args = read_args(iprot, Resume_args)
      result = Resume_result.new()
      @handler.resume()
      write_result(result, oprot, 'resume', seqid)
    end

    def process_getLag(seqid, iprot, oprot)
      args = read_args(iprot, GetLag_args)
      result = GetLag_result.new()
      result.success = @handler.getLag()
      write_result(result, oprot, 'getLag', seqid)
    end

  end

  # HELPER FUNCTIONS AND STRUCTURES

  class GetActiveJobs_args
    include ::Thrift::Struct, ::Thrift::Struct_Union
    AFTERID = 1
    MAXJOBS = 2

    FIELDS = {
      AFTERID => {:type => ::Thrift::Types::I64, :name => 'afterId'},
      MAXJOBS => {:type => ::Thrift::Types::I32, :name => 'maxJobs'}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class GetActiveJobs_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => ::TReplicationJob}}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class GetRetiredJobs_args
    include ::Thrift::Struct, ::Thrift::Struct_Union
    AFTERID = 1
    MAXJOBS = 2

    FIELDS = {
      AFTERID => {:type => ::Thrift::Types::I64, :name => 'afterId'},
      MAXJOBS => {:type => ::Thrift::Types::I32, :name => 'maxJobs'}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class GetRetiredJobs_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => ::TReplicationJob}}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class GetJobs_args
    include ::Thrift::Struct, ::Thrift::Struct_Union
    IDS = 1

    FIELDS = {
      IDS => {:type => ::Thrift::Types::LIST, :name => 'ids', :element => {:type => ::Thrift::Types::I64}}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class GetJobs_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::MAP, :name => 'success', :key => {:type => ::Thrift::Types::I64}, :value => {:type => ::Thrift::Types::STRUCT, :class => ::TReplicationJob}}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Pause_args
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Pause_result
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Resume_args
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Resume_result
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class GetLag_args
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class GetLag_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

end

