transaction
stac_fastapi.extensions.core.transaction ¶
transaction extension module.
AsyncBaseTransactionsClient ¶
Bases: ABC
Defines a pattern for implementing the STAC transaction extension.
Source code in stac_fastapi/extensions/core/transaction/client.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
|
create_collection
abstractmethod
async
¶
create_collection(collection: Collection, **kwargs) -> Optional[Union[Collection, Response]]
Create a new collection.
Called with POST /collections
.
Parameters:
-
collection
(Collection
) –the collection
Returns:
-
Optional[Union[Collection, Response]]
–The collection that was created.
Source code in stac_fastapi/extensions/core/transaction/client.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
create_item
abstractmethod
async
¶
create_item(
collection_id: str, item: Union[Item, ItemCollection], **kwargs
) -> Optional[Union[Item, Response, None]]
Create a new item.
Called with POST /collections/{collection_id}/items
.
Parameters:
-
item
(Union[Item, ItemCollection]
) –the item or item collection
-
collection_id
(str
) –the id of the collection from the resource path
Returns:
Source code in stac_fastapi/extensions/core/transaction/client.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
delete_collection
abstractmethod
async
¶
delete_collection(collection_id: str, **kwargs) -> Optional[Union[Collection, Response]]
Delete a collection.
Called with DELETE /collections/{collection_id}
Parameters:
-
collection_id
(str
) –id of the collection.
Returns:
-
Optional[Union[Collection, Response]]
–The deleted collection.
Source code in stac_fastapi/extensions/core/transaction/client.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
|
delete_item
abstractmethod
async
¶
Delete an item from a collection.
Called with DELETE /collections/{collection_id}/items/{item_id}
Parameters:
Returns:
Source code in stac_fastapi/extensions/core/transaction/client.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
patch_collection
abstractmethod
async
¶
patch_collection(
collection_id: str, patch: Union[PartialCollection, List[PatchOperation]], **kwargs
) -> Optional[Union[Collection, Response]]
Update a collection.
Called with PATCH /collections/{collection_id}
example
convert merge patch item to list of operations¶
if isinstance(patch, PartialCollection): patch = patch.operations()
collection = backend.patch_collection(collection_id, patch)
return collection
Parameters:
-
collection_id
(str
) –id of the collection.
-
patch
(Union[PartialCollection, List[PatchOperation]]
) –either the partial collection or list of patch operations.
Returns:
-
Optional[Union[Collection, Response]]
–The patched collection.
Source code in stac_fastapi/extensions/core/transaction/client.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
patch_item
abstractmethod
async
¶
patch_item(
collection_id: str, item_id: str, patch: Union[PartialItem, List[PatchOperation]], **kwargs
) -> Optional[Union[Item, Response]]
Update an item from a collection.
Called with PATCH /collections/{collection_id}/items/{item_id}
example
convert merge patch item to list of operations¶
if isinstance(patch, PartialItem): patch = patch.operations()
item = backend.patch_item(collection_id, item_id, patch)
return item
Parameters:
-
item_id
(str
) –id of the item.
-
collection_id
(str
) –id of the collection.
-
patch
(Union[PartialItem, List[PatchOperation]]
) –either the partial item or list of patch operations.
Returns:
Source code in stac_fastapi/extensions/core/transaction/client.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
update_collection
abstractmethod
async
¶
update_collection(
collection_id: str, collection: Collection, **kwargs
) -> Optional[Union[Collection, Response]]
Perform a complete update on an existing collection.
Called with PUT /collections/{collection_id}
. It is expected that this item
already exists. The update should do a diff against the saved collection and
perform any necessary updates. Partial updates are not supported by the
transactions extension.
Parameters:
-
collection_id
(str
) –id of the existing collection to be updated
-
collection
(Collection
) –the updated collection (must be complete)
Returns:
-
Optional[Union[Collection, Response]]
–The updated collection.
Source code in stac_fastapi/extensions/core/transaction/client.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
|
update_item
abstractmethod
async
¶
update_item(
collection_id: str, item_id: str, item: Item, **kwargs
) -> Optional[Union[Item, Response]]
Perform a complete update on an existing item.
Called with PUT /collections/{collection_id}/items
. It is expected
that this item already exists. The update should do a diff against the
saved item and perform any necessary updates. Partial updates are not
supported by the transactions extension.
Parameters:
-
item
(Item
) –the item (must be complete)
Returns:
Source code in stac_fastapi/extensions/core/transaction/client.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
BaseTransactionsClient ¶
Bases: ABC
Defines a pattern for implementing the STAC API Transaction Extension.
Source code in stac_fastapi/extensions/core/transaction/client.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
create_collection
abstractmethod
¶
create_collection(collection: Collection, **kwargs) -> Optional[Union[Collection, Response]]
Create a new collection.
Called with POST /collections
.
Parameters:
-
collection
(Collection
) –the collection
Returns:
-
Optional[Union[Collection, Response]]
–The collection that was created.
Source code in stac_fastapi/extensions/core/transaction/client.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
create_item
abstractmethod
¶
create_item(
collection_id: str, item: Union[Item, ItemCollection], **kwargs
) -> Optional[Union[Item, Response, None]]
Create a new item.
Called with POST /collections/{collection_id}/items
.
Parameters:
-
item
(Union[Item, ItemCollection]
) –the item or item collection
-
collection_id
(str
) –the id of the collection from the resource path
Returns:
Source code in stac_fastapi/extensions/core/transaction/client.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
delete_collection
abstractmethod
¶
delete_collection(collection_id: str, **kwargs) -> Optional[Union[Collection, Response]]
Delete a collection.
Called with DELETE /collections/{collection_id}
Parameters:
-
collection_id
(str
) –id of the collection.
Returns:
-
Optional[Union[Collection, Response]]
–The deleted collection.
Source code in stac_fastapi/extensions/core/transaction/client.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
delete_item
abstractmethod
¶
Delete an item from a collection.
Called with DELETE /collections/{collection_id}/items/{item_id}
Parameters:
Returns:
Source code in stac_fastapi/extensions/core/transaction/client.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
patch_collection
abstractmethod
¶
patch_collection(
collection_id: str, patch: Union[PartialCollection, List[PatchOperation]], **kwargs
) -> Optional[Union[Collection, Response]]
Update a collection.
Called with PATCH /collections/{collection_id}
example
convert merge patch item to list of operations¶
if isinstance(patch, PartialCollection): patch = patch.operations()
collection = backend.patch_collection(collection_id, patch)
return collection
Parameters:
-
collection_id
(str
) –id of the collection.
-
patch
(Union[PartialCollection, List[PatchOperation]]
) –either the partial collection or list of patch operations.
Returns:
-
Optional[Union[Collection, Response]]
–The patched collection.
Source code in stac_fastapi/extensions/core/transaction/client.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
patch_item
abstractmethod
¶
patch_item(
collection_id: str, item_id: str, patch: Union[PartialItem, List[PatchOperation]], **kwargs
) -> Optional[Union[Item, Response]]
Update an item from a collection.
Called with PATCH /collections/{collection_id}/items/{item_id}
example
convert merge patch item to list of operations¶
if isinstance(patch, PartialItem): patch = patch.operations()
item = backend.patch_item(collection_id, item_id, patch)
return item
Parameters:
-
item_id
(str
) –id of the item.
-
collection_id
(str
) –id of the collection.
-
patch
(Union[PartialItem, List[PatchOperation]]
) –either the partial item or list of patch operations.
Returns:
Source code in stac_fastapi/extensions/core/transaction/client.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
update_collection
abstractmethod
¶
update_collection(
collection_id: str, collection: Collection, **kwargs
) -> Optional[Union[Collection, Response]]
Perform a complete update on an existing collection.
Called with PUT /collections/{collection_id}
. It is expected that this
collection already exists. The update should do a diff against the saved
collection and perform any necessary updates. Partial updates are not
supported by the transactions extension.
Parameters:
-
collection_id
(str
) –id of the existing collection to be updated
-
collection
(Collection
) –the updated collection (must be complete)
Returns:
-
Optional[Union[Collection, Response]]
–The updated collection.
Source code in stac_fastapi/extensions/core/transaction/client.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
update_item
abstractmethod
¶
update_item(
collection_id: str, item_id: str, item: Item, **kwargs
) -> Optional[Union[Item, Response]]
Perform a complete update on an existing item.
Called with PUT /collections/{collection_id}/items
. It is expected
that this item already exists. The update should do a diff against the
saved item and perform any necessary updates. Partial updates are not
supported by the transactions extension.
Parameters:
-
item
(Item
) –the item (must be complete)
-
collection_id
(str
) –the id of the collection from the resource path
Returns:
Source code in stac_fastapi/extensions/core/transaction/client.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
TransactionConformanceClasses ¶
Conformance classes for the Transaction extension.
See stac-api-extensions/transaction
Source code in stac_fastapi/extensions/core/transaction/transaction.py
23 24 25 26 27 28 29 30 31 |
|
TransactionExtension ¶
Bases: ApiExtension
Transaction Extension.
The transaction extension adds several endpoints which allow the creation, deletion, and updating of items and collections: POST /collections PUT /collections/{collection_id} DELETE /collections/{collection_id} POST /collections/{collection_id}/items PUT /collections/{collection_id}/items DELETE /collections/{collection_id}/items
stac-api-extensions/transaction stac-api-extensions/collection-transaction
Attributes:
-
client
(Union[AsyncBaseTransactionsClient, BaseTransactionsClient]
) –CRUD application logic
Source code in stac_fastapi/extensions/core/transaction/transaction.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
|
register ¶
register(app: FastAPI) -> None
Register the extension with a FastAPI application.
Parameters:
-
app
(FastAPI
) –target FastAPI application.
Returns:
-
None
–None
Source code in stac_fastapi/extensions/core/transaction/transaction.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
|
register_create_collection ¶
register_create_collection()
Register create collection endpoint (POST /collections).
Source code in stac_fastapi/extensions/core/transaction/transaction.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
|
register_create_item ¶
register_create_item()
Register create item endpoint (POST /collections/{collection_id}/items).
Source code in stac_fastapi/extensions/core/transaction/transaction.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
register_delete_collection ¶
register_delete_collection()
Register delete collection endpoint (DELETE /collections/{collection_id}).
Source code in stac_fastapi/extensions/core/transaction/transaction.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
|
register_delete_item ¶
register_delete_item()
Register delete item endpoint (DELETE /collections/{collection_id}/items/{item_id}).
Source code in stac_fastapi/extensions/core/transaction/transaction.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
register_patch_collection ¶
register_patch_collection()
Register patch collection endpoint (PATCH /collections/{collection_id}).
Source code in stac_fastapi/extensions/core/transaction/transaction.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
|
register_patch_item ¶
register_patch_item()
Register patch item endpoint (PATCH /collections/{collection_id}/items/{item_id}).
Source code in stac_fastapi/extensions/core/transaction/transaction.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
register_update_collection ¶
register_update_collection()
Register update collection endpoint (PUT /collections/{collection_id}).
Source code in stac_fastapi/extensions/core/transaction/transaction.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
register_update_item ¶
register_update_item()
Register update item endpoint (PUT /collections/{collection_id}/items/{item_id}).
Source code in stac_fastapi/extensions/core/transaction/transaction.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|