Class: Datadog::AIGuard::Evaluation::Result
- Inherits:
-
Object
- Object
- Datadog::AIGuard::Evaluation::Result
- 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
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#sds_findings ⇒ Object
readonly
Returns the value of attribute sds_findings.
-
#tag_probabilities ⇒ Object
readonly
Returns the value of attribute tag_probabilities.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #abort? ⇒ Boolean
- #allow? ⇒ Boolean
- #blocking_enabled? ⇒ Boolean
- #deny? ⇒ Boolean
-
#initialize(raw_response) ⇒ Result
constructor
A new instance of Result.
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
#action ⇒ Object (readonly)
Returns the value of attribute action.
12 13 14 |
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 12 def action @action end |
#reason ⇒ Object (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_findings ⇒ Object (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_probabilities ⇒ Object (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 |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
12 13 14 |
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 12 def @tags end |
Instance Method Details
#abort? ⇒ Boolean
35 36 37 |
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 35 def abort? action == ABORT_ACTION end |
#allow? ⇒ Boolean
27 28 29 |
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 27 def allow? action == ALLOW_ACTION end |
#blocking_enabled? ⇒ Boolean
39 40 41 |
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 39 def blocking_enabled? !!@is_blocking_enabled end |
#deny? ⇒ Boolean
31 32 33 |
# File 'lib/datadog/ai_guard/evaluation/result.rb', line 31 def deny? action == DENY_ACTION end |