Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 3cfea09

Browse files
committed
feat: initial work
1 parent fb9d96a commit 3cfea09

File tree

5 files changed

+460
-0
lines changed

5 files changed

+460
-0
lines changed

.python-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

pyproject.toml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[project]
2+
name = "stapi-pydantic"
3+
version = "0.0.1"
4+
description = "Pydantic models for the Satellite Tasking API (STAPI) Specification"
5+
readme = "README.md"
6+
authors = [{ name = "Pete Gadomski", email = "[email protected]" }]
7+
requires-python = ">=3.10"
8+
dependencies = [
9+
"geojson-pydantic>=1.2.0",
10+
"pydantic>=2.10.6",
11+
]
12+
13+
[build-system]
14+
requires = ["hatchling"]
15+
build-backend = "hatchling.build"
16+
17+
[dependency-groups]
18+
dev = [
19+
"mypy>=1.15.0",
20+
"pytest>=8.3.5",
21+
"ruff>=0.11.2",
22+
]

src/stapi_pydantic/__init__.py

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
from __future__ import annotations
2+
3+
import datetime
4+
from typing import Any
5+
6+
from geojson_pydantic.geometries import Geometry
7+
from pydantic import BaseModel
8+
9+
10+
class CreateOrder(BaseModel):
11+
"""A request for the provider to collect or otherwise gather data."""
12+
13+
datetime: str
14+
"""Time interval with a solidus (forward slash, /) separator, using RFC 3339 datetime, empty string, or .. values."""
15+
16+
productId: str
17+
"""Product identifier.
18+
19+
The ID should be unique and is a reference to the parameters which can be used in the parameters field."""
20+
21+
geometry: Geometry
22+
"""Provide a Geometry that the tasked data must be within."""
23+
24+
filter: dict[str, Any] | None = None
25+
"""A set of additional parameters in CQL2 JSON based on the parameters exposed in the product."""
26+
27+
28+
class Order(BaseModel):
29+
"""An order"""
30+
31+
id: str
32+
"""Unique provider generated order ID"""
33+
34+
user: str
35+
"""User or organization ID ?"""
36+
37+
created: datetime.datetime
38+
"""When the order was created"""
39+
40+
status: Status
41+
"""Current Order Status object"""
42+
43+
links: list[Link] = []
44+
"""Links will be very provider specific."""
45+
46+
47+
class Status(BaseModel):
48+
"""Order status"""
49+
50+
timestamp: datetime.datetime
51+
"""ISO 8601 timestamp for the order status"""
52+
53+
status_code: str
54+
"""Enumerated status code"""
55+
56+
reason_code: str | None = None
57+
"""Enumerated reason code for why the status was set"""
58+
59+
reason_text: str | None = None
60+
"""Textual description for why the status was set"""
61+
62+
links: list[Link] = []
63+
"""List of references to documents, such as delivered asset, processing log, delivery manifest, etc."""
64+
65+
66+
class Link(BaseModel):
67+
"""Links will be very provider specific."""
68+
69+
href: str
70+
"""The actual link in the format of an URL.
71+
72+
Relative and absolute links are both allowed. Trailing slashes are significant."""
73+
74+
rel: str
75+
"""Relationship between the current document and the linked document.
76+
77+
See chapter "Relation types" for more information."""
78+
79+
type: str | None = None
80+
"""Media type of the referenced entity."""
81+
82+
title: str | None = None
83+
"""A human readable title to be used in rendered displays of the link."""
84+
85+
method: str | None = None
86+
"""The HTTP method that shall be used for the request to the target resource, in uppercase.
87+
88+
GET by default"""
89+
90+
headers: dict[str, str | list[str]] | None = None
91+
"""The HTTP headers to be sent for the request to the target resource."""

tests/test_order.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from stapi_pydantic import CreateOrder
2+
3+
4+
def test_create_order() -> None:
5+
CreateOrder.model_validate(
6+
{
7+
"datetime": "2025-03-24T00:00:00Z/..",
8+
"productId": "42",
9+
"geometry": {"type": "Point", "coordinates": [-105.1019, 40.1672]},
10+
}
11+
)
12+
13+
14+
def test_create_order_with_filter() -> None:
15+
CreateOrder.model_validate(
16+
{
17+
"datetime": "2025-03-24T00:00:00Z/..",
18+
"productId": "42",
19+
"geometry": {"type": "Point", "coordinates": [-105.1019, 40.1672]},
20+
"filter": {"op": "like", "args": [{"property": "eo:instrument"}, "OLI%"]},
21+
}
22+
)

0 commit comments

Comments
 (0)