Skip to content

Commit 3f53df4

Browse files
committed
Aggregation of queryables across select collections
1 parent 6c4af70 commit 3f53df4

File tree

4 files changed

+636
-2
lines changed

4 files changed

+636
-2
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ repos:
3333
- pytest-vcr
3434
- types-requests
3535
- types-python-dateutil
36+
- orjson

pystac_client/mixins.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,24 @@ def _get_href(self, rel: str, link: Optional[pystac.Link], endpoint: str) -> str
3232
class QueryablesMixin(BaseMixin):
3333
"""Mixin for adding support for /queryables endpoint"""
3434

35-
def get_queryables(self) -> Dict[str, Any]:
36-
"""Return all queryables.
35+
def get_queryables(self, *collections: Optional[str]) -> Dict[str, Any]:
36+
"""Return all queryables, or limit to those of specified collections.
3737
3838
Output is a dictionary that can be used in ``jsonshema.validate``
39+
Args:
40+
*collections: The IDs of the items to include.
3941
4042
Return:
4143
Dict[str, Any]: Dictionary containing queryable fields
4244
"""
45+
if collections and isinstance(self, pystac.Catalog):
46+
response = self.get_collection(collections[0]).get_queryables()
47+
response.pop("$id")
48+
for collection in collections[1:]:
49+
col_resp = self.get_collection(collection).get_queryables()
50+
response["properties"].update(col_resp["properties"])
51+
return response
52+
4353
if self._stac_io is None:
4454
raise APIError("API access is not properly configured")
4555

0 commit comments

Comments
 (0)