imgwire 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/AGENTS.md +8 -0
  3. data/CODEGEN_VERSION +1 -0
  4. data/LICENSE +21 -0
  5. data/README.md +159 -0
  6. data/generated/lib/imgwire-generated/api/cors_origins_api.rb +355 -0
  7. data/generated/lib/imgwire-generated/api/custom_domain_api.rb +253 -0
  8. data/generated/lib/imgwire-generated/api/images_api.rb +534 -0
  9. data/generated/lib/imgwire-generated/api/metrics_api.rb +156 -0
  10. data/generated/lib/imgwire-generated/api_client.rb +392 -0
  11. data/generated/lib/imgwire-generated/api_error.rb +58 -0
  12. data/generated/lib/imgwire-generated/configuration.rb +301 -0
  13. data/generated/lib/imgwire-generated/models/bulk_delete_images_schema.rb +248 -0
  14. data/generated/lib/imgwire-generated/models/cache_hit_ratio_dataset_point_schema.rb +263 -0
  15. data/generated/lib/imgwire-generated/models/cors_origin_create_schema.rb +246 -0
  16. data/generated/lib/imgwire-generated/models/cors_origin_schema.rb +341 -0
  17. data/generated/lib/imgwire-generated/models/cors_origin_update_schema.rb +246 -0
  18. data/generated/lib/imgwire-generated/models/custom_domain_certificate_status.rb +41 -0
  19. data/generated/lib/imgwire-generated/models/custom_domain_create_schema.rb +237 -0
  20. data/generated/lib/imgwire-generated/models/custom_domain_schema.rb +531 -0
  21. data/generated/lib/imgwire-generated/models/custom_domain_status.rb +41 -0
  22. data/generated/lib/imgwire-generated/models/custom_metadata_value.rb +106 -0
  23. data/generated/lib/imgwire-generated/models/http_validation_error.rb +222 -0
  24. data/generated/lib/imgwire-generated/models/image_download_job_create_schema.rb +248 -0
  25. data/generated/lib/imgwire-generated/models/image_download_job_schema.rb +389 -0
  26. data/generated/lib/imgwire-generated/models/image_download_status.rb +42 -0
  27. data/generated/lib/imgwire-generated/models/image_schema.rb +659 -0
  28. data/generated/lib/imgwire-generated/models/image_status.rb +42 -0
  29. data/generated/lib/imgwire-generated/models/location_inner.rb +104 -0
  30. data/generated/lib/imgwire-generated/models/metrics_dataset_interval.rb +42 -0
  31. data/generated/lib/imgwire-generated/models/metrics_datasets_schema.rb +379 -0
  32. data/generated/lib/imgwire-generated/models/metrics_stat_value_schema.rb +275 -0
  33. data/generated/lib/imgwire-generated/models/metrics_stats_schema.rb +367 -0
  34. data/generated/lib/imgwire-generated/models/requests_dataset_point_schema.rb +263 -0
  35. data/generated/lib/imgwire-generated/models/standard_upload_create_schema.rb +415 -0
  36. data/generated/lib/imgwire-generated/models/standard_upload_response_schema.rb +263 -0
  37. data/generated/lib/imgwire-generated/models/storage_bytes_dataset_point_schema.rb +289 -0
  38. data/generated/lib/imgwire-generated/models/supported_mime_type.rb +43 -0
  39. data/generated/lib/imgwire-generated/models/transfer_bytes_dataset_point_schema.rb +263 -0
  40. data/generated/lib/imgwire-generated/models/transformations_dataset_point_schema.rb +263 -0
  41. data/generated/lib/imgwire-generated/models/upload_token_create_response_schema.rb +379 -0
  42. data/generated/lib/imgwire-generated/models/uploads_dataset_point_schema.rb +263 -0
  43. data/generated/lib/imgwire-generated/models/validation_error.rb +291 -0
  44. data/generated/lib/imgwire-generated/version.rb +15 -0
  45. data/generated/lib/imgwire-generated.rb +74 -0
  46. data/lib/imgwire/client.rb +52 -0
  47. data/lib/imgwire/client_options.rb +14 -0
  48. data/lib/imgwire/http/upload_client.rb +53 -0
  49. data/lib/imgwire/image.rb +137 -0
  50. data/lib/imgwire/pagination.rb +82 -0
  51. data/lib/imgwire/resources/base_resource.rb +29 -0
  52. data/lib/imgwire/resources/cors_origins_resource.rb +47 -0
  53. data/lib/imgwire/resources/custom_domain_resource.rb +30 -0
  54. data/lib/imgwire/resources/images_resource.rb +106 -0
  55. data/lib/imgwire/resources/metrics_resource.rb +24 -0
  56. data/lib/imgwire/uploads.rb +78 -0
  57. data/lib/imgwire/version.rb +5 -0
  58. data/lib/imgwire.rb +18 -0
  59. metadata +158 -0
@@ -0,0 +1,263 @@
1
+ =begin
2
+ #imgwire.dev Backend API development
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.14.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module ImgwireGenerated
17
+ class RequestsDatasetPointSchema
18
+ attr_accessor :requests
19
+
20
+ attr_accessor :timestamp
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'requests' => :'requests',
26
+ :'timestamp' => :'timestamp'
27
+ }
28
+ end
29
+
30
+ # Returns attribute mapping this model knows about
31
+ def self.acceptable_attribute_map
32
+ attribute_map
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ acceptable_attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'requests' => :'Integer',
44
+ :'timestamp' => :'Time'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ImgwireGenerated::RequestsDatasetPointSchema` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ acceptable_attribute_map = self.class.acceptable_attribute_map
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!acceptable_attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ImgwireGenerated::RequestsDatasetPointSchema`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'requests')
71
+ self.requests = attributes[:'requests']
72
+ else
73
+ self.requests = nil
74
+ end
75
+
76
+ if attributes.key?(:'timestamp')
77
+ self.timestamp = attributes[:'timestamp']
78
+ else
79
+ self.timestamp = nil
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
87
+ invalid_properties = Array.new
88
+ if @requests.nil?
89
+ invalid_properties.push('invalid value for "requests", requests cannot be nil.')
90
+ end
91
+
92
+ if @timestamp.nil?
93
+ invalid_properties.push('invalid value for "timestamp", timestamp cannot be nil.')
94
+ end
95
+
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ warn '[DEPRECATED] the `valid?` method is obsolete'
103
+ return false if @requests.nil?
104
+ return false if @timestamp.nil?
105
+ true
106
+ end
107
+
108
+ # Custom attribute writer method with validation
109
+ # @param [Object] requests Value to be assigned
110
+ def requests=(requests)
111
+ if requests.nil?
112
+ fail ArgumentError, 'requests cannot be nil'
113
+ end
114
+
115
+ @requests = requests
116
+ end
117
+
118
+ # Custom attribute writer method with validation
119
+ # @param [Object] timestamp Value to be assigned
120
+ def timestamp=(timestamp)
121
+ if timestamp.nil?
122
+ fail ArgumentError, 'timestamp cannot be nil'
123
+ end
124
+
125
+ @timestamp = timestamp
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(o)
131
+ return true if self.equal?(o)
132
+ self.class == o.class &&
133
+ requests == o.requests &&
134
+ timestamp == o.timestamp
135
+ end
136
+
137
+ # @see the `==` method
138
+ # @param [Object] Object to be compared
139
+ def eql?(o)
140
+ self == o
141
+ end
142
+
143
+ # Calculates hash code according to all attributes.
144
+ # @return [Integer] Hash code
145
+ def hash
146
+ [requests, timestamp].hash
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def self.build_from_hash(attributes)
153
+ return nil unless attributes.is_a?(Hash)
154
+ attributes = attributes.transform_keys(&:to_sym)
155
+ transformed_hash = {}
156
+ openapi_types.each_pair do |key, type|
157
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
158
+ transformed_hash["#{key}"] = nil
159
+ elsif type =~ /\AArray<(.*)>/i
160
+ # check to ensure the input is an array given that the attribute
161
+ # is documented as an array but the input is not
162
+ if attributes[attribute_map[key]].is_a?(Array)
163
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
164
+ end
165
+ elsif !attributes[attribute_map[key]].nil?
166
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
167
+ end
168
+ end
169
+ new(transformed_hash)
170
+ end
171
+
172
+ # Deserializes the data based on type
173
+ # @param string type Data type
174
+ # @param string value Value to be deserialized
175
+ # @return [Object] Deserialized data
176
+ def self._deserialize(type, value)
177
+ case type.to_sym
178
+ when :Time
179
+ Time.parse(value)
180
+ when :Date
181
+ Date.parse(value)
182
+ when :String
183
+ value.to_s
184
+ when :Integer
185
+ value.to_i
186
+ when :Float
187
+ value.to_f
188
+ when :Boolean
189
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
190
+ true
191
+ else
192
+ false
193
+ end
194
+ when :Object
195
+ # generic object (usually a Hash), return directly
196
+ value
197
+ when /\AArray<(?<inner_type>.+)>\z/
198
+ inner_type = Regexp.last_match[:inner_type]
199
+ value.map { |v| _deserialize(inner_type, v) }
200
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
201
+ k_type = Regexp.last_match[:k_type]
202
+ v_type = Regexp.last_match[:v_type]
203
+ {}.tap do |hash|
204
+ value.each do |k, v|
205
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
206
+ end
207
+ end
208
+ else # model
209
+ # models (e.g. Pet) or oneOf
210
+ klass = ImgwireGenerated.const_get(type)
211
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
212
+ end
213
+ end
214
+
215
+ # Returns the string representation of the object
216
+ # @return [String] String presentation of the object
217
+ def to_s
218
+ to_hash.to_s
219
+ end
220
+
221
+ # to_body is an alias to to_hash (backward compatibility)
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_body
224
+ to_hash
225
+ end
226
+
227
+ # Returns the object in the form of hash
228
+ # @return [Hash] Returns the object in the form of hash
229
+ def to_hash
230
+ hash = {}
231
+ self.class.attribute_map.each_pair do |attr, param|
232
+ value = self.send(attr)
233
+ if value.nil?
234
+ is_nullable = self.class.openapi_nullable.include?(attr)
235
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
236
+ end
237
+
238
+ hash[param] = _to_hash(value)
239
+ end
240
+ hash
241
+ end
242
+
243
+ # Outputs non-array value in the form of hash
244
+ # For object, use to_hash. Otherwise, just return the value
245
+ # @param [Object] value Any valid value
246
+ # @return [Hash] Returns the value in the form of hash
247
+ def _to_hash(value)
248
+ if value.is_a?(Array)
249
+ value.compact.map { |v| _to_hash(v) }
250
+ elsif value.is_a?(Hash)
251
+ {}.tap do |hash|
252
+ value.each { |k, v| hash[k] = _to_hash(v) }
253
+ end
254
+ elsif value.respond_to? :to_hash
255
+ value.to_hash
256
+ else
257
+ value
258
+ end
259
+ end
260
+
261
+ end
262
+
263
+ end
@@ -0,0 +1,415 @@
1
+ =begin
2
+ #imgwire.dev Backend API development
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.14.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module ImgwireGenerated
17
+ class StandardUploadCreateSchema
18
+ attr_accessor :content_length
19
+
20
+ attr_accessor :custom_metadata
21
+
22
+ attr_accessor :file_name
23
+
24
+ attr_accessor :hash_sha256
25
+
26
+ attr_accessor :idempotency_key
27
+
28
+ attr_accessor :mime_type
29
+
30
+ attr_accessor :purpose
31
+
32
+ class EnumAttributeValidator
33
+ attr_reader :datatype
34
+ attr_reader :allowable_values
35
+
36
+ def initialize(datatype, allowable_values)
37
+ @allowable_values = allowable_values.map do |value|
38
+ case datatype.to_s
39
+ when /Integer/i
40
+ value.to_i
41
+ when /Float/i
42
+ value.to_f
43
+ else
44
+ value
45
+ end
46
+ end
47
+ end
48
+
49
+ def valid?(value)
50
+ !value || allowable_values.include?(value)
51
+ end
52
+ end
53
+
54
+ # Attribute mapping from ruby-style variable name to JSON key.
55
+ def self.attribute_map
56
+ {
57
+ :'content_length' => :'content_length',
58
+ :'custom_metadata' => :'custom_metadata',
59
+ :'file_name' => :'file_name',
60
+ :'hash_sha256' => :'hash_sha256',
61
+ :'idempotency_key' => :'idempotency_key',
62
+ :'mime_type' => :'mime_type',
63
+ :'purpose' => :'purpose'
64
+ }
65
+ end
66
+
67
+ # Returns attribute mapping this model knows about
68
+ def self.acceptable_attribute_map
69
+ attribute_map
70
+ end
71
+
72
+ # Returns all the JSON keys this model knows about
73
+ def self.acceptable_attributes
74
+ acceptable_attribute_map.values
75
+ end
76
+
77
+ # Attribute type mapping.
78
+ def self.openapi_types
79
+ {
80
+ :'content_length' => :'Integer',
81
+ :'custom_metadata' => :'Hash<String, CustomMetadataValue>',
82
+ :'file_name' => :'String',
83
+ :'hash_sha256' => :'String',
84
+ :'idempotency_key' => :'String',
85
+ :'mime_type' => :'SupportedMimeType',
86
+ :'purpose' => :'String'
87
+ }
88
+ end
89
+
90
+ # List of attributes with nullable: true
91
+ def self.openapi_nullable
92
+ Set.new([
93
+ :'content_length',
94
+ :'hash_sha256',
95
+ :'idempotency_key',
96
+ :'purpose'
97
+ ])
98
+ end
99
+
100
+ # Initializes the object
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ def initialize(attributes = {})
103
+ if (!attributes.is_a?(Hash))
104
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ImgwireGenerated::StandardUploadCreateSchema` initialize method"
105
+ end
106
+
107
+ # check to see if the attribute exists and convert string to symbol for hash key
108
+ acceptable_attribute_map = self.class.acceptable_attribute_map
109
+ attributes = attributes.each_with_object({}) { |(k, v), h|
110
+ if (!acceptable_attribute_map.key?(k.to_sym))
111
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ImgwireGenerated::StandardUploadCreateSchema`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
112
+ end
113
+ h[k.to_sym] = v
114
+ }
115
+
116
+ if attributes.key?(:'content_length')
117
+ self.content_length = attributes[:'content_length']
118
+ end
119
+
120
+ if attributes.key?(:'custom_metadata')
121
+ if (value = attributes[:'custom_metadata']).is_a?(Hash)
122
+ self.custom_metadata = value
123
+ end
124
+ end
125
+
126
+ if attributes.key?(:'file_name')
127
+ self.file_name = attributes[:'file_name']
128
+ else
129
+ self.file_name = nil
130
+ end
131
+
132
+ if attributes.key?(:'hash_sha256')
133
+ self.hash_sha256 = attributes[:'hash_sha256']
134
+ end
135
+
136
+ if attributes.key?(:'idempotency_key')
137
+ self.idempotency_key = attributes[:'idempotency_key']
138
+ end
139
+
140
+ if attributes.key?(:'mime_type')
141
+ self.mime_type = attributes[:'mime_type']
142
+ end
143
+
144
+ if attributes.key?(:'purpose')
145
+ self.purpose = attributes[:'purpose']
146
+ end
147
+ end
148
+
149
+ # Show invalid properties with the reasons. Usually used together with valid?
150
+ # @return Array for valid properties with the reasons
151
+ def list_invalid_properties
152
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
153
+ invalid_properties = Array.new
154
+ if !@content_length.nil? && @content_length < 0
155
+ invalid_properties.push('invalid value for "content_length", must be greater than or equal to 0.')
156
+ end
157
+
158
+ if @file_name.nil?
159
+ invalid_properties.push('invalid value for "file_name", file_name cannot be nil.')
160
+ end
161
+
162
+ if @file_name.to_s.length < 1
163
+ invalid_properties.push('invalid value for "file_name", the character length must be greater than or equal to 1.')
164
+ end
165
+
166
+ if !@hash_sha256.nil? && @hash_sha256.to_s.length > 255
167
+ invalid_properties.push('invalid value for "hash_sha256", the character length must be smaller than or equal to 255.')
168
+ end
169
+
170
+ if !@hash_sha256.nil? && @hash_sha256.to_s.length < 1
171
+ invalid_properties.push('invalid value for "hash_sha256", the character length must be greater than or equal to 1.')
172
+ end
173
+
174
+ if !@idempotency_key.nil? && @idempotency_key.to_s.length > 255
175
+ invalid_properties.push('invalid value for "idempotency_key", the character length must be smaller than or equal to 255.')
176
+ end
177
+
178
+ if !@idempotency_key.nil? && @idempotency_key.to_s.length < 1
179
+ invalid_properties.push('invalid value for "idempotency_key", the character length must be greater than or equal to 1.')
180
+ end
181
+
182
+ if !@purpose.nil? && @purpose.to_s.length > 255
183
+ invalid_properties.push('invalid value for "purpose", the character length must be smaller than or equal to 255.')
184
+ end
185
+
186
+ if !@purpose.nil? && @purpose.to_s.length < 1
187
+ invalid_properties.push('invalid value for "purpose", the character length must be greater than or equal to 1.')
188
+ end
189
+
190
+ invalid_properties
191
+ end
192
+
193
+ # Check to see if the all the properties in the model are valid
194
+ # @return true if the model is valid
195
+ def valid?
196
+ warn '[DEPRECATED] the `valid?` method is obsolete'
197
+ return false if !@content_length.nil? && @content_length < 0
198
+ return false if @file_name.nil?
199
+ return false if @file_name.to_s.length < 1
200
+ return false if !@hash_sha256.nil? && @hash_sha256.to_s.length > 255
201
+ return false if !@hash_sha256.nil? && @hash_sha256.to_s.length < 1
202
+ return false if !@idempotency_key.nil? && @idempotency_key.to_s.length > 255
203
+ return false if !@idempotency_key.nil? && @idempotency_key.to_s.length < 1
204
+ return false if !@purpose.nil? && @purpose.to_s.length > 255
205
+ return false if !@purpose.nil? && @purpose.to_s.length < 1
206
+ true
207
+ end
208
+
209
+ # Custom attribute writer method with validation
210
+ # @param [Object] content_length Value to be assigned
211
+ def content_length=(content_length)
212
+ if !content_length.nil? && content_length < 0
213
+ fail ArgumentError, 'invalid value for "content_length", must be greater than or equal to 0.'
214
+ end
215
+
216
+ @content_length = content_length
217
+ end
218
+
219
+ # Custom attribute writer method with validation
220
+ # @param [Object] file_name Value to be assigned
221
+ def file_name=(file_name)
222
+ if file_name.nil?
223
+ fail ArgumentError, 'file_name cannot be nil'
224
+ end
225
+
226
+ if file_name.to_s.length < 1
227
+ fail ArgumentError, 'invalid value for "file_name", the character length must be greater than or equal to 1.'
228
+ end
229
+
230
+ @file_name = file_name
231
+ end
232
+
233
+ # Custom attribute writer method with validation
234
+ # @param [Object] hash_sha256 Value to be assigned
235
+ def hash_sha256=(hash_sha256)
236
+ if !hash_sha256.nil? && hash_sha256.to_s.length > 255
237
+ fail ArgumentError, 'invalid value for "hash_sha256", the character length must be smaller than or equal to 255.'
238
+ end
239
+
240
+ if !hash_sha256.nil? && hash_sha256.to_s.length < 1
241
+ fail ArgumentError, 'invalid value for "hash_sha256", the character length must be greater than or equal to 1.'
242
+ end
243
+
244
+ @hash_sha256 = hash_sha256
245
+ end
246
+
247
+ # Custom attribute writer method with validation
248
+ # @param [Object] idempotency_key Value to be assigned
249
+ def idempotency_key=(idempotency_key)
250
+ if !idempotency_key.nil? && idempotency_key.to_s.length > 255
251
+ fail ArgumentError, 'invalid value for "idempotency_key", the character length must be smaller than or equal to 255.'
252
+ end
253
+
254
+ if !idempotency_key.nil? && idempotency_key.to_s.length < 1
255
+ fail ArgumentError, 'invalid value for "idempotency_key", the character length must be greater than or equal to 1.'
256
+ end
257
+
258
+ @idempotency_key = idempotency_key
259
+ end
260
+
261
+ # Custom attribute writer method with validation
262
+ # @param [Object] purpose Value to be assigned
263
+ def purpose=(purpose)
264
+ if !purpose.nil? && purpose.to_s.length > 255
265
+ fail ArgumentError, 'invalid value for "purpose", the character length must be smaller than or equal to 255.'
266
+ end
267
+
268
+ if !purpose.nil? && purpose.to_s.length < 1
269
+ fail ArgumentError, 'invalid value for "purpose", the character length must be greater than or equal to 1.'
270
+ end
271
+
272
+ @purpose = purpose
273
+ end
274
+
275
+ # Checks equality by comparing each attribute.
276
+ # @param [Object] Object to be compared
277
+ def ==(o)
278
+ return true if self.equal?(o)
279
+ self.class == o.class &&
280
+ content_length == o.content_length &&
281
+ custom_metadata == o.custom_metadata &&
282
+ file_name == o.file_name &&
283
+ hash_sha256 == o.hash_sha256 &&
284
+ idempotency_key == o.idempotency_key &&
285
+ mime_type == o.mime_type &&
286
+ purpose == o.purpose
287
+ end
288
+
289
+ # @see the `==` method
290
+ # @param [Object] Object to be compared
291
+ def eql?(o)
292
+ self == o
293
+ end
294
+
295
+ # Calculates hash code according to all attributes.
296
+ # @return [Integer] Hash code
297
+ def hash
298
+ [content_length, custom_metadata, file_name, hash_sha256, idempotency_key, mime_type, purpose].hash
299
+ end
300
+
301
+ # Builds the object from hash
302
+ # @param [Hash] attributes Model attributes in the form of hash
303
+ # @return [Object] Returns the model itself
304
+ def self.build_from_hash(attributes)
305
+ return nil unless attributes.is_a?(Hash)
306
+ attributes = attributes.transform_keys(&:to_sym)
307
+ transformed_hash = {}
308
+ openapi_types.each_pair do |key, type|
309
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
310
+ transformed_hash["#{key}"] = nil
311
+ elsif type =~ /\AArray<(.*)>/i
312
+ # check to ensure the input is an array given that the attribute
313
+ # is documented as an array but the input is not
314
+ if attributes[attribute_map[key]].is_a?(Array)
315
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
316
+ end
317
+ elsif !attributes[attribute_map[key]].nil?
318
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
319
+ end
320
+ end
321
+ new(transformed_hash)
322
+ end
323
+
324
+ # Deserializes the data based on type
325
+ # @param string type Data type
326
+ # @param string value Value to be deserialized
327
+ # @return [Object] Deserialized data
328
+ def self._deserialize(type, value)
329
+ case type.to_sym
330
+ when :Time
331
+ Time.parse(value)
332
+ when :Date
333
+ Date.parse(value)
334
+ when :String
335
+ value.to_s
336
+ when :Integer
337
+ value.to_i
338
+ when :Float
339
+ value.to_f
340
+ when :Boolean
341
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
342
+ true
343
+ else
344
+ false
345
+ end
346
+ when :Object
347
+ # generic object (usually a Hash), return directly
348
+ value
349
+ when /\AArray<(?<inner_type>.+)>\z/
350
+ inner_type = Regexp.last_match[:inner_type]
351
+ value.map { |v| _deserialize(inner_type, v) }
352
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
353
+ k_type = Regexp.last_match[:k_type]
354
+ v_type = Regexp.last_match[:v_type]
355
+ {}.tap do |hash|
356
+ value.each do |k, v|
357
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
358
+ end
359
+ end
360
+ else # model
361
+ # models (e.g. Pet) or oneOf
362
+ klass = ImgwireGenerated.const_get(type)
363
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
364
+ end
365
+ end
366
+
367
+ # Returns the string representation of the object
368
+ # @return [String] String presentation of the object
369
+ def to_s
370
+ to_hash.to_s
371
+ end
372
+
373
+ # to_body is an alias to to_hash (backward compatibility)
374
+ # @return [Hash] Returns the object in the form of hash
375
+ def to_body
376
+ to_hash
377
+ end
378
+
379
+ # Returns the object in the form of hash
380
+ # @return [Hash] Returns the object in the form of hash
381
+ def to_hash
382
+ hash = {}
383
+ self.class.attribute_map.each_pair do |attr, param|
384
+ value = self.send(attr)
385
+ if value.nil?
386
+ is_nullable = self.class.openapi_nullable.include?(attr)
387
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
388
+ end
389
+
390
+ hash[param] = _to_hash(value)
391
+ end
392
+ hash
393
+ end
394
+
395
+ # Outputs non-array value in the form of hash
396
+ # For object, use to_hash. Otherwise, just return the value
397
+ # @param [Object] value Any valid value
398
+ # @return [Hash] Returns the value in the form of hash
399
+ def _to_hash(value)
400
+ if value.is_a?(Array)
401
+ value.compact.map { |v| _to_hash(v) }
402
+ elsif value.is_a?(Hash)
403
+ {}.tap do |hash|
404
+ value.each { |k, v| hash[k] = _to_hash(v) }
405
+ end
406
+ elsif value.respond_to? :to_hash
407
+ value.to_hash
408
+ else
409
+ value
410
+ end
411
+ end
412
+
413
+ end
414
+
415
+ end