Class: CtdDocumentation::Asset

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/ctd_documentation/models/asset.rb

Overview

Asset Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(resource_id = SKIP, id = SKIP, site_id = SKIP, approved = SKIP, asset_type_number = SKIP, asset_type_name = SKIP, class_type = SKIP, criticality_number = SKIP, criticality_name = SKIP, display_name = SKIP, first_seen = SKIP, last_seen = SKIP, last_updated = SKIP, ghost = SKIP, hostname = SKIP, installed_programs_count = SKIP, mac = SKIP, name = SKIP, network_id = SKIP, num_alerts = SKIP, patch_count = SKIP, parsed = SKIP, protocol = SKIP, purdue_level = 3, risk_level = SKIP, site_name = SKIP, special_hint = SKIP, special_hint_name = SKIP, vlan = SKIP, virtual_zone_id = SKIP, virtual_zone_name = SKIP, vendor = SKIP, valid = SKIP, subnet_id = SKIP, usb_devices_count = SKIP, timestamp = SKIP, network = SKIP, active_queries_names = SKIP, active_scans_names = SKIP, children = SKIP, custom_attributes = SKIP, custom_informations = SKIP, insight_names = SKIP, code_sections = SKIP) ⇒ Asset

Returns a new instance of Asset.



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'lib/ctd_documentation/models/asset.rb', line 293

def initialize(resource_id = SKIP,
               id = SKIP,
               site_id = SKIP,
               approved = SKIP,
               asset_type_number = SKIP,
               asset_type_name = SKIP,
               class_type = SKIP,
               criticality_number = SKIP,
               criticality_name = SKIP,
               display_name = SKIP,
               first_seen = SKIP,
               last_seen = SKIP,
               last_updated = SKIP,
               ghost = SKIP,
               hostname = SKIP,
               installed_programs_count = SKIP,
               mac = SKIP,
               name = SKIP,
               network_id = SKIP,
               num_alerts = SKIP,
               patch_count = SKIP,
               parsed = SKIP,
               protocol = SKIP,
               purdue_level = 3,
               risk_level = SKIP,
               site_name = SKIP,
               special_hint = SKIP,
               special_hint_name = SKIP,
               vlan = SKIP,
               virtual_zone_id = SKIP,
               virtual_zone_name = SKIP,
               vendor = SKIP,
               valid = SKIP,
               subnet_id = SKIP,
               usb_devices_count = SKIP,
               timestamp = SKIP,
               network = SKIP,
               active_queries_names = SKIP,
               active_scans_names = SKIP,
               children = SKIP,
               custom_attributes = SKIP,
               custom_informations = SKIP,
               insight_names = SKIP,
               code_sections = SKIP)
  @resource_id = resource_id unless resource_id == SKIP
  @id = id unless id == SKIP
  @site_id = site_id unless site_id == SKIP
  @approved = approved unless approved == SKIP
  @asset_type_number = asset_type_number unless asset_type_number == SKIP
  @asset_type_name = asset_type_name unless asset_type_name == SKIP
  @class_type = class_type unless class_type == SKIP
  @criticality_number = criticality_number unless criticality_number == SKIP
  @criticality_name = criticality_name unless criticality_name == SKIP
  @display_name = display_name unless display_name == SKIP
  @first_seen = first_seen unless first_seen == SKIP
  @last_seen = last_seen unless last_seen == SKIP
  @last_updated = last_updated unless last_updated == SKIP
  @ghost = ghost unless ghost == SKIP
  @hostname = hostname unless hostname == SKIP
  @installed_programs_count = installed_programs_count unless installed_programs_count == SKIP
  @mac = mac unless mac == SKIP
  @name = name unless name == SKIP
  @network_id = network_id unless network_id == SKIP
  @num_alerts = num_alerts unless num_alerts == SKIP
  @patch_count = patch_count unless patch_count == SKIP
  @parsed = parsed unless parsed == SKIP
  @protocol = protocol unless protocol == SKIP
  @purdue_level = purdue_level unless purdue_level == SKIP
  @risk_level = risk_level unless risk_level == SKIP
  @site_name = site_name unless site_name == SKIP
  @special_hint = special_hint unless special_hint == SKIP
  @special_hint_name = special_hint_name unless special_hint_name == SKIP
  @vlan = vlan unless vlan == SKIP
  @virtual_zone_id = virtual_zone_id unless virtual_zone_id == SKIP
  @virtual_zone_name = virtual_zone_name unless virtual_zone_name == SKIP
  @vendor = vendor unless vendor == SKIP
  @valid = valid unless valid == SKIP
  @subnet_id = subnet_id unless subnet_id == SKIP
  @usb_devices_count = usb_devices_count unless usb_devices_count == SKIP
  @timestamp = timestamp unless timestamp == SKIP
  @network = network unless network == SKIP
  @active_queries_names = active_queries_names unless active_queries_names == SKIP
  @active_scans_names = active_scans_names unless active_scans_names == SKIP
  @children = children unless children == SKIP
  @custom_attributes = custom_attributes unless custom_attributes == SKIP
  @custom_informations = custom_informations unless custom_informations == SKIP
  @insight_names = insight_names unless insight_names == SKIP
  @code_sections = code_sections unless code_sections == SKIP
end

Instance Attribute Details

#active_queries_namesList of String

TODO: Write general description for this method

Returns:

  • (List of String)


162
163
164
# File 'lib/ctd_documentation/models/asset.rb', line 162

def active_queries_names
  @active_queries_names
end

#active_scans_namesList of String

TODO: Write general description for this method

Returns:

  • (List of String)


166
167
168
# File 'lib/ctd_documentation/models/asset.rb', line 166

def active_scans_names
  @active_scans_names
end

#approvedTrueClass|FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass|FalseClass)


26
27
28
# File 'lib/ctd_documentation/models/asset.rb', line 26

def approved
  @approved
end

#asset_type_nameString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/ctd_documentation/models/asset.rb', line 34

def asset_type_name
  @asset_type_name
end

#asset_type_numberInteger

TODO: Write general description for this method

Returns:

  • (Integer)


30
31
32
# File 'lib/ctd_documentation/models/asset.rb', line 30

def asset_type_number
  @asset_type_number
end

#childrenList of Object

TODO: Write general description for this method

Returns:



170
171
172
# File 'lib/ctd_documentation/models/asset.rb', line 170

def children
  @children
end

#class_typeString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/ctd_documentation/models/asset.rb', line 38

def class_type
  @class_type
end

#code_sectionsList of CodeSections

TODO: Write general description for this method

Returns:



186
187
188
# File 'lib/ctd_documentation/models/asset.rb', line 186

def code_sections
  @code_sections
end

#criticality_nameString

TODO: Write general description for this method

Returns:

  • (String)


46
47
48
# File 'lib/ctd_documentation/models/asset.rb', line 46

def criticality_name
  @criticality_name
end

#criticality_numberInteger

TODO: Write general description for this method

Returns:

  • (Integer)


42
43
44
# File 'lib/ctd_documentation/models/asset.rb', line 42

def criticality_number
  @criticality_number
end

#custom_attributesList of Object

TODO: Write general description for this method

Returns:



174
175
176
# File 'lib/ctd_documentation/models/asset.rb', line 174

def custom_attributes
  @custom_attributes
end

#custom_informationsList of Object

TODO: Write general description for this method

Returns:



178
179
180
# File 'lib/ctd_documentation/models/asset.rb', line 178

def custom_informations
  @custom_informations
end

#display_nameString

TODO: Write general description for this method

Returns:

  • (String)


50
51
52
# File 'lib/ctd_documentation/models/asset.rb', line 50

def display_name
  @display_name
end

#first_seenString

TODO: Write general description for this method

Returns:

  • (String)


54
55
56
# File 'lib/ctd_documentation/models/asset.rb', line 54

def first_seen
  @first_seen
end

#ghostTrueClass|FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass|FalseClass)


66
67
68
# File 'lib/ctd_documentation/models/asset.rb', line 66

def ghost
  @ghost
end

#hostnameString

TODO: Write general description for this method

Returns:

  • (String)


70
71
72
# File 'lib/ctd_documentation/models/asset.rb', line 70

def hostname
  @hostname
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/ctd_documentation/models/asset.rb', line 18

def id
  @id
end

#insight_namesList of String

TODO: Write general description for this method

Returns:

  • (List of String)


182
183
184
# File 'lib/ctd_documentation/models/asset.rb', line 182

def insight_names
  @insight_names
end

#installed_programs_countInteger

TODO: Write general description for this method

Returns:

  • (Integer)


74
75
76
# File 'lib/ctd_documentation/models/asset.rb', line 74

def installed_programs_count
  @installed_programs_count
end

#last_seenString

TODO: Write general description for this method

Returns:

  • (String)


58
59
60
# File 'lib/ctd_documentation/models/asset.rb', line 58

def last_seen
  @last_seen
end

#last_updatedString

TODO: Write general description for this method

Returns:

  • (String)


62
63
64
# File 'lib/ctd_documentation/models/asset.rb', line 62

def last_updated
  @last_updated
end

#macList of String

TODO: Write general description for this method

Returns:

  • (List of String)


78
79
80
# File 'lib/ctd_documentation/models/asset.rb', line 78

def mac
  @mac
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


82
83
84
# File 'lib/ctd_documentation/models/asset.rb', line 82

def name
  @name
end

#networkNetwork

TODO: Write general description for this method

Returns:



158
159
160
# File 'lib/ctd_documentation/models/asset.rb', line 158

def network
  @network
end

#network_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


86
87
88
# File 'lib/ctd_documentation/models/asset.rb', line 86

def network_id
  @network_id
end

#num_alertsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


90
91
92
# File 'lib/ctd_documentation/models/asset.rb', line 90

def num_alerts
  @num_alerts
end

#parsedTrueClass|FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass|FalseClass)


98
99
100
# File 'lib/ctd_documentation/models/asset.rb', line 98

def parsed
  @parsed
end

#patch_countInteger

TODO: Write general description for this method

Returns:

  • (Integer)


94
95
96
# File 'lib/ctd_documentation/models/asset.rb', line 94

def patch_count
  @patch_count
end

#protocolList of String

TODO: Write general description for this method

Returns:

  • (List of String)


102
103
104
# File 'lib/ctd_documentation/models/asset.rb', line 102

def protocol
  @protocol
end

#purdue_levelFloat

TODO: Write general description for this method

Returns:

  • (Float)


106
107
108
# File 'lib/ctd_documentation/models/asset.rb', line 106

def purdue_level
  @purdue_level
end

#resource_idString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/ctd_documentation/models/asset.rb', line 14

def resource_id
  @resource_id
end

#risk_levelInteger

TODO: Write general description for this method

Returns:

  • (Integer)


110
111
112
# File 'lib/ctd_documentation/models/asset.rb', line 110

def risk_level
  @risk_level
end

#site_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/ctd_documentation/models/asset.rb', line 22

def site_id
  @site_id
end

#site_nameString

TODO: Write general description for this method

Returns:

  • (String)


114
115
116
# File 'lib/ctd_documentation/models/asset.rb', line 114

def site_name
  @site_name
end

#special_hintInteger

TODO: Write general description for this method

Returns:

  • (Integer)


118
119
120
# File 'lib/ctd_documentation/models/asset.rb', line 118

def special_hint
  @special_hint
end

#special_hint_nameString

TODO: Write general description for this method

Returns:

  • (String)


122
123
124
# File 'lib/ctd_documentation/models/asset.rb', line 122

def special_hint_name
  @special_hint_name
end

#subnet_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


146
147
148
# File 'lib/ctd_documentation/models/asset.rb', line 146

def subnet_id
  @subnet_id
end

#timestampString

TODO: Write general description for this method

Returns:

  • (String)


154
155
156
# File 'lib/ctd_documentation/models/asset.rb', line 154

def timestamp
  @timestamp
end

#usb_devices_countInteger

TODO: Write general description for this method

Returns:

  • (Integer)


150
151
152
# File 'lib/ctd_documentation/models/asset.rb', line 150

def usb_devices_count
  @usb_devices_count
end

#validTrueClass|FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass|FalseClass)


142
143
144
# File 'lib/ctd_documentation/models/asset.rb', line 142

def valid
  @valid
end

#vendorString

TODO: Write general description for this method

Returns:

  • (String)


138
139
140
# File 'lib/ctd_documentation/models/asset.rb', line 138

def vendor
  @vendor
end

#virtual_zone_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


130
131
132
# File 'lib/ctd_documentation/models/asset.rb', line 130

def virtual_zone_id
  @virtual_zone_id
end

#virtual_zone_nameString

TODO: Write general description for this method

Returns:

  • (String)


134
135
136
# File 'lib/ctd_documentation/models/asset.rb', line 134

def virtual_zone_name
  @virtual_zone_name
end

#vlanList of String

TODO: Write general description for this method

Returns:

  • (List of String)


126
127
128
# File 'lib/ctd_documentation/models/asset.rb', line 126

def vlan
  @vlan
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'lib/ctd_documentation/models/asset.rb', line 384

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  resource_id = hash.key?('resource_id') ? hash['resource_id'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  site_id = hash.key?('site_id') ? hash['site_id'] : SKIP
  approved = hash.key?('approved') ? hash['approved'] : SKIP
  asset_type_number =
    hash.key?('asset_type_number') ? hash['asset_type_number'] : SKIP
  asset_type_name =
    hash.key?('asset_type_name') ? hash['asset_type_name'] : SKIP
  class_type = hash.key?('class_type') ? hash['class_type'] : SKIP
  criticality_number =
    hash.key?('criticality_number') ? hash['criticality_number'] : SKIP
  criticality_name =
    hash.key?('criticality_name') ? hash['criticality_name'] : SKIP
  display_name = hash.key?('display_name') ? hash['display_name'] : SKIP
  first_seen = hash.key?('first_seen') ? hash['first_seen'] : SKIP
  last_seen = hash.key?('last_seen') ? hash['last_seen'] : SKIP
  last_updated = hash.key?('last_updated') ? hash['last_updated'] : SKIP
  ghost = hash.key?('ghost') ? hash['ghost'] : SKIP
  hostname = hash.key?('hostname') ? hash['hostname'] : SKIP
  installed_programs_count =
    hash.key?('installed_programs_count') ? hash['installed_programs_count'] : SKIP
  mac = hash.key?('mac') ? hash['mac'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  network_id = hash.key?('network_id') ? hash['network_id'] : SKIP
  num_alerts = hash.key?('num_alerts') ? hash['num_alerts'] : SKIP
  patch_count = hash.key?('patch_count') ? hash['patch_count'] : SKIP
  parsed = hash.key?('parsed') ? hash['parsed'] : SKIP
  protocol = hash.key?('protocol') ? hash['protocol'] : SKIP
  purdue_level = hash['purdue_level'] ||= 3
  risk_level = hash.key?('risk_level') ? hash['risk_level'] : SKIP
  site_name = hash.key?('site_name') ? hash['site_name'] : SKIP
  special_hint = hash.key?('special_hint_') ? hash['special_hint_'] : SKIP
  special_hint_name =
    hash.key?('special_hint_name') ? hash['special_hint_name'] : SKIP
  vlan = hash.key?('vlan') ? hash['vlan'] : SKIP
  virtual_zone_id =
    hash.key?('virtual_zone_id') ? hash['virtual_zone_id'] : SKIP
  virtual_zone_name =
    hash.key?('virtual_zone_name') ? hash['virtual_zone_name'] : SKIP
  vendor = hash.key?('vendor') ? hash['vendor'] : SKIP
  valid = hash.key?('valid') ? hash['valid'] : SKIP
  subnet_id = hash.key?('subnet_id') ? hash['subnet_id'] : SKIP
  usb_devices_count =
    hash.key?('usb_devices_count') ? hash['usb_devices_count'] : SKIP
  timestamp = hash.key?('timestamp') ? hash['timestamp'] : SKIP
  network = Network.from_hash(hash['network']) if hash['network']
  active_queries_names =
    hash.key?('active_queries_names') ? hash['active_queries_names'] : SKIP
  active_scans_names =
    hash.key?('active_scans_names') ? hash['active_scans_names'] : SKIP
  # Parameter is an array, so we need to iterate through it
  children = nil
  unless hash['children'].nil?
    children = []
    hash['children'].each do |structure|
      children << (Object.from_hash(structure) if structure)
    end
  end

  children = SKIP unless hash.key?('children')
  # Parameter is an array, so we need to iterate through it
  custom_attributes = nil
  unless hash['custom_attributes'].nil?
    custom_attributes = []
    hash['custom_attributes'].each do |structure|
      custom_attributes << (Object.from_hash(structure) if structure)
    end
  end

  custom_attributes = SKIP unless hash.key?('custom_attributes')
  # Parameter is an array, so we need to iterate through it
  custom_informations = nil
  unless hash['custom_informations'].nil?
    custom_informations = []
    hash['custom_informations'].each do |structure|
      custom_informations << (Object.from_hash(structure) if structure)
    end
  end

  custom_informations = SKIP unless hash.key?('custom_informations')
  insight_names = hash.key?('insight_names') ? hash['insight_names'] : SKIP
  # Parameter is an array, so we need to iterate through it
  code_sections = nil
  unless hash['code_sections'].nil?
    code_sections = []
    hash['code_sections'].each do |structure|
      code_sections << (CodeSections.from_hash(structure) if structure)
    end
  end

  code_sections = SKIP unless hash.key?('code_sections')

  # Create object from extracted values.
  Asset.new(resource_id,
            id,
            site_id,
            approved,
            asset_type_number,
            asset_type_name,
            class_type,
            criticality_number,
            criticality_name,
            display_name,
            first_seen,
            last_seen,
            last_updated,
            ghost,
            hostname,
            installed_programs_count,
            mac,
            name,
            network_id,
            num_alerts,
            patch_count,
            parsed,
            protocol,
            purdue_level,
            risk_level,
            site_name,
            special_hint,
            special_hint_name,
            vlan,
            virtual_zone_id,
            virtual_zone_name,
            vendor,
            valid,
            subnet_id,
            usb_devices_count,
            timestamp,
            network,
            active_queries_names,
            active_scans_names,
            children,
            custom_attributes,
            custom_informations,
            insight_names,
            code_sections)
end

.namesObject

A mapping from model property names to API property names.



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/ctd_documentation/models/asset.rb', line 189

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['resource_id'] = 'resource_id'
  @_hash['id'] = 'id'
  @_hash['site_id'] = 'site_id'
  @_hash['approved'] = 'approved'
  @_hash['asset_type_number'] = 'asset_type_number'
  @_hash['asset_type_name'] = 'asset_type_name'
  @_hash['class_type'] = 'class_type'
  @_hash['criticality_number'] = 'criticality_number'
  @_hash['criticality_name'] = 'criticality_name'
  @_hash['display_name'] = 'display_name'
  @_hash['first_seen'] = 'first_seen'
  @_hash['last_seen'] = 'last_seen'
  @_hash['last_updated'] = 'last_updated'
  @_hash['ghost'] = 'ghost'
  @_hash['hostname'] = 'hostname'
  @_hash['installed_programs_count'] = 'installed_programs_count'
  @_hash['mac'] = 'mac'
  @_hash['name'] = 'name'
  @_hash['network_id'] = 'network_id'
  @_hash['num_alerts'] = 'num_alerts'
  @_hash['patch_count'] = 'patch_count'
  @_hash['parsed'] = 'parsed'
  @_hash['protocol'] = 'protocol'
  @_hash['purdue_level'] = 'purdue_level'
  @_hash['risk_level'] = 'risk_level'
  @_hash['site_name'] = 'site_name'
  @_hash['special_hint'] = 'special_hint_'
  @_hash['special_hint_name'] = 'special_hint_name'
  @_hash['vlan'] = 'vlan'
  @_hash['virtual_zone_id'] = 'virtual_zone_id'
  @_hash['virtual_zone_name'] = 'virtual_zone_name'
  @_hash['vendor'] = 'vendor'
  @_hash['valid'] = 'valid'
  @_hash['subnet_id'] = 'subnet_id'
  @_hash['usb_devices_count'] = 'usb_devices_count'
  @_hash['timestamp'] = 'timestamp'
  @_hash['network'] = 'network'
  @_hash['active_queries_names'] = 'active_queries_names'
  @_hash['active_scans_names'] = 'active_scans_names'
  @_hash['children'] = 'children'
  @_hash['custom_attributes'] = 'custom_attributes'
  @_hash['custom_informations'] = 'custom_informations'
  @_hash['insight_names'] = 'insight_names'
  @_hash['code_sections'] = 'code_sections'
  @_hash
end

.nullablesObject

An array for nullable fields



289
290
291
# File 'lib/ctd_documentation/models/asset.rb', line 289

def self.nullables
  []
end

.optionalsObject

An array for optional fields



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/ctd_documentation/models/asset.rb', line 239

def self.optionals
  %w[
    resource_id
    id
    site_id
    approved
    asset_type_number
    asset_type_name
    class_type
    criticality_number
    criticality_name
    display_name
    first_seen
    last_seen
    last_updated
    ghost
    hostname
    installed_programs_count
    mac
    name
    network_id
    num_alerts
    patch_count
    parsed
    protocol
    purdue_level
    risk_level
    site_name
    special_hint
    special_hint_name
    vlan
    virtual_zone_id
    virtual_zone_name
    vendor
    valid
    subnet_id
    usb_devices_count
    timestamp
    network
    active_queries_names
    active_scans_names
    children
    custom_attributes
    custom_informations
    insight_names
    code_sections
  ]
end