Skip to content

Commit

Permalink
feat: add collections
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Nov 26, 2024
1 parent c5070c8 commit e490ae5
Show file tree
Hide file tree
Showing 39 changed files with 5,295 additions and 40 deletions.
78 changes: 68 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ name = "pgstacrs"
crate-type = ["cdylib"]

[dependencies]
pyo3 = "0.23.0"
tokio-postgres = "0.7.12"
pyo3 = "0.23.2"
tokio-postgres = { version = "0.7.12", features = ["with-serde_json-1"] }
pyo3-async-runtimes = { version = "0.23.0", features = [
"tokio",
"tokio-runtime",
Expand All @@ -18,3 +18,5 @@ tokio = "1.41.1"
thiserror = "2.0.3"
bb8 = "0.8.6"
bb8-postgres = "0.8.1"
serde_json = "1.0.133"
pythonize = "0.23.0"
46 changes: 46 additions & 0 deletions pgstacrs.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Any

class Client:
"""A pgstac client."""

Expand All @@ -20,5 +22,49 @@ class Client:
The pgstac version as a string
"""

async def get_collection(self, id: str) -> str | 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 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
"""

class PgstacError:
"""An exception returned from pgstac"""
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ filterwarnings = [
"ignore:the default for the ConnectionPool:DeprecationWarning",
]

[tool.uv]
# https://github.com/PyO3/maturin/issues/2314#issuecomment-2488542771
cache-keys = [
{ file = "pyproject.toml" },
{ file = "Cargo.toml" },
{ file = "src/*.rs" },
]

[build-system]
requires = ["maturin>=1.7,<2.0"]
build-backend = "maturin"
Expand Down
43 changes: 43 additions & 0 deletions spec-examples/v1.0.0/catalog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"id": "examples",
"type": "Catalog",
"title": "Example Catalog",
"stac_version": "1.0.0",
"description": "This catalog is a simple demonstration of an example catalog that is used to organize a hierarchy of collections and their items.",
"links": [
{
"rel": "root",
"href": "./catalog.json",
"type": "application/json"
},
{
"rel": "child",
"href": "./extensions-collection/collection.json",
"type": "application/json",
"title": "Collection Demonstrating STAC Extensions"
},
{
"rel": "child",
"href": "./collection-only/collection.json",
"type": "application/json",
"title": "Collection with no items (standalone)"
},
{
"rel": "child",
"href": "./collection-only/collection-with-schemas.json",
"type": "application/json",
"title": "Collection with no items (standalone with JSON Schemas)"
},
{
"rel": "item",
"href": "./collectionless-item.json",
"type": "application/json",
"title": "Collection with no items (standalone)"
},
{
"rel": "self",
"href": "https://raw.githubusercontent.com/radiantearth/stac-spec/v1.0.0/examples/catalog.json",
"type": "application/json"
}
]
}
Loading

0 comments on commit e490ae5

Please sign in to comment.