Skip to content

Add support for Patch endpoints #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 79 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
e0bd94f
Adding patch endpoints to transactions extension to elasticsearch.
rhysrevans3 Aug 29, 2024
01c1563
Adding patch to opensearch backend.
rhysrevans3 Aug 29, 2024
d171c24
Pinning to pull request version for tests.
rhysrevans3 Aug 30, 2024
59661c5
Merge branch 'main' of github.com:stac-utils/stac-fastapi-elasticsear…
rhysrevans3 Aug 30, 2024
5400e42
Updating patch types.
rhysrevans3 Sep 16, 2024
fe8530a
Adding checks for existing properties.
rhysrevans3 Sep 17, 2024
7cf36eb
Updating utils.
rhysrevans3 Nov 19, 2024
5929b00
Adding model for path.
rhysrevans3 Mar 26, 2025
d94d8fe
Switch to use pydantic model for operation path.
rhysrevans3 Mar 26, 2025
4623a43
Merge branch 'main' of github.com:stac-utils/stac-fastapi-elasticsear…
rhysrevans3 Mar 26, 2025
093c593
Adding computed_field output type.
rhysrevans3 Mar 26, 2025
d4bd07a
pre-commit.
rhysrevans3 Mar 26, 2025
b6b0721
Add changes to opensearch.
rhysrevans3 Mar 26, 2025
90a287f
pre-commit.
rhysrevans3 Mar 26, 2025
f1c320a
Switch to model validator.
rhysrevans3 Mar 26, 2025
a2d6f48
Simplify conversion logic.
rhysrevans3 Mar 27, 2025
3a75b68
Opensearch update body not script.
rhysrevans3 Mar 27, 2025
ee90324
pre-commit.
rhysrevans3 Mar 27, 2025
173ef0d
Remove duplicate test name.
rhysrevans3 Mar 27, 2025
93350c7
PatchOperation not dict for tests.
rhysrevans3 Mar 27, 2025
bf6f96a
pre-commit.
rhysrevans3 Mar 27, 2025
29f6e2e
filter_expr not filter for aggregation request.
rhysrevans3 Mar 31, 2025
3d5b168
pre-commit.
rhysrevans3 Mar 31, 2025
ca64ba3
Filter fix.
rhysrevans3 Mar 31, 2025
b412576
remove PatchOperation in tests.
rhysrevans3 Mar 31, 2025
7368d8d
patch bugs.
rhysrevans3 Mar 31, 2025
2b359f6
Switch to http exception.
rhysrevans3 Mar 31, 2025
0274b64
test_item_search_temporal_window_get fix.
rhysrevans3 Mar 31, 2025
1c4fe43
Request not BadRequest for opensearch.
rhysrevans3 Mar 31, 2025
fb6fe82
Opensearch update body.
rhysrevans3 Mar 31, 2025
fa6afb3
Adding collection patch tests.
rhysrevans3 Apr 1, 2025
b1aa252
Array list fixes.
rhysrevans3 Apr 1, 2025
5c972d1
Consolidating add and copy commands.
rhysrevans3 Apr 1, 2025
b532058
remove debug prints.
rhysrevans3 Apr 1, 2025
3ffe9d5
Move extension replacement to ElasticPath.
rhysrevans3 Apr 2, 2025
0822417
Reset command set between different patches.
rhysrevans3 Apr 2, 2025
050254f
Correcting bad check command.
rhysrevans3 Apr 2, 2025
b5544dd
Update opensearch collection patch.
rhysrevans3 Apr 2, 2025
5887227
RequestError not BadRequestError for opensearch.
rhysrevans3 Apr 2, 2025
2b13818
Remove python 3.8 support.
rhysrevans3 Apr 2, 2025
c2c5832
Latest core changes.
rhysrevans3 Apr 10, 2025
9bc4863
Update and add tests.
rhysrevans3 May 20, 2025
6a29945
Merge branch 'main' of github.com:stac-utils/stac-fastapi-elasticsear…
rhysrevans3 May 20, 2025
324907c
Adding headers for mock patches.
rhysrevans3 May 21, 2025
93eb352
Adding headers to MockRequest
rhysrevans3 May 21, 2025
d39286e
pre-commit.
rhysrevans3 May 21, 2025
58d1061
content-type casing.
rhysrevans3 May 27, 2025
c245d55
Adding missing await.
rhysrevans3 May 28, 2025
9c143c1
Removing MockRequest from test_api.py
rhysrevans3 May 28, 2025
a34e881
Updating es path regex.
rhysrevans3 May 28, 2025
4666f9e
Patch regex error.
rhysrevans3 May 28, 2025
0b86ab3
use params for script.
rhysrevans3 May 28, 2025
6905919
Remove json dump for param values.
rhysrevans3 May 28, 2025
c720ac3
Refresh after id changes.
rhysrevans3 May 28, 2025
b0ecbca
Adding missing test params.
rhysrevans3 May 28, 2025
f93bc3b
Fix tests.
rhysrevans3 Jun 2, 2025
922f552
Merge branch 'main' of github.com:stac-utils/stac-fastapi-elasticsear…
rhysrevans3 Jun 5, 2025
3cf4997
Updating stac_pydantic for core.
rhysrevans3 Jun 5, 2025
dcb9fb0
Removing datetime from core search.
rhysrevans3 Jun 5, 2025
502da27
Adding timezone to test collection.
rhysrevans3 Jun 10, 2025
3bcd739
Merge branch 'main' of github.com:stac-utils/stac-fastapi-elasticsear…
rhysrevans3 Jun 10, 2025
11b94e3
fix len miss match.
rhysrevans3 Jun 10, 2025
24b319b
Patch test path correction.
rhysrevans3 Jun 11, 2025
dc9db54
Remove bad operations.
rhysrevans3 Jun 11, 2025
f93c04c
Move op test.
rhysrevans3 Jun 11, 2025
968be95
pre-commit.
rhysrevans3 Jun 11, 2025
9ca04ef
Opensearch use body for script update.
rhysrevans3 Jun 11, 2025
92611a7
patch operations test.
rhysrevans3 Jun 11, 2025
530eba7
collection json patch just add.
rhysrevans3 Jun 11, 2025
5393405
Json patch replace.
rhysrevans3 Jun 11, 2025
49b80b2
move in collection.
rhysrevans3 Jun 11, 2025
26cdde8
copy operation.
rhysrevans3 Jun 11, 2025
66ea717
No nest bug fix.
rhysrevans3 Jun 11, 2025
3dd27aa
Merge branch 'main' of github.com:stac-utils/stac-fastapi-elasticsear…
rhysrevans3 Jun 11, 2025
6394c18
Moving ES-related code from core to sfeos_helpers.
rhysrevans3 Jun 19, 2025
1da1f60
Merge branch 'main' of github.com:stac-utils/stac-fastapi-elasticsear…
rhysrevans3 Jun 19, 2025
2bf706a
Import fix.
rhysrevans3 Jun 19, 2025
01a3eeb
stac-fastapi v6.0.0
rhysrevans3 Jun 20, 2025
ec9b1dd
Updated CHANGELOG.
rhysrevans3 Jun 20, 2025
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
Prev Previous commit
Next Next commit
remove PatchOperation in tests.
  • Loading branch information
rhysrevans3 committed Mar 31, 2025
commit b41257621f2623787599738bb88ad42b3046ac5d
5 changes: 1 addition & 4 deletions stac_fastapi/core/stac_fastapi/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,9 @@ async def get_search(
"token": token,
"query": orjson.loads(query) if query else query,
"q": q,
"datetime": datetime,
}

if datetime:
base_args["datetime"] = self._format_datetime_range(datetime)

if intersects:
base_args["intersects"] = orjson.loads(unquote_plus(intersects))

Expand All @@ -508,7 +506,6 @@ async def get_search(
]

if filter_expr:
print("GET FE", filter_expr)
base_args["filter-lang"] = "cql2-json"
base_args["filter"] = orjson.loads(
unquote_plus(filter_expr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ async def aggregate(
"geometry_geohash_grid_frequency_precision": geometry_geohash_grid_frequency_precision,
"geometry_geotile_grid_frequency_precision": geometry_geotile_grid_frequency_precision,
"datetime_frequency_interval": datetime_frequency_interval,
"datetime": datetime,
}

if collection_id:
Expand All @@ -377,9 +378,6 @@ async def aggregate(
if intersects:
base_args["intersects"] = orjson.loads(unquote_plus(intersects))

if datetime:
base_args["datetime"] = self._format_datetime_range(datetime)

if filter_expr:
base_args["filter"] = self.get_filter(filter_expr, filter_lang)
aggregate_request = EsAggregationExtensionPostRequest(**base_args)
Expand Down
44 changes: 25 additions & 19 deletions stac_fastapi/tests/clients/test_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from stac_fastapi.extensions.third_party.bulk_transactions import Items
from stac_fastapi.types.errors import ConflictError, NotFoundError
from stac_fastapi.types.stac import PatchOperation
from stac_fastapi.types.stac import PatchAddReplaceTest, PatchMoveCopy, PatchRemove

from ..conftest import MockRequest, create_item

Expand Down Expand Up @@ -282,7 +282,9 @@ async def test_json_patch_item_add(ctx, core_client, txn_client):
collection_id = item["collection"]
item_id = item["id"]
operations = [
PatchOperation(**{"op": "add", "path": "properties.foo", "value": "bar"}),
PatchAddReplaceTest.model_validate(
{"op": "add", "path": "properties.foo", "value": "bar"}
),
]

await txn_client.json_patch_item(
Expand All @@ -305,7 +307,9 @@ async def test_json_patch_item_replace(ctx, core_client, txn_client):
collection_id = item["collection"]
item_id = item["id"]
operations = [
PatchOperation(**{"op": "replace", "path": "properties.foo", "value": 100}),
PatchAddReplaceTest.model_validate(
{"op": "replace", "path": "properties.foo", "value": 100}
),
]

await txn_client.json_patch_item(
Expand All @@ -328,7 +332,9 @@ async def test_json_patch_item_test(ctx, core_client, txn_client):
collection_id = item["collection"]
item_id = item["id"]
operations = [
PatchOperation(**{"op": "test", "path": "properties.foo", "value": 100}),
PatchAddReplaceTest.model_validate(
{"op": "test", "path": "properties.foo", "value": 100}
),
]

await txn_client.json_patch_item(
Expand All @@ -351,8 +357,8 @@ async def test_json_patch_item_move(ctx, core_client, txn_client):
collection_id = item["collection"]
item_id = item["id"]
operations = [
PatchOperation(
**{"op": "move", "path": "properties.bar", "from": "properties.foo"}
PatchMoveCopy.model_validate(
{"op": "move", "path": "properties.bar", "from": "properties.foo"}
),
]

Expand All @@ -377,8 +383,8 @@ async def test_json_patch_item_copy(ctx, core_client, txn_client):
collection_id = item["collection"]
item_id = item["id"]
operations = [
PatchOperation(
**{"op": "copy", "path": "properties.foo", "from": "properties.bar"}
PatchMoveCopy.model_validate(
{"op": "copy", "path": "properties.foo", "from": "properties.bar"}
),
]

Expand All @@ -402,8 +408,8 @@ async def test_json_patch_item_remove(ctx, core_client, txn_client):
collection_id = item["collection"]
item_id = item["id"]
operations = [
PatchOperation(**{"op": "remove", "path": "properties.foo"}),
PatchOperation(**{"op": "remove", "path": "properties.bar"}),
PatchRemove.model_validate({"op": "remove", "path": "properties.foo"}),
PatchRemove.model_validate({"op": "remove", "path": "properties.bar"}),
]

await txn_client.json_patch_item(
Expand All @@ -427,8 +433,8 @@ async def test_json_patch_item_test_wrong_value(ctx, core_client, txn_client):
collection_id = item["collection"]
item_id = item["id"]
operations = [
PatchOperation(
**{"op": "test", "path": "properties.platform", "value": "landsat-9"}
PatchAddReplaceTest.model_validate(
{"op": "test", "path": "properties.platform", "value": "landsat-9"}
),
]

Expand All @@ -450,8 +456,8 @@ async def test_json_patch_item_replace_property_does_not_exists(
collection_id = item["collection"]
item_id = item["id"]
operations = [
PatchOperation(
**{"op": "replace", "path": "properties.foo", "value": "landsat-9"}
PatchAddReplaceTest.model_validate(
{"op": "replace", "path": "properties.foo", "value": "landsat-9"}
),
]

Expand All @@ -473,7 +479,7 @@ async def test_json_patch_item_remove_property_does_not_exists(
collection_id = item["collection"]
item_id = item["id"]
operations = [
PatchOperation(**{"op": "remove", "path": "properties.foo"}),
PatchRemove.model_validate({"op": "remove", "path": "properties.foo"}),
]

with pytest.raises(ConflictError):
Expand All @@ -494,8 +500,8 @@ async def test_json_patch_item_move_property_does_not_exists(
collection_id = item["collection"]
item_id = item["id"]
operations = [
PatchOperation(
**{"op": "move", "path": "properties.bar", "from": "properties.foo"}
PatchMoveCopy.model_validate(
{"op": "move", "path": "properties.bar", "from": "properties.foo"}
),
]

Expand All @@ -517,8 +523,8 @@ async def test_json_patch_item_copy_property_does_not_exists(
collection_id = item["collection"]
item_id = item["id"]
operations = [
PatchOperation(
**{"op": "copy", "path": "properties.bar", "from": "properties.foo"}
PatchMoveCopy.model_validate(
{"op": "copy", "path": "properties.bar", "from": "properties.foo"}
),
]

Expand Down
Loading