search¶
Search pydantic-model ¶
A general coordinated OPTIMADE search
Important
Either database_ids or optimade_urls MUST be specified.
database_ids: Set[str] pydantic-field ¶
A list of registered database IDs. Go to /databases to get all registered databases.
endpoint: str pydantic-field ¶
The entry endpoint queried. According to the OPTIMADE specification, this is the same as the resource's type.
optimade_urls: Set[pydantic.networks.AnyUrl] pydantic-field ¶
A list of OPTIMADE base URLs. If a versioned base URL is supplied it will be used as is, as long as it represents a supported version. If an un-versioned base URL, standard version negotiation will be conducted to get the versioned base URL, which will be used as long as it represents a supported version. Note, a single URL can be supplied as well, and it will automatically be wrapped in a list in the server logic.
query_parameters: OptimadeQueryParameters pydantic-field ¶
OPTIMADE query parameters for entry listing endpoints used for this query.
either_ids_or_urls(values) classmethod ¶
Either database_ids or optimade_urls must be defined
Source code in optimade_gateway/models/search.py
@root_validator
def either_ids_or_urls(cls, values: dict) -> dict:
"""Either `database_ids` or `optimade_urls` must be defined"""
if not any(values.get(field) for field in ("database_ids", "optimade_urls")):
raise ValueError(
"Either 'database_ids' or 'optimade_urls' MUST be specified."
)
return values
sort_not_supported(value) classmethod ¶
Warn and reset value if sort is supplied.
Source code in optimade_gateway/models/search.py
@validator("query_parameters")
def sort_not_supported(
cls, value: OptimadeQueryParameters
) -> OptimadeQueryParameters:
"""Warn and reset value if `sort` is supplied."""
if value.sort:
warnings.warn(SortNotSupported())
value.sort = None
return value