`apply()` with kwargs, not only `md`
Currently apply()
can only work with a single argument: md
.
Suppose we have the following code:
# Extension metadata model
class MyExtensionMetadataModel(BaseModel):
# Required so that one model can be instantiated with the attribute name
# rather than the alias
model_config = ConfigDict(populate_by_name=True)
# Metadata fields
name: str = Field(title="Process name", alias=f"{PREFIX}:name")
authors: List[str] = Field(title="Authors", alias=f"{PREFIX}:authors")
version: str = Field(title="Process version", alias=f"{PREFIX}:version")
# Create the extension class
MyExtension = create_extension_cls(
model_cls=MyExtensionMetadataModel,
schema_uri=SCHEMA_URI
)
Then we only can apply the extension to an item this way:
ext = MyExtension(item)
ext.apply(
md=MyExtensionMetadataModel(
name="test",
authors=["michel", "denis"],
version="alpha"
)
)
We should also be able to apply the extension using kwargs, which is more close to pystac extensions:
ext = MyExtension(item)
ext.apply(
name="test",
authors=["michel", "denis"],
version="alpha"
)