From 72744349c2e2144772ecb3161620742a018c3e0f Mon Sep 17 00:00:00 2001 From: dschristianson Date: Thu, 20 Jul 2023 11:28:24 -0700 Subject: [PATCH] docs --- basin3d/core/schema/query.py | 7 +------ basin3d/core/synthesis.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/basin3d/core/schema/query.py b/basin3d/core/schema/query.py index c136bd5..72dae4e 100644 --- a/basin3d/core/schema/query.py +++ b/basin3d/core/schema/query.py @@ -71,14 +71,9 @@ class Config: prefixed_fields: ClassVar[List[str]] = [] -# class QueryById(QueryBase): -# """Query for a single data object by identifier""" -# -# id: str = Field(title="Identifier", description="The unique identifier for the desired data object") - - class QueryMonitoringFeature(QueryBase): """Query :class:`basin3d.core.models.MonitoringFeature`""" + # optional but id (QueryBase) is required to query by named monitoring feature feature_type: Optional[FeatureTypeEnum] = Field(title="Feature Type", description="Filter results by the specified feature type.") monitoring_feature: Optional[List[str]] = Field(title="Monitoring Features", diff --git a/basin3d/core/synthesis.py b/basin3d/core/synthesis.py index 1d1d48c..8132aa3 100644 --- a/basin3d/core/synthesis.py +++ b/basin3d/core/synthesis.py @@ -33,7 +33,7 @@ class MonitorMixin(object): def log(self, message: str, level: Optional[MessageLevelEnum] = None, where: Optional[List] = None) -> Optional[SynthesisMessage]: """ - Add a synthesis message to the synthesis respoonse + Add a synthesis message to the synthesis response :param message: The message :param level: The message level :param where: Where the message is from @@ -188,7 +188,7 @@ def __next__(self) -> Base: def log(self, message: str, level: Optional[MessageLevelEnum] = None, where: Optional[List] = None): # type: ignore[override] """ - Add a synthesis message to the synthesis respoonse + Add a synthesis message to the synthesis response :param message: The message :param level: The message level :return: None @@ -331,6 +331,9 @@ class MonitoringFeatureAccess(DataSourceModelAccess): **Filter** by the following attributes (/?attribute=parameter&attribute=parameter&...) * *datasource (optional):* a single data source id prefix (e.g ?datasource=`datasource.id_prefix`) + * *id (optional):* a single monitoring feature id. Cannot be combined with monitoring_feature (e.g ?id=`id`) + * *parent_feature (optional)*: a list of parent feature ids. Plugin must have this functionality (e.g ?parent_feature=`id`,`id`) + * *monitoring_feature (optional)*: a list of monitoring feature ids. Cannot be combined with id which will take precedence. (e.g ?monitoring_feature=`id`,`id`) **Restrict fields** with query parameter ‘fields’. (e.g. ?fields=id,name) """ @@ -350,10 +353,13 @@ def synthesize_query(self, plugin_access: DataSourcePluginAccess, query: QueryMo def retrieve(self, query: QueryMonitoringFeature) -> SynthesisResponse: """ + Retrieve the specified Monitoring Feature - :param query: - :return: + :param query: :class:`basin3d.core.schema.query.QueryMonitoringFeature`, id must be specified; monitoring_feature if specified will be removed. + :return: The synthesized response containing the specified MonitoringFeature if it exists """ + + # validate that id is specified if not query.id: return SynthesisResponse( query=query, @@ -362,12 +368,14 @@ def retrieve(self, query: QueryMonitoringFeature) -> SynthesisResponse: msg = [] + # remove monitoring_feature specification (i.e., id takes precedence) if query.monitoring_feature: mf_text = ', '.join(query.monitoring_feature) query.monitoring_feature = None msg.append(self.log(f'Monitoring Feature query has both id {query.id} and monitoring_feature {mf_text} ' f'specified. Removing monitoring_feature and using id.', MessageLevelEnum.WARN)) + # retrieve / get method order should be: MonitoringFeatureAccess, DataSourceModelAccess, MonitoringFeatureAccess.get synthesis_response: SynthesisResponse = super().retrieve(query=query, messages=msg) return synthesis_response