6
6
7
7
import attr
8
8
from fastapi import Request
9
- from stac_pydantic .api import Search
10
9
from stac_pydantic .links import Relations
11
10
from stac_pydantic .shared import MimeTypes
12
11
from stac_pydantic .version import STAC_VERSION
12
+ from starlette .responses import Response
13
13
14
14
from stac_fastapi .types import stac as stac_types
15
15
from stac_fastapi .types .conformance import BASE_CONFORMANCE_CLASSES
23
23
24
24
@attr .s # type:ignore
25
25
class BaseTransactionsClient (abc .ABC ):
26
- """Defines a pattern for implementing the STAC transaction extension ."""
26
+ """Defines a pattern for implementing the STAC API Transaction Extension ."""
27
27
28
28
@abc .abstractmethod
29
- def create_item (self , item : stac_types .Item , ** kwargs ) -> stac_types .Item :
29
+ def create_item (
30
+ self , item : stac_types .Item , ** kwargs
31
+ ) -> Optional [Union [stac_types .Item , Response ]]:
30
32
"""Create a new item.
31
33
32
34
Called with `POST /collections/{collection_id}/items`.
33
35
34
36
Args:
35
37
item: the item
38
+ collection_id: the id of the collection from the resource path
36
39
37
40
Returns:
38
41
The item that was created.
@@ -41,7 +44,9 @@ def create_item(self, item: stac_types.Item, **kwargs) -> stac_types.Item:
41
44
...
42
45
43
46
@abc .abstractmethod
44
- def update_item (self , item : stac_types .Item , ** kwargs ) -> stac_types .Item :
47
+ def update_item (
48
+ self , item : stac_types .Item , ** kwargs
49
+ ) -> Optional [Union [stac_types .Item , Response ]]:
45
50
"""Perform a complete update on an existing item.
46
51
47
52
Called with `PUT /collections/{collection_id}/items`. It is expected that this item already exists. The update
@@ -50,6 +55,7 @@ def update_item(self, item: stac_types.Item, **kwargs) -> stac_types.Item:
50
55
51
56
Args:
52
57
item: the item (must be complete)
58
+ collection_id: the id of the collection from the resource path
53
59
54
60
Returns:
55
61
The updated item.
@@ -59,7 +65,7 @@ def update_item(self, item: stac_types.Item, **kwargs) -> stac_types.Item:
59
65
@abc .abstractmethod
60
66
def delete_item (
61
67
self , item_id : str , collection_id : str , ** kwargs
62
- ) -> stac_types .Item :
68
+ ) -> Optional [ Union [ stac_types .Item , Response ]] :
63
69
"""Delete an item from a collection.
64
70
65
71
Called with `DELETE /collections/{collection_id}/items/{item_id}`
@@ -76,7 +82,7 @@ def delete_item(
76
82
@abc .abstractmethod
77
83
def create_collection (
78
84
self , collection : stac_types .Collection , ** kwargs
79
- ) -> stac_types .Collection :
85
+ ) -> Optional [ Union [ stac_types .Collection , Response ]] :
80
86
"""Create a new collection.
81
87
82
88
Called with `POST /collections`.
@@ -92,7 +98,7 @@ def create_collection(
92
98
@abc .abstractmethod
93
99
def update_collection (
94
100
self , collection : stac_types .Collection , ** kwargs
95
- ) -> stac_types .Collection :
101
+ ) -> Optional [ Union [ stac_types .Collection , Response ]] :
96
102
"""Perform a complete update on an existing collection.
97
103
98
104
Called with `PUT /collections`. It is expected that this item already exists. The update should do a diff
@@ -101,14 +107,17 @@ def update_collection(
101
107
102
108
Args:
103
109
collection: the collection (must be complete)
110
+ collection_id: the id of the collection from the resource path
104
111
105
112
Returns:
106
113
The updated collection.
107
114
"""
108
115
...
109
116
110
117
@abc .abstractmethod
111
- def delete_collection (self , collection_id : str , ** kwargs ) -> stac_types .Collection :
118
+ def delete_collection (
119
+ self , collection_id : str , ** kwargs
120
+ ) -> Optional [Union [stac_types .Collection , Response ]]:
112
121
"""Delete a collection.
113
122
114
123
Called with `DELETE /collections/{collection_id}`
@@ -127,7 +136,9 @@ class AsyncBaseTransactionsClient(abc.ABC):
127
136
"""Defines a pattern for implementing the STAC transaction extension."""
128
137
129
138
@abc .abstractmethod
130
- async def create_item (self , item : stac_types .Item , ** kwargs ) -> stac_types .Item :
139
+ async def create_item (
140
+ self , item : stac_types .Item , ** kwargs
141
+ ) -> Optional [Union [stac_types .Item , Response ]]:
131
142
"""Create a new item.
132
143
133
144
Called with `POST /collections/{collection_id}/items`.
@@ -142,7 +153,9 @@ async def create_item(self, item: stac_types.Item, **kwargs) -> stac_types.Item:
142
153
...
143
154
144
155
@abc .abstractmethod
145
- async def update_item (self , item : stac_types .Item , ** kwargs ) -> stac_types .Item :
156
+ async def update_item (
157
+ self , item : stac_types .Item , ** kwargs
158
+ ) -> Optional [Union [stac_types .Item , Response ]]:
146
159
"""Perform a complete update on an existing item.
147
160
148
161
Called with `PUT /collections/{collection_id}/items`. It is expected that this item already exists. The update
@@ -160,7 +173,7 @@ async def update_item(self, item: stac_types.Item, **kwargs) -> stac_types.Item:
160
173
@abc .abstractmethod
161
174
async def delete_item (
162
175
self , item_id : str , collection_id : str , ** kwargs
163
- ) -> stac_types .Item :
176
+ ) -> Optional [ Union [ stac_types .Item , Response ]] :
164
177
"""Delete an item from a collection.
165
178
166
179
Called with `DELETE /collections/{collection_id}/items/{item_id}`
@@ -177,7 +190,7 @@ async def delete_item(
177
190
@abc .abstractmethod
178
191
async def create_collection (
179
192
self , collection : stac_types .Collection , ** kwargs
180
- ) -> stac_types .Collection :
193
+ ) -> Optional [ Union [ stac_types .Collection , Response ]] :
181
194
"""Create a new collection.
182
195
183
196
Called with `POST /collections`.
@@ -193,7 +206,7 @@ async def create_collection(
193
206
@abc .abstractmethod
194
207
async def update_collection (
195
208
self , collection : stac_types .Collection , ** kwargs
196
- ) -> stac_types .Collection :
209
+ ) -> Optional [ Union [ stac_types .Collection , Response ]] :
197
210
"""Perform a complete update on an existing collection.
198
211
199
212
Called with `PUT /collections`. It is expected that this item already exists. The update should do a diff
@@ -211,7 +224,7 @@ async def update_collection(
211
224
@abc .abstractmethod
212
225
async def delete_collection (
213
226
self , collection_id : str , ** kwargs
214
- ) -> stac_types .Collection :
227
+ ) -> Optional [ Union [ stac_types .Collection , Response ]] :
215
228
"""Delete a collection.
216
229
217
230
Called with `DELETE /collections/{collection_id}`
@@ -394,7 +407,7 @@ def conformance(self, **kwargs) -> stac_types.Conformance:
394
407
395
408
@abc .abstractmethod
396
409
def post_search (
397
- self , search_request : Search , ** kwargs
410
+ self , search_request : BaseSearchPostRequest , ** kwargs
398
411
) -> stac_types .ItemCollection :
399
412
"""Cross catalog search (POST).
400
413
@@ -581,7 +594,7 @@ async def conformance(self, **kwargs) -> stac_types.Conformance:
581
594
582
595
@abc .abstractmethod
583
596
async def post_search (
584
- self , search_request : Search , ** kwargs
597
+ self , search_request : BaseSearchPostRequest , ** kwargs
585
598
) -> stac_types .ItemCollection :
586
599
"""Cross catalog search (POST).
587
600
0 commit comments