Skip to content

Commit

Permalink
[uss_qualifier] rid: ISAChange exposes subscribers as returned by DSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Shastick committed Nov 3, 2024
1 parent dd28059 commit b9c3b9e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
28 changes: 19 additions & 9 deletions monitoring/monitorlib/mutate/rid.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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):
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"""
Expand Down

0 comments on commit b9c3b9e

Please sign in to comment.