@@ -84,6 +84,42 @@ def register(self, app: FastAPI, settings=None) -> None:
8484 tags = ["Catalogs" ],
8585 )
8686
87+ # Add endpoint for getting a specific collection in a catalog
88+ self .router .add_api_route (
89+ path = "/catalogs/{catalog_id}/collections/{collection_id}" ,
90+ endpoint = self .get_catalog_collection ,
91+ methods = ["GET" ],
92+ response_model = stac_types .Collection ,
93+ response_class = self .response_class ,
94+ summary = "Get Catalog Collection" ,
95+ description = "Get a specific collection from a catalog." ,
96+ tags = ["Catalogs" ],
97+ )
98+
99+ # Add endpoint for getting items in a collection within a catalog
100+ self .router .add_api_route (
101+ path = "/catalogs/{catalog_id}/collections/{collection_id}/items" ,
102+ endpoint = self .get_catalog_collection_items ,
103+ methods = ["GET" ],
104+ response_model = stac_types .ItemCollection ,
105+ response_class = self .response_class ,
106+ summary = "Get Catalog Collection Items" ,
107+ description = "Get items from a collection in a catalog." ,
108+ tags = ["Catalogs" ],
109+ )
110+
111+ # Add endpoint for getting a specific item in a collection within a catalog
112+ self .router .add_api_route (
113+ path = "/catalogs/{catalog_id}/collections/{collection_id}/items/{item_id}" ,
114+ endpoint = self .get_catalog_collection_item ,
115+ methods = ["GET" ],
116+ response_model = stac_types .Item ,
117+ response_class = self .response_class ,
118+ summary = "Get Catalog Collection Item" ,
119+ description = "Get a specific item from a collection in a catalog." ,
120+ tags = ["Catalogs" ],
121+ )
122+
87123 app .include_router (self .router , tags = ["Catalogs" ])
88124
89125 async def catalogs (self , request : Request ) -> Catalog :
@@ -253,3 +289,82 @@ async def get_catalog_collections(
253289 raise HTTPException (
254290 status_code = 404 , detail = f"Catalog { catalog_id } not found"
255291 )
292+
293+ async def get_catalog_collection (
294+ self , catalog_id : str , collection_id : str , request : Request
295+ ) -> stac_types .Collection :
296+ """Get a specific collection from a catalog.
297+
298+ Args:
299+ catalog_id: The ID of the catalog.
300+ collection_id: The ID of the collection.
301+ request: Request object.
302+
303+ Returns:
304+ The requested collection.
305+ """
306+ # Verify the catalog exists
307+ try :
308+ await self .client .database .find_catalog (catalog_id )
309+ except Exception :
310+ raise HTTPException (
311+ status_code = 404 , detail = f"Catalog { catalog_id } not found"
312+ )
313+
314+ # Delegate to the core client's get_collection method
315+ return await self .client .get_collection (
316+ collection_id = collection_id , request = request
317+ )
318+
319+ async def get_catalog_collection_items (
320+ self , catalog_id : str , collection_id : str , request : Request
321+ ) -> stac_types .ItemCollection :
322+ """Get items from a collection in a catalog.
323+
324+ Args:
325+ catalog_id: The ID of the catalog.
326+ collection_id: The ID of the collection.
327+ request: Request object.
328+
329+ Returns:
330+ ItemCollection containing items from the collection.
331+ """
332+ # Verify the catalog exists
333+ try :
334+ await self .client .database .find_catalog (catalog_id )
335+ except Exception :
336+ raise HTTPException (
337+ status_code = 404 , detail = f"Catalog { catalog_id } not found"
338+ )
339+
340+ # Delegate to the core client's item_collection method
341+ return await self .client .item_collection (
342+ collection_id = collection_id , request = request
343+ )
344+
345+ async def get_catalog_collection_item (
346+ self , catalog_id : str , collection_id : str , item_id : str , request : Request
347+ ) -> stac_types .Item :
348+ """Get a specific item from a collection in a catalog.
349+
350+ Args:
351+ catalog_id: The ID of the catalog.
352+ collection_id: The ID of the collection.
353+ item_id: The ID of the item.
354+ request: Request object.
355+
356+ Returns:
357+ The requested item.
358+ """
359+ # Verify the catalog exists
360+ try :
361+ await self .client .database .find_catalog (catalog_id )
362+ except Exception :
363+ raise HTTPException (
364+ status_code = 404 , detail = f"Catalog { catalog_id } not found"
365+ )
366+
367+ # Delegate to the core client's get_item method
368+ return await self .client .get_item (
369+ item_id = item_id , collection_id = collection_id , request = request
370+ )
0 commit comments