diff --git a/src/sasquatchbackpack/schemas/__init__.py b/src/sasquatchbackpack/schemas/__init__.py new file mode 100644 index 0000000..2b72230 --- /dev/null +++ b/src/sasquatchbackpack/schemas/__init__.py @@ -0,0 +1 @@ +"""Avro schemas.""" diff --git a/src/sasquatchbackpack/schemas/usgs.avsc b/src/sasquatchbackpack/schemas/usgs.avsc deleted file mode 100644 index a2c158c..0000000 --- a/src/sasquatchbackpack/schemas/usgs.avsc +++ /dev/null @@ -1 +0,0 @@ -{"namespace": "$namespace", "name": "$topic_name", "type": "record", "description": "Collection of earthquakes near the summit", "fields": [{"name": "timestamp", "type": "long"}, {"name": "id", "type": "string", "description": "unique earthquake id"}, {"name": "latitude", "type": "float", "units": "Degrees"}, {"name": "longitude", "type": "float", "units": "Degrees"}, {"name": "depth", "type": "float", "units": "Km"}, {"name": "magnitude", "type": "float", "units": "Richter Magnitudes"}]} \ No newline at end of file diff --git a/src/sasquatchbackpack/schemas/usgs.py b/src/sasquatchbackpack/schemas/usgs.py new file mode 100644 index 0000000..6b79afc --- /dev/null +++ b/src/sasquatchbackpack/schemas/usgs.py @@ -0,0 +1,17 @@ +"""USGS Schemas.""" + +from dataclasses import dataclass, field + +from dataclasses_avroschema import AvroModel + + +@dataclass +class EarthquakeSchema(AvroModel): + """USGS Earthquake schema.""" + + timestamp: int + id: str = field(metadata={"description": "unique earthquake id"}) + latitude: float = field(metadata={"units": "degree"}) + longitude: float = field(metadata={"units": "degree"}) + depth: float = field(metadata={"units": "km"}) + magnitude: float = field(metadata={"units": "u.richter_magnitudes"})