Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions pygeoapi/provider/base_edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
# =================================================================

import logging
from typing import Optional

from pygeoapi.provider.base import BaseProvider, ProviderInvalidDataError
from pygeoapi.provider.base import (BaseProvider, ProviderInvalidDataError,
ProviderQueryError)

LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -116,8 +118,16 @@ def query(self, **kwargs):

:returns: coverage data as `dict` of CoverageJSON or native format
"""

query_type: Optional[str] = kwargs.get('query_type')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        query_type = kwargs.get('query_type')

        if query_type is None:
            raise ProviderQueryError('Missing query_type parameter is required')

if not query_type:
raise ProviderQueryError(
'query_type parameter is required'
)
try:
return getattr(self, kwargs.get('query_type'))(**kwargs)
query_function = getattr(self, query_type)
except AttributeError:
raise NotImplementedError('Query not implemented!')
raise NotImplementedError(
f'Query "{query_type}" not implemented in registered query types: {self.query_types}' # noqa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A client can always autodiscover the query types from collection links. Suggest, then:

f'Query type not implemented'.

)

return query_function(**kwargs)