Skip to content

Use GET with comma-separated values for multi-value waterdata queries#233

Merged
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix-waterdata-get-multivalue
May 15, 2026
Merged

Use GET with comma-separated values for multi-value waterdata queries#233
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix-waterdata-get-multivalue

Conversation

@thodson-usgs
Copy link
Copy Markdown
Collaborator

@thodson-usgs thodson-usgs commented Apr 14, 2026

Route most multi-value waterdata kwargs through GET with comma-joined values instead of POST+CQL2. The OGC API supports ?parameter_code=00060,00010 for all collections except monitoring-locations, which still rejects comma-separated values and so retains the POST+CQL2 path.

Service-scoped routing

A new _CQL2_REQUIRED_SERVICES = frozenset({"monitoring-locations"}) constant picks the path. When the Water Data APIs team enables comma-separated support on monitoring-locations, emptying this set drops the POST branch in one edit.

Date formatting moved before routing

_format_api_dates now runs once at the top of _construct_api_requests, so both routing paths consume an already-formatted ISO8601 string rather than the original list shape.

Closes #210

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Water Data OGC request builder to use comma-separated GET parameters for multi-value queries where supported, reducing reliance on POST+CQL2 while preserving POST behavior for monitoring-locations.

Changes:

  • Adds _CQL2_REQUIRED_SERVICES to keep monitoring-locations on POST+CQL2.
  • Formats date/time parameters before choosing GET vs POST.
  • Adds unit tests for multi-value GET, monitoring-location POST fallback, scalar handling, numeric list joining, and date interval formatting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
dataretrieval/waterdata/utils.py Updates request construction logic to comma-join list parameters for GET except for CQL2-required services.
tests/waterdata_test.py Adds tests covering the updated request construction behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@thodson-usgs thodson-usgs marked this pull request as ready for review May 15, 2026 19:34
The OGC Water Data API supports comma-separated multi-value parameters
for most collections, so list-valued kwargs (e.g. parameter_code=
["00060", "00010"]) can now be sent as a single GET request instead of
a POST+CQL2 body. The monitoring-locations collection still rejects
comma-separated values and so retains the POST+CQL2 path; a new
_CQL2_REQUIRED_SERVICES frozenset is the single removal point for
when the upstream API closes that gap.

Date/time parameters are now formatted to ISO8601 once at the top of
_construct_api_requests ahead of the routing decision, so both paths
see a post-formatted string instead of the original list shape.

Tests cover the GET multi-value path, the POST+CQL2 path (including
the full CQL2 envelope shape), single-value scalars, numeric lists,
and the two-element date-list interval case.

Closes DOI-USGS#210
@thodson-usgs thodson-usgs force-pushed the fix-waterdata-get-multivalue branch from a432be8 to 40ed9eb Compare May 15, 2026 19:36
@thodson-usgs thodson-usgs merged commit 36866a0 into DOI-USGS:main May 15, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand usage of GET calls in waterdata module

2 participants