cyber_trackr_live 1.0.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 (38) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG-GEM.md +47 -0
  3. data/CODE_OF_CONDUCT.md +20 -0
  4. data/CONTRIBUTING.md +422 -0
  5. data/LICENSE.md +16 -0
  6. data/NOTICE.md +16 -0
  7. data/README-GEM.md +75 -0
  8. data/SECURITY.md +86 -0
  9. data/cyber_trackr_live.gemspec +56 -0
  10. data/examples/cyber_trackr_client.rb +208 -0
  11. data/examples/fetch-complete-stig +174 -0
  12. data/examples/fetch-stig-complete +67 -0
  13. data/examples/fetch-stig-direct +99 -0
  14. data/examples/use_helper.rb +50 -0
  15. data/lib/cyber_trackr_client/api/api_documentation_api.rb +79 -0
  16. data/lib/cyber_trackr_client/api/cci_api.rb +147 -0
  17. data/lib/cyber_trackr_client/api/documents_api.rb +276 -0
  18. data/lib/cyber_trackr_client/api/rmf_controls_api.rb +272 -0
  19. data/lib/cyber_trackr_client/api/scap_api.rb +276 -0
  20. data/lib/cyber_trackr_client/api_client.rb +437 -0
  21. data/lib/cyber_trackr_client/api_error.rb +58 -0
  22. data/lib/cyber_trackr_client/configuration.rb +400 -0
  23. data/lib/cyber_trackr_client/models/api_documentation.rb +238 -0
  24. data/lib/cyber_trackr_client/models/assessment_procedure.rb +321 -0
  25. data/lib/cyber_trackr_client/models/cci_detail.rb +391 -0
  26. data/lib/cyber_trackr_client/models/document_detail.rb +434 -0
  27. data/lib/cyber_trackr_client/models/document_version.rb +385 -0
  28. data/lib/cyber_trackr_client/models/error.rb +313 -0
  29. data/lib/cyber_trackr_client/models/requirement_detail.rb +580 -0
  30. data/lib/cyber_trackr_client/models/requirement_summary.rb +360 -0
  31. data/lib/cyber_trackr_client/models/rmf_control_detail.rb +436 -0
  32. data/lib/cyber_trackr_client/models/rmf_control_list.rb +241 -0
  33. data/lib/cyber_trackr_client/version.rb +15 -0
  34. data/lib/cyber_trackr_client.rb +54 -0
  35. data/lib/cyber_trackr_helper.rb +269 -0
  36. data/lib/rubocop/cop/cyber_trackr_api/README.md +81 -0
  37. data/openapi/openapi.yaml +798 -0
  38. metadata +271 -0
@@ -0,0 +1,385 @@
1
+ =begin
2
+ #Cyber Trackr API
3
+
4
+ #Complete OpenAPI 3.1.1 specification for cyber.trackr.live API. This API provides access to DISA STIGs, SRGs, RMF controls, CCIs, and SCAP data. ## DISA Cybersecurity Ecosystem Hierarchy ``` NIST RMF Controls (high-level policy framework) ↓ (decomposed into atomic, testable statements) CCIs (Control Correlation Identifiers - bridge policy to implementation) ↓ (grouped by technology class into generic requirements) SRGs (Security Requirements Guides - technology class \"what\" to do) ↓ (implemented as vendor-specific \"how\" to do it) STIGs (Security Technical Implementation Guides - vendor/product specific) ↓ (automated versions for scanning tools) SCAP (Security Content Automation Protocol documents) ``` ## Critical Relationships - **RMF Controls** contain assessment procedures that reference **CCIs** - **CCIs** map back to **RMF Controls** and forward to **STIG/SRG requirements** - **SRGs** define generic technology requirements that **STIGs** implement specifically - **V-IDs** can appear in both SRG and corresponding STIG (same requirement, different specificity) - **SV-IDs** are XCCDF rule identifiers with revision tracking across document releases
5
+
6
+ The version of the OpenAPI document: 1.0.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 CyberTrackrClient
17
+ # Version information for a specific document release
18
+ class DocumentVersion
19
+ # File creation/build date in YYYY-MM-DD format (may be empty)
20
+ attr_accessor :date
21
+
22
+ # Publication/release date in human-readable format (with leading space)
23
+ attr_accessor :released
24
+
25
+ attr_accessor :version
26
+
27
+ attr_accessor :release
28
+
29
+ attr_accessor :link
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'date' => :'date',
35
+ :'released' => :'released',
36
+ :'version' => :'version',
37
+ :'release' => :'release',
38
+ :'link' => :'link'
39
+ }
40
+ end
41
+
42
+ # Returns attribute mapping this model knows about
43
+ def self.acceptable_attribute_map
44
+ attribute_map
45
+ end
46
+
47
+ # Returns all the JSON keys this model knows about
48
+ def self.acceptable_attributes
49
+ acceptable_attribute_map.values
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.openapi_types
54
+ {
55
+ :'date' => :'String',
56
+ :'released' => :'String',
57
+ :'version' => :'String',
58
+ :'release' => :'String',
59
+ :'link' => :'String'
60
+ }
61
+ end
62
+
63
+ # List of attributes with nullable: true
64
+ def self.openapi_nullable
65
+ Set.new([
66
+ ])
67
+ end
68
+
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
71
+ def initialize(attributes = {})
72
+ if (!attributes.is_a?(Hash))
73
+ fail ArgumentError, "The input argument (attributes) must be a hash in `CyberTrackrClient::DocumentVersion` initialize method"
74
+ end
75
+
76
+ # check to see if the attribute exists and convert string to symbol for hash key
77
+ acceptable_attribute_map = self.class.acceptable_attribute_map
78
+ attributes = attributes.each_with_object({}) { |(k, v), h|
79
+ if (!acceptable_attribute_map.key?(k.to_sym))
80
+ fail ArgumentError, "`#{k}` is not a valid attribute in `CyberTrackrClient::DocumentVersion`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
81
+ end
82
+ h[k.to_sym] = v
83
+ }
84
+
85
+ if attributes.key?(:'date')
86
+ self.date = attributes[:'date']
87
+ end
88
+
89
+ if attributes.key?(:'released')
90
+ self.released = attributes[:'released']
91
+ end
92
+
93
+ if attributes.key?(:'version')
94
+ self.version = attributes[:'version']
95
+ else
96
+ self.version = nil
97
+ end
98
+
99
+ if attributes.key?(:'release')
100
+ self.release = attributes[:'release']
101
+ else
102
+ self.release = nil
103
+ end
104
+
105
+ if attributes.key?(:'link')
106
+ self.link = attributes[:'link']
107
+ else
108
+ self.link = nil
109
+ end
110
+ end
111
+
112
+ # Show invalid properties with the reasons. Usually used together with valid?
113
+ # @return Array for valid properties with the reasons
114
+ def list_invalid_properties
115
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
116
+ invalid_properties = Array.new
117
+ pattern = Regexp.new(/^(\d{4}-\d{2}-\d{2}|)$/)
118
+ if !@date.nil? && @date !~ pattern
119
+ invalid_properties.push("invalid value for \"date\", must conform to the pattern #{pattern}.")
120
+ end
121
+
122
+ pattern = Regexp.new(/^ \d{1,2} \w+ \d{4}$/)
123
+ if !@released.nil? && @released !~ pattern
124
+ invalid_properties.push("invalid value for \"released\", must conform to the pattern #{pattern}.")
125
+ end
126
+
127
+ if @version.nil?
128
+ invalid_properties.push('invalid value for "version", version cannot be nil.')
129
+ end
130
+
131
+ pattern = Regexp.new(/^[Vv]?\d+$/)
132
+ if @version !~ pattern
133
+ invalid_properties.push("invalid value for \"version\", must conform to the pattern #{pattern}.")
134
+ end
135
+
136
+ if @release.nil?
137
+ invalid_properties.push('invalid value for "release", release cannot be nil.')
138
+ end
139
+
140
+ pattern = Regexp.new(/^\d+(\.\d+)?$/)
141
+ if @release !~ pattern
142
+ invalid_properties.push("invalid value for \"release\", must conform to the pattern #{pattern}.")
143
+ end
144
+
145
+ if @link.nil?
146
+ invalid_properties.push('invalid value for "link", link cannot be nil.')
147
+ end
148
+
149
+ pattern = Regexp.new(/^\/(stig|scap)\/.+$/)
150
+ if @link !~ pattern
151
+ invalid_properties.push("invalid value for \"link\", must conform to the pattern #{pattern}.")
152
+ end
153
+
154
+ invalid_properties
155
+ end
156
+
157
+ # Check to see if the all the properties in the model are valid
158
+ # @return true if the model is valid
159
+ def valid?
160
+ warn '[DEPRECATED] the `valid?` method is obsolete'
161
+ return false if !@date.nil? && @date !~ Regexp.new(/^(\d{4}-\d{2}-\d{2}|)$/)
162
+ return false if !@released.nil? && @released !~ Regexp.new(/^ \d{1,2} \w+ \d{4}$/)
163
+ return false if @version.nil?
164
+ return false if @version !~ Regexp.new(/^[Vv]?\d+$/)
165
+ return false if @release.nil?
166
+ return false if @release !~ Regexp.new(/^\d+(\.\d+)?$/)
167
+ return false if @link.nil?
168
+ return false if @link !~ Regexp.new(/^\/(stig|scap)\/.+$/)
169
+ true
170
+ end
171
+
172
+ # Custom attribute writer method with validation
173
+ # @param [Object] date Value to be assigned
174
+ def date=(date)
175
+ if date.nil?
176
+ fail ArgumentError, 'date cannot be nil'
177
+ end
178
+
179
+ pattern = Regexp.new(/^(\d{4}-\d{2}-\d{2}|)$/)
180
+ if date !~ pattern
181
+ fail ArgumentError, "invalid value for \"date\", must conform to the pattern #{pattern}."
182
+ end
183
+
184
+ @date = date
185
+ end
186
+
187
+ # Custom attribute writer method with validation
188
+ # @param [Object] released Value to be assigned
189
+ def released=(released)
190
+ if released.nil?
191
+ fail ArgumentError, 'released cannot be nil'
192
+ end
193
+
194
+ pattern = Regexp.new(/^ \d{1,2} \w+ \d{4}$/)
195
+ if released !~ pattern
196
+ fail ArgumentError, "invalid value for \"released\", must conform to the pattern #{pattern}."
197
+ end
198
+
199
+ @released = released
200
+ end
201
+
202
+ # Custom attribute writer method with validation
203
+ # @param [Object] version Value to be assigned
204
+ def version=(version)
205
+ if version.nil?
206
+ fail ArgumentError, 'version cannot be nil'
207
+ end
208
+
209
+ pattern = Regexp.new(/^[Vv]?\d+$/)
210
+ if version !~ pattern
211
+ fail ArgumentError, "invalid value for \"version\", must conform to the pattern #{pattern}."
212
+ end
213
+
214
+ @version = version
215
+ end
216
+
217
+ # Custom attribute writer method with validation
218
+ # @param [Object] release Value to be assigned
219
+ def release=(release)
220
+ if release.nil?
221
+ fail ArgumentError, 'release cannot be nil'
222
+ end
223
+
224
+ pattern = Regexp.new(/^\d+(\.\d+)?$/)
225
+ if release !~ pattern
226
+ fail ArgumentError, "invalid value for \"release\", must conform to the pattern #{pattern}."
227
+ end
228
+
229
+ @release = release
230
+ end
231
+
232
+ # Custom attribute writer method with validation
233
+ # @param [Object] link Value to be assigned
234
+ def link=(link)
235
+ if link.nil?
236
+ fail ArgumentError, 'link cannot be nil'
237
+ end
238
+
239
+ pattern = Regexp.new(/^\/(stig|scap)\/.+$/)
240
+ if link !~ pattern
241
+ fail ArgumentError, "invalid value for \"link\", must conform to the pattern #{pattern}."
242
+ end
243
+
244
+ @link = link
245
+ end
246
+
247
+ # Checks equality by comparing each attribute.
248
+ # @param [Object] Object to be compared
249
+ def ==(o)
250
+ return true if self.equal?(o)
251
+ self.class == o.class &&
252
+ date == o.date &&
253
+ released == o.released &&
254
+ version == o.version &&
255
+ release == o.release &&
256
+ link == o.link
257
+ end
258
+
259
+ # @see the `==` method
260
+ # @param [Object] Object to be compared
261
+ def eql?(o)
262
+ self == o
263
+ end
264
+
265
+ # Calculates hash code according to all attributes.
266
+ # @return [Integer] Hash code
267
+ def hash
268
+ [date, released, version, release, link].hash
269
+ end
270
+
271
+ # Builds the object from hash
272
+ # @param [Hash] attributes Model attributes in the form of hash
273
+ # @return [Object] Returns the model itself
274
+ def self.build_from_hash(attributes)
275
+ return nil unless attributes.is_a?(Hash)
276
+ attributes = attributes.transform_keys(&:to_sym)
277
+ transformed_hash = {}
278
+ openapi_types.each_pair do |key, type|
279
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
280
+ transformed_hash["#{key}"] = nil
281
+ elsif type =~ /\AArray<(.*)>/i
282
+ # check to ensure the input is an array given that the attribute
283
+ # is documented as an array but the input is not
284
+ if attributes[attribute_map[key]].is_a?(Array)
285
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
286
+ end
287
+ elsif !attributes[attribute_map[key]].nil?
288
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
289
+ end
290
+ end
291
+ new(transformed_hash)
292
+ end
293
+
294
+ # Deserializes the data based on type
295
+ # @param string type Data type
296
+ # @param string value Value to be deserialized
297
+ # @return [Object] Deserialized data
298
+ def self._deserialize(type, value)
299
+ case type.to_sym
300
+ when :Time
301
+ Time.parse(value)
302
+ when :Date
303
+ Date.parse(value)
304
+ when :String
305
+ value.to_s
306
+ when :Integer
307
+ value.to_i
308
+ when :Float
309
+ value.to_f
310
+ when :Boolean
311
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
312
+ true
313
+ else
314
+ false
315
+ end
316
+ when :Object
317
+ # generic object (usually a Hash), return directly
318
+ value
319
+ when /\AArray<(?<inner_type>.+)>\z/
320
+ inner_type = Regexp.last_match[:inner_type]
321
+ value.map { |v| _deserialize(inner_type, v) }
322
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
323
+ k_type = Regexp.last_match[:k_type]
324
+ v_type = Regexp.last_match[:v_type]
325
+ {}.tap do |hash|
326
+ value.each do |k, v|
327
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
328
+ end
329
+ end
330
+ else # model
331
+ # models (e.g. Pet) or oneOf
332
+ klass = CyberTrackrClient.const_get(type)
333
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
334
+ end
335
+ end
336
+
337
+ # Returns the string representation of the object
338
+ # @return [String] String presentation of the object
339
+ def to_s
340
+ to_hash.to_s
341
+ end
342
+
343
+ # to_body is an alias to to_hash (backward compatibility)
344
+ # @return [Hash] Returns the object in the form of hash
345
+ def to_body
346
+ to_hash
347
+ end
348
+
349
+ # Returns the object in the form of hash
350
+ # @return [Hash] Returns the object in the form of hash
351
+ def to_hash
352
+ hash = {}
353
+ self.class.attribute_map.each_pair do |attr, param|
354
+ value = self.send(attr)
355
+ if value.nil?
356
+ is_nullable = self.class.openapi_nullable.include?(attr)
357
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
358
+ end
359
+
360
+ hash[param] = _to_hash(value)
361
+ end
362
+ hash
363
+ end
364
+
365
+ # Outputs non-array value in the form of hash
366
+ # For object, use to_hash. Otherwise, just return the value
367
+ # @param [Object] value Any valid value
368
+ # @return [Hash] Returns the value in the form of hash
369
+ def _to_hash(value)
370
+ if value.is_a?(Array)
371
+ value.compact.map { |v| _to_hash(v) }
372
+ elsif value.is_a?(Hash)
373
+ {}.tap do |hash|
374
+ value.each { |k, v| hash[k] = _to_hash(v) }
375
+ end
376
+ elsif value.respond_to? :to_hash
377
+ value.to_hash
378
+ else
379
+ value
380
+ end
381
+ end
382
+
383
+ end
384
+
385
+ end
@@ -0,0 +1,313 @@
1
+ =begin
2
+ #Cyber Trackr API
3
+
4
+ #Complete OpenAPI 3.1.1 specification for cyber.trackr.live API. This API provides access to DISA STIGs, SRGs, RMF controls, CCIs, and SCAP data. ## DISA Cybersecurity Ecosystem Hierarchy ``` NIST RMF Controls (high-level policy framework) ↓ (decomposed into atomic, testable statements) CCIs (Control Correlation Identifiers - bridge policy to implementation) ↓ (grouped by technology class into generic requirements) SRGs (Security Requirements Guides - technology class \"what\" to do) ↓ (implemented as vendor-specific \"how\" to do it) STIGs (Security Technical Implementation Guides - vendor/product specific) ↓ (automated versions for scanning tools) SCAP (Security Content Automation Protocol documents) ``` ## Critical Relationships - **RMF Controls** contain assessment procedures that reference **CCIs** - **CCIs** map back to **RMF Controls** and forward to **STIG/SRG requirements** - **SRGs** define generic technology requirements that **STIGs** implement specifically - **V-IDs** can appear in both SRG and corresponding STIG (same requirement, different specificity) - **SV-IDs** are XCCDF rule identifiers with revision tracking across document releases
5
+
6
+ The version of the OpenAPI document: 1.0.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 CyberTrackrClient
17
+ # Error response format
18
+ class Error
19
+ # Error type reference
20
+ attr_accessor :type
21
+
22
+ # Error title
23
+ attr_accessor :title
24
+
25
+ # HTTP status code
26
+ attr_accessor :status
27
+
28
+ # Error details
29
+ attr_accessor :detail
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'type' => :'type',
35
+ :'title' => :'title',
36
+ :'status' => :'status',
37
+ :'detail' => :'detail'
38
+ }
39
+ end
40
+
41
+ # Returns attribute mapping this model knows about
42
+ def self.acceptable_attribute_map
43
+ attribute_map
44
+ end
45
+
46
+ # Returns all the JSON keys this model knows about
47
+ def self.acceptable_attributes
48
+ acceptable_attribute_map.values
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.openapi_types
53
+ {
54
+ :'type' => :'String',
55
+ :'title' => :'String',
56
+ :'status' => :'Integer',
57
+ :'detail' => :'String'
58
+ }
59
+ end
60
+
61
+ # List of attributes with nullable: true
62
+ def self.openapi_nullable
63
+ Set.new([
64
+ ])
65
+ end
66
+
67
+ # Initializes the object
68
+ # @param [Hash] attributes Model attributes in the form of hash
69
+ def initialize(attributes = {})
70
+ if (!attributes.is_a?(Hash))
71
+ fail ArgumentError, "The input argument (attributes) must be a hash in `CyberTrackrClient::Error` initialize method"
72
+ end
73
+
74
+ # check to see if the attribute exists and convert string to symbol for hash key
75
+ acceptable_attribute_map = self.class.acceptable_attribute_map
76
+ attributes = attributes.each_with_object({}) { |(k, v), h|
77
+ if (!acceptable_attribute_map.key?(k.to_sym))
78
+ fail ArgumentError, "`#{k}` is not a valid attribute in `CyberTrackrClient::Error`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
79
+ end
80
+ h[k.to_sym] = v
81
+ }
82
+
83
+ if attributes.key?(:'type')
84
+ self.type = attributes[:'type']
85
+ end
86
+
87
+ if attributes.key?(:'title')
88
+ self.title = attributes[:'title']
89
+ else
90
+ self.title = nil
91
+ end
92
+
93
+ if attributes.key?(:'status')
94
+ self.status = attributes[:'status']
95
+ else
96
+ self.status = nil
97
+ end
98
+
99
+ if attributes.key?(:'detail')
100
+ self.detail = attributes[:'detail']
101
+ end
102
+ end
103
+
104
+ # Show invalid properties with the reasons. Usually used together with valid?
105
+ # @return Array for valid properties with the reasons
106
+ def list_invalid_properties
107
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
108
+ invalid_properties = Array.new
109
+ if @title.nil?
110
+ invalid_properties.push('invalid value for "title", title cannot be nil.')
111
+ end
112
+
113
+ if @title.to_s.length < 1
114
+ invalid_properties.push('invalid value for "title", the character length must be greater than or equal to 1.')
115
+ end
116
+
117
+ if @status.nil?
118
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
119
+ end
120
+
121
+ if @status > 599
122
+ invalid_properties.push('invalid value for "status", must be smaller than or equal to 599.')
123
+ end
124
+
125
+ if @status < 400
126
+ invalid_properties.push('invalid value for "status", must be greater than or equal to 400.')
127
+ end
128
+
129
+ invalid_properties
130
+ end
131
+
132
+ # Check to see if the all the properties in the model are valid
133
+ # @return true if the model is valid
134
+ def valid?
135
+ warn '[DEPRECATED] the `valid?` method is obsolete'
136
+ return false if @title.nil?
137
+ return false if @title.to_s.length < 1
138
+ return false if @status.nil?
139
+ return false if @status > 599
140
+ return false if @status < 400
141
+ true
142
+ end
143
+
144
+ # Custom attribute writer method with validation
145
+ # @param [Object] title Value to be assigned
146
+ def title=(title)
147
+ if title.nil?
148
+ fail ArgumentError, 'title cannot be nil'
149
+ end
150
+
151
+ if title.to_s.length < 1
152
+ fail ArgumentError, 'invalid value for "title", the character length must be greater than or equal to 1.'
153
+ end
154
+
155
+ @title = title
156
+ end
157
+
158
+ # Custom attribute writer method with validation
159
+ # @param [Object] status Value to be assigned
160
+ def status=(status)
161
+ if status.nil?
162
+ fail ArgumentError, 'status cannot be nil'
163
+ end
164
+
165
+ if status > 599
166
+ fail ArgumentError, 'invalid value for "status", must be smaller than or equal to 599.'
167
+ end
168
+
169
+ if status < 400
170
+ fail ArgumentError, 'invalid value for "status", must be greater than or equal to 400.'
171
+ end
172
+
173
+ @status = status
174
+ end
175
+
176
+ # Checks equality by comparing each attribute.
177
+ # @param [Object] Object to be compared
178
+ def ==(o)
179
+ return true if self.equal?(o)
180
+ self.class == o.class &&
181
+ type == o.type &&
182
+ title == o.title &&
183
+ status == o.status &&
184
+ detail == o.detail
185
+ end
186
+
187
+ # @see the `==` method
188
+ # @param [Object] Object to be compared
189
+ def eql?(o)
190
+ self == o
191
+ end
192
+
193
+ # Calculates hash code according to all attributes.
194
+ # @return [Integer] Hash code
195
+ def hash
196
+ [type, title, status, detail].hash
197
+ end
198
+
199
+ # Builds the object from hash
200
+ # @param [Hash] attributes Model attributes in the form of hash
201
+ # @return [Object] Returns the model itself
202
+ def self.build_from_hash(attributes)
203
+ return nil unless attributes.is_a?(Hash)
204
+ attributes = attributes.transform_keys(&:to_sym)
205
+ transformed_hash = {}
206
+ openapi_types.each_pair do |key, type|
207
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
208
+ transformed_hash["#{key}"] = nil
209
+ elsif type =~ /\AArray<(.*)>/i
210
+ # check to ensure the input is an array given that the attribute
211
+ # is documented as an array but the input is not
212
+ if attributes[attribute_map[key]].is_a?(Array)
213
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
214
+ end
215
+ elsif !attributes[attribute_map[key]].nil?
216
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
217
+ end
218
+ end
219
+ new(transformed_hash)
220
+ end
221
+
222
+ # Deserializes the data based on type
223
+ # @param string type Data type
224
+ # @param string value Value to be deserialized
225
+ # @return [Object] Deserialized data
226
+ def self._deserialize(type, value)
227
+ case type.to_sym
228
+ when :Time
229
+ Time.parse(value)
230
+ when :Date
231
+ Date.parse(value)
232
+ when :String
233
+ value.to_s
234
+ when :Integer
235
+ value.to_i
236
+ when :Float
237
+ value.to_f
238
+ when :Boolean
239
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
240
+ true
241
+ else
242
+ false
243
+ end
244
+ when :Object
245
+ # generic object (usually a Hash), return directly
246
+ value
247
+ when /\AArray<(?<inner_type>.+)>\z/
248
+ inner_type = Regexp.last_match[:inner_type]
249
+ value.map { |v| _deserialize(inner_type, v) }
250
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
251
+ k_type = Regexp.last_match[:k_type]
252
+ v_type = Regexp.last_match[:v_type]
253
+ {}.tap do |hash|
254
+ value.each do |k, v|
255
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
256
+ end
257
+ end
258
+ else # model
259
+ # models (e.g. Pet) or oneOf
260
+ klass = CyberTrackrClient.const_get(type)
261
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
262
+ end
263
+ end
264
+
265
+ # Returns the string representation of the object
266
+ # @return [String] String presentation of the object
267
+ def to_s
268
+ to_hash.to_s
269
+ end
270
+
271
+ # to_body is an alias to to_hash (backward compatibility)
272
+ # @return [Hash] Returns the object in the form of hash
273
+ def to_body
274
+ to_hash
275
+ end
276
+
277
+ # Returns the object in the form of hash
278
+ # @return [Hash] Returns the object in the form of hash
279
+ def to_hash
280
+ hash = {}
281
+ self.class.attribute_map.each_pair do |attr, param|
282
+ value = self.send(attr)
283
+ if value.nil?
284
+ is_nullable = self.class.openapi_nullable.include?(attr)
285
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
286
+ end
287
+
288
+ hash[param] = _to_hash(value)
289
+ end
290
+ hash
291
+ end
292
+
293
+ # Outputs non-array value in the form of hash
294
+ # For object, use to_hash. Otherwise, just return the value
295
+ # @param [Object] value Any valid value
296
+ # @return [Hash] Returns the value in the form of hash
297
+ def _to_hash(value)
298
+ if value.is_a?(Array)
299
+ value.compact.map { |v| _to_hash(v) }
300
+ elsif value.is_a?(Hash)
301
+ {}.tap do |hash|
302
+ value.each { |k, v| hash[k] = _to_hash(v) }
303
+ end
304
+ elsif value.respond_to? :to_hash
305
+ value.to_hash
306
+ else
307
+ value
308
+ end
309
+ end
310
+
311
+ end
312
+
313
+ end