=begin #Cloudsmith API #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.2.3 =end require 'date' module CloudsmithApi class Repository # attr_accessor :cdn_url # attr_accessor :self_url # attr_accessor :repository_type_str # attr_accessor :description # The identifier used by GPG for this key. attr_accessor :gpg_fingerprint # If checked, files contained in packages will be indexed, which increase the synchronisation time required for packages. Note that it is recommended you keep this enabled unless the synchronisation time is significantly impacted. attr_accessor :index_files # A descriptive name for the repository. attr_accessor :name # attr_accessor :created_at # attr_accessor :is_open_source # attr_accessor :namespace # attr_accessor :self_html_url # The public key given to repo users. attr_accessor :gpg_public_key # attr_accessor :namespace_url # attr_accessor :slug_perm # attr_accessor :is_public # attr_accessor :deleted_at # The repository type changes how it is accessed and billed. Private repositories can only be used on paid plans, but are visible only to you or authorised delegates. Open-Source repositories are always visible to everyone and are restricted by licensing, but are free to use and come with generous bandwidth/storage. You can only select Open-Source at repository creation time. attr_accessor :repository_type # The slug identifies the repository in URIs. attr_accessor :slug # attr_accessor :is_private # The calculated size of the repository. attr_accessor :size # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'cdn_url' => :'cdn_url', :'self_url' => :'self_url', :'repository_type_str' => :'repository_type_str', :'description' => :'description', :'gpg_fingerprint' => :'gpg_fingerprint', :'index_files' => :'index_files', :'name' => :'name', :'created_at' => :'created_at', :'is_open_source' => :'is_open_source', :'namespace' => :'namespace', :'self_html_url' => :'self_html_url', :'gpg_public_key' => :'gpg_public_key', :'namespace_url' => :'namespace_url', :'slug_perm' => :'slug_perm', :'is_public' => :'is_public', :'deleted_at' => :'deleted_at', :'repository_type' => :'repository_type', :'slug' => :'slug', :'is_private' => :'is_private', :'size' => :'size' } end # Attribute type mapping. def self.swagger_types { :'cdn_url' => :'String', :'self_url' => :'String', :'repository_type_str' => :'String', :'description' => :'String', :'gpg_fingerprint' => :'String', :'index_files' => :'BOOLEAN', :'name' => :'String', :'created_at' => :'String', :'is_open_source' => :'BOOLEAN', :'namespace' => :'String', :'self_html_url' => :'String', :'gpg_public_key' => :'String', :'namespace_url' => :'String', :'slug_perm' => :'String', :'is_public' => :'BOOLEAN', :'deleted_at' => :'String', :'repository_type' => :'String', :'slug' => :'String', :'is_private' => :'BOOLEAN', :'size' => :'Integer' } 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?(:'cdn_url') self.cdn_url = attributes[:'cdn_url'] end if attributes.has_key?(:'self_url') self.self_url = attributes[:'self_url'] end if attributes.has_key?(:'repository_type_str') self.repository_type_str = attributes[:'repository_type_str'] end if attributes.has_key?(:'description') self.description = attributes[:'description'] end if attributes.has_key?(:'gpg_fingerprint') self.gpg_fingerprint = attributes[:'gpg_fingerprint'] end if attributes.has_key?(:'index_files') self.index_files = attributes[:'index_files'] end if attributes.has_key?(:'name') self.name = attributes[:'name'] end if attributes.has_key?(:'created_at') self.created_at = attributes[:'created_at'] end if attributes.has_key?(:'is_open_source') self.is_open_source = attributes[:'is_open_source'] end if attributes.has_key?(:'namespace') self.namespace = attributes[:'namespace'] end if attributes.has_key?(:'self_html_url') self.self_html_url = attributes[:'self_html_url'] end if attributes.has_key?(:'gpg_public_key') self.gpg_public_key = attributes[:'gpg_public_key'] end if attributes.has_key?(:'namespace_url') self.namespace_url = attributes[:'namespace_url'] end if attributes.has_key?(:'slug_perm') self.slug_perm = attributes[:'slug_perm'] end if attributes.has_key?(:'is_public') self.is_public = attributes[:'is_public'] end if attributes.has_key?(:'deleted_at') self.deleted_at = attributes[:'deleted_at'] end if attributes.has_key?(:'repository_type') self.repository_type = attributes[:'repository_type'] end if attributes.has_key?(:'slug') self.slug = attributes[:'slug'] end if attributes.has_key?(:'is_private') self.is_private = attributes[:'is_private'] end if attributes.has_key?(:'size') self.size = attributes[:'size'] end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properies with the reasons def list_invalid_properties invalid_properties = Array.new if @description.nil? invalid_properties.push("invalid value for 'description', description cannot be nil.") end if @is_open_source.nil? invalid_properties.push("invalid value for 'is_open_source', is_open_source cannot be nil.") end if @namespace.nil? invalid_properties.push("invalid value for 'namespace', namespace cannot be nil.") end if @is_public.nil? invalid_properties.push("invalid value for 'is_public', is_public cannot be nil.") end if @is_private.nil? invalid_properties.push("invalid value for 'is_private', is_private cannot be nil.") end return 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 @description.nil? return false if @is_open_source.nil? return false if @namespace.nil? return false if @is_public.nil? return false if @is_private.nil? return 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 && cdn_url == o.cdn_url && self_url == o.self_url && repository_type_str == o.repository_type_str && description == o.description && gpg_fingerprint == o.gpg_fingerprint && index_files == o.index_files && name == o.name && created_at == o.created_at && is_open_source == o.is_open_source && namespace == o.namespace && self_html_url == o.self_html_url && gpg_public_key == o.gpg_public_key && namespace_url == o.namespace_url && slug_perm == o.slug_perm && is_public == o.is_public && deleted_at == o.deleted_at && repository_type == o.repository_type && slug == o.slug && is_private == o.is_private && size == o.size 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 [cdn_url, self_url, repository_type_str, description, gpg_fingerprint, index_files, name, created_at, is_open_source, namespace, self_html_url, gpg_public_key, namespace_url, slug_perm, is_public, deleted_at, repository_type, slug, is_private, size].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 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