Class: Datadog::AIGuard::Evaluation::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ai_guard/evaluation/result.rb

Overview

Wrapper class for evaluation API response

Constant Summary collapse

ALLOW_ACTION =
"ALLOW"
DENY_ACTION =
"DENY"
ABORT_ACTION =
"ABORT"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_response) ⇒ Result

Returns a new instance of Result.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 14

def initialize(raw_response)
  attributes = raw_response.fetch("data").fetch("attributes")

  @action = attributes.fetch("action")
  @reason = attributes.fetch("reason")
  @tags = attributes.fetch("tags")
  @tag_probabilities = attributes.fetch("tag_probs")
  @is_blocking_enabled = attributes.fetch("is_blocking_enabled")
  @sds_findings = attributes.fetch("sds_findings", [])
rescue KeyError => e
  raise AIGuardClientError, "Missing key: \"#{e.key}\""
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



12
13
14
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 12

def action
  @action
end

#reasonObject (readonly)

Returns the value of attribute reason.



12
13
14
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 12

def reason
  @reason
end

#sds_findingsObject (readonly)

Returns the value of attribute sds_findings.



12
13
14
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 12

def sds_findings
  @sds_findings
end

#tag_probabilitiesObject (readonly)

Returns the value of attribute tag_probabilities.



12
13
14
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 12

def tag_probabilities
  @tag_probabilities
end

#tagsObject (readonly)

Returns the value of attribute tags.



12
13
14
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 12

def tags
  @tags
end

Instance Method Details

#abort?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 35

def abort?
  action == ABORT_ACTION
end

#allow?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 27

def allow?
  action == ALLOW_ACTION
end

#blocking_enabled?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 39

def blocking_enabled?
  !!@is_blocking_enabled
end

#deny?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 31

def deny?
  action == DENY_ACTION
end