Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 164 additions & 0 deletions src/sentry/apidocs/examples/workflow_engine_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,167 @@ class WorkflowEngineExamples:
response_only=True,
)
]

GET_WORKFLOW = [
OpenApiExample(
"Fetch a Workflow",
value={
"id": "2957581",
"name": "My Workflow",
"organizationId": "1",
"createdBy": "2787837",
"dateCreated": "2026-01-14T20:08:32.273220Z",
"dateUpdated": "2026-01-14T20:08:32.273209Z",
"triggers": {
"id": "6735377",
"organizationId": "1",
"logicType": "any-short",
"conditions": [
{
"id": "10501219",
"type": "first_seen_event",
"comparison": True,
"conditionResult": True,
},
{
"id": "10501220",
"type": "issue_resolved_trigger",
"comparison": True,
"conditionResult": True,
},
{
"id": "10501221",
"type": "reappeared_event",
"comparison": True,
"conditionResult": True,
},
{
"id": "10501222",
"type": "regression_event",
"comparison": True,
"conditionResult": True,
},
],
"actions": [],
},
"actionFilters": [
{
"id": "6735378",
"organizationId": "1",
"logicType": "any-short",
"conditions": [
{
"id": "10501223",
"type": "issue_priority_deescalating",
"comparison": True,
"conditionResult": True,
}
],
"actions": [
{
"id": "7654195",
"type": "slack",
"integrationId": "1",
"data": {},
"config": {
"targetType": "specific",
"targetDisplay": "@jane-doe",
"targetIdentifier": "ABCDE123456",
},
"status": "active",
}
],
}
],
"environment": None,
"config": {"frequency": 1440},
"detectorIds": ["6239232"],
"enabled": True,
"lastTriggered": None,
},
status_codes=["200"],
response_only=True,
)
]

UPDATE_WORKFLOW = [
OpenApiExample(
"Update a Workflow",
value={
"id": "2957581",
"name": "My Updated Workflow",
"organizationId": "1",
"createdBy": "2787837",
"dateCreated": "2026-01-14T20:08:32.273220Z",
"dateUpdated": "2026-01-14T21:59:45.609912Z",
"triggers": {
"id": "6735377",
"organizationId": "1",
"logicType": "any-short",
"conditions": [
{
"id": "10501219",
"type": "first_seen_event",
"comparison": True,
"conditionResult": True,
},
{
"id": "10501220",
"type": "issue_resolved_trigger",
"comparison": True,
"conditionResult": True,
},
{
"id": "10501221",
"type": "reappeared_event",
"comparison": True,
"conditionResult": True,
},
{
"id": "10501222",
"type": "regression_event",
"comparison": True,
"conditionResult": True,
},
],
"actions": [],
},
"actionFilters": [
{
"id": "6735378",
"organizationId": "1",
"logicType": "any-short",
"conditions": [
{
"id": "10501223",
"type": "issue_priority_deescalating",
"comparison": True,
"conditionResult": True,
}
],
"actions": [
{
"id": "7654195",
"type": "slack",
"integrationId": "1",
"data": {},
"config": {
"targetType": "specific",
"targetDisplay": "@jane-doe",
"targetIdentifier": "ABCDE123456",
},
"status": "active",
}
],
}
],
"environment": None,
"config": {"frequency": 1440},
"detectorIds": ["6239232"],
"enabled": True,
"lastTriggered": None,
},
status_codes=["200"],
response_only=True,
)
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
from sentry.apidocs.constants import (
RESPONSE_BAD_REQUEST,
RESPONSE_FORBIDDEN,
RESPONSE_NO_CONTENT,
RESPONSE_NOT_FOUND,
RESPONSE_UNAUTHORIZED,
)
from sentry.apidocs.examples.workflow_engine_examples import WorkflowEngineExamples
from sentry.apidocs.parameters import GlobalParams, WorkflowParams
from sentry.constants import ObjectStatus
from sentry.deletions.models.scheduleddeletion import RegionScheduledDeletion
Expand All @@ -41,22 +43,23 @@ class OrganizationWorkflowDetailsEndpoint(OrganizationWorkflowEndpoint):
owner = ApiOwner.ALERTS_NOTIFICATIONS

@extend_schema(
operation_id="Fetch a Workflow",
operation_id="Fetch an Alert",
parameters=[
GlobalParams.ORG_ID_OR_SLUG,
WorkflowParams.WORKFLOW_ID,
],
responses={
201: WorkflowSerializer,
200: WorkflowSerializer,
400: RESPONSE_BAD_REQUEST,
401: RESPONSE_UNAUTHORIZED,
403: RESPONSE_FORBIDDEN,
404: RESPONSE_NOT_FOUND,
},
examples=WorkflowEngineExamples.GET_WORKFLOW,
)
def get(self, request: Request, organization: Organization, workflow: Workflow):
"""
Returns a workflow
Returns an alert.
"""
serialized_workflow = serialize(
workflow,
Expand All @@ -66,22 +69,24 @@ def get(self, request: Request, organization: Organization, workflow: Workflow):
return Response(serialized_workflow)

@extend_schema(
operation_id="Update a Workflow",
operation_id="Update an Alert",
parameters=[
GlobalParams.ORG_ID_OR_SLUG,
WorkflowParams.WORKFLOW_ID,
],
request=WorkflowValidator,
responses={
201: WorkflowSerializer,
200: WorkflowSerializer,
400: RESPONSE_BAD_REQUEST,
401: RESPONSE_UNAUTHORIZED,
403: RESPONSE_FORBIDDEN,
404: RESPONSE_NOT_FOUND,
},
examples=WorkflowEngineExamples.UPDATE_WORKFLOW,
)
def put(self, request: Request, organization: Organization, workflow: Workflow):
"""
Updates a workflow
Updates an alert.
"""
validator = WorkflowValidator(
data=request.data,
Expand Down Expand Up @@ -129,9 +134,23 @@ def put(self, request: Request, organization: Organization, workflow: Workflow):
status=200,
)

@extend_schema(
operation_id="Delete an Alert",
parameters=[
GlobalParams.ORG_ID_OR_SLUG,
WorkflowParams.WORKFLOW_ID,
],
responses={
204: RESPONSE_NO_CONTENT,
400: RESPONSE_BAD_REQUEST,
401: RESPONSE_UNAUTHORIZED,
403: RESPONSE_FORBIDDEN,
404: RESPONSE_NOT_FOUND,
},
)
def delete(self, request: Request, organization: Organization, workflow: Workflow):
"""
Delete a workflow
Deletes an alert.
"""
RegionScheduledDeletion.schedule(workflow, days=0, actor=request.user)
workflow.update(status=ObjectStatus.PENDING_DELETION)
Expand Down
Loading