=begin Titan API The ultimate, language agnostic, container based job processing framework. OpenAPI spec version: 0.0.4 Generated by: https://github.com/swagger-api/swagger-codegen.git =end require 'date' module IronTitan class Job # Docker image to use for job. attr_accessor :image # Time when job was submitted. attr_accessor :created_at # Priority of the job. 3 levels from 0-2. Default 0. attr_accessor :priority # Сorresponding error message, only when status=='error'. attr_accessor :error # Maximum runtime in seconds. If job runs for longer, it will be killed. Default 60 seconds. attr_accessor :timeout # Number of retries. Default 3. attr_accessor :retries # Time when job completed, whether it was successul or failed. attr_accessor :completed_at # Number of seconds to wait before starting. Default 0. attr_accessor :delay # Payload for the job. This is what you pass into each job to make it do something. attr_accessor :payload # Docker image to use for job. Default is 'image' attr_accessor :name # Time when job started execution. attr_accessor :started_at # Unique identifier representing a specific job. attr_accessor :id # Status of job. One of: [pending, running, success, error, timeout] attr_accessor :status # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'image' => :'image', :'created_at' => :'created_at', :'priority' => :'priority', :'error' => :'error', :'timeout' => :'timeout', :'retries' => :'retries', :'completed_at' => :'completed_at', :'delay' => :'delay', :'payload' => :'payload', :'name' => :'name', :'started_at' => :'started_at', :'id' => :'id', :'status' => :'status' } end # Attribute type mapping. def self.swagger_types { :'image' => :'String', :'created_at' => :'DateTime', :'priority' => :'Integer', :'error' => :'String', :'timeout' => :'Integer', :'retries' => :'Integer', :'completed_at' => :'DateTime', :'delay' => :'Integer', :'payload' => :'String', :'name' => :'String', :'started_at' => :'DateTime', :'id' => :'String', :'status' => :'String' } end def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} if attributes[:'image'] self.image = attributes[:'image'] end if attributes[:'created_at'] self.created_at = attributes[:'created_at'] end if attributes[:'priority'] self.priority = attributes[:'priority'] end if attributes[:'error'] self.error = attributes[:'error'] end if attributes[:'timeout'] self.timeout = attributes[:'timeout'] end if attributes[:'retries'] self.retries = attributes[:'retries'] end if attributes[:'completed_at'] self.completed_at = attributes[:'completed_at'] end if attributes[:'delay'] self.delay = attributes[:'delay'] end if attributes[:'payload'] self.payload = attributes[:'payload'] end if attributes[:'name'] self.name = attributes[:'name'] end if attributes[:'started_at'] self.started_at = attributes[:'started_at'] end if attributes[:'id'] self.id = attributes[:'id'] end if attributes[:'status'] self.status = attributes[:'status'] end end # Check equality by comparing each attribute. def ==(o) return true if self.equal?(o) self.class == o.class && image == o.image && created_at == o.created_at && priority == o.priority && error == o.error && timeout == o.timeout && retries == o.retries && completed_at == o.completed_at && delay == o.delay && payload == o.payload && name == o.name && started_at == o.started_at && id == o.id && status == o.status end # @see the `==` method def eql?(o) self == o end # Calculate hash code according to all attributes. def hash [image, created_at, priority, error, timeout, retries, completed_at, delay, payload, name, started_at, id, status].hash end # build the object from hash def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) else #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) else # data not found in attributes(hash), not an issue as the data can be optional end end self end def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /^(true|t|yes|y|1)$/i true else false end when /\AArray<(?.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?.+), (?.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model _model = IronTitan.const_get(type).new _model.build_from_hash(value) end end def to_s to_hash.to_s end # to_body is an alias to to_body (backward compatibility)) def to_body to_hash end # return the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end # Method to output non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end end end