from typing import Optional
import tdw_catalog.metadata_template.field as field
from tdw_catalog.errors import CatalogUnimplementedException
from tdw_catalog.utils import MetadataFieldType
[docs]class Field(field.MetadataTemplateField[None]):
"""
Attach files as metadata directly to a :class:`.Dataset`. Default attachment values are not currently supported.
Attributes
----------
None
"""
def __init__(self, key: str, optional: Optional[bool]) -> None:
super().__init__(key, default_value=None, optional=optional)
@field.MetadataTemplateField.default_value.getter
def default_value(self):
raise CatalogUnimplementedException(
message=
"Default values are not currently supported for attachment fields")
@field.MetadataTemplateField.default_value.setter
def default_value(self, value: Optional['field.T']):
if value != None:
raise CatalogUnimplementedException(
message=
"Default values are not currently supported for attachment fields"
)
def serialize(self) -> dict:
res = super().serialize()
res["default_value"] = None
res["field_type"] = MetadataFieldType.FT_ATTACHMENT
return res