carbon_ruby_sdk 0.2.19 → 0.2.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -4
  3. data/README.md +113 -8
  4. data/lib/carbon_ruby_sdk/api/embeddings_api.rb +6 -2
  5. data/lib/carbon_ruby_sdk/api/files_api.rb +231 -6
  6. data/lib/carbon_ruby_sdk/api/integrations_api.rb +12 -8
  7. data/lib/carbon_ruby_sdk/models/cold_storage_props.rb +229 -0
  8. data/lib/carbon_ruby_sdk/models/embedding_storage_status.rb +38 -0
  9. data/lib/carbon_ruby_sdk/models/file_sync_config.rb +13 -1
  10. data/lib/carbon_ruby_sdk/models/file_sync_config_nullable.rb +13 -1
  11. data/lib/carbon_ruby_sdk/models/get_embedding_documents_body.rb +17 -5
  12. data/lib/carbon_ruby_sdk/models/modify_cold_storage_parameters_query_input.rb +235 -0
  13. data/lib/carbon_ruby_sdk/models/move_to_hot_storage_query_input.rb +215 -0
  14. data/lib/carbon_ruby_sdk/models/o_auth_url_request.rb +17 -6
  15. data/lib/carbon_ruby_sdk/models/raw_text_input.rb +14 -5
  16. data/lib/carbon_ruby_sdk/models/sent_webhook_payload.rb +2 -2
  17. data/lib/carbon_ruby_sdk/models/sync_files_request.rb +1 -1
  18. data/lib/carbon_ruby_sdk/models/sync_options.rb +17 -6
  19. data/lib/carbon_ruby_sdk/models/upload_file_from_url_input.rb +24 -4
  20. data/lib/carbon_ruby_sdk/models/user_file.rb +39 -1
  21. data/lib/carbon_ruby_sdk/version.rb +1 -1
  22. data/lib/carbon_ruby_sdk.rb +4 -0
  23. data/spec/api/files_api_spec.rb +25 -0
  24. data/spec/models/cold_storage_props_spec.rb +34 -0
  25. data/spec/models/embedding_storage_status_spec.rb +22 -0
  26. data/spec/models/file_sync_config_nullable_spec.rb +6 -0
  27. data/spec/models/file_sync_config_spec.rb +6 -0
  28. data/spec/models/get_embedding_documents_body_spec.rb +6 -0
  29. data/spec/models/modify_cold_storage_parameters_query_input_spec.rb +40 -0
  30. data/spec/models/move_to_hot_storage_query_input_spec.rb +28 -0
  31. data/spec/models/o_auth_url_request_spec.rb +6 -0
  32. data/spec/models/raw_text_input_spec.rb +6 -0
  33. data/spec/models/sent_webhook_payload_spec.rb +1 -1
  34. data/spec/models/sync_options_spec.rb +6 -0
  35. data/spec/models/upload_file_from_url_input_spec.rb +12 -0
  36. data/spec/models/user_file_spec.rb +18 -0
  37. metadata +158 -146
@@ -0,0 +1,229 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class ColdStorageProps
14
+ # Enable cold storage for the file. If set to true, the file will be moved to cold storage after a certain period of inactivity. Default is false.
15
+ attr_accessor :enable_cold_storage
16
+
17
+ # Time in seconds after which the file will be moved to cold storage.
18
+ attr_accessor :hot_storage_time_to_live
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'enable_cold_storage' => :'enable_cold_storage',
24
+ :'hot_storage_time_to_live' => :'hot_storage_time_to_live'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'enable_cold_storage' => :'Boolean',
37
+ :'hot_storage_time_to_live' => :'Integer'
38
+ }
39
+ end
40
+
41
+ # List of attributes with nullable: true
42
+ def self.openapi_nullable
43
+ Set.new([
44
+ :'hot_storage_time_to_live'
45
+ ])
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ if (!attributes.is_a?(Hash))
52
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::ColdStorageProps` initialize method"
53
+ end
54
+
55
+ # check to see if the attribute exists and convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) { |(k, v), h|
57
+ if (!self.class.attribute_map.key?(k.to_sym))
58
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::ColdStorageProps`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
59
+ end
60
+ h[k.to_sym] = v
61
+ }
62
+
63
+ if attributes.key?(:'enable_cold_storage')
64
+ self.enable_cold_storage = attributes[:'enable_cold_storage']
65
+ else
66
+ self.enable_cold_storage = false
67
+ end
68
+
69
+ if attributes.key?(:'hot_storage_time_to_live')
70
+ self.hot_storage_time_to_live = attributes[:'hot_storage_time_to_live']
71
+ end
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ invalid_properties = Array.new
78
+ invalid_properties
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ enable_cold_storage == o.enable_cold_storage &&
93
+ hot_storage_time_to_live == o.hot_storage_time_to_live
94
+ end
95
+
96
+ # @see the `==` method
97
+ # @param [Object] Object to be compared
98
+ def eql?(o)
99
+ self == o
100
+ end
101
+
102
+ # Calculates hash code according to all attributes.
103
+ # @return [Integer] Hash code
104
+ def hash
105
+ [enable_cold_storage, hot_storage_time_to_live].hash
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def self.build_from_hash(attributes)
112
+ new.build_from_hash(attributes)
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ attributes = attributes.transform_keys(&:to_sym)
121
+ self.class.openapi_types.each_pair do |key, type|
122
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
123
+ self.send("#{key}=", nil)
124
+ elsif type =~ /\AArray<(.*)>/i
125
+ # check to ensure the input is an array given that the attribute
126
+ # is documented as an array but the input is not
127
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
128
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
129
+ end
130
+ elsif !attributes[self.class.attribute_map[key]].nil?
131
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
132
+ end
133
+ end
134
+
135
+ self
136
+ end
137
+
138
+ # Deserializes the data based on type
139
+ # @param string type Data type
140
+ # @param string value Value to be deserialized
141
+ # @return [Object] Deserialized data
142
+ def _deserialize(type, value)
143
+ case type.to_sym
144
+ when :Time
145
+ Time.parse(value)
146
+ when :Date
147
+ Date.parse(value)
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :Boolean
155
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
156
+ true
157
+ else
158
+ false
159
+ end
160
+ when :Object
161
+ # generic object (usually a Hash), return directly
162
+ value
163
+ when /\AArray<(?<inner_type>.+)>\z/
164
+ inner_type = Regexp.last_match[:inner_type]
165
+ value.map { |v| _deserialize(inner_type, v) }
166
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
167
+ k_type = Regexp.last_match[:k_type]
168
+ v_type = Regexp.last_match[:v_type]
169
+ {}.tap do |hash|
170
+ value.each do |k, v|
171
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
172
+ end
173
+ end
174
+ else # model
175
+ # models (e.g. Pet) or oneOf
176
+ klass = Carbon.const_get(type)
177
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ if value.nil?
200
+ is_nullable = self.class.openapi_nullable.include?(attr)
201
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
202
+ end
203
+
204
+ hash[param] = _to_hash(value)
205
+ end
206
+ hash
207
+ end
208
+
209
+ # Outputs non-array value in the form of hash
210
+ # For object, use to_hash. Otherwise, just return the value
211
+ # @param [Object] value Any valid value
212
+ # @return [Hash] Returns the value in the form of hash
213
+ def _to_hash(value)
214
+ if value.is_a?(Array)
215
+ value.compact.map { |v| _to_hash(v) }
216
+ elsif value.is_a?(Hash)
217
+ {}.tap do |hash|
218
+ value.each { |k, v| hash[k] = _to_hash(v) }
219
+ end
220
+ elsif value.respond_to? :to_hash
221
+ value.to_hash
222
+ else
223
+ value
224
+ end
225
+ end
226
+
227
+ end
228
+
229
+ end
@@ -0,0 +1,38 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class EmbeddingStorageStatus
14
+ HOT_STORAGE = "HOT_STORAGE".freeze
15
+ HOT_TO_COLD = "HOT_TO_COLD".freeze
16
+ COLD_STORAGE = "COLD_STORAGE".freeze
17
+ COLD_TO_HOT = "COLD_TO_HOT".freeze
18
+
19
+ def self.all_vars
20
+ @all_vars ||= [HOT_STORAGE, HOT_TO_COLD, COLD_STORAGE, COLD_TO_HOT].freeze
21
+ end
22
+
23
+ # Builds the enum from string
24
+ # @param [String] The enum value in the form of the string
25
+ # @return [String] The enum value
26
+ def self.build_from_hash(value)
27
+ new.build_from_hash(value)
28
+ end
29
+
30
+ # Builds the enum from string
31
+ # @param [String] The enum value in the form of the string
32
+ # @return [String] The enum value
33
+ def build_from_hash(value)
34
+ return value if EmbeddingStorageStatus.all_vars.include?(value)
35
+ raise "Invalid ENUM value #{value} for class #EmbeddingStorageStatus"
36
+ end
37
+ end
38
+ end
@@ -22,6 +22,9 @@ module Carbon
22
22
 
23
23
  attr_accessor :transcription_service
24
24
 
25
+ # Detect multiple speakers and label segments of speech by speaker for audio files.
26
+ attr_accessor :include_speaker_labels
27
+
25
28
  # Whether to split tabular rows into chunks. Currently only valid for CSV, TSV, and XLSX files.
26
29
  attr_accessor :split_rows
27
30
 
@@ -32,6 +35,7 @@ module Carbon
32
35
  :'sync_attachments' => :'sync_attachments',
33
36
  :'detect_audio_language' => :'detect_audio_language',
34
37
  :'transcription_service' => :'transcription_service',
38
+ :'include_speaker_labels' => :'include_speaker_labels',
35
39
  :'split_rows' => :'split_rows'
36
40
  }
37
41
  end
@@ -48,6 +52,7 @@ module Carbon
48
52
  :'sync_attachments' => :'Boolean',
49
53
  :'detect_audio_language' => :'Boolean',
50
54
  :'transcription_service' => :'TranscriptionServiceNullable',
55
+ :'include_speaker_labels' => :'Boolean',
51
56
  :'split_rows' => :'Boolean'
52
57
  }
53
58
  end
@@ -96,6 +101,12 @@ module Carbon
96
101
  self.transcription_service = attributes[:'transcription_service']
97
102
  end
98
103
 
104
+ if attributes.key?(:'include_speaker_labels')
105
+ self.include_speaker_labels = attributes[:'include_speaker_labels']
106
+ else
107
+ self.include_speaker_labels = false
108
+ end
109
+
99
110
  if attributes.key?(:'split_rows')
100
111
  self.split_rows = attributes[:'split_rows']
101
112
  else
@@ -125,6 +136,7 @@ module Carbon
125
136
  sync_attachments == o.sync_attachments &&
126
137
  detect_audio_language == o.detect_audio_language &&
127
138
  transcription_service == o.transcription_service &&
139
+ include_speaker_labels == o.include_speaker_labels &&
128
140
  split_rows == o.split_rows
129
141
  end
130
142
 
@@ -137,7 +149,7 @@ module Carbon
137
149
  # Calculates hash code according to all attributes.
138
150
  # @return [Integer] Hash code
139
151
  def hash
140
- [auto_synced_source_types, sync_attachments, detect_audio_language, transcription_service, split_rows].hash
152
+ [auto_synced_source_types, sync_attachments, detect_audio_language, transcription_service, include_speaker_labels, split_rows].hash
141
153
  end
142
154
 
143
155
  # Builds the object from hash
@@ -23,6 +23,9 @@ module Carbon
23
23
 
24
24
  attr_accessor :transcription_service
25
25
 
26
+ # Detect multiple speakers and label segments of speech by speaker for audio files.
27
+ attr_accessor :include_speaker_labels
28
+
26
29
  # Whether to split tabular rows into chunks. Currently only valid for CSV, TSV, and XLSX files.
27
30
  attr_accessor :split_rows
28
31
 
@@ -33,6 +36,7 @@ module Carbon
33
36
  :'sync_attachments' => :'sync_attachments',
34
37
  :'detect_audio_language' => :'detect_audio_language',
35
38
  :'transcription_service' => :'transcription_service',
39
+ :'include_speaker_labels' => :'include_speaker_labels',
36
40
  :'split_rows' => :'split_rows'
37
41
  }
38
42
  end
@@ -49,6 +53,7 @@ module Carbon
49
53
  :'sync_attachments' => :'Boolean',
50
54
  :'detect_audio_language' => :'Boolean',
51
55
  :'transcription_service' => :'TranscriptionServiceNullable',
56
+ :'include_speaker_labels' => :'Boolean',
52
57
  :'split_rows' => :'Boolean'
53
58
  }
54
59
  end
@@ -97,6 +102,12 @@ module Carbon
97
102
  self.transcription_service = attributes[:'transcription_service']
98
103
  end
99
104
 
105
+ if attributes.key?(:'include_speaker_labels')
106
+ self.include_speaker_labels = attributes[:'include_speaker_labels']
107
+ else
108
+ self.include_speaker_labels = false
109
+ end
110
+
100
111
  if attributes.key?(:'split_rows')
101
112
  self.split_rows = attributes[:'split_rows']
102
113
  else
@@ -126,6 +137,7 @@ module Carbon
126
137
  sync_attachments == o.sync_attachments &&
127
138
  detect_audio_language == o.detect_audio_language &&
128
139
  transcription_service == o.transcription_service &&
140
+ include_speaker_labels == o.include_speaker_labels &&
129
141
  split_rows == o.split_rows
130
142
  end
131
143
 
@@ -138,7 +150,7 @@ module Carbon
138
150
  # Calculates hash code according to all attributes.
139
151
  # @return [Integer] Hash code
140
152
  def hash
141
- [auto_synced_source_types, sync_attachments, detect_audio_language, transcription_service, split_rows].hash
153
+ [auto_synced_source_types, sync_attachments, detect_audio_language, transcription_service, include_speaker_labels, split_rows].hash
142
154
  end
143
155
 
144
156
  # Builds the object from hash
@@ -64,6 +64,9 @@ module Carbon
64
64
  # Filter files based on their type at the source (for example help center tickets and articles)
65
65
  attr_accessor :file_types_at_source
66
66
 
67
+ # Flag to control whether or not to exclude files that are not in hot storage. If set to False, then an error will be returned if any filtered files are in cold storage.
68
+ attr_accessor :exclude_cold_storage_files
69
+
67
70
  # Attribute mapping from ruby-style variable name to JSON key.
68
71
  def self.attribute_map
69
72
  {
@@ -85,7 +88,8 @@ module Carbon
85
88
  :'include_file_level_metadata' => :'include_file_level_metadata',
86
89
  :'high_accuracy' => :'high_accuracy',
87
90
  :'rerank' => :'rerank',
88
- :'file_types_at_source' => :'file_types_at_source'
91
+ :'file_types_at_source' => :'file_types_at_source',
92
+ :'exclude_cold_storage_files' => :'exclude_cold_storage_files'
89
93
  }
90
94
  end
91
95
 
@@ -115,7 +119,8 @@ module Carbon
115
119
  :'include_file_level_metadata' => :'Boolean',
116
120
  :'high_accuracy' => :'Boolean',
117
121
  :'rerank' => :'RerankParamsNullable',
118
- :'file_types_at_source' => :'Array<HelpdeskFileTypes>'
122
+ :'file_types_at_source' => :'Array<HelpdeskFileTypes>',
123
+ :'exclude_cold_storage_files' => :'Boolean'
119
124
  }
120
125
  end
121
126
 
@@ -137,7 +142,7 @@ module Carbon
137
142
  :'include_file_level_metadata',
138
143
  :'high_accuracy',
139
144
  :'rerank',
140
- :'file_types_at_source'
145
+ :'file_types_at_source',
141
146
  ])
142
147
  end
143
148
 
@@ -249,6 +254,12 @@ module Carbon
249
254
  self.file_types_at_source = value
250
255
  end
251
256
  end
257
+
258
+ if attributes.key?(:'exclude_cold_storage_files')
259
+ self.exclude_cold_storage_files = attributes[:'exclude_cold_storage_files']
260
+ else
261
+ self.exclude_cold_storage_files = false
262
+ end
252
263
  end
253
264
 
254
265
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -335,7 +346,8 @@ module Carbon
335
346
  include_file_level_metadata == o.include_file_level_metadata &&
336
347
  high_accuracy == o.high_accuracy &&
337
348
  rerank == o.rerank &&
338
- file_types_at_source == o.file_types_at_source
349
+ file_types_at_source == o.file_types_at_source &&
350
+ exclude_cold_storage_files == o.exclude_cold_storage_files
339
351
  end
340
352
 
341
353
  # @see the `==` method
@@ -347,7 +359,7 @@ module Carbon
347
359
  # Calculates hash code according to all attributes.
348
360
  # @return [Integer] Hash code
349
361
  def hash
350
- [tags, query, query_vector, k, file_ids, parent_file_ids, include_all_children, tags_v2, include_tags, include_vectors, include_raw_file, hybrid_search, hybrid_search_tuning_parameters, media_type, embedding_model, include_file_level_metadata, high_accuracy, rerank, file_types_at_source].hash
362
+ [tags, query, query_vector, k, file_ids, parent_file_ids, include_all_children, tags_v2, include_tags, include_vectors, include_raw_file, hybrid_search, hybrid_search_tuning_parameters, media_type, embedding_model, include_file_level_metadata, high_accuracy, rerank, file_types_at_source, exclude_cold_storage_files].hash
351
363
  end
352
364
 
353
365
  # Builds the object from hash
@@ -0,0 +1,235 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class ModifyColdStorageParametersQueryInput
14
+ attr_accessor :filters
15
+
16
+ attr_accessor :enable_cold_storage
17
+
18
+ attr_accessor :hot_storage_time_to_live
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'filters' => :'filters',
24
+ :'enable_cold_storage' => :'enable_cold_storage',
25
+ :'hot_storage_time_to_live' => :'hot_storage_time_to_live'
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ :'filters' => :'OrganizationUserFilesToSyncFilters',
38
+ :'enable_cold_storage' => :'Boolean',
39
+ :'hot_storage_time_to_live' => :'Integer'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ :'enable_cold_storage',
47
+ :'hot_storage_time_to_live'
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::ModifyColdStorageParametersQueryInput` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::ModifyColdStorageParametersQueryInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'filters')
67
+ self.filters = attributes[:'filters']
68
+ end
69
+
70
+ if attributes.key?(:'enable_cold_storage')
71
+ self.enable_cold_storage = attributes[:'enable_cold_storage']
72
+ end
73
+
74
+ if attributes.key?(:'hot_storage_time_to_live')
75
+ self.hot_storage_time_to_live = attributes[:'hot_storage_time_to_live']
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ invalid_properties
84
+ end
85
+
86
+ # Check to see if the all the properties in the model are valid
87
+ # @return true if the model is valid
88
+ def valid?
89
+ true
90
+ end
91
+
92
+ # Checks equality by comparing each attribute.
93
+ # @param [Object] Object to be compared
94
+ def ==(o)
95
+ return true if self.equal?(o)
96
+ self.class == o.class &&
97
+ filters == o.filters &&
98
+ enable_cold_storage == o.enable_cold_storage &&
99
+ hot_storage_time_to_live == o.hot_storage_time_to_live
100
+ end
101
+
102
+ # @see the `==` method
103
+ # @param [Object] Object to be compared
104
+ def eql?(o)
105
+ self == o
106
+ end
107
+
108
+ # Calculates hash code according to all attributes.
109
+ # @return [Integer] Hash code
110
+ def hash
111
+ [filters, enable_cold_storage, hot_storage_time_to_live].hash
112
+ end
113
+
114
+ # Builds the object from hash
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ # @return [Object] Returns the model itself
117
+ def self.build_from_hash(attributes)
118
+ new.build_from_hash(attributes)
119
+ end
120
+
121
+ # Builds the object from hash
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ # @return [Object] Returns the model itself
124
+ def build_from_hash(attributes)
125
+ return nil unless attributes.is_a?(Hash)
126
+ attributes = attributes.transform_keys(&:to_sym)
127
+ self.class.openapi_types.each_pair do |key, type|
128
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
129
+ self.send("#{key}=", nil)
130
+ elsif type =~ /\AArray<(.*)>/i
131
+ # check to ensure the input is an array given that the attribute
132
+ # is documented as an array but the input is not
133
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
134
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
135
+ end
136
+ elsif !attributes[self.class.attribute_map[key]].nil?
137
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
138
+ end
139
+ end
140
+
141
+ self
142
+ end
143
+
144
+ # Deserializes the data based on type
145
+ # @param string type Data type
146
+ # @param string value Value to be deserialized
147
+ # @return [Object] Deserialized data
148
+ def _deserialize(type, value)
149
+ case type.to_sym
150
+ when :Time
151
+ Time.parse(value)
152
+ when :Date
153
+ Date.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :Boolean
161
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+ when :Object
167
+ # generic object (usually a Hash), return directly
168
+ value
169
+ when /\AArray<(?<inner_type>.+)>\z/
170
+ inner_type = Regexp.last_match[:inner_type]
171
+ value.map { |v| _deserialize(inner_type, v) }
172
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
173
+ k_type = Regexp.last_match[:k_type]
174
+ v_type = Regexp.last_match[:v_type]
175
+ {}.tap do |hash|
176
+ value.each do |k, v|
177
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
+ end
179
+ end
180
+ else # model
181
+ # models (e.g. Pet) or oneOf
182
+ klass = Carbon.const_get(type)
183
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
184
+ end
185
+ end
186
+
187
+ # Returns the string representation of the object
188
+ # @return [String] String presentation of the object
189
+ def to_s
190
+ to_hash.to_s
191
+ end
192
+
193
+ # to_body is an alias to to_hash (backward compatibility)
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_body
196
+ to_hash
197
+ end
198
+
199
+ # Returns the object in the form of hash
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_hash
202
+ hash = {}
203
+ self.class.attribute_map.each_pair do |attr, param|
204
+ value = self.send(attr)
205
+ if value.nil?
206
+ is_nullable = self.class.openapi_nullable.include?(attr)
207
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
208
+ end
209
+
210
+ hash[param] = _to_hash(value)
211
+ end
212
+ hash
213
+ end
214
+
215
+ # Outputs non-array value in the form of hash
216
+ # For object, use to_hash. Otherwise, just return the value
217
+ # @param [Object] value Any valid value
218
+ # @return [Hash] Returns the value in the form of hash
219
+ def _to_hash(value)
220
+ if value.is_a?(Array)
221
+ value.compact.map { |v| _to_hash(v) }
222
+ elsif value.is_a?(Hash)
223
+ {}.tap do |hash|
224
+ value.each { |k, v| hash[k] = _to_hash(v) }
225
+ end
226
+ elsif value.respond_to? :to_hash
227
+ value.to_hash
228
+ else
229
+ value
230
+ end
231
+ end
232
+
233
+ end
234
+
235
+ end