=begin #Cloudsmith API (v1) #The API to the Cloudsmith Service OpenAPI spec version: v1 Contact: support@cloudsmith.io Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.43 =end require 'date' module CloudsmithApi class RepositoryAuditLog attr_accessor :actor attr_accessor :actor_ip_address attr_accessor :actor_kind attr_accessor :actor_location attr_accessor :actor_slug_perm attr_accessor :actor_url attr_accessor :context attr_accessor :event attr_accessor :event_at attr_accessor :object attr_accessor :object_kind attr_accessor :object_slug_perm attr_accessor :uuid # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'actor' => :'actor', :'actor_ip_address' => :'actor_ip_address', :'actor_kind' => :'actor_kind', :'actor_location' => :'actor_location', :'actor_slug_perm' => :'actor_slug_perm', :'actor_url' => :'actor_url', :'context' => :'context', :'event' => :'event', :'event_at' => :'event_at', :'object' => :'object', :'object_kind' => :'object_kind', :'object_slug_perm' => :'object_slug_perm', :'uuid' => :'uuid' } end # Attribute type mapping. def self.swagger_types { :'actor' => :'String', :'actor_ip_address' => :'String', :'actor_kind' => :'String', :'actor_location' => :'GeoIpLocation', :'actor_slug_perm' => :'String', :'actor_url' => :'String', :'context' => :'String', :'event' => :'String', :'event_at' => :'DateTime', :'object' => :'String', :'object_kind' => :'String', :'object_slug_perm' => :'String', :'uuid' => :'String' } end # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'actor') self.actor = attributes[:'actor'] end if attributes.has_key?(:'actor_ip_address') self.actor_ip_address = attributes[:'actor_ip_address'] end if attributes.has_key?(:'actor_kind') self.actor_kind = attributes[:'actor_kind'] end if attributes.has_key?(:'actor_location') self.actor_location = attributes[:'actor_location'] end if attributes.has_key?(:'actor_slug_perm') self.actor_slug_perm = attributes[:'actor_slug_perm'] end if attributes.has_key?(:'actor_url') self.actor_url = attributes[:'actor_url'] end if attributes.has_key?(:'context') self.context = attributes[:'context'] end if attributes.has_key?(:'event') self.event = attributes[:'event'] end if attributes.has_key?(:'event_at') self.event_at = attributes[:'event_at'] end if attributes.has_key?(:'object') self.object = attributes[:'object'] end if attributes.has_key?(:'object_kind') self.object_kind = attributes[:'object_kind'] end if attributes.has_key?(:'object_slug_perm') self.object_slug_perm = attributes[:'object_slug_perm'] end if attributes.has_key?(:'uuid') self.uuid = attributes[:'uuid'] end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new if @actor.nil? invalid_properties.push('invalid value for "actor", actor cannot be nil.') end if @actor_ip_address.nil? invalid_properties.push('invalid value for "actor_ip_address", actor_ip_address cannot be nil.') end if @actor_location.nil? invalid_properties.push('invalid value for "actor_location", actor_location cannot be nil.') end if @actor_slug_perm.nil? invalid_properties.push('invalid value for "actor_slug_perm", actor_slug_perm cannot be nil.') end if @context.nil? invalid_properties.push('invalid value for "context", context cannot be nil.') end if @event.nil? invalid_properties.push('invalid value for "event", event cannot be nil.') end if @event_at.nil? invalid_properties.push('invalid value for "event_at", event_at cannot be nil.') end if @object.nil? invalid_properties.push('invalid value for "object", object cannot be nil.') end if @object_kind.nil? invalid_properties.push('invalid value for "object_kind", object_kind cannot be nil.') end if @object_slug_perm.nil? invalid_properties.push('invalid value for "object_slug_perm", object_slug_perm cannot be nil.') end invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? return false if @actor.nil? return false if @actor_ip_address.nil? return false if @actor_location.nil? return false if @actor_slug_perm.nil? return false if @context.nil? return false if @event.nil? return false if @event_at.nil? return false if @object.nil? return false if @object_kind.nil? return false if @object_slug_perm.nil? true end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && actor == o.actor && actor_ip_address == o.actor_ip_address && actor_kind == o.actor_kind && actor_location == o.actor_location && actor_slug_perm == o.actor_slug_perm && actor_url == o.actor_url && context == o.context && event == o.event && event_at == o.event_at && object == o.object && object_kind == o.object_kind && object_slug_perm == o.object_slug_perm && uuid == o.uuid end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash [actor, actor_ip_address, actor_kind, actor_location, actor_slug_perm, actor_url, context, event, event_at, object, object_kind, object_slug_perm, uuid].hash end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end # Deserializes the data based on type # @param string type Data type # @param string value Value to be deserialized # @return [Object] Deserialized data 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 =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value 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 temp_model = CloudsmithApi.const_get(type).new temp_model.build_from_hash(value) end end # Returns the string representation of the object # @return [String] String presentation of the object def to_s to_hash.to_s end # to_body is an alias to to_hash (backward compatibility) # @return [Hash] Returns the object in the form of hash def to_body to_hash end # Returns the object in the form of hash # @return [Hash] Returns 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 # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash 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