Skip to content
Snippets Groups Projects

No extra params

Files
3
@@ -4,7 +4,7 @@ import os
@@ -4,7 +4,7 @@ import os
from typing import Dict, List, Union
from typing import Dict, List, Union
from obspy import UTCDateTime
from obspy import UTCDateTime
from pydantic import BaseModel, root_validator, validator
from pydantic import BaseModel, Extra, root_validator, validator
from ... import pydantic_utcdatetime
from ... import pydantic_utcdatetime
from .Element import ELEMENTS
from .Element import ELEMENTS
@@ -46,19 +46,20 @@ class DataApiQuery(BaseModel):
@@ -46,19 +46,20 @@ class DataApiQuery(BaseModel):
endtime: UTCDateTime = None
endtime: UTCDateTime = None
elements: List[str] = DEFAULT_ELEMENTS
elements: List[str] = DEFAULT_ELEMENTS
sampling_period: SamplingPeriod = SamplingPeriod.MINUTE
sampling_period: SamplingPeriod = SamplingPeriod.MINUTE
data_type: Union[DataType, str] = DataType.VARIATION
type: Union[DataType, str] = DataType.VARIATION
format: OutputFormat = OutputFormat.IAGA2002
format: OutputFormat = OutputFormat.IAGA2002
@validator("data_type")
class Config:
def validate_data_type(
extra = Extra.forbid
cls, data_type: Union[DataType, str]
) -> Union[DataType, str]:
@validator("type")
if data_type not in DataType.values() and len(data_type) != 2:
def validate_data_type(cls, type: Union[DataType, str]) -> Union[DataType, str]:
 
if type not in DataType.values() and len(type) != 2:
raise ValueError(
raise ValueError(
f"Bad data type value '{data_type}'."
f"Bad data type value '{type}'."
f" Valid values are: {', '.join(DataType.values())}"
f" Valid values are: {', '.join(DataType.values())}"
)
)
return data_type
return type
@validator("elements", pre=True, always=True)
@validator("elements", pre=True, always=True)
def validate_elements(cls, elements: List[str]) -> List[str]:
def validate_elements(cls, elements: List[str]) -> List[str]:
Loading