4141)
4242from uas_standards .astm .f3548 .v21 .constants import Scope
4343
44- from monitoring .monitorlib import infrastructure
4544from monitoring .monitorlib .fetch import Query , QueryError , QueryType , query_and_describe
4645from monitoring .monitorlib .fetch import scd as fetch
4746from monitoring .monitorlib .fetch .scd import FetchedSubscription , FetchedSubscriptions
47+ from monitoring .monitorlib .infrastructure import UTMClientSession
4848from monitoring .monitorlib .inspection import calling_function_name , fullname
4949from monitoring .monitorlib .mutate import scd as mutate
5050from monitoring .monitorlib .mutate .scd import MutatedSubscription
@@ -65,6 +65,9 @@ class DSSInstanceSpecification(ImplicitDict):
6565 supports_ovn_request : Optional [bool ]
6666 """Whether this DSS instance supports the optional extension not part of the original F3548 standard API allowing a USS to request a specific OVN when creating or updating an operational intent."""
6767
68+ timeout_seconds : Optional [float ]
69+ """If specified, number of seconds to allow before timing out requests to this DSS instance."""
70+
6871 def __init__ (self , * args , ** kwargs ):
6972 super ().__init__ (** kwargs )
7073 try :
@@ -77,21 +80,21 @@ class DSSInstance:
7780 participant_id : str
7881 user_participant_ids : list [str ]
7982 base_url : str
80- client : infrastructure . UTMClientSession
83+ client : UTMClientSession
8184 _scopes_authorized : set [str ]
8285
8386 def __init__ (
8487 self ,
8588 participant_id : str ,
8689 user_participant_ids : list [str ],
8790 base_url : str ,
88- auth_adapter : infrastructure . AuthAdapter ,
91+ client : UTMClientSession ,
8992 scopes_authorized : list [str ],
9093 ):
9194 self .participant_id = participant_id
9295 self .user_participant_ids = user_participant_ids
9396 self .base_url = base_url
94- self .client = infrastructure . UTMClientSession ( base_url , auth_adapter )
97+ self .client = client
9598 self ._scopes_authorized = set (
9699 s .value if isinstance (s , Enum ) else s for s in scopes_authorized
97100 )
@@ -126,7 +129,11 @@ def with_different_auth(
126129 participant_id = self .participant_id ,
127130 user_participant_ids = self .user_participant_ids ,
128131 base_url = self .base_url ,
129- auth_adapter = auth_adapter .adapter ,
132+ client = UTMClientSession (
133+ self .base_url ,
134+ auth_adapter = auth_adapter .adapter ,
135+ timeout_seconds = self .client .timeout_seconds ,
136+ ),
130137 scopes_authorized = list (scopes_required ),
131138 )
132139
@@ -694,6 +701,7 @@ def delete_subscription(self, sub_id: str, sub_version: str) -> MutatedSubscript
694701class DSSInstanceResource (Resource [DSSInstanceSpecification ]):
695702 _specification : DSSInstanceSpecification
696703 _auth_adapter : AuthAdapterResource
704+ _client : UTMClientSession
697705
698706 def __init__ (
699707 self ,
@@ -704,6 +712,14 @@ def __init__(
704712 super ().__init__ (specification , resource_origin )
705713 self ._specification = specification
706714 self ._auth_adapter = auth_adapter
715+ timeout_seconds = (
716+ specification .timeout_seconds
717+ if "timeout_seconds" in specification
718+ else None
719+ )
720+ self ._client = UTMClientSession (
721+ self ._specification .base_url , auth_adapter .adapter , timeout_seconds
722+ )
707723
708724 def can_use_scope (self , scope : str ) -> bool :
709725 return scope in self ._auth_adapter .scopes
@@ -777,7 +793,7 @@ def get_instance(self, scopes_required: dict[str, str]) -> DSSInstance:
777793 else []
778794 ),
779795 self ._specification .base_url ,
780- self ._auth_adapter . adapter ,
796+ self ._client ,
781797 list (scopes_required ),
782798 )
783799
0 commit comments