You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

230 lines
6.6 KiB

2 years ago
  1. =begin
  2. #Seaweedfs Master Server API
  3. #The Seaweedfs Master Server API allows you to store blobs
  4. The version of the OpenAPI document: 3.43.0
  5. Generated by: https://openapi-generator.tech
  6. OpenAPI Generator version: 6.4.0
  7. =end
  8. require 'date'
  9. require 'time'
  10. module OpenapiClient
  11. class Location
  12. attr_accessor :public_url
  13. attr_accessor :url
  14. # Attribute mapping from ruby-style variable name to JSON key.
  15. def self.attribute_map
  16. {
  17. :'public_url' => :'publicUrl',
  18. :'url' => :'url'
  19. }
  20. end
  21. # Returns all the JSON keys this model knows about
  22. def self.acceptable_attributes
  23. attribute_map.values
  24. end
  25. # Attribute type mapping.
  26. def self.openapi_types
  27. {
  28. :'public_url' => :'Object',
  29. :'url' => :'Object'
  30. }
  31. end
  32. # List of attributes with nullable: true
  33. def self.openapi_nullable
  34. Set.new([
  35. :'public_url',
  36. :'url'
  37. ])
  38. end
  39. # Initializes the object
  40. # @param [Hash] attributes Model attributes in the form of hash
  41. def initialize(attributes = {})
  42. if (!attributes.is_a?(Hash))
  43. fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Location` initialize method"
  44. end
  45. # check to see if the attribute exists and convert string to symbol for hash key
  46. attributes = attributes.each_with_object({}) { |(k, v), h|
  47. if (!self.class.attribute_map.key?(k.to_sym))
  48. fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Location`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
  49. end
  50. h[k.to_sym] = v
  51. }
  52. if attributes.key?(:'public_url')
  53. self.public_url = attributes[:'public_url']
  54. end
  55. if attributes.key?(:'url')
  56. self.url = attributes[:'url']
  57. end
  58. end
  59. # Show invalid properties with the reasons. Usually used together with valid?
  60. # @return Array for valid properties with the reasons
  61. def list_invalid_properties
  62. invalid_properties = Array.new
  63. invalid_properties
  64. end
  65. # Check to see if the all the properties in the model are valid
  66. # @return true if the model is valid
  67. def valid?
  68. true
  69. end
  70. # Checks equality by comparing each attribute.
  71. # @param [Object] Object to be compared
  72. def ==(o)
  73. return true if self.equal?(o)
  74. self.class == o.class &&
  75. public_url == o.public_url &&
  76. url == o.url
  77. end
  78. # @see the `==` method
  79. # @param [Object] Object to be compared
  80. def eql?(o)
  81. self == o
  82. end
  83. # Calculates hash code according to all attributes.
  84. # @return [Integer] Hash code
  85. def hash
  86. [public_url, url].hash
  87. end
  88. # Builds the object from hash
  89. # @param [Hash] attributes Model attributes in the form of hash
  90. # @return [Object] Returns the model itself
  91. def self.build_from_hash(attributes)
  92. new.build_from_hash(attributes)
  93. end
  94. # Builds the object from hash
  95. # @param [Hash] attributes Model attributes in the form of hash
  96. # @return [Object] Returns the model itself
  97. def build_from_hash(attributes)
  98. return nil unless attributes.is_a?(Hash)
  99. attributes = attributes.transform_keys(&:to_sym)
  100. self.class.openapi_types.each_pair do |key, type|
  101. if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
  102. self.send("#{key}=", nil)
  103. elsif type =~ /\AArray<(.*)>/i
  104. # check to ensure the input is an array given that the attribute
  105. # is documented as an array but the input is not
  106. if attributes[self.class.attribute_map[key]].is_a?(Array)
  107. self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
  108. end
  109. elsif !attributes[self.class.attribute_map[key]].nil?
  110. self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
  111. end
  112. end
  113. self
  114. end
  115. # Deserializes the data based on type
  116. # @param string type Data type
  117. # @param string value Value to be deserialized
  118. # @return [Object] Deserialized data
  119. def _deserialize(type, value)
  120. case type.to_sym
  121. when :Time
  122. Time.parse(value)
  123. when :Date
  124. Date.parse(value)
  125. when :String
  126. value.to_s
  127. when :Integer
  128. value.to_i
  129. when :Float
  130. value.to_f
  131. when :Boolean
  132. if value.to_s =~ /\A(true|t|yes|y|1)\z/i
  133. true
  134. else
  135. false
  136. end
  137. when :Object
  138. # generic object (usually a Hash), return directly
  139. value
  140. when /\AArray<(?<inner_type>.+)>\z/
  141. inner_type = Regexp.last_match[:inner_type]
  142. value.map { |v| _deserialize(inner_type, v) }
  143. when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
  144. k_type = Regexp.last_match[:k_type]
  145. v_type = Regexp.last_match[:v_type]
  146. {}.tap do |hash|
  147. value.each do |k, v|
  148. hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
  149. end
  150. end
  151. else # model
  152. # models (e.g. Pet) or oneOf
  153. klass = OpenapiClient.const_get(type)
  154. klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  155. end
  156. end
  157. # Returns the string representation of the object
  158. # @return [String] String presentation of the object
  159. def to_s
  160. to_hash.to_s
  161. end
  162. # to_body is an alias to to_hash (backward compatibility)
  163. # @return [Hash] Returns the object in the form of hash
  164. def to_body
  165. to_hash
  166. end
  167. # Returns the object in the form of hash
  168. # @return [Hash] Returns the object in the form of hash
  169. def to_hash
  170. hash = {}
  171. self.class.attribute_map.each_pair do |attr, param|
  172. value = self.send(attr)
  173. if value.nil?
  174. is_nullable = self.class.openapi_nullable.include?(attr)
  175. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  176. end
  177. hash[param] = _to_hash(value)
  178. end
  179. hash
  180. end
  181. # Outputs non-array value in the form of hash
  182. # For object, use to_hash. Otherwise, just return the value
  183. # @param [Object] value Any valid value
  184. # @return [Hash] Returns the value in the form of hash
  185. def _to_hash(value)
  186. if value.is_a?(Array)
  187. value.compact.map { |v| _to_hash(v) }
  188. elsif value.is_a?(Hash)
  189. {}.tap do |hash|
  190. value.each { |k, v| hash[k] = _to_hash(v) }
  191. end
  192. elsif value.respond_to? :to_hash
  193. value.to_hash
  194. else
  195. value
  196. end
  197. end
  198. end
  199. end