Skip to main content

Disposition with prompts

A VI disposition can require more than an id: a note, a reason code, a child document, or a per-SFE result. When the definition demands something you did not supply, the SDK raises DispositionPromptRequiredError with a typed missing list. Catch it, prompt, retry.

import sasvi
from sasvi import AlertScenarioDispositionInput, errors

client = sasvi.SVIClient.from_env()

alert = client.alerts.get(alert_id="<alert-id>")


def collect(missing: tuple[str, ...]) -> dict[str, object]:
"""Ask for each missing input, in the type disposition() takes it."""
answers: dict[str, object] = {}
if "note" in missing:
answers["note"] = input("note: ").strip()
if "reason_code" in missing:
answers["reason_code"] = input("reason code: ").strip()
if "document_fields" in missing:
# Field names come from the entity the disposition creates.
answers["document_fields"] = {"investigation_name": input("case name: ").strip()}
sfe_reason = "scenario_fired_event_dispositions.reason_code" in missing
if "scenario_fired_event_dispositions" in missing or sfe_reason:
answers["scenario_fired_event_dispositions"] = [
AlertScenarioDispositionInput(
scenario_fired_event=event,
resolution_code=input(f"result for {event.scenario_name}: ").strip(),
reason_code=(
input(f"reason for {event.scenario_name}: ").strip() if sfe_reason else None
),
)
for event in alert.scenario_fired_events.list(limit=500)
]
return answers


try:
result = alert.disposition(disposition_id="<disposition-id>")
except errors.DispositionPromptRequiredError as exc:
result = alert.disposition(disposition_id="<disposition-id>", **collect(exc.missing))
print(repr(result))
# AlertDispositionResult(success=True, disposition_id='...')

exc.missing names every input the disposition still needs, as the keyword disposition() takes: note, reason_code, document_fields or scenario_fired_event_dispositions. When the alert's domain also wants a reason for each scenario-fired event, it names scenario_fired_event_dispositions.reason_code: give every AlertScenarioDispositionInput a reason_code, taken from the same list as the alert's reason. One retry with all of them is enough. Nothing is sent while an input is missing, so the first call left the alert unchanged.

Discover applicable dispositions​

options = alert.disposition_options()
for option in options:
print(option.id, option.label, option.resolution_code)

disposition_options() reads every applicable disposition, 100 rows per request, so the list is complete for an alert with more than one page of them. Pass the chosen option.id as disposition_id=. Each option also carries prompt_for_note, prompt_for_reason, and scenario_disposition_prompt, the flags that say what the disposition prompts the analyst for. For a single alert, option.requirements() also tells you whether each scenario-fired event needs a reason (prompt_for_sfe_reason).

Async​

try:
await alert.disposition_async(disposition_id=disposition_id)
except errors.DispositionPromptRequiredError as exc:
await alert.disposition_async(disposition_id=disposition_id, **collect(exc.missing))

Go further​

  • Alerts guide. Scenario fired event dispositions, contributing objects, productivity ratings.
  • Errors reference. DispositionPromptRequiredError.missing.