4343
4444@attr .s
4545class CoreClient (AsyncBaseCoreClient ):
46- """Client for core endpoints defined by stac."""
46+ """Client for core endpoints defined by the STAC specification.
47+
48+ This class is a implementation of `AsyncBaseCoreClient` that implements the core endpoints
49+ defined by the STAC specification. It uses the `DatabaseLogic` class to interact with the
50+ database, and `ItemSerializer` and `CollectionSerializer` to convert between STAC objects and
51+ database records.
52+
53+ Attributes:
54+ session (Session): A requests session instance to be used for all HTTP requests.
55+ item_serializer (Type[serializers.ItemSerializer]): A serializer class to be used to convert
56+ between STAC items and database records.
57+ collection_serializer (Type[serializers.CollectionSerializer]): A serializer class to be
58+ used to convert between STAC collections and database records.
59+ database (DatabaseLogic): An instance of the `DatabaseLogic` class that is used to interact
60+ with the database.
61+ """
4762
4863 session : Session = attr .ib (default = attr .Factory (Session .create_from_env ))
4964 item_serializer : Type [serializers .ItemSerializer ] = attr .ib (
@@ -56,7 +71,15 @@ class CoreClient(AsyncBaseCoreClient):
5671
5772 @overrides
5873 async def all_collections (self , ** kwargs ) -> Collections :
59- """Read all collections from the database."""
74+ """Read all collections from the database.
75+
76+ Returns:
77+ Collections: A `Collections` object containing all the collections in the database and
78+ links to various resources.
79+
80+ Raises:
81+ Exception: If any error occurs while reading the collections from the database.
82+ """
6083 base_url = str (kwargs ["request" ].base_url )
6184
6285 return Collections (
@@ -85,7 +108,18 @@ async def all_collections(self, **kwargs) -> Collections:
85108
86109 @overrides
87110 async def get_collection (self , collection_id : str , ** kwargs ) -> Collection :
88- """Get collection by id."""
111+ """Get a collection from the database by its id.
112+
113+ Args:
114+ collection_id (str): The id of the collection to retrieve.
115+ kwargs: Additional keyword arguments passed to the API call.
116+
117+ Returns:
118+ Collection: A `Collection` object representing the requested collection.
119+
120+ Raises:
121+ NotFoundError: If the collection with the given id cannot be found in the database.
122+ """
89123 base_url = str (kwargs ["request" ].base_url )
90124 collection = await self .database .find_collection (collection_id = collection_id )
91125 return self .collection_serializer .db_to_stac (collection , base_url )
@@ -100,7 +134,24 @@ async def item_collection(
100134 token : str = None ,
101135 ** kwargs ,
102136 ) -> ItemCollection :
103- """Read an item collection from the database."""
137+ """Read items from a specific collection in the database.
138+
139+ Args:
140+ collection_id (str): The identifier of the collection to read items from.
141+ bbox (Optional[List[NumType]]): The bounding box to filter items by.
142+ datetime (Union[str, datetime_type, None]): The datetime range to filter items by.
143+ limit (int): The maximum number of items to return. The default value is 10.
144+ token (str): A token used for pagination.
145+ request (Request): The incoming request.
146+
147+ Returns:
148+ ItemCollection: An `ItemCollection` object containing the items from the specified collection that meet
149+ the filter criteria and links to various resources.
150+
151+ Raises:
152+ HTTPException: If the specified collection is not found.
153+ Exception: If any error occurs while reading the items from the database.
154+ """
104155 request : Request = kwargs ["request" ]
105156 base_url = str (request .base_url )
106157
@@ -163,7 +214,15 @@ async def item_collection(
163214
164215 @overrides
165216 async def get_item (self , item_id : str , collection_id : str , ** kwargs ) -> Item :
166- """Get item by item id, collection id."""
217+ """Get an item from the database based on its id and collection id.
218+
219+ Returns:
220+ Item: An `Item` object representing the requested item.
221+
222+ Raises:
223+ Exception: If any error occurs while getting the item from the database.
224+ NotFoundError: If the item does not exist in the specified collection.
225+ """
167226 base_url = str (kwargs ["request" ].base_url )
168227 item = await self .database .get_one_item (
169228 item_id = item_id , collection_id = collection_id
0 commit comments