From 8e46667212e479f8a09f4c00b72cdee61dba6233 Mon Sep 17 00:00:00 2001 From: Julien Perrochet Date: Sun, 3 Nov 2024 18:00:56 +0100 Subject: [PATCH] [uss_qualifier] rid: ISAChange exposes subscribers as returned by DSS --- monitoring/monitorlib/mutate/rid.py | 28 +++++++++++++------ .../netrid/common/dss/token_validation.py | 15 ++++++++-- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/monitoring/monitorlib/mutate/rid.py b/monitoring/monitorlib/mutate/rid.py index 851df074aa..c4cdae5d07 100644 --- a/monitoring/monitorlib/mutate/rid.py +++ b/monitoring/monitorlib/mutate/rid.py @@ -1,19 +1,15 @@ import datetime from typing import Dict, List, Optional, Union, Set -from implicitdict import ImplicitDict import s2sphere -from uas_standards import Operation - -from monitoring.monitorlib.fetch import QueryType -from monitoring.monitorlib.fetch.rid import RIDQuery, Subscription, ISA -from monitoring.monitorlib.rid import RIDVersion -from uas_standards.astm.f3411 import v19, v22a import uas_standards.astm.f3411.v19.api import uas_standards.astm.f3411.v19.constants import uas_standards.astm.f3411.v22a.api import uas_standards.astm.f3411.v22a.constants import yaml +from implicitdict import ImplicitDict +from uas_standards import Operation +from uas_standards.astm.f3411 import v19, v22a from yaml.representer import Representer from monitoring.monitorlib import ( @@ -22,6 +18,9 @@ rid_v1, rid_v2, ) +from monitoring.monitorlib.fetch import QueryType +from monitoring.monitorlib.fetch.rid import RIDQuery, Subscription, ISA +from monitoring.monitorlib.rid import RIDVersion class ChangedSubscription(RIDQuery): @@ -450,6 +449,9 @@ class ISAChange(ImplicitDict): notifications: Dict[str, ISAChangeNotification] """Mapping from USS base URL to change notification query""" + subscribers: List[SubscriberToNotify] + """List of subscribers that required a notification for the change.""" + def build_isa_request_body( area_vertices: List[s2sphere.LatLng], @@ -597,10 +599,14 @@ def put_isa( for sub in dss_response.subscribers if not any(sub.url.startswith(base_url) for base_url in do_not_notify) } + subscribers = dss_response.subscribers else: notifications = {} + subscribers = [] - return ISAChange(dss_query=dss_response, notifications=notifications) + return ISAChange( + dss_query=dss_response, notifications=notifications, subscribers=subscribers + ) def delete_isa( @@ -653,10 +659,14 @@ def delete_isa( for sub in dss_response.subscribers if not any(sub.url.startswith(base_url) for base_url in do_not_notify) } + subscribers = dss_response.subscribers else: notifications = {} + subscribers = [] - return ISAChange(dss_query=dss_response, notifications=notifications) + return ISAChange( + dss_query=dss_response, notifications=notifications, subscribers=subscribers + ) yaml.add_representer(ChangedSubscription, Representer.represent_dict) diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/token_validation.py b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/token_validation.py index f6b4505712..c75f9d257c 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/token_validation.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/token_validation.py @@ -4,6 +4,7 @@ import arrow import s2sphere from uas_standards.astm.f3411 import v19, v22a +from zope.event import subscribers from monitoring.monitorlib import fetch, infrastructure from monitoring.monitorlib import rid_v1, rid_v2 @@ -531,12 +532,16 @@ def _put_isa_tweak_auth( sub.url: sub.notify(isa.id, utm_client, isa) for sub in dss_response.subscribers } + subscribers = dss_response.subscribers else: notifications = {} + subscribers = [] self.record_query(dss_response.query) - return ISAChange(dss_query=dss_response, notifications=notifications) + return ISAChange( + dss_query=dss_response, notifications=notifications, subscribers=subscribers + ) def _get_isa_tweak_auth(self, utm_client: infrastructure.UTMClientSession): """A local version of fetch.rid.isa that lets us control authentication parameters""" @@ -627,14 +632,20 @@ def _del_isa_tweak_auth( sub.url: sub.notify(isa.id, utm_client) for sub in dss_response.subscribers } + isa_subscribers = dss_response.subscribers else: notifications = {} + isa_subscribers = [] self.record_query(dss_response.query) for notification_query in notifications.values(): self.record_query(notification_query.query) - return ISAChange(dss_query=dss_response, notifications=notifications) + return ISAChange( + dss_query=dss_response, + notifications=notifications, + subscribers=isa_subscribers, + ) def _search_isas_tweak_auth( self,