lib/cloudsmith-api/models/files_validate.rb in cloudsmith-api-1.61.3 vs lib/cloudsmith-api/models/files_validate.rb in cloudsmith-api-1.120.3

- old
+ new

@@ -24,10 +24,32 @@ attr_accessor :method # SHA256 checksum for a PUT-based package file upload. attr_accessor :sha256_checksum + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'filename' => :'filename', :'md5_checksum' => :'md5_checksum', @@ -84,10 +106,22 @@ # 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 @filename.nil? + method_validator = EnumAttributeValidator.new('String', ['put_parts', 'put', 'post', 'presigned', 'unsigned_put']) + return false unless method_validator.valid?(@method) true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] method Object to be assigned + def method=(method) + validator = EnumAttributeValidator.new('String', ['put_parts', 'put', 'post', 'presigned', 'unsigned_put']) + unless validator.valid?(method) + fail ArgumentError, 'invalid value for "method", must be one of #{validator.allowable_values}.' + end + @method = method end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o)