Skip to content

Commit 53bfe47

Browse files
committed
Adding example code for patch.
1 parent c1003d4 commit 53bfe47

File tree

1 file changed

+36
-0
lines changed
  • stac_fastapi/types/stac_fastapi/types

1 file changed

+36
-0
lines changed

stac_fastapi/types/stac_fastapi/types/core.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ def patch_item(
9292
9393
Called with `PATCH /collections/{collection_id}/items/{item_id}`
9494
95+
example:
96+
# convert merge patch item to list of operations
97+
if isinstance(patch, PartialItem):
98+
patch = patch.operations()
99+
100+
item = backend.update_item(collection_id, item_id, patch)
101+
102+
return item
103+
95104
Args:
96105
item_id: id of the item.
97106
collection_id: id of the collection.
@@ -166,6 +175,15 @@ def patch_collection(
166175
167176
Called with `PATCH /collections/{collection_id}`
168177
178+
example:
179+
# convert merge patch item to list of operations
180+
if isinstance(patch, PartialCollection):
181+
patch = patch.operations()
182+
183+
collection = backend.update_item(collection_id, patch)
184+
185+
return collection
186+
169187
Args:
170188
collection_id: id of the collection.
171189
patch: either the partial collection or list of patch operations.
@@ -247,6 +265,15 @@ async def patch_item(
247265
248266
Called with `PATCH /collections/{collection_id}/items/{item_id}`
249267
268+
example:
269+
# convert merge patch item to list of operations
270+
if isinstance(patch, PartialItem):
271+
patch = patch.operations()
272+
273+
item = backend.update_item(collection_id, item_id, patch)
274+
275+
return item
276+
250277
Args:
251278
item_id: id of the item.
252279
collection_id: id of the collection.
@@ -321,6 +348,15 @@ async def patch_collection(
321348
322349
Called with `PATCH /collections/{collection_id}`
323350
351+
example:
352+
# convert merge patch item to list of operations
353+
if isinstance(patch, PartialCollection):
354+
patch = patch.operations()
355+
356+
collection = backend.update_item(collection_id, patch)
357+
358+
return collection
359+
324360
Args:
325361
collection_id: id of the collection.
326362
patch: either the partial collection or list of patch operations.

0 commit comments

Comments
 (0)