Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dschristianson committed Jul 20, 2023
1 parent 15fd498 commit 7274434
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
7 changes: 1 addition & 6 deletions basin3d/core/schema/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 12 additions & 4 deletions basin3d/core/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
"""
Expand All @@ -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,
Expand All @@ -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, <plugin>MonitoringFeatureAccess.get
synthesis_response: SynthesisResponse = super().retrieve(query=query, messages=msg)
return synthesis_response

Expand Down

0 comments on commit 7274434

Please sign in to comment.