-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mock_uss] add isa notification endpoint to mock RID display provider (…
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
from monitoring.mock_uss import webapp | ||
from monitoring.mock_uss.riddp.config import KEY_RID_VERSION | ||
from ...monitorlib.rid import RIDVersion | ||
|
||
rid_version: RIDVersion = webapp.config[KEY_RID_VERSION] | ||
|
||
|
||
@webapp.route("/riddp/status") | ||
def riddp_status(): | ||
return "Mock RID Display Provider ok" | ||
|
||
|
||
if rid_version == RIDVersion.f3411_19: | ||
from . import routes_riddp_v19 | ||
elif rid_version == RIDVersion.f3411_22a: | ||
from . import routes_riddp_v22a | ||
else: | ||
raise NotImplementedError( | ||
f"Mock USS does not yet support RID version {rid_version}" | ||
) | ||
|
||
from . import routes_observation | ||
from . import routes_behavior |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import flask | ||
from implicitdict import ImplicitDict | ||
from uas_standards.astm.f3411.v19.api import ( | ||
OperationID, | ||
OPERATIONS, | ||
PutIdentificationServiceAreaNotificationParameters, | ||
) | ||
from uas_standards.astm.f3411.v19.constants import ( | ||
Scope, | ||
) | ||
|
||
from monitoring.mock_uss import webapp | ||
from monitoring.mock_uss.auth import requires_scope | ||
|
||
|
||
def rid_v19_operation(op_id: OperationID): | ||
op = OPERATIONS[op_id] | ||
path = op.path.replace("{", "<").replace("}", ">") | ||
return webapp.route("/mock/riddp" + path, methods=[op.verb]) | ||
|
||
|
||
@rid_v19_operation(OperationID.PostIdentificationServiceArea) | ||
@requires_scope(Scope.Write) | ||
def ridsp_notify_isa_v19(id: str): | ||
try: | ||
json = flask.request.json | ||
if json is None: | ||
raise ValueError("Request did not contain a JSON payload") | ||
ImplicitDict.parse(json, PutIdentificationServiceAreaNotificationParameters) | ||
except ValueError as e: | ||
msg = "Unable to parse PutIdentificationServiceAreaNotificationParameters JSON request: {}".format( | ||
e | ||
) | ||
return msg, 400 | ||
|
||
return ( | ||
flask.jsonify(None), | ||
204, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import flask | ||
from implicitdict import ImplicitDict | ||
from uas_standards.astm.f3411.v22a.api import ( | ||
OperationID, | ||
OPERATIONS, | ||
PutIdentificationServiceAreaNotificationParameters, | ||
) | ||
from uas_standards.astm.f3411.v22a.constants import ( | ||
Scope, | ||
) | ||
|
||
from monitoring.mock_uss import webapp | ||
from monitoring.mock_uss.auth import requires_scope | ||
|
||
|
||
def rid_v22a_operation(op_id: OperationID): | ||
op = OPERATIONS[op_id] | ||
path = op.path.replace("{", "<").replace("}", ">") | ||
return webapp.route("/mock/riddp" + path, methods=[op.verb]) | ||
|
||
|
||
@rid_v22a_operation(OperationID.PostIdentificationServiceArea) | ||
@requires_scope(Scope.ServiceProvider) | ||
def ridsp_notify_isa_v22a(id: str): | ||
try: | ||
json = flask.request.json | ||
if json is None: | ||
raise ValueError("Request did not contain a JSON payload") | ||
ImplicitDict.parse(json, PutIdentificationServiceAreaNotificationParameters) | ||
except ValueError as e: | ||
msg = "Unable to parse PutIdentificationServiceAreaNotificationParameters JSON request: {}".format( | ||
e | ||
) | ||
return msg, 400 | ||
|
||
return ( | ||
flask.jsonify(None), | ||
204, | ||
) |