Class: SmplkitGeneratedClient::Audit::Event

Inherits:
ApiModelBase show all
Defined in:
lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb

Overview

An audit event — a record that something happened, attributed to an actor and a resource. When recording a snapshot of the resource at the time of the event, place it inside ‘data`. smplkit’s own integrations nest it under ‘data.snapshot`, but the slot is yours to use however you like.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Event

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



110
111
112
113
114
115
116
117
118
119
120
121
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 110

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::Audit::Event` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::Audit::Event`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'action')
    self.action = attributes[:'action']
  else
    self.action = nil
  end

  if attributes.key?(:'resource_type')
    self.resource_type = attributes[:'resource_type']
  else
    self.resource_type = nil
  end

  if attributes.key?(:'resource_id')
    self.resource_id = attributes[:'resource_id']
  else
    self.resource_id = nil
  end

  if attributes.key?(:'occurred_at')
    self.occurred_at = attributes[:'occurred_at']
  end

  if attributes.key?(:'data')
    if (value = attributes[:'data']).is_a?(Hash)
      self.data = value
    end
  end

  if attributes.key?(:'do_not_forward')
    self.do_not_forward = attributes[:'do_not_forward']
  else
    self.do_not_forward = false
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  end

  if attributes.key?(:'actor_type')
    self.actor_type = attributes[:'actor_type']
  end

  if attributes.key?(:'actor_id')
    self.actor_id = attributes[:'actor_id']
  end

  if attributes.key?(:'actor_label')
    self.actor_label = attributes[:'actor_label']
  end

  if attributes.key?(:'idempotency_key')
    self.idempotency_key = attributes[:'idempotency_key']
  end
end

Instance Attribute Details

#actionObject

Slug for what happened, e.g. ‘user.created`. Lowercase, dot-separated.



20
21
22
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 20

def action
  @action
end

#actor_idObject

Identifier of the actor that emitted the event.



44
45
46
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 44

def actor_id
  @actor_id
end

#actor_labelObject

Human-readable label for the actor (e.g. the user’s email address or the API key name) at the time the event was recorded.



47
48
49
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 47

def actor_label
  @actor_label
end

#actor_typeObject

Kind of credential that emitted the event, e.g. ‘USER` or `API_KEY`. Resolved server-side from the request credential.



41
42
43
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 41

def actor_type
  @actor_type
end

#created_atObject

When the event was received and recorded.



38
39
40
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 38

def created_at
  @created_at
end

#dataObject

Free-form payload attached to the event. Use it for resource snapshots (by convention under ‘data.snapshot`), request identifiers, or any other context the event needs to carry.



32
33
34
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 32

def data
  @data
end

#do_not_forwardObject

When ‘true`, the event is recorded but not delivered to any forwarder. A delivery log entry with status `SKIPPED_DO_NOT_FORWARD` is written for each enabled forwarder so the skip is visible in the delivery log.



35
36
37
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 35

def do_not_forward
  @do_not_forward
end

#idempotency_keyObject

The idempotency key used to deduplicate the record. Echoes the ‘Idempotency-Key` header if one was supplied, otherwise a key derived from the event’s content.



50
51
52
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 50

def idempotency_key
  @idempotency_key
end

#occurred_atObject

When the event actually happened. Defaults to the server receipt time (‘created_at`).



29
30
31
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 29

def occurred_at
  @occurred_at
end

#resource_idObject

Identifier of the specific resource the event is about.



26
27
28
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 26

def resource_id
  @resource_id
end

#resource_typeObject

Slug for the kind of resource the event is about, e.g. ‘user`. Lowercase, dot-separated.



23
24
25
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 23

def resource_type
  @resource_type
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



70
71
72
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 70

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



75
76
77
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 75

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 53

def self.attribute_map
  {
    :'action' => :'action',
    :'resource_type' => :'resource_type',
    :'resource_id' => :'resource_id',
    :'occurred_at' => :'occurred_at',
    :'data' => :'data',
    :'do_not_forward' => :'do_not_forward',
    :'created_at' => :'created_at',
    :'actor_type' => :'actor_type',
    :'actor_id' => :'actor_id',
    :'actor_label' => :'actor_label',
    :'idempotency_key' => :'idempotency_key'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 299

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



97
98
99
100
101
102
103
104
105
106
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 97

def self.openapi_nullable
  Set.new([
    :'occurred_at',
    :'created_at',
    :'actor_type',
    :'actor_id',
    :'actor_label',
    :'idempotency_key'
  ])
end

.openapi_typesObject

Attribute type mapping.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 80

def self.openapi_types
  {
    :'action' => :'String',
    :'resource_type' => :'String',
    :'resource_id' => :'String',
    :'occurred_at' => :'Time',
    :'data' => :'Hash<String, Object>',
    :'do_not_forward' => :'Boolean',
    :'created_at' => :'Time',
    :'actor_type' => :'String',
    :'actor_id' => :'String',
    :'actor_label' => :'String',
    :'idempotency_key' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 268

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      action == o.action &&
      resource_type == o.resource_type &&
      resource_id == o.resource_id &&
      occurred_at == o.occurred_at &&
      data == o.data &&
      do_not_forward == o.do_not_forward &&
      created_at == o.created_at &&
      actor_type == o.actor_type &&
      actor_id == o.actor_id &&
      actor_label == o.actor_label &&
      idempotency_key == o.idempotency_key
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


286
287
288
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 286

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



292
293
294
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 292

def hash
  [action, resource_type, resource_id, occurred_at, data, do_not_forward, created_at, actor_type, actor_id, actor_label, idempotency_key].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 181

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @action.nil?
    invalid_properties.push('invalid value for "action", action cannot be nil.')
  end

  if @action.to_s.length < 1
    invalid_properties.push('invalid value for "action", the character length must be greater than or equal to 1.')
  end

  if @resource_type.nil?
    invalid_properties.push('invalid value for "resource_type", resource_type cannot be nil.')
  end

  if @resource_type.to_s.length < 1
    invalid_properties.push('invalid value for "resource_type", the character length must be greater than or equal to 1.')
  end

  if @resource_id.nil?
    invalid_properties.push('invalid value for "resource_id", resource_id cannot be nil.')
  end

  if @resource_id.to_s.length < 1
    invalid_properties.push('invalid value for "resource_id", the character length must be greater than or equal to 1.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 321

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



213
214
215
216
217
218
219
220
221
222
# File 'lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb', line 213

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @action.nil?
  return false if @action.to_s.length < 1
  return false if @resource_type.nil?
  return false if @resource_type.to_s.length < 1
  return false if @resource_id.nil?
  return false if @resource_id.to_s.length < 1
  true
end