-
Notifications
You must be signed in to change notification settings - Fork 0
/
pgstacrs.pyi
220 lines (168 loc) · 6.59 KB
/
pgstacrs.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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
from typing import Any
class Client:
"""A pgstac client."""
@classmethod
async def open(cls: type[Client], params: str) -> Client:
"""Opens a new client, backed by a connection pool.
Args:
params: The connection parameters, either in `postgresql://` or
`host=localhost user=username` format.
Returns:
A pgstac client
Examples:
>>> from pgstacrs import Client
>>> client = await Client.open("postgresql://username:password@localhost:5432/pgstac")
>>> client = await Client.open("user=username password=password dbname=pgstac")
"""
async def search(
self,
*,
intersects: str | dict[str, Any] | None = None,
ids: str | list[str] | None = None,
collections: str | list[str] | None = None,
limit: int | None = None,
bbox: list[float] | None = None,
datetime: str | None = None,
include: str | list[str] | None = None,
exclude: str | list[str] | None = None,
sortby: str | list[str] | None = None,
filter: str | dict[str, Any] | None = None,
query: dict[str, Any] | None = None,
**kwargs: str,
) -> dict[str, Any]:
"""
Searches the database with STAC API item search.
Args:
collections: Array of one or more Collection IDs that
each matching Item must be in.
ids: Array of Item ids to return.
intersects: Searches items by performing intersection between their
geometry and provided GeoJSON geometry.
bbox: Requested bounding box.
datetime: Single date+time, or a range (`/` separator), formatted to
RFC 3339, section 5.6. Use double dots .. for open date ranges.
include: Fields to include in the response (see [the extension
docs](https://github.com/stac-api-extensions/fields?tab=readme-ov-file#includeexclude-semantics))
for more on the semantics).
exclude: Fields to exclude from the response (see [the extension
docs](https://github.com/stac-api-extensions/fields?tab=readme-ov-file#includeexclude-semantics))
for more on the semantics).
sortby: Fields by which to sort results (use `-field` to sort descending).
filter: CQL2 filter expression. Strings will be interpreted as
cql2-text, dictionaries as cql2-json.
query: Additional filtering based on properties.
It is recommended to use filter instead, if possible.
limit: The page size returned from the server.
kwargs: Any additional arguments to pass down into the search, e.g a pagination token
"""
async def print_config(self) -> None:
"""Prints the postgresql configuration.
Redacts the password
"""
async def set_setting(self, key: str, value: str) -> None:
"""Sets a pgstac setting.
Args:
key: The setting name, e.g. `base_url`
value: The setting value, e.g. `http://pgstacrs.test`
"""
async def get_version(self) -> str:
"""Returns the pgstac version.
Returns:
The pgstac version as a string
"""
async def get_collection(self, id: str) -> dict[str, Any] | None:
"""Returns a collection by id, or none if one does not exist.
Args:
id: The collection id
Returns:
A STAC collection, or None
"""
async def create_collection(self, collection: dict[str, Any]) -> None:
"""Creates a new collection.
Args:
collection: The collection
Raises:
PgstacError: If the collection already exists.
"""
async def update_collection(self, collection: dict[str, Any]) -> None:
"""Updates a collection.
Args:
collection: The collection
Raises:
PgstacError: If the collection does not exist.
"""
async def update_collection_extents(self) -> None:
"""Updates all collection extents."""
async def upsert_collection(self, collection: dict[str, Any]) -> None:
"""Upserts a collection.
Args:
collection: The collection
"""
async def delete_collection(self, id: str) -> None:
"""Deletes a collection by id.
Args:
id: The collection id
"""
async def all_collections(self) -> list[dict[str, Any]]:
"""Returns all collections.
Returns:
All collections in the database
"""
async def get_item(
self, id: str, collection_id: str | None = None
) -> dict[str, Any] | None:
"""Returns an item by id.
Args:
id: The item id
collection_id: The optional collection id
Returns:
The item, or None if the item does not exist
"""
async def create_item(self, item: dict[str, Any]) -> None:
"""Creates an item.
Args:
item: The item
Raises:
PgstacError: If the item's collection does not exist. The collection
is determined by the `collection` attribute of the item.
"""
async def create_items(self, items: list[dict[str, Any]]) -> None:
"""Creates many items.
Args:
items: The items
Raises:
PgstacError: If the items' collection(s) does not exist.
"""
async def update_item(self, item: dict[str, Any]) -> None:
"""Updates an item.
Args:
item: The item
Raises:
PgstacError: If the item does not exist
"""
async def upsert_item(self, item: dict[str, Any]) -> None:
"""Upserts an item.
Args:
item: The item
Raises:
PgstacError: If the item's collection does not exist.
"""
async def upsert_items(self, items: list[dict[str, Any]]) -> None:
"""Upserts many items.
Args:
items: The items
Raises:
PgstacError: If the items' collection(s) does not exist.
"""
async def delete_item(self, id: str, collection_id: str | None = None) -> None:
"""Deletes an item by id.
Args:
id: The item id
collection_id: The optional collection id
Raises:
PgstacError: If the item cannot be found
"""
class PgstacError:
"""An exception returned from pgstac"""
class StacError:
"""Something doesn't match the STAC specification"""