1- from typing import Optional , Dict , Any , Union
21import warnings
2+ from typing import Any , Dict , Optional , Union
33
44import pystac
55
6- from pystac_client .exceptions import APIError
76from pystac_client .conformance import ConformanceClasses
7+ from pystac_client .exceptions import APIError
88from pystac_client .stac_api_io import StacApiIO
99from pystac_client .warnings import DoesNotConformTo , MissingLink
1010
@@ -32,34 +32,21 @@ def _get_href(self, rel: str, link: Optional[pystac.Link], endpoint: str) -> str
3232class QueryablesMixin (BaseMixin ):
3333 """Mixin for adding support for /queryables endpoint"""
3434
35- def get_queryables (self , * collections : Optional [str ]) -> Dict [str , Any ]:
36- """Return all queryables, or limit to those of specified collections.
37-
38- Queryables from multiple collections are unioned together, except in the case when the same queryable key has a different definition, in which case that key is dropped.
35+ def get_queryables_from (self , url : str ) -> Dict [str , Any ]:
36+ """Return all queryables.
3937
4038 Output is a dictionary that can be used in ``jsonshema.validate``
39+
4140 Args:
42- *collections: The IDs of the items to include.
41+ url: a queryables url
4342
4443 Return:
4544 Dict[str, Any]: Dictionary containing queryable fields
4645 """
47- if collections and isinstance (self , pystac .Catalog ):
48- response = self .get_collection (collections [0 ]).get_queryables ()
49- response .pop ("$id" )
50- for collection in collections [1 :]:
51- col_resp = self .get_collection (collection ).get_queryables ()
52- response ["properties" ].update (col_resp ["properties" ])
53- return response
5446
5547 if self ._stac_io is None :
5648 raise APIError ("API access is not properly configured" )
5749
58- if not self .conforms_to (ConformanceClasses .FILTER ):
59- raise DoesNotConformTo (ConformanceClasses .FILTER .name )
60-
61- url = self ._get_queryables_href ()
62-
6350 result = self ._stac_io .read_json (url )
6451 if "properties" not in result :
6552 raise APIError (
@@ -69,7 +56,14 @@ def get_queryables(self, *collections: Optional[str]) -> Dict[str, Any]:
6956
7057 return result
7158
59+ def get_queryables (self ) -> Dict [str , Any ]:
60+ url = self ._get_queryables_href ()
61+ return self .get_queryables_from (url )
62+
7263 def _get_queryables_href (self ) -> str :
64+ if not self .conforms_to (ConformanceClasses .FILTER ):
65+ raise DoesNotConformTo (ConformanceClasses .FILTER .name )
66+
7367 link = self .get_single_link (QUERYABLES_REL )
7468 href = self ._get_href (QUERYABLES_REL , link , QUERYABLES_ENDPOINT )
7569 return href
0 commit comments