diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5b1ac483c..1e4babb6a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
- Enum MediaType entry for PDF documents ([#758](https://github.com/stac-utils/pystac/pull/758))
- Updated Link to obtain stac_io from owner root ([#762](https://github.com/stac-utils/pystac/pull/762))
+- Updated AssetDefinition to have create, apply methods ([#768](https://github.com/stac-utils/pystac/pull/768))
### Removed
diff --git a/pystac/catalog.py b/pystac/catalog.py
index ce13e5e67..95f268df7 100644
--- a/pystac/catalog.py
+++ b/pystac/catalog.py
@@ -115,7 +115,7 @@ class Catalog(STACObject):
Args:
id : Identifier for the catalog. Must be unique within the STAC.
description : Detailed multi-line description to fully explain the catalog.
- `CommonMark 0.28 syntax `_ MAY be used for rich
+ `CommonMark 0.29 syntax `_ MAY be used for rich
text representation.
title : Optional short descriptive one-line title for the catalog.
stac_extensions : Optional list of extensions the Catalog implements.
diff --git a/pystac/collection.py b/pystac/collection.py
index 86d4ccd54..af99a4320 100644
--- a/pystac/collection.py
+++ b/pystac/collection.py
@@ -421,7 +421,7 @@ class Collection(Catalog):
Args:
id : Identifier for the collection. Must be unique within the STAC.
description : Detailed multi-line description to fully explain the
- collection. `CommonMark 0.28 syntax `_ MAY
+ collection. `CommonMark 0.29 syntax `_ MAY
be used for rich text representation.
extent : Spatial and temporal extents that describe the bounds of
all items contained within this Collection.
diff --git a/pystac/extensions/item_assets.py b/pystac/extensions/item_assets.py
index c92b1282f..38caae9a0 100644
--- a/pystac/extensions/item_assets.py
+++ b/pystac/extensions/item_assets.py
@@ -36,6 +36,64 @@ def __eq__(self, o: object) -> bool:
return NotImplemented
return self.to_dict() == o.to_dict()
+ @classmethod
+ def create(
+ cls,
+ title: Optional[str],
+ description: Optional[str],
+ media_type: Optional[str],
+ roles: Optional[List[str]],
+ ) -> "AssetDefinition":
+ """
+ Creates a new asset definition.
+
+ Args:
+ title : Displayed title for clients and users.
+ description : Description of the Asset providing additional details,
+ such as how it was processed or created.
+ `CommonMark 0.29 `__ syntax MAY be used
+ for rich text representation.
+ media_type : `media type
+ `__
+ of the asset.
+ roles : `semantic roles
+ `__
+ of the asset, similar to the use of rel in links.
+ """
+ asset_defn = cls({})
+ asset_defn.apply(
+ title=title, description=description, media_type=media_type, roles=roles
+ )
+ return asset_defn
+
+ def apply(
+ self,
+ title: Optional[str],
+ description: Optional[str],
+ media_type: Optional[str],
+ roles: Optional[List[str]],
+ ) -> None:
+ """
+ Sets the properties for this asset definition.
+
+ Args:
+ title : Displayed title for clients and users.
+ description : Description of the Asset providing additional details,
+ such as how it was processed or created.
+ `CommonMark 0.29 `__ syntax MAY be used
+ for rich text representation.
+ media_type : `media type
+ `__
+ of the asset.
+ roles : `semantic roles
+ `__
+ of the asset, similar to the use of rel in links.
+ """
+ self.title = title
+ self.description = description
+ self.media_type = media_type
+ self.roles = roles
+
@property
def title(self) -> Optional[str]:
"""Gets or sets the displayed title for clients and users."""
@@ -65,7 +123,7 @@ def description(self, v: Optional[str]) -> None:
@property
def media_type(self) -> Optional[str]:
"""Gets or sets the `media type
- `__
+ `__
of the asset."""
return self.properties.get(ASSET_TYPE_PROP)
@@ -79,7 +137,7 @@ def media_type(self, v: Optional[str]) -> None:
@property
def roles(self) -> Optional[List[str]]:
"""Gets or sets the `semantic roles
- `__
+ `__
of the asset, similar to the use of rel in links."""
return self.properties.get(ASSET_ROLES_PROP)
diff --git a/tests/extensions/test_eo.py b/tests/extensions/test_eo.py
index be879f9f3..656fb3e55 100644
--- a/tests/extensions/test_eo.py
+++ b/tests/extensions/test_eo.py
@@ -21,6 +21,7 @@ def test_create(self) -> None:
description=Band.band_description("red"),
center_wavelength=0.65,
full_width_half_max=0.1,
+ solar_illumination=42.0,
)
self.assertEqual(band.name, "B01")
@@ -28,7 +29,7 @@ def test_create(self) -> None:
self.assertEqual(band.description, "Common name: red, Range: 0.6 to 0.7")
self.assertEqual(band.center_wavelength, 0.65)
self.assertEqual(band.full_width_half_max, 0.1)
-
+ self.assertEqual(band.solar_illumination, 42.0)
self.assertEqual(band.__repr__(), "")
def test_band_description_unknown_band(self) -> None:
diff --git a/tests/extensions/test_item_assets.py b/tests/extensions/test_item_assets.py
index 67267d075..28e243d0c 100644
--- a/tests/extensions/test_item_assets.py
+++ b/tests/extensions/test_item_assets.py
@@ -46,6 +46,19 @@ def setUp(self) -> None:
TestCases.get_path("data-files/item-assets/example-landsat8.json")
)
+ def test_create(self) -> None:
+ title = "Coastal Band (B1)"
+ description = "Coastal Band Top Of the Atmosphere"
+ media_type = "image/tiff; application=geotiff"
+ roles = ["data"]
+ asset_defn = AssetDefinition.create(
+ title=title, description=description, media_type=media_type, roles=roles
+ )
+ self.assertEqual(asset_defn.title, title)
+ self.assertEqual(asset_defn.description, description)
+ self.assertEqual(asset_defn.media_type, media_type)
+ self.assertEqual(asset_defn.roles, roles)
+
def test_title(self) -> None:
asset_defn = AssetDefinition({})
title = "Very Important Asset"