Module stac_fastapi.core.serializers¶
Serializers.
Variables¶
logger
Classes¶
CatalogSerializer¶
class CatalogSerializer(
)
Serialization methods for STAC catalogs.
Ancestors (in MRO)¶
- stac_fastapi.core.serializers.Serializer
- abc.ABC
Static methods¶
db_to_stac¶
def db_to_stac(
catalog: dict,
request: starlette.requests.Request,
extensions: Optional[List[str]] = []
) -> stac_fastapi.core.models.Catalog
Transform database model to STAC catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| catalog | dict | The catalog data in dictionary form, extracted from the database. | None |
| request | Request | the API request | None |
| extensions | None | A list of the extension class names (ext.__name__) or all enabled STAC API extensions. |
None |
Returns:
| Type | Description |
|---|---|
| Catalog | The STAC catalog object. |
stac_to_db¶
def stac_to_db(
catalog: stac_fastapi.core.models.Catalog,
request: starlette.requests.Request
) -> stac_fastapi.core.models.Catalog
Transform STAC Catalog to database-ready STAC catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| catalog | None | the STAC Catalog object to be transformed | None |
| request | None | the API request | None |
Returns:
| Type | Description |
|---|---|
| Catalog | The database-ready STAC Catalog object. |
CollectionSerializer¶
class CollectionSerializer(
)
Serialization methods for STAC collections.
Ancestors (in MRO)¶
- stac_fastapi.core.serializers.Serializer
- abc.ABC
Static methods¶
db_to_stac¶
def db_to_stac(
collection: dict,
request: starlette.requests.Request,
extensions: Optional[List[str]] = []
) -> stac_fastapi.types.stac.Collection
Transform database model to STAC collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| collection | dict | The collection data in dictionary form, extracted from the database. | None |
| starlette.requests.Request | None | the API request | None |
| extensions | None | A list of the extension class names (ext.__name__) or all enabled STAC API extensions. |
None |
Returns:
| Type | Description |
|---|---|
| stac_types.Collection | The STAC collection object. |
db_to_stac_in_catalog¶
def db_to_stac_in_catalog(
collection: dict,
request: starlette.requests.Request,
catalog_id: str,
extensions: Optional[List[str]] = []
) -> stac_fastapi.types.stac.Collection
Transform database model to STAC collection within a catalog context.
This method is used when a collection is accessed via /catalogs/{id}/collections/{id}. It sets the structural parent to the catalog and injects a catalog link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| collection | dict | The collection data in dictionary form, extracted from the database. | None |
| request | None | the API request | None |
| catalog_id | None | The ID of the parent catalog (sets structural parent) | None |
| extensions | None | A list of the extension class names (ext.__name__) or all enabled STAC API extensions. |
None |
Returns:
| Type | Description |
|---|---|
| stac_types.Collection | The STAC collection object with catalog context. |
stac_to_db¶
def stac_to_db(
collection: stac_fastapi.types.stac.Collection,
request: starlette.requests.Request
) -> stac_fastapi.types.stac.Collection
Transform STAC Collection to database-ready STAC collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| stac_data | None | the STAC Collection object to be transformed | None |
| starlette.requests.Request | None | the API request | None |
Returns:
| Type | Description |
|---|---|
| stac_types.Collection | The database-ready STAC Collection object. |
ItemSerializer¶
class ItemSerializer(
)
Serialization methods for STAC items.
Ancestors (in MRO)¶
- stac_fastapi.core.serializers.Serializer
- abc.ABC
Static methods¶
db_to_stac¶
def db_to_stac(
item: dict,
base_url: str
) -> stac_fastapi.types.stac.Item
Transform database-ready STAC item to STAC item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| item | dict | The database-ready STAC item to be transformed. | None |
| base_url | str | The base URL for the STAC API. | None |
Returns:
| Type | Description |
|---|---|
| stac_types.Item | The STAC item object. |
stac_to_db¶
def stac_to_db(
stac_data: stac_fastapi.types.stac.Item,
base_url: str
) -> stac_fastapi.types.stac.Item
Transform STAC item to database-ready STAC item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| stac_data | stac_types.Item | The STAC item object to be transformed. | None |
| base_url | str | The base URL for the STAC API. | None |
Returns:
| Type | Description |
|---|---|
| stac_types.Item | The database-ready STAC item object. |
Serializer¶
class Serializer(
)
Defines serialization methods between the API and the data model.
This class is meant to be subclassed and implemented by specific serializers for different STAC objects (e.g. Item, Collection).
Ancestors (in MRO)¶
- abc.ABC
Descendants¶
- stac_fastapi.core.serializers.ItemSerializer
- stac_fastapi.core.serializers.CollectionSerializer
- stac_fastapi.core.serializers.CatalogSerializer
Static methods¶
db_to_stac¶
def db_to_stac(
item: dict,
base_url: str
) -> Any
Transform database model to STAC object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| item | dict | A dictionary representing the database model. | None |
| base_url | str | The base URL of the STAC API. | None |
Returns:
| Type | Description |
|---|---|
| Any | A STAC object, e.g. an Item or Collection, representing the input item. |
stac_to_db¶
def stac_to_db(
stac_object: Any,
base_url: str
) -> dict
Transform STAC object to database model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| stac_object | Any | A STAC object, e.g. an Item or Collection. |
None |
| base_url | str | The base URL of the STAC API. | None |
Returns:
| Type | Description |
|---|---|
| dict | A dictionary representing the database model. |