Class: MistApi::LogEvent

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/log_event.rb

Overview

LogEvent Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(message = nil, org_id = nil, timestamp = nil, admin_id = SKIP, admin_name = SKIP, after = SKIP, before = SKIP, device_id = SKIP, for_site = SKIP, id = SKIP, site_id = SKIP, src_ip = SKIP) ⇒ LogEvent

Returns a new instance of LogEvent.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/mist_api/models/log_event.rb', line 103

def initialize(message = nil, org_id = nil, timestamp = nil,
               admin_id = SKIP, admin_name = SKIP, after = SKIP,
               before = SKIP, device_id = SKIP, for_site = SKIP, id = SKIP,
               site_id = SKIP, src_ip = SKIP)
  @admin_id = admin_id unless admin_id == SKIP
  @admin_name = admin_name unless admin_name == SKIP
  @after = after unless after == SKIP
  @before = before unless before == SKIP
  @device_id = device_id unless device_id == SKIP
  @for_site = for_site unless for_site == SKIP
  @id = id unless id == SKIP
  @message = message
  @org_id = org_id
  @site_id = site_id unless site_id == SKIP
  @src_ip = src_ip unless src_ip == SKIP
  @timestamp = timestamp
end

Instance Attribute Details

#admin_idUUID | String

admin id

Returns:

  • (UUID | String)


14
15
16
# File 'lib/mist_api/models/log_event.rb', line 14

def admin_id
  @admin_id
end

#admin_nameString

Name of the admin that performs the action

Returns:

  • (String)


18
19
20
# File 'lib/mist_api/models/log_event.rb', line 18

def admin_name
  @admin_name
end

#afterObject

field values after the change

Returns:

  • (Object)


22
23
24
# File 'lib/mist_api/models/log_event.rb', line 22

def after
  @after
end

#beforeObject

field values prior to the change

Returns:

  • (Object)


26
27
28
# File 'lib/mist_api/models/log_event.rb', line 26

def before
  @before
end

#device_idUUID | String

Device id

Returns:

  • (UUID | String)


30
31
32
# File 'lib/mist_api/models/log_event.rb', line 30

def device_id
  @device_id
end

#for_siteTrueClass | FalseClass

Device id

Returns:

  • (TrueClass | FalseClass)


34
35
36
# File 'lib/mist_api/models/log_event.rb', line 34

def for_site
  @for_site
end

#idUUID | String

Unique ID of the object instance in the Mist Organization

Returns:

  • (UUID | String)


38
39
40
# File 'lib/mist_api/models/log_event.rb', line 38

def id
  @id
end

#messageString

log message

Returns:

  • (String)


42
43
44
# File 'lib/mist_api/models/log_event.rb', line 42

def message
  @message
end

#org_idUUID | String

log message

Returns:

  • (UUID | String)


46
47
48
# File 'lib/mist_api/models/log_event.rb', line 46

def org_id
  @org_id
end

#site_idUUID | String

log message

Returns:

  • (UUID | String)


50
51
52
# File 'lib/mist_api/models/log_event.rb', line 50

def site_id
  @site_id
end

#src_ipString

sender source ip address

Returns:

  • (String)


54
55
56
# File 'lib/mist_api/models/log_event.rb', line 54

def src_ip
  @src_ip
end

#timestampFloat

Epoch (seconds)

Returns:

  • (Float)


58
59
60
# File 'lib/mist_api/models/log_event.rb', line 58

def timestamp
  @timestamp
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/mist_api/models/log_event.rb', line 122

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  message = hash.key?('message') ? hash['message'] : nil
  org_id = hash.key?('org_id') ? hash['org_id'] : nil
  timestamp = hash.key?('timestamp') ? hash['timestamp'] : nil
  admin_id = hash.key?('admin_id') ? hash['admin_id'] : SKIP
  admin_name = hash.key?('admin_name') ? hash['admin_name'] : SKIP
  after = hash.key?('after') ? hash['after'] : SKIP
  before = hash.key?('before') ? hash['before'] : SKIP
  device_id = hash.key?('device_id') ? hash['device_id'] : SKIP
  for_site = hash.key?('for_site') ? hash['for_site'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  site_id = hash.key?('site_id') ? hash['site_id'] : SKIP
  src_ip = hash.key?('src_ip') ? hash['src_ip'] : SKIP

  # Create object from extracted values.
  LogEvent.new(message,
               org_id,
               timestamp,
               admin_id,
               admin_name,
               after,
               before,
               device_id,
               for_site,
               id,
               site_id,
               src_ip)
end

.namesObject

A mapping from model property names to API property names.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/mist_api/models/log_event.rb', line 61

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['admin_id'] = 'admin_id'
  @_hash['admin_name'] = 'admin_name'
  @_hash['after'] = 'after'
  @_hash['before'] = 'before'
  @_hash['device_id'] = 'device_id'
  @_hash['for_site'] = 'for_site'
  @_hash['id'] = 'id'
  @_hash['message'] = 'message'
  @_hash['org_id'] = 'org_id'
  @_hash['site_id'] = 'site_id'
  @_hash['src_ip'] = 'src_ip'
  @_hash['timestamp'] = 'timestamp'
  @_hash
end

.nullablesObject

An array for nullable fields



94
95
96
97
98
99
100
101
# File 'lib/mist_api/models/log_event.rb', line 94

def self.nullables
  %w[
    admin_id
    admin_name
    device_id
    site_id
  ]
end

.optionalsObject

An array for optional fields



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/mist_api/models/log_event.rb', line 79

def self.optionals
  %w[
    admin_id
    admin_name
    after
    before
    device_id
    for_site
    id
    site_id
    src_ip
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (LogEvent | Hash)

    value against the validation is performed.



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/mist_api/models/log_event.rb', line 156

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.message,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.org_id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.timestamp,
                              ->(val) { val.instance_of? Float })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['message'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['org_id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['timestamp'],
                            ->(val) { val.instance_of? Float })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



190
191
192
193
194
195
196
197
# File 'lib/mist_api/models/log_event.rb', line 190

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} admin_id: #{@admin_id.inspect}, admin_name: #{@admin_name.inspect}, after:"\
  " #{@after.inspect}, before: #{@before.inspect}, device_id: #{@device_id.inspect}, for_site:"\
  " #{@for_site.inspect}, id: #{@id.inspect}, message: #{@message.inspect}, org_id:"\
  " #{@org_id.inspect}, site_id: #{@site_id.inspect}, src_ip: #{@src_ip.inspect}, timestamp:"\
  " #{@timestamp.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



181
182
183
184
185
186
187
# File 'lib/mist_api/models/log_event.rb', line 181

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} admin_id: #{@admin_id}, admin_name: #{@admin_name}, after: #{@after},"\
  " before: #{@before}, device_id: #{@device_id}, for_site: #{@for_site}, id: #{@id}, message:"\
  " #{@message}, org_id: #{@org_id}, site_id: #{@site_id}, src_ip: #{@src_ip}, timestamp:"\
  " #{@timestamp}>"
end