Class: TalonOne::Risk

Inherits:
ApiModelBase show all
Defined in:
lib/talon_one_sdk/models/risk.rb

Overview

A risk detected by the anomaly detection service for one Application group.

Defined Under Namespace

Classes: EnumAttributeValidator

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 = {}) ⇒ Risk

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
178
179
180
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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/talon_one_sdk/models/risk.rb', line 153

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TalonOne::Risk` 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 `TalonOne::Risk`. 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?(:'id')
    self.id = attributes[:'id']
  else
    self.id = nil
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#activityObject

The activity metric the risk was detected in.



47
48
49
# File 'lib/talon_one_sdk/models/risk.rb', line 47

def activity
  @activity
end

#affected_entity_countObject

The total number of entities affected by this risk.



56
57
58
# File 'lib/talon_one_sdk/models/risk.rb', line 56

def affected_entity_count
  @affected_entity_count
end

#application_idObject

The ID of the Application this risk belongs to. Absent for global metrics.



35
36
37
# File 'lib/talon_one_sdk/models/risk.rb', line 35

def application_id
  @application_id
end

#createdObject

The time this entity was created.



23
24
25
# File 'lib/talon_one_sdk/models/risk.rb', line 23

def created
  @created
end

#criticalityObject

The critical classification bucket of this risk.



41
42
43
# File 'lib/talon_one_sdk/models/risk.rb', line 41

def criticality
  @criticality
end

#descriptionObject

Human-readable description of the detected anomaly.



59
60
61
# File 'lib/talon_one_sdk/models/risk.rb', line 59

def description
  @description
end

#entityObject

The entity type the risk was detected in.



44
45
46
# File 'lib/talon_one_sdk/models/risk.rb', line 44

def entity
  @entity
end

#group_keyObject

The Application group this risk was detected in. Contains the Application ID, or ‘__GLOBAL__` for metrics that are not grouped by Application.



32
33
34
# File 'lib/talon_one_sdk/models/risk.rb', line 32

def group_key
  @group_key
end

#idObject

The internal ID of this entity.



20
21
22
# File 'lib/talon_one_sdk/models/risk.rb', line 20

def id
  @id
end

#modifiedObject

Timestamp of the most recent update.



62
63
64
# File 'lib/talon_one_sdk/models/risk.rb', line 62

def modified
  @modified
end

#notification_idObject

The ID of the risk notification rule that flagged this risk.



26
27
28
# File 'lib/talon_one_sdk/models/risk.rb', line 26

def notification_id
  @notification_id
end

#reported_dateObject

The time the ML service reported this risk.



53
54
55
# File 'lib/talon_one_sdk/models/risk.rb', line 53

def reported_date
  @reported_date
end

#run_dateObject

The date of the ML pipeline run that detected this risk.



29
30
31
# File 'lib/talon_one_sdk/models/risk.rb', line 29

def run_date
  @run_date
end

#statusObject

The triage lifecycle status of this risk.



38
39
40
# File 'lib/talon_one_sdk/models/risk.rb', line 38

def status
  @status
end

#time_frameObject

The rolling time window of the risk evaluation.



50
51
52
# File 'lib/talon_one_sdk/models/risk.rb', line 50

def time_frame
  @time_frame
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



108
109
110
# File 'lib/talon_one_sdk/models/risk.rb', line 108

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



113
114
115
# File 'lib/talon_one_sdk/models/risk.rb', line 113

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/talon_one_sdk/models/risk.rb', line 87

def self.attribute_map
  {
    :'id' => :'id',
    :'created' => :'created',
    :'notification_id' => :'notificationId',
    :'run_date' => :'runDate',
    :'group_key' => :'groupKey',
    :'application_id' => :'applicationId',
    :'status' => :'status',
    :'criticality' => :'criticality',
    :'entity' => :'entity',
    :'activity' => :'activity',
    :'time_frame' => :'timeFrame',
    :'reported_date' => :'reportedDate',
    :'affected_entity_count' => :'affectedEntityCount',
    :'description' => :'description',
    :'modified' => :'modified'
  }
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



511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/talon_one_sdk/models/risk.rb', line 511

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_all_ofObject

List of class defined in allOf (OpenAPI v3)



145
146
147
148
149
# File 'lib/talon_one_sdk/models/risk.rb', line 145

def self.openapi_all_of
  [
  :'Entity'
  ]
end

.openapi_nullableObject

List of attributes with nullable: true



139
140
141
142
# File 'lib/talon_one_sdk/models/risk.rb', line 139

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/talon_one_sdk/models/risk.rb', line 118

def self.openapi_types
  {
    :'id' => :'Integer',
    :'created' => :'Time',
    :'notification_id' => :'Integer',
    :'run_date' => :'Date',
    :'group_key' => :'String',
    :'application_id' => :'Integer',
    :'status' => :'String',
    :'criticality' => :'String',
    :'entity' => :'String',
    :'activity' => :'String',
    :'time_frame' => :'String',
    :'reported_date' => :'Time',
    :'affected_entity_count' => :'Integer',
    :'description' => :'String',
    :'modified' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/talon_one_sdk/models/risk.rb', line 476

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      created == o.created &&
      notification_id == o.notification_id &&
      run_date == o.run_date &&
      group_key == o.group_key &&
      application_id == o.application_id &&
      status == o.status &&
      criticality == o.criticality &&
      entity == o.entity &&
      activity == o.activity &&
      time_frame == o.time_frame &&
      reported_date == o.reported_date &&
      affected_entity_count == o.affected_entity_count &&
      description == o.description &&
      modified == o.modified
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


498
499
500
# File 'lib/talon_one_sdk/models/risk.rb', line 498

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



504
505
506
# File 'lib/talon_one_sdk/models/risk.rb', line 504

def hash
  [id, created, notification_id, run_date, group_key, application_id, status, criticality, entity, activity, time_frame, reported_date, affected_entity_count, description, modified].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/talon_one_sdk/models/risk.rb', line 256

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

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

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

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

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

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

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

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

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

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

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

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

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

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



533
534
535
536
537
538
539
540
541
542
543
544
545
# File 'lib/talon_one_sdk/models/risk.rb', line 533

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



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
# File 'lib/talon_one_sdk/models/risk.rb', line 316

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @created.nil?
  return false if @notification_id.nil?
  return false if @run_date.nil?
  return false if @group_key.nil?
  return false if @status.nil?
  status_validator = EnumAttributeValidator.new('String', ["active", "in_review", "confirmed", "discarded"])
  return false unless status_validator.valid?(@status)
  return false if @criticality.nil?
  criticality_validator = EnumAttributeValidator.new('String', ["critical", "not_critical"])
  return false unless criticality_validator.valid?(@criticality)
  return false if @entity.nil?
  entity_validator = EnumAttributeValidator.new('String', ["customer_profile", "customer_session"])
  return false unless entity_validator.valid?(@entity)
  return false if @activity.nil?
  activity_validator = EnumAttributeValidator.new('String', ["loyalty_points_earned", "discounted_amount", "completed_orders", "coupon_attempts"])
  return false unless activity_validator.valid?(@activity)
  return false if @time_frame.nil?
  time_frame_validator = EnumAttributeValidator.new('String', ["1_day", "1_week", "1_month"])
  return false unless time_frame_validator.valid?(@time_frame)
  return false if @reported_date.nil?
  return false if @affected_entity_count.nil?
  return false if @modified.nil?
  true
end