Skip to content

Commit

Permalink
Pass if any additional_fields in the InjectFlightRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
punamverma committed Nov 3, 2023
1 parent ef76e72 commit de0d0e4
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Tuple, Optional, Set
from typing import Tuple, Optional, Set, get_type_hints
from urllib.parse import urlparse
from implicitdict import ImplicitDict

from monitoring.monitorlib import infrastructure, fetch
from monitoring.monitorlib.clients.flight_planning.client import (
PlanningActivityError,
Expand Down Expand Up @@ -90,6 +89,13 @@ def to_client(
)


def _additional_fields_in_request(request: InjectFlightRequest) -> dict:
addl_fields = {}
for k, v in request.items():
if k not in get_type_hints(InjectFlightRequest):
addl_fields[k] = v
return addl_fields

class FlightPlanner:
"""Manages the state and the interactions with flight planner USS.
Expand Down Expand Up @@ -123,7 +129,6 @@ def request_flight(
self,
request: InjectFlightRequest,
flight_id: Optional[str] = None,
additional_fields: Optional[dict] = None,
) -> Tuple[InjectFlightResponse, fetch.Query, str]:
usage_states = {
OperationalIntentState.Accepted: AirspaceUsageState.Planned,
Expand Down Expand Up @@ -168,6 +173,13 @@ def request_flight(
uspace_flight_authorisation=uspace_flight_authorisation,
)

# Extracting if any additional fields from subclasses of InjectFlightRequest
additional_fields = (
None
if not _additional_fields_in_request(request)
else _additional_fields_in_request(request)
)

if not flight_id:
try:
resp = self.client.try_plan_flight(
Expand Down

0 comments on commit de0d0e4

Please sign in to comment.