Python API

Import the extension from pystac.extensions.application. Use ApplicationExtension.ext() for Items, Catalogs, Collections, Assets, item asset definitions, and Links. Use ApplicationExtension.summaries() for Collection summaries and AssetTemplate for nested template values.

pystac.extensions.application

Generated PySTAC extension. Edit the source schema and regenerate to update.

SCHEMA_URI = 'https://stac-extensions.github.io/application/v0.1.0/schema.json' module-attribute

FIELD_NAMES = {'container': 'application:container', 'entrypoint': 'application:entrypoint', 'languages': 'application:languages', 'assetTemplates': 'assetTemplates', 'linkTemplates': 'linkTemplates'} module-attribute

FIELD_TARGETS = {'application:container': ['asset', 'catalog', 'collection', 'item', 'item_asset', 'link', 'summary'], 'application:entrypoint': ['asset', 'catalog', 'collection', 'item', 'item_asset', 'link', 'summary'], 'application:languages': ['asset', 'catalog', 'collection', 'item', 'item_asset', 'link', 'summary'], 'assetTemplates': ['catalog', 'collection'], 'linkTemplates': ['catalog', 'collection']} module-attribute

TARGETS = ['asset', 'catalog', 'collection', 'item', 'item_asset', 'link', 'summary'] module-attribute

ApplicationExtension

Bases: PropertiesExtension, ExtensionManagementMixin[Item | Collection | Catalog], Generic[T]

Typed property wrapper; use ext() to check/register the extension.

Setters preserve JSON representations, including date/time strings and nested dictionaries. None removes a property; set_null() explicitly writes JSON null. Validate the owning STAC object to enforce full schema constraints.

Source code in pystac/extensions/application.py
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
class ApplicationExtension(
    PropertiesExtension,
    ExtensionManagementMixin[pystac.Item | pystac.Collection | pystac.Catalog],
    Generic[T],
):
    """Typed property wrapper; use ext() to check/register the extension.

    Setters preserve JSON representations, including date/time strings and nested
    dictionaries. None removes a property; set_null() explicitly writes JSON null.
    Validate the owning STAC object to enforce full schema constraints.
    """

    def __init__(self, obj: T, target: str) -> None:
        """Bind a schema-supported STAC object's metadata for live updates."""
        self.obj: T = obj
        self._target = target
        self.additional_read_properties: list[dict[str, Any]] | None = None
        if isinstance(obj, (pystac.Item, pystac.ItemAssetDefinition)):
            self.properties = obj.properties
        else:
            self.properties = obj.extra_fields
        if isinstance(obj, pystac.Asset) and isinstance(obj.owner, pystac.Item):
            self.additional_read_properties = [obj.owner.properties]

    @classmethod
    def get_schema_uri(cls) -> str:
        """The canonical schema identifier used for extension registration."""
        return SCHEMA_URI

    @classmethod
    def has_extension(cls, obj: pystac.STACObject) -> bool:
        """Check this exact schema version; migrations are not generated."""
        return SCHEMA_URI in (obj.stac_extensions or [])

    @classmethod
    def ext(cls, obj: T, add_if_missing: bool = False) -> ApplicationExtension[T]:
        """Wrap a schema-supported object and optionally register its extension."""
        target = _target_for(obj)
        if isinstance(obj, (pystac.Asset, pystac.ItemAssetDefinition, pystac.Link)):
            cls.ensure_owner_has_extension(obj, add_if_missing)
        else:
            cls.ensure_has_extension(obj, add_if_missing)
        return cls(obj, target)

    def _check_field(self, key: str) -> None:
        if self._target not in FIELD_TARGETS[key]:
            raise pystac.ExtensionTypeError(f"{key} does not apply to {self._target}")

    def clear(self, name: str) -> None:
        """Remove a field using its generated Python attribute name."""
        key = FIELD_NAMES[name]
        self._check_field(key)
        self.properties.pop(key, None)

    def set_null(self, name: str) -> None:
        """Write explicit JSON null; schema validation checks whether it is permitted."""
        key = FIELD_NAMES[name]
        self._check_field(key)
        self._set_property(key, None, pop_if_none=False)

    def apply(self, **values: Any) -> None:
        """Update only supplied fields; omitted fields are preserved.

        Keys are generated Python attribute names. Unknown or inapplicable fields
        are rejected before mutation. Validate the STAC object to check values afterwards.
        """
        for name in values:
            if name not in FIELD_NAMES:
                raise TypeError(f"Unknown extension field: {name}")
            self._check_field(FIELD_NAMES[name])
        for name, value in values.items():
            setattr(self, name, value)

    @property
    def container(self) -> str | None:
        "application:container"
        self._check_field("application:container")
        if "application:container" in self.properties:
            return cast("str | None", self.properties["application:container"])
        return cast("str | None", self._get_property("application:container", object))

    @container.setter
    def container(self, value: str | None) -> None:
        self._check_field("application:container")
        self._set_property("application:container", _encode(value))

    @property
    def entrypoint(self) -> str | None:
        "application:entrypoint"
        self._check_field("application:entrypoint")
        if "application:entrypoint" in self.properties:
            return cast("str | None", self.properties["application:entrypoint"])
        return cast("str | None", self._get_property("application:entrypoint", object))

    @entrypoint.setter
    def entrypoint(self, value: str | None) -> None:
        self._check_field("application:entrypoint")
        self._set_property("application:entrypoint", _encode(value))

    @property
    def languages(self) -> list[str] | None:
        "application:languages"
        self._check_field("application:languages")
        if "application:languages" in self.properties:
            return cast("list[str] | None", self.properties["application:languages"])
        return cast("list[str] | None", self._get_property("application:languages", object))

    @languages.setter
    def languages(self, value: list[str] | None) -> None:
        self._check_field("application:languages")
        self._set_property("application:languages", _encode(value))

    @property
    def assetTemplates(self) -> dict[str, AssetTemplate] | None:
        "assetTemplates"
        self._check_field("assetTemplates")
        if "assetTemplates" in self.properties:
            return cast(
                "dict[str, AssetTemplate] | None",
                _decode(self.properties["assetTemplates"], ["map", ["object", "AssetTemplate"]]),
            )
        return cast(
            "dict[str, AssetTemplate] | None",
            _decode(
                self._get_property("assetTemplates", object), ["map", ["object", "AssetTemplate"]]
            ),
        )

    @assetTemplates.setter
    def assetTemplates(self, value: dict[str, AssetTemplate] | None) -> None:
        self._check_field("assetTemplates")
        self._set_property("assetTemplates", _encode(value))

    @property
    def linkTemplates(self) -> list[AssetTemplate] | None:
        "linkTemplates"
        self._check_field("linkTemplates")
        if "linkTemplates" in self.properties:
            return cast(
                "list[AssetTemplate] | None",
                _decode(self.properties["linkTemplates"], ["list", ["object", "AssetTemplate"]]),
            )
        return cast(
            "list[AssetTemplate] | None",
            _decode(
                self._get_property("linkTemplates", object), ["list", ["object", "AssetTemplate"]]
            ),
        )

    @linkTemplates.setter
    def linkTemplates(self, value: list[AssetTemplate] | None) -> None:
        self._check_field("linkTemplates")
        self._set_property("linkTemplates", _encode(value))

    @classmethod
    def summaries(
        cls, obj: pystac.Collection, add_if_missing: bool = False
    ) -> SummariesApplicationExtension:
        """Wrap schema-declared Collection summaries and optionally register the extension."""
        if not isinstance(obj, pystac.Collection):
            raise pystac.ExtensionTypeError("Summaries require a Collection")
        cls.ensure_has_extension(obj, add_if_missing)
        return SummariesApplicationExtension(obj)

assetTemplates: dict[str, AssetTemplate] | None property writable

assetTemplates

container: str | None property writable

application:container

entrypoint: str | None property writable

application:entrypoint

languages: list[str] | None property writable

application:languages

linkTemplates: list[AssetTemplate] | None property writable

linkTemplates

__init__(obj: T, target: str) -> None

Bind a schema-supported STAC object's metadata for live updates.

Source code in pystac/extensions/application.py
293
294
295
296
297
298
299
300
301
302
303
def __init__(self, obj: T, target: str) -> None:
    """Bind a schema-supported STAC object's metadata for live updates."""
    self.obj: T = obj
    self._target = target
    self.additional_read_properties: list[dict[str, Any]] | None = None
    if isinstance(obj, (pystac.Item, pystac.ItemAssetDefinition)):
        self.properties = obj.properties
    else:
        self.properties = obj.extra_fields
    if isinstance(obj, pystac.Asset) and isinstance(obj.owner, pystac.Item):
        self.additional_read_properties = [obj.owner.properties]

apply(**values: Any) -> None

Update only supplied fields; omitted fields are preserved.

Keys are generated Python attribute names. Unknown or inapplicable fields are rejected before mutation. Validate the STAC object to check values afterwards.

Source code in pystac/extensions/application.py
341
342
343
344
345
346
347
348
349
350
351
352
def apply(self, **values: Any) -> None:
    """Update only supplied fields; omitted fields are preserved.

    Keys are generated Python attribute names. Unknown or inapplicable fields
    are rejected before mutation. Validate the STAC object to check values afterwards.
    """
    for name in values:
        if name not in FIELD_NAMES:
            raise TypeError(f"Unknown extension field: {name}")
        self._check_field(FIELD_NAMES[name])
    for name, value in values.items():
        setattr(self, name, value)

clear(name: str) -> None

Remove a field using its generated Python attribute name.

Source code in pystac/extensions/application.py
329
330
331
332
333
def clear(self, name: str) -> None:
    """Remove a field using its generated Python attribute name."""
    key = FIELD_NAMES[name]
    self._check_field(key)
    self.properties.pop(key, None)

ext(obj: T, add_if_missing: bool = False) -> ApplicationExtension[T] classmethod

Wrap a schema-supported object and optionally register its extension.

Source code in pystac/extensions/application.py
315
316
317
318
319
320
321
322
323
@classmethod
def ext(cls, obj: T, add_if_missing: bool = False) -> ApplicationExtension[T]:
    """Wrap a schema-supported object and optionally register its extension."""
    target = _target_for(obj)
    if isinstance(obj, (pystac.Asset, pystac.ItemAssetDefinition, pystac.Link)):
        cls.ensure_owner_has_extension(obj, add_if_missing)
    else:
        cls.ensure_has_extension(obj, add_if_missing)
    return cls(obj, target)

get_schema_uri() -> str classmethod

The canonical schema identifier used for extension registration.

Source code in pystac/extensions/application.py
305
306
307
308
@classmethod
def get_schema_uri(cls) -> str:
    """The canonical schema identifier used for extension registration."""
    return SCHEMA_URI

has_extension(obj: pystac.STACObject) -> bool classmethod

Check this exact schema version; migrations are not generated.

Source code in pystac/extensions/application.py
310
311
312
313
@classmethod
def has_extension(cls, obj: pystac.STACObject) -> bool:
    """Check this exact schema version; migrations are not generated."""
    return SCHEMA_URI in (obj.stac_extensions or [])

set_null(name: str) -> None

Write explicit JSON null; schema validation checks whether it is permitted.

Source code in pystac/extensions/application.py
335
336
337
338
339
def set_null(self, name: str) -> None:
    """Write explicit JSON null; schema validation checks whether it is permitted."""
    key = FIELD_NAMES[name]
    self._check_field(key)
    self._set_property(key, None, pop_if_none=False)

summaries(obj: pystac.Collection, add_if_missing: bool = False) -> SummariesApplicationExtension classmethod

Wrap schema-declared Collection summaries and optionally register the extension.

Source code in pystac/extensions/application.py
435
436
437
438
439
440
441
442
443
@classmethod
def summaries(
    cls, obj: pystac.Collection, add_if_missing: bool = False
) -> SummariesApplicationExtension:
    """Wrap schema-declared Collection summaries and optionally register the extension."""
    if not isinstance(obj, pystac.Collection):
        raise pystac.ExtensionTypeError("Summaries require a Collection")
    cls.ensure_has_extension(obj, add_if_missing)
    return SummariesApplicationExtension(obj)

SummariesApplicationExtension

Bases: SummariesExtension

Collection summaries; ranges, lists and JSON Schema objects are preserved.

Source code in pystac/extensions/application.py
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
class SummariesApplicationExtension(SummariesExtension):
    """Collection summaries; ranges, lists and JSON Schema objects are preserved."""

    @property
    def container(self) -> list[Any] | pystac.RangeSummary[Any] | dict[str, Any] | None:
        value = self.summaries.to_dict().get("application:container")
        if isinstance(value, dict) and "minimum" in value and "maximum" in value:
            return self.summaries.get_range("application:container")
        return value

    @container.setter
    def container(
        self, value: list[Any] | pystac.RangeSummary[Any] | dict[str, Any] | None
    ) -> None:
        self.summaries.remove("application:container")
        self._set_summary("application:container", value)

    @property
    def entrypoint(self) -> list[Any] | pystac.RangeSummary[Any] | dict[str, Any] | None:
        value = self.summaries.to_dict().get("application:entrypoint")
        if isinstance(value, dict) and "minimum" in value and "maximum" in value:
            return self.summaries.get_range("application:entrypoint")
        return value

    @entrypoint.setter
    def entrypoint(
        self, value: list[Any] | pystac.RangeSummary[Any] | dict[str, Any] | None
    ) -> None:
        self.summaries.remove("application:entrypoint")
        self._set_summary("application:entrypoint", value)

    @property
    def languages(self) -> list[Any] | pystac.RangeSummary[Any] | dict[str, Any] | None:
        value = self.summaries.to_dict().get("application:languages")
        if isinstance(value, dict) and "minimum" in value and "maximum" in value:
            return self.summaries.get_range("application:languages")
        return value

    @languages.setter
    def languages(
        self, value: list[Any] | pystac.RangeSummary[Any] | dict[str, Any] | None
    ) -> None:
        self.summaries.remove("application:languages")
        self._set_summary("application:languages", value)

AssetTemplate dataclass

Bases: _Object

Generated nested value object; unknown JSON members are preserved.

Source code in pystac/extensions/application.py
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
class AssetTemplate(_Object):
    """Generated nested value object; unknown JSON members are preserved."""

    _members: ClassVar[dict[str, str]] = {
        "container": "application:container",
        "entrypoint": "application:entrypoint",
        "languages": "application:languages",
    }

    @classmethod
    def create(
        cls,
        *,
        container: str | _Unset = _UNSET,
        entrypoint: str | _Unset = _UNSET,
        languages: list[str] | _Unset = _UNSET,
    ) -> AssetTemplate:
        """Create with typed members; omitted optionals are not written.

        Explicit None writes null. Validate the STAC object to check value constraints.
        """
        _values = {
            "application:container": container,
            "application:entrypoint": entrypoint,
            "application:languages": languages,
        }
        return cls(
            {key: _encode(value) for key, value in _values.items() if not isinstance(value, _Unset)}
        )

    def apply(
        self,
        *,
        container: str | _Unset | None = _UNSET,
        entrypoint: str | _Unset | None = _UNSET,
        languages: list[str] | _Unset | None = _UNSET,
    ) -> None:
        """Update supplied members; omitted values are preserved and None removes."""
        self._apply(
            {
                "container": container,
                "entrypoint": entrypoint,
                "languages": languages,
            }
        )

    @property
    def container(self) -> str | None:
        "application:container"
        # Schema-derived typing at the unvalidated PySTAC JSON boundary.
        return cast("str | None", self.properties.get("application:container"))

    @container.setter
    def container(self, value: str | None) -> None:
        if value is None:
            self.properties.pop("application:container", None)
        else:
            self.properties["application:container"] = _encode(value)

    @property
    def entrypoint(self) -> str | None:
        "application:entrypoint"
        # Schema-derived typing at the unvalidated PySTAC JSON boundary.
        return cast("str | None", self.properties.get("application:entrypoint"))

    @entrypoint.setter
    def entrypoint(self, value: str | None) -> None:
        if value is None:
            self.properties.pop("application:entrypoint", None)
        else:
            self.properties["application:entrypoint"] = _encode(value)

    @property
    def languages(self) -> list[str] | None:
        "application:languages"
        # Schema-derived typing at the unvalidated PySTAC JSON boundary.
        return cast("list[str] | None", self.properties.get("application:languages"))

    @languages.setter
    def languages(self, value: list[str] | None) -> None:
        if value is None:
            self.properties.pop("application:languages", None)
        else:
            self.properties["application:languages"] = _encode(value)

container: str | None property writable

application:container

entrypoint: str | None property writable

application:entrypoint

languages: list[str] | None property writable

application:languages

apply(*, container: str | _Unset | None = _UNSET, entrypoint: str | _Unset | None = _UNSET, languages: list[str] | _Unset | None = _UNSET) -> None

Update supplied members; omitted values are preserved and None removes.

Source code in pystac/extensions/application.py
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
def apply(
    self,
    *,
    container: str | _Unset | None = _UNSET,
    entrypoint: str | _Unset | None = _UNSET,
    languages: list[str] | _Unset | None = _UNSET,
) -> None:
    """Update supplied members; omitted values are preserved and None removes."""
    self._apply(
        {
            "container": container,
            "entrypoint": entrypoint,
            "languages": languages,
        }
    )

create(*, container: str | _Unset = _UNSET, entrypoint: str | _Unset = _UNSET, languages: list[str] | _Unset = _UNSET) -> AssetTemplate classmethod

Create with typed members; omitted optionals are not written.

Explicit None writes null. Validate the STAC object to check value constraints.

Source code in pystac/extensions/application.py
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
@classmethod
def create(
    cls,
    *,
    container: str | _Unset = _UNSET,
    entrypoint: str | _Unset = _UNSET,
    languages: list[str] | _Unset = _UNSET,
) -> AssetTemplate:
    """Create with typed members; omitted optionals are not written.

    Explicit None writes null. Validate the STAC object to check value constraints.
    """
    _values = {
        "application:container": container,
        "application:entrypoint": entrypoint,
        "application:languages": languages,
    }
    return cls(
        {key: _encode(value) for key, value in _values.items() if not isinstance(value, _Unset)}
    )