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,321 @@
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
+ # Assessment procedure linking RMF control sub-parts to CCIs
18
+ class AssessmentProcedure
19
+ attr_accessor :assessment_procedures
20
+
21
+ attr_accessor :cci
22
+
23
+ attr_accessor :description
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'assessment_procedures' => :'assessment_procedures',
29
+ :'cci' => :'cci',
30
+ :'description' => :'description'
31
+ }
32
+ end
33
+
34
+ # Returns attribute mapping this model knows about
35
+ def self.acceptable_attribute_map
36
+ attribute_map
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ acceptable_attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'assessment_procedures' => :'String',
48
+ :'cci' => :'String',
49
+ :'description' => :'String'
50
+ }
51
+ end
52
+
53
+ # List of attributes with nullable: true
54
+ def self.openapi_nullable
55
+ Set.new([
56
+ ])
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ if (!attributes.is_a?(Hash))
63
+ fail ArgumentError, "The input argument (attributes) must be a hash in `CyberTrackrClient::AssessmentProcedure` initialize method"
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ acceptable_attribute_map = self.class.acceptable_attribute_map
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!acceptable_attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `CyberTrackrClient::AssessmentProcedure`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'assessment_procedures')
76
+ self.assessment_procedures = attributes[:'assessment_procedures']
77
+ else
78
+ self.assessment_procedures = nil
79
+ end
80
+
81
+ if attributes.key?(:'cci')
82
+ self.cci = attributes[:'cci']
83
+ else
84
+ self.cci = nil
85
+ end
86
+
87
+ if attributes.key?(:'description')
88
+ self.description = attributes[:'description']
89
+ else
90
+ self.description = nil
91
+ end
92
+ end
93
+
94
+ # Show invalid properties with the reasons. Usually used together with valid?
95
+ # @return Array for valid properties with the reasons
96
+ def list_invalid_properties
97
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
98
+ invalid_properties = Array.new
99
+ if @assessment_procedures.nil?
100
+ invalid_properties.push('invalid value for "assessment_procedures", assessment_procedures cannot be nil.')
101
+ end
102
+
103
+ pattern = Regexp.new(/^[A-Z]+-\d+\.\d+$/)
104
+ if @assessment_procedures !~ pattern
105
+ invalid_properties.push("invalid value for \"assessment_procedures\", must conform to the pattern #{pattern}.")
106
+ end
107
+
108
+ if @cci.nil?
109
+ invalid_properties.push('invalid value for "cci", cci cannot be nil.')
110
+ end
111
+
112
+ pattern = Regexp.new(/^CCI-\d{6}$/)
113
+ if @cci !~ pattern
114
+ invalid_properties.push("invalid value for \"cci\", must conform to the pattern #{pattern}.")
115
+ end
116
+
117
+ if @description.nil?
118
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
119
+ end
120
+
121
+ if @description.to_s.length < 1
122
+ invalid_properties.push('invalid value for "description", the character length must be greater than or equal to 1.')
123
+ end
124
+
125
+ invalid_properties
126
+ end
127
+
128
+ # Check to see if the all the properties in the model are valid
129
+ # @return true if the model is valid
130
+ def valid?
131
+ warn '[DEPRECATED] the `valid?` method is obsolete'
132
+ return false if @assessment_procedures.nil?
133
+ return false if @assessment_procedures !~ Regexp.new(/^[A-Z]+-\d+\.\d+$/)
134
+ return false if @cci.nil?
135
+ return false if @cci !~ Regexp.new(/^CCI-\d{6}$/)
136
+ return false if @description.nil?
137
+ return false if @description.to_s.length < 1
138
+ true
139
+ end
140
+
141
+ # Custom attribute writer method with validation
142
+ # @param [Object] assessment_procedures Value to be assigned
143
+ def assessment_procedures=(assessment_procedures)
144
+ if assessment_procedures.nil?
145
+ fail ArgumentError, 'assessment_procedures cannot be nil'
146
+ end
147
+
148
+ pattern = Regexp.new(/^[A-Z]+-\d+\.\d+$/)
149
+ if assessment_procedures !~ pattern
150
+ fail ArgumentError, "invalid value for \"assessment_procedures\", must conform to the pattern #{pattern}."
151
+ end
152
+
153
+ @assessment_procedures = assessment_procedures
154
+ end
155
+
156
+ # Custom attribute writer method with validation
157
+ # @param [Object] cci Value to be assigned
158
+ def cci=(cci)
159
+ if cci.nil?
160
+ fail ArgumentError, 'cci cannot be nil'
161
+ end
162
+
163
+ pattern = Regexp.new(/^CCI-\d{6}$/)
164
+ if cci !~ pattern
165
+ fail ArgumentError, "invalid value for \"cci\", must conform to the pattern #{pattern}."
166
+ end
167
+
168
+ @cci = cci
169
+ end
170
+
171
+ # Custom attribute writer method with validation
172
+ # @param [Object] description Value to be assigned
173
+ def description=(description)
174
+ if description.nil?
175
+ fail ArgumentError, 'description cannot be nil'
176
+ end
177
+
178
+ if description.to_s.length < 1
179
+ fail ArgumentError, 'invalid value for "description", the character length must be greater than or equal to 1.'
180
+ end
181
+
182
+ @description = description
183
+ end
184
+
185
+ # Checks equality by comparing each attribute.
186
+ # @param [Object] Object to be compared
187
+ def ==(o)
188
+ return true if self.equal?(o)
189
+ self.class == o.class &&
190
+ assessment_procedures == o.assessment_procedures &&
191
+ cci == o.cci &&
192
+ description == o.description
193
+ end
194
+
195
+ # @see the `==` method
196
+ # @param [Object] Object to be compared
197
+ def eql?(o)
198
+ self == o
199
+ end
200
+
201
+ # Calculates hash code according to all attributes.
202
+ # @return [Integer] Hash code
203
+ def hash
204
+ [assessment_procedures, cci, description].hash
205
+ end
206
+
207
+ # Builds the object from hash
208
+ # @param [Hash] attributes Model attributes in the form of hash
209
+ # @return [Object] Returns the model itself
210
+ def self.build_from_hash(attributes)
211
+ return nil unless attributes.is_a?(Hash)
212
+ attributes = attributes.transform_keys(&:to_sym)
213
+ transformed_hash = {}
214
+ openapi_types.each_pair do |key, type|
215
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
216
+ transformed_hash["#{key}"] = nil
217
+ elsif type =~ /\AArray<(.*)>/i
218
+ # check to ensure the input is an array given that the attribute
219
+ # is documented as an array but the input is not
220
+ if attributes[attribute_map[key]].is_a?(Array)
221
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
222
+ end
223
+ elsif !attributes[attribute_map[key]].nil?
224
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
225
+ end
226
+ end
227
+ new(transformed_hash)
228
+ end
229
+
230
+ # Deserializes the data based on type
231
+ # @param string type Data type
232
+ # @param string value Value to be deserialized
233
+ # @return [Object] Deserialized data
234
+ def self._deserialize(type, value)
235
+ case type.to_sym
236
+ when :Time
237
+ Time.parse(value)
238
+ when :Date
239
+ Date.parse(value)
240
+ when :String
241
+ value.to_s
242
+ when :Integer
243
+ value.to_i
244
+ when :Float
245
+ value.to_f
246
+ when :Boolean
247
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
248
+ true
249
+ else
250
+ false
251
+ end
252
+ when :Object
253
+ # generic object (usually a Hash), return directly
254
+ value
255
+ when /\AArray<(?<inner_type>.+)>\z/
256
+ inner_type = Regexp.last_match[:inner_type]
257
+ value.map { |v| _deserialize(inner_type, v) }
258
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
259
+ k_type = Regexp.last_match[:k_type]
260
+ v_type = Regexp.last_match[:v_type]
261
+ {}.tap do |hash|
262
+ value.each do |k, v|
263
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
264
+ end
265
+ end
266
+ else # model
267
+ # models (e.g. Pet) or oneOf
268
+ klass = CyberTrackrClient.const_get(type)
269
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
270
+ end
271
+ end
272
+
273
+ # Returns the string representation of the object
274
+ # @return [String] String presentation of the object
275
+ def to_s
276
+ to_hash.to_s
277
+ end
278
+
279
+ # to_body is an alias to to_hash (backward compatibility)
280
+ # @return [Hash] Returns the object in the form of hash
281
+ def to_body
282
+ to_hash
283
+ end
284
+
285
+ # Returns the object in the form of hash
286
+ # @return [Hash] Returns the object in the form of hash
287
+ def to_hash
288
+ hash = {}
289
+ self.class.attribute_map.each_pair do |attr, param|
290
+ value = self.send(attr)
291
+ if value.nil?
292
+ is_nullable = self.class.openapi_nullable.include?(attr)
293
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
294
+ end
295
+
296
+ hash[param] = _to_hash(value)
297
+ end
298
+ hash
299
+ end
300
+
301
+ # Outputs non-array value in the form of hash
302
+ # For object, use to_hash. Otherwise, just return the value
303
+ # @param [Object] value Any valid value
304
+ # @return [Hash] Returns the value in the form of hash
305
+ def _to_hash(value)
306
+ if value.is_a?(Array)
307
+ value.compact.map { |v| _to_hash(v) }
308
+ elsif value.is_a?(Hash)
309
+ {}.tap do |hash|
310
+ value.each { |k, v| hash[k] = _to_hash(v) }
311
+ end
312
+ elsif value.respond_to? :to_hash
313
+ value.to_hash
314
+ else
315
+ value
316
+ end
317
+ end
318
+
319
+ end
320
+
321
+ end
@@ -0,0 +1,391 @@
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
+ # Complete CCI details with RMF control mapping
18
+ class CciDetail
19
+ attr_accessor :cci
20
+
21
+ attr_accessor :cci_definition
22
+
23
+ attr_accessor :rmf
24
+
25
+ attr_accessor :family
26
+
27
+ attr_accessor :name
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'cci' => :'cci',
33
+ :'cci_definition' => :'cci_definition',
34
+ :'rmf' => :'rmf',
35
+ :'family' => :'family',
36
+ :'name' => :'name'
37
+ }
38
+ end
39
+
40
+ # Returns attribute mapping this model knows about
41
+ def self.acceptable_attribute_map
42
+ attribute_map
43
+ end
44
+
45
+ # Returns all the JSON keys this model knows about
46
+ def self.acceptable_attributes
47
+ acceptable_attribute_map.values
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'cci' => :'String',
54
+ :'cci_definition' => :'String',
55
+ :'rmf' => :'String',
56
+ :'family' => :'String',
57
+ :'name' => :'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::CciDetail` 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::CciDetail`. 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?(:'cci')
84
+ self.cci = attributes[:'cci']
85
+ else
86
+ self.cci = nil
87
+ end
88
+
89
+ if attributes.key?(:'cci_definition')
90
+ self.cci_definition = attributes[:'cci_definition']
91
+ else
92
+ self.cci_definition = nil
93
+ end
94
+
95
+ if attributes.key?(:'rmf')
96
+ self.rmf = attributes[:'rmf']
97
+ else
98
+ self.rmf = nil
99
+ end
100
+
101
+ if attributes.key?(:'family')
102
+ self.family = attributes[:'family']
103
+ else
104
+ self.family = nil
105
+ end
106
+
107
+ if attributes.key?(:'name')
108
+ self.name = attributes[:'name']
109
+ else
110
+ self.name = nil
111
+ end
112
+ end
113
+
114
+ # Show invalid properties with the reasons. Usually used together with valid?
115
+ # @return Array for valid properties with the reasons
116
+ def list_invalid_properties
117
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
118
+ invalid_properties = Array.new
119
+ if @cci.nil?
120
+ invalid_properties.push('invalid value for "cci", cci cannot be nil.')
121
+ end
122
+
123
+ pattern = Regexp.new(/^CCI-\d{6}$/)
124
+ if @cci !~ pattern
125
+ invalid_properties.push("invalid value for \"cci\", must conform to the pattern #{pattern}.")
126
+ end
127
+
128
+ if @cci_definition.nil?
129
+ invalid_properties.push('invalid value for "cci_definition", cci_definition cannot be nil.')
130
+ end
131
+
132
+ if @cci_definition.to_s.length < 1
133
+ invalid_properties.push('invalid value for "cci_definition", the character length must be greater than or equal to 1.')
134
+ end
135
+
136
+ if @rmf.nil?
137
+ invalid_properties.push('invalid value for "rmf", rmf cannot be nil.')
138
+ end
139
+
140
+ pattern = Regexp.new(/^[A-Z]+-\d+$/)
141
+ if @rmf !~ pattern
142
+ invalid_properties.push("invalid value for \"rmf\", must conform to the pattern #{pattern}.")
143
+ end
144
+
145
+ if @family.nil?
146
+ invalid_properties.push('invalid value for "family", family cannot be nil.')
147
+ end
148
+
149
+ if @family.to_s.length < 1
150
+ invalid_properties.push('invalid value for "family", the character length must be greater than or equal to 1.')
151
+ end
152
+
153
+ if @name.nil?
154
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
155
+ end
156
+
157
+ if @name.to_s.length < 1
158
+ invalid_properties.push('invalid value for "name", the character length must be greater than or equal to 1.')
159
+ end
160
+
161
+ invalid_properties
162
+ end
163
+
164
+ # Check to see if the all the properties in the model are valid
165
+ # @return true if the model is valid
166
+ def valid?
167
+ warn '[DEPRECATED] the `valid?` method is obsolete'
168
+ return false if @cci.nil?
169
+ return false if @cci !~ Regexp.new(/^CCI-\d{6}$/)
170
+ return false if @cci_definition.nil?
171
+ return false if @cci_definition.to_s.length < 1
172
+ return false if @rmf.nil?
173
+ return false if @rmf !~ Regexp.new(/^[A-Z]+-\d+$/)
174
+ return false if @family.nil?
175
+ return false if @family.to_s.length < 1
176
+ return false if @name.nil?
177
+ return false if @name.to_s.length < 1
178
+ true
179
+ end
180
+
181
+ # Custom attribute writer method with validation
182
+ # @param [Object] cci Value to be assigned
183
+ def cci=(cci)
184
+ if cci.nil?
185
+ fail ArgumentError, 'cci cannot be nil'
186
+ end
187
+
188
+ pattern = Regexp.new(/^CCI-\d{6}$/)
189
+ if cci !~ pattern
190
+ fail ArgumentError, "invalid value for \"cci\", must conform to the pattern #{pattern}."
191
+ end
192
+
193
+ @cci = cci
194
+ end
195
+
196
+ # Custom attribute writer method with validation
197
+ # @param [Object] cci_definition Value to be assigned
198
+ def cci_definition=(cci_definition)
199
+ if cci_definition.nil?
200
+ fail ArgumentError, 'cci_definition cannot be nil'
201
+ end
202
+
203
+ if cci_definition.to_s.length < 1
204
+ fail ArgumentError, 'invalid value for "cci_definition", the character length must be greater than or equal to 1.'
205
+ end
206
+
207
+ @cci_definition = cci_definition
208
+ end
209
+
210
+ # Custom attribute writer method with validation
211
+ # @param [Object] rmf Value to be assigned
212
+ def rmf=(rmf)
213
+ if rmf.nil?
214
+ fail ArgumentError, 'rmf cannot be nil'
215
+ end
216
+
217
+ pattern = Regexp.new(/^[A-Z]+-\d+$/)
218
+ if rmf !~ pattern
219
+ fail ArgumentError, "invalid value for \"rmf\", must conform to the pattern #{pattern}."
220
+ end
221
+
222
+ @rmf = rmf
223
+ end
224
+
225
+ # Custom attribute writer method with validation
226
+ # @param [Object] family Value to be assigned
227
+ def family=(family)
228
+ if family.nil?
229
+ fail ArgumentError, 'family cannot be nil'
230
+ end
231
+
232
+ if family.to_s.length < 1
233
+ fail ArgumentError, 'invalid value for "family", the character length must be greater than or equal to 1.'
234
+ end
235
+
236
+ @family = family
237
+ end
238
+
239
+ # Custom attribute writer method with validation
240
+ # @param [Object] name Value to be assigned
241
+ def name=(name)
242
+ if name.nil?
243
+ fail ArgumentError, 'name cannot be nil'
244
+ end
245
+
246
+ if name.to_s.length < 1
247
+ fail ArgumentError, 'invalid value for "name", the character length must be greater than or equal to 1.'
248
+ end
249
+
250
+ @name = name
251
+ end
252
+
253
+ # Checks equality by comparing each attribute.
254
+ # @param [Object] Object to be compared
255
+ def ==(o)
256
+ return true if self.equal?(o)
257
+ self.class == o.class &&
258
+ cci == o.cci &&
259
+ cci_definition == o.cci_definition &&
260
+ rmf == o.rmf &&
261
+ family == o.family &&
262
+ name == o.name
263
+ end
264
+
265
+ # @see the `==` method
266
+ # @param [Object] Object to be compared
267
+ def eql?(o)
268
+ self == o
269
+ end
270
+
271
+ # Calculates hash code according to all attributes.
272
+ # @return [Integer] Hash code
273
+ def hash
274
+ [cci, cci_definition, rmf, family, name].hash
275
+ end
276
+
277
+ # Builds the object from hash
278
+ # @param [Hash] attributes Model attributes in the form of hash
279
+ # @return [Object] Returns the model itself
280
+ def self.build_from_hash(attributes)
281
+ return nil unless attributes.is_a?(Hash)
282
+ attributes = attributes.transform_keys(&:to_sym)
283
+ transformed_hash = {}
284
+ openapi_types.each_pair do |key, type|
285
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
286
+ transformed_hash["#{key}"] = nil
287
+ elsif type =~ /\AArray<(.*)>/i
288
+ # check to ensure the input is an array given that the attribute
289
+ # is documented as an array but the input is not
290
+ if attributes[attribute_map[key]].is_a?(Array)
291
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
292
+ end
293
+ elsif !attributes[attribute_map[key]].nil?
294
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
295
+ end
296
+ end
297
+ new(transformed_hash)
298
+ end
299
+
300
+ # Deserializes the data based on type
301
+ # @param string type Data type
302
+ # @param string value Value to be deserialized
303
+ # @return [Object] Deserialized data
304
+ def self._deserialize(type, value)
305
+ case type.to_sym
306
+ when :Time
307
+ Time.parse(value)
308
+ when :Date
309
+ Date.parse(value)
310
+ when :String
311
+ value.to_s
312
+ when :Integer
313
+ value.to_i
314
+ when :Float
315
+ value.to_f
316
+ when :Boolean
317
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
318
+ true
319
+ else
320
+ false
321
+ end
322
+ when :Object
323
+ # generic object (usually a Hash), return directly
324
+ value
325
+ when /\AArray<(?<inner_type>.+)>\z/
326
+ inner_type = Regexp.last_match[:inner_type]
327
+ value.map { |v| _deserialize(inner_type, v) }
328
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
329
+ k_type = Regexp.last_match[:k_type]
330
+ v_type = Regexp.last_match[:v_type]
331
+ {}.tap do |hash|
332
+ value.each do |k, v|
333
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
334
+ end
335
+ end
336
+ else # model
337
+ # models (e.g. Pet) or oneOf
338
+ klass = CyberTrackrClient.const_get(type)
339
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
340
+ end
341
+ end
342
+
343
+ # Returns the string representation of the object
344
+ # @return [String] String presentation of the object
345
+ def to_s
346
+ to_hash.to_s
347
+ end
348
+
349
+ # to_body is an alias to to_hash (backward compatibility)
350
+ # @return [Hash] Returns the object in the form of hash
351
+ def to_body
352
+ to_hash
353
+ end
354
+
355
+ # Returns the object in the form of hash
356
+ # @return [Hash] Returns the object in the form of hash
357
+ def to_hash
358
+ hash = {}
359
+ self.class.attribute_map.each_pair do |attr, param|
360
+ value = self.send(attr)
361
+ if value.nil?
362
+ is_nullable = self.class.openapi_nullable.include?(attr)
363
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
364
+ end
365
+
366
+ hash[param] = _to_hash(value)
367
+ end
368
+ hash
369
+ end
370
+
371
+ # Outputs non-array value in the form of hash
372
+ # For object, use to_hash. Otherwise, just return the value
373
+ # @param [Object] value Any valid value
374
+ # @return [Hash] Returns the value in the form of hash
375
+ def _to_hash(value)
376
+ if value.is_a?(Array)
377
+ value.compact.map { |v| _to_hash(v) }
378
+ elsif value.is_a?(Hash)
379
+ {}.tap do |hash|
380
+ value.each { |k, v| hash[k] = _to_hash(v) }
381
+ end
382
+ elsif value.respond_to? :to_hash
383
+ value.to_hash
384
+ else
385
+ value
386
+ end
387
+ end
388
+
389
+ end
390
+
391
+ end