Skip to content

stapi-pydantic

Pydantic models for the Satellite Tasking API (STAPI) specification.

Note

This package has no input/output (IO) functionality. For making requests to a STAPI API, use pystapi-client.

API

Order

Bases: _GeoJsonBase, Generic[T]

Source code in stapi-pydantic/src/stapi_pydantic/order.py
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
class Order(_GeoJsonBase, Generic[T]):
    # We need to enforce that orders have an id defined, as that is required to
    # retrieve them via the API
    id: StrictStr
    type: Literal["Feature"] = "Feature"
    stapi_type: Literal["Order"] = "Order"
    stapi_version: str = STAPI_VERSION

    geometry: Geometry = Field(...)
    properties: OrderProperties[T] = Field(...)

    links: list[Link] = Field(default_factory=list)

    __geojson_exclude_if_none__ = {"bbox", "id"}

    @field_validator("geometry", mode="before")
    def set_geometry(cls, geometry: Any) -> Any:
        """set geometry from geo interface or input"""
        if hasattr(geometry, "__geo_interface__"):
            return geometry.__geo_interface__

        return geometry

set_geometry(geometry)

set geometry from geo interface or input

Source code in stapi-pydantic/src/stapi_pydantic/order.py
103
104
105
106
107
108
109
@field_validator("geometry", mode="before")
def set_geometry(cls, geometry: Any) -> Any:
    """set geometry from geo interface or input"""
    if hasattr(geometry, "__geo_interface__"):
        return geometry.__geo_interface__

    return geometry

OrderCollection

Bases: _GeoJsonBase, Generic[T]

Source code in stapi-pydantic/src/stapi_pydantic/order.py
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
class OrderCollection(_GeoJsonBase, Generic[T]):
    type: Literal["FeatureCollection"] = "FeatureCollection"
    features: list[Order[T]]
    links: list[Link] = Field(default_factory=list)

    def __iter__(self) -> Iterator[Order[T]]:  # type: ignore [override]
        """iterate over features"""
        return iter(self.features)

    def __len__(self) -> int:
        """return features length"""
        return len(self.features)

    def __getitem__(self, index: int) -> Order[T]:
        """get feature at a given index"""
        return self.features[index]

__getitem__(index)

get feature at a given index

Source code in stapi-pydantic/src/stapi_pydantic/order.py
126
127
128
def __getitem__(self, index: int) -> Order[T]:
    """get feature at a given index"""
    return self.features[index]

__iter__()

iterate over features

Source code in stapi-pydantic/src/stapi_pydantic/order.py
118
119
120
def __iter__(self) -> Iterator[Order[T]]:  # type: ignore [override]
    """iterate over features"""
    return iter(self.features)

__len__()

return features length

Source code in stapi-pydantic/src/stapi_pydantic/order.py
122
123
124
def __len__(self) -> int:
    """return features length"""
    return len(self.features)