-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathdecision_point.py
More file actions
67 lines (53 loc) · 2.03 KB
/
Copy pathdecision_point.py
File metadata and controls
67 lines (53 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
"""
API Routes for decision_point
"""
# Copyright (c) 2025 Carnegie Mellon University.
# NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE
# ENGINEERING INSTITUTE MATERIAL IS FURNISHED ON AN "AS-IS" BASIS.
# CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND,
# EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT
# NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE OR
# MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE
# OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE
# ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM
# PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT.
# Licensed under a MIT (SEI)-style license, please see LICENSE or contact
# permission@sei.cmu.edu for full terms.
# [DISTRIBUTION STATEMENT A] This material has been approved for
# public release and unlimited distribution. Please see Copyright notice
# for non-US Government use and distribution.
# This Software includes and/or makes use of Third-Party Software each
# subject to its own license.
# DM24-0278
from fastapi import HTTPException
from ssvc.api.helpers import _404_on_none
from ssvc.decision_points.base import DecisionPoint
from ssvc.registry.base import get_registry
from ssvc.registry.base import lookup_version
r = get_registry()
from fastapi import APIRouter
router = APIRouter(prefix="/decision_point", tags=["Decision Point"])
@router.get("/", response_model=DecisionPoint)
async def get_decision_point_by_id(id: str) -> DecisionPoint:
"""Returns a single DecisionPoint object by its ID."""
try:
(namespace, key, version) = id.split(":")
except ValueError:
raise HTTPException(
status_code=400,
detail="ID must be in the format 'namespace:key:version'",
)
version = lookup_version(
objtype="DecisionPoint",
namespace=namespace,
key=key,
version=version,
registry=r,
)
_404_on_none(version)
return version.obj
def main():
pass
if __name__ == "__main__":
main()