oncall-engine/engine/apps/slack/scenarios/declare_incident.py
Innokentii Konstantinov 1465db36e5
Support stack header from chatops-proxy (#4578)
This PR supports new flow of selecting org to run command in a slack
workspace if several stacks are using it. In this case user selects
default stack to run commands or pass a --stack flag. Both handled by
chatops-proxy which injects selected stack as a header.
On a side note - I found one ScenarioStep with incompatible set of
arguments with parent class. I didn't fixed it, just left TODO
https://github.com/grafana/oncall/pull/4578/files#diff-e323b5f38ed665f73d5da3fa0575958ed54ab587f6521b4cd87e1491b5430f8bR364

Related to https://github.com/grafana/oncall-gateway/issues/256

---------

Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
2024-07-19 10:08:52 +00:00

32 lines
1.1 KiB
Python

import typing
from apps.slack.scenarios import scenario_step
from apps.slack.types import BlockActionType, EventPayload, PayloadType, ScenarioRoute
if typing.TYPE_CHECKING:
from apps.slack.models import SlackTeamIdentity, SlackUserIdentity
from apps.user_management.models import Organization
class DeclareIncidentStep(scenario_step.ScenarioStep):
def process_scenario(
self,
slack_user_identity: "SlackUserIdentity",
slack_team_identity: "SlackTeamIdentity",
payload: "EventPayload",
predefined_org: typing.Optional["Organization"] = None,
) -> None:
"""
Slack sends a POST request to the backend upon clicking a button with a redirect link to Incident.
This is a dummy step, that is used to prevent raising 'Step is undefined' exception.
"""
STEPS_ROUTING: ScenarioRoute.RoutingSteps = [
{
"payload_type": PayloadType.BLOCK_ACTIONS,
"block_action_type": BlockActionType.BUTTON,
"block_action_id": DeclareIncidentStep.routing_uid(),
"step": DeclareIncidentStep,
},
]