=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 RepositoryToken # The datetime the token was updated at. attr_accessor :created_at # attr_accessor :created_by # attr_accessor :created_by_url # If selected this is the default token for this repository. attr_accessor :default # attr_accessor :has_limits # attr_accessor :identifier # If enabled, the token will allow downloads based on configured restrictions (if any). attr_accessor :is_active # attr_accessor :is_limited # The starting date/time the token is allowed to be used from. attr_accessor :limit_date_range_from # The ending date/time the token is allowed to be used until. attr_accessor :limit_date_range_to # The maximum number of unique clients allowed for the token. Please note that since clients are calculated asynchronously (after the download happens), the limit may not be imposed immediately but at a later point. attr_accessor :limit_num_clients # The maximum number of downloads allowed for the token. Please note that since downloads are calculated asynchronously (after the download happens), the limit may not be imposed immediately but at a later point. attr_accessor :limit_num_downloads # The package-based search query to apply to restrict downloads to. This uses the same syntax as the standard search used for repositories, and also supports boolean logic operators such as OR/AND/NOT and parentheses for grouping. This will still allow access to non-package files, such as metadata. For package formats that support dynamic metadata indexes, the contents of the metadata will also be filtered. attr_accessor :limit_package_query # The path-based search query to apply to restrict downloads to. This supports boolean logic operators such as OR/AND/NOT and parentheses for grouping. The path evaluated does not include the domain name, the namespace, the entitlement code used, the package format, etc. and it always starts with a forward slash. attr_accessor :limit_path_query # attr_accessor :metadata # attr_accessor :name # attr_accessor :refresh_url # attr_accessor :self_url # attr_accessor :slug_perm # attr_accessor :token # The datetime the token was updated at. attr_accessor :updated_at # attr_accessor :updated_by # attr_accessor :updated_by_url # attr_accessor :user # attr_accessor :user_url # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'created_at' => :'created_at', :'created_by' => :'created_by', :'created_by_url' => :'created_by_url', :'default' => :'default', :'has_limits' => :'has_limits', :'identifier' => :'identifier', :'is_active' => :'is_active', :'is_limited' => :'is_limited', :'limit_date_range_from' => :'limit_date_range_from', :'limit_date_range_to' => :'limit_date_range_to', :'limit_num_clients' => :'limit_num_clients', :'limit_num_downloads' => :'limit_num_downloads', :'limit_package_query' => :'limit_package_query', :'limit_path_query' => :'limit_path_query', :'metadata' => :'metadata', :'name' => :'name', :'refresh_url' => :'refresh_url', :'self_url' => :'self_url', :'slug_perm' => :'slug_perm', :'token' => :'token', :'updated_at' => :'updated_at', :'updated_by' => :'updated_by', :'updated_by_url' => :'updated_by_url', :'user' => :'user', :'user_url' => :'user_url' } end # Attribute type mapping. def self.swagger_types { :'created_at' => :'String', :'created_by' => :'String', :'created_by_url' => :'String', :'default' => :'BOOLEAN', :'has_limits' => :'String', :'identifier' => :'Integer', :'is_active' => :'BOOLEAN', :'is_limited' => :'String', :'limit_date_range_from' => :'String', :'limit_date_range_to' => :'String', :'limit_num_clients' => :'Integer', :'limit_num_downloads' => :'Integer', :'limit_package_query' => :'String', :'limit_path_query' => :'String', :'metadata' => :'Object', :'name' => :'String', :'refresh_url' => :'String', :'self_url' => :'String', :'slug_perm' => :'String', :'token' => :'String', :'updated_at' => :'String', :'updated_by' => :'String', :'updated_by_url' => :'String', :'user' => :'String', :'user_url' => :'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?(:'created_at') self.created_at = attributes[:'created_at'] end if attributes.has_key?(:'created_by') self.created_by = attributes[:'created_by'] end if attributes.has_key?(:'created_by_url') self.created_by_url = attributes[:'created_by_url'] end if attributes.has_key?(:'default') self.default = attributes[:'default'] end if attributes.has_key?(:'has_limits') self.has_limits = attributes[:'has_limits'] end if attributes.has_key?(:'identifier') self.identifier = attributes[:'identifier'] end if attributes.has_key?(:'is_active') self.is_active = attributes[:'is_active'] end if attributes.has_key?(:'is_limited') self.is_limited = attributes[:'is_limited'] end if attributes.has_key?(:'limit_date_range_from') self.limit_date_range_from = attributes[:'limit_date_range_from'] end if attributes.has_key?(:'limit_date_range_to') self.limit_date_range_to = attributes[:'limit_date_range_to'] end if attributes.has_key?(:'limit_num_clients') self.limit_num_clients = attributes[:'limit_num_clients'] end if attributes.has_key?(:'limit_num_downloads') self.limit_num_downloads = attributes[:'limit_num_downloads'] end if attributes.has_key?(:'limit_package_query') self.limit_package_query = attributes[:'limit_package_query'] end if attributes.has_key?(:'limit_path_query') self.limit_path_query = attributes[:'limit_path_query'] end if attributes.has_key?(:'metadata') self.metadata = attributes[:'metadata'] end if attributes.has_key?(:'name') self.name = attributes[:'name'] end if attributes.has_key?(:'refresh_url') self.refresh_url = attributes[:'refresh_url'] end if attributes.has_key?(:'self_url') self.self_url = attributes[:'self_url'] end if attributes.has_key?(:'slug_perm') self.slug_perm = attributes[:'slug_perm'] end if attributes.has_key?(:'token') self.token = attributes[:'token'] end if attributes.has_key?(:'updated_at') self.updated_at = attributes[:'updated_at'] end if attributes.has_key?(:'updated_by') self.updated_by = attributes[:'updated_by'] end if attributes.has_key?(:'updated_by_url') self.updated_by_url = attributes[:'updated_by_url'] end if attributes.has_key?(:'user') self.user = attributes[:'user'] end if attributes.has_key?(:'user_url') self.user_url = attributes[:'user_url'] 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 @name.nil? invalid_properties.push("invalid value for 'name', name 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 @name.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 && created_at == o.created_at && created_by == o.created_by && created_by_url == o.created_by_url && default == o.default && has_limits == o.has_limits && identifier == o.identifier && is_active == o.is_active && is_limited == o.is_limited && limit_date_range_from == o.limit_date_range_from && limit_date_range_to == o.limit_date_range_to && limit_num_clients == o.limit_num_clients && limit_num_downloads == o.limit_num_downloads && limit_package_query == o.limit_package_query && limit_path_query == o.limit_path_query && metadata == o.metadata && name == o.name && refresh_url == o.refresh_url && self_url == o.self_url && slug_perm == o.slug_perm && token == o.token && updated_at == o.updated_at && updated_by == o.updated_by && updated_by_url == o.updated_by_url && user == o.user && user_url == o.user_url 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 [created_at, created_by, created_by_url, default, has_limits, identifier, is_active, is_limited, limit_date_range_from, limit_date_range_to, limit_num_clients, limit_num_downloads, limit_package_query, limit_path_query, metadata, name, refresh_url, self_url, slug_perm, token, updated_at, updated_by, updated_by_url, user, user_url].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