-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Airlock API - instrument the airlock with notifications events (#2195)
* Add notification topic * implement notification sending * fix tests * CI errors fixes * api version change Co-authored-by: Anat Balzam <anatbalzam@microsoft.com>
- Loading branch information
Showing
18 changed files
with
187 additions
and
67 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.3.36" | ||
__version__ = "0.3.37" |
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
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
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,37 @@ | ||
import logging | ||
from azure.eventgrid import EventGridEvent | ||
from models.domain.events import StatusChangedData, AirlockNotificationData | ||
from event_grid.helpers import publish_event | ||
from core import config | ||
from models.domain.airlock_request import AirlockRequest | ||
|
||
|
||
async def send_status_changed_event(airlock_request: AirlockRequest): | ||
request_id = airlock_request.id | ||
status = airlock_request.status.value | ||
request_type = airlock_request.requestType.value | ||
short_workspace_id = airlock_request.workspaceId[-4:] | ||
|
||
status_changed_event = EventGridEvent( | ||
event_type="statusChanged", | ||
data=StatusChangedData(request_id=request_id, status=status, type=request_type, workspace_id=short_workspace_id).__dict__, | ||
subject=f"{request_id}/statusChanged", | ||
data_version="2.0" | ||
) | ||
logging.info(f"Sending status changed event with request ID {request_id}, status: {status}") | ||
await publish_event(status_changed_event, config.EVENT_GRID_STATUS_CHANGED_TOPIC_ENDPOINT) | ||
|
||
|
||
async def send_airlock_notification_event(airlock_request: AirlockRequest, researchers_emails, owners_emails): | ||
request_id = airlock_request.id | ||
status = airlock_request.status.value | ||
short_workspace_id = airlock_request.workspaceId[-4:] | ||
|
||
airlock_notification = EventGridEvent( | ||
event_type="airlockNotification", | ||
data=AirlockNotificationData(request_id=request_id, event_type="status_changed", event_value=status, researchers_emails=researchers_emails, owners_emails=owners_emails, workspace_id=short_workspace_id).__dict__, | ||
subject=f"{request_id}/airlockNotification", | ||
data_version="2.0" | ||
) | ||
logging.info(f"Sending airlock notification event with request ID {request_id}, status: {status}") | ||
await publish_event(airlock_notification, config.EVENT_GRID_AIRLOCK_NOTIFICATION_TOPIC_ENDPOINT) |
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
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,18 @@ | ||
from typing import List | ||
from models.domain.azuretremodel import AzureTREModel | ||
|
||
|
||
class AirlockNotificationData(AzureTREModel): | ||
request_id: str | ||
event_type: str | ||
event_value: str | ||
researchers_emails: List[str] | ||
owners_emails: List[str] | ||
workspace_id: str | ||
|
||
|
||
class StatusChangedData(AzureTREModel): | ||
request_id: str | ||
status: str | ||
type: str | ||
workspace_id: str |
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
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
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
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
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
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
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
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
Oops, something went wrong.