@@ -40,7 +40,7 @@ class LicensesApiImpl(BaseLicensesApi):
4040 """
4141
4242 @with_db_session
43- async def get_license (
43+ def handle_get_license (
4444 self ,
4545 id : StrictStr ,
4646 db_session : Session = None ,
@@ -59,11 +59,21 @@ async def get_license(
5959 # Build Pydantic model from ORM object attributes
6060 return LicenseWithRulesImpl .from_orm (license_orm )
6161
62+ async def get_license (
63+ self ,
64+ id : StrictStr ,
65+ ) -> LicenseWithRules :
66+ """Get the specified license from the Mobility Database.
67+
68+ Raises 404 if the license is not found.
69+ """
70+ return self .handle_get_license (id )
71+
6272 @with_db_session
63- async def get_licenses (
73+ def handle_get_licenses (
6474 self ,
65- limit : int ,
66- offset : int ,
75+ offset : str = "0" ,
76+ limit : str = "100" ,
6777 search_query : Optional [StrictStr ] = None ,
6878 is_spdx : Optional [bool ] = None ,
6979 db_session : Session = None ,
@@ -83,6 +93,8 @@ async def get_licenses(
8393 is_spdx ,
8494 )
8595
96+ limit_int = int (limit )
97+ offset_int = int (offset )
8698 query = db_session .query (OrmLicense )
8799
88100 # Text search by name or id
@@ -101,9 +113,24 @@ async def get_licenses(
101113 if is_spdx is not None :
102114 query = query .filter (OrmLicense .is_spdx == is_spdx )
103115
104- query = query .order_by (OrmLicense .id ).offset (offset ).limit (limit )
116+ query = query .order_by (OrmLicense .id ).offset (offset_int ).limit (limit_int )
105117 items : List [OrmLicense ] = query .all ()
106118
107119 logging .info ("Fetched %d licenses" , len (items ))
108120
109121 return [LicenseBaseImpl .from_orm (item ) for item in items ]
122+
123+ async def get_licenses (
124+ self ,
125+ offset : str = "0" ,
126+ limit : str = "100" ,
127+ search_query : Optional [StrictStr ] = None ,
128+ is_spdx : Optional [bool ] = None ,
129+ ) -> List [LicenseBase ]:
130+ """Get the list of licenses from the Mobility Database.
131+
132+ Supports pagination via `limit` and `offset`, optional
133+ case-insensitive text search on license name / id, and
134+ optional filtering by SPDX status.
135+ """
136+ return self .handle_get_licenses (offset , limit , search_query , is_spdx )
0 commit comments