Skip to main content
`Ctrl`+`K`

# pytac.extensions.base

class pystac.extensions.base.ExtensionManagementMixin

  Abstract base class with methods for adding and removing extensions from STAC Objects. This class is generic over the type of object being extended (e.g. `Item`).

  Concrete extension implementations should inherit from this class and either provide a concrete type or a bounded type variable.

  See `EOExtension` for an example implementation.

  classmethod add_to(obj: S) → None

    Add the schema URI for this extension to the `stac_extensions` list for the given object, if it is not already present.

  classmethod ensure_has_extension(obj: S, add_if_missing: bool = False) → None

    Given a `STACObject`, checks if the object has this extension’s schema URI in its `stac_extensions` list. If `add_if_missing` is `True`, the schema URI will be added to the object.

    Parameters:

      - obj – The object to validate.

      - add_if_missing – Whether to add the schema URI to the object if it is not already present. Defaults to False.

  classmethod ensure_owner_has_extension(asset_or_link: Asset | ItemAssetDefinition | Link, add_if_missing: bool = False) → None

    Given an `Asset`, checks if the asset’s owner has this extension’s schema URI in its `stac_extensions` list. If `add_if_missing` is `True`, the schema URI will be added to the owner.

    Parameters:

      - asset – The asset whose owner should be validated.

      - add_if_missing – Whether to add the schema URI to the owner if it is not already present. Defaults to False.

    Raises:

      STACError – If `add_if_missing` is `True` and `asset.owner` is `None`.

  abstractmethod classmethod get_schema_uri() → str

    Gets the schema URI associated with this extension.

  classmethod get_schema_uris() → list[str]

    Gets a list of schema URIs associated with this extension.

  classmethod has_extension(obj: S) → bool

    Check if the given object implements this extension by checking `pystac.STACObject.stac_extensions` for this extension’s schema URI.

  classmethod remove_from(obj: S) → None

    Remove the schema URI for this extension from the `pystac.STACObject.stac_extensions` list for the given object.

  classmethod validate_has_extension(obj: S, add_if_missing: bool = False) → None

    DEPRECATED

    Deprecated since version 1.9: Use `ensure_has_extension()` instead.

    Given a `STACObject`, checks if the object has this extension’s schema URI in its `stac_extensions` list. If `add_if_missing` is `True`, the schema URI will be added to the object.

    Parameters:

      - obj – The object to validate.

      - add_if_missing – Whether to add the schema URI to the object if it is not already present. Defaults to False.

  classmethod validate_owner_has_extension(asset: Asset | ItemAssetDefinition, add_if_missing: bool = False) → None

    DEPRECATED

    Deprecated since version 1.9: Use `ensure_owner_has_extension()` instead.

    Given an `Asset`, checks if the asset’s owner has this extension’s schema URI in its `stac_extensions` list. If `add_if_missing` is `True`, the schema URI will be added to the owner.

    Parameters:

      - asset – The asset whose owner should be validated.

      - add_if_missing – Whether to add the schema URI to the owner if it is not already present. Defaults to False.

    Raises:

      STACError – If `add_if_missing` is `True` and `asset.owner` is `None`.

class pystac.extensions.base.PropertiesExtension

  Abstract base class for extending the properties of an `Item` to include properties defined by a STAC Extension.

  This class should not be instantiated directly. Instead, create an extension-specific class that inherits from this class and instantiate that. See `EOExtension` for an example.

  additional_read_properties: Iterable[dict[str, Any]] | None = None

    Additional read-only properties accessible from the extended object.

    These are used when extending an `Asset` to give access to the properties of the owning `Item`. If a property exists in both `additional_read_properties` and `properties`, the value in `additional_read_properties` will take precedence.

  properties: dict[str, Any]

    The properties that this extension wraps.

    The extension which implements PropertiesExtension can use `_get_property` and `_set_property` to get and set values on this instance. Note that _set_properties mutates the properties directly.

class pystac.extensions.base.SummariesExtension(collection: Collection)

  Base class for extending the properties in `pystac.Collection.summaries` to include properties defined by a STAC Extension.

  This class should generally not be instantiated directly. Instead, create an extension-specific class that inherits from this class and instantiate that. See `SummariesEOExtension` for an example.

  summaries: Summaries

    The summaries for the `Collection` being extended.