-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff59f2d
commit 68b88bf
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
examples/access_review/workflows/notification_permission_change.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}, | ||
) |