Skip to content

Commit

Permalink
feat: added new example workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
christophergrittner committed Aug 26, 2024
1 parent ff59f2d commit 68b88bf
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/access_review/workflows/notification_permission_change.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from admyral.workflow import workflow, Webhook, Schedule
from admyral.typings import JsonValue
from admyral.actions import get_jira_audit_records, send_slack_message_to_user_by_email


@workflow(
description="Monitors Jira for newly created user accounts and sends a Slack notification with relevant details. "
"This workflow automatically retrieves audit records for user creation events and notifies the specified recipient "
"via Slack with the user ID and creation timestamp.",
triggers=[Webhook(), Schedule(interval_days=1)],
)
def notification_permission_change(payload: dict[str, JsonValue]):
# jira get audit records for newly created users
records = get_jira_audit_records(
filter=["User", "created"],
start_date="2024-08-01T00:00:00",
secrets={"JIRA_SECRET": "jira_secret"},
)

# notify via Slack about changes
send_slack_message_to_user_by_email(
email="[email protected]",
text=f"*A new user was created*\n\nUser ID: {records[0]['objectItem']['id']}\nCreated on: {records[0]['created']}",
secrets={"SLACK_SECRET": "slack_secret"},
)

0 comments on commit 68b88bf

Please sign in to comment.