Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[uss_qualifier]Check and pass any additional fields in the InjectFlightRequest #315

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading