entries¶
EntryInfoProperty (BaseModel)
pydantic-model
¶
description: str
pydantic-field
required
¶
A human-readable description of the entry property
sortable: bool
pydantic-field
¶
Defines whether the entry property can be used for sorting with the "sort" parameter. If the entry listing endpoint supports sorting, this key MUST be present for sortable properties with value true
.
type: DataType
pydantic-field
¶
The type of the property's value. This MUST be any of the types defined in the Data types section. For the purpose of compatibility with future versions of this specification, a client MUST accept values that are not string
values specifying any of the OPTIMADE Data types, but MUST then also disregard the type
field. Note, if the value is a nested type, only the outermost type should be reported. E.g., for the entry resource structures
, the species
property is defined as a list of dictionaries, hence its type
value would be list
.
unit: str
pydantic-field
¶
The physical unit of the entry property. This MUST be a valid representation of units according to version 2.1 of The Unified Code for Units of Measure. It is RECOMMENDED that non-standard (non-SI) units are described in the description for the property.
EntryInfoResource (BaseModel)
pydantic-model
¶
description: str
pydantic-field
required
¶
Description of the entry.
formats: List[str]
pydantic-field
required
¶
List of output formats available for this type of entry.
output_fields_by_format: Dict[str, List[str]]
pydantic-field
required
¶
Dictionary of available output fields for this entry type, where the keys are the values of the formats
list and the values are the keys of the properties
dictionary.
properties: Dict[str, optimade.models.entries.EntryInfoProperty]
pydantic-field
required
¶
A dictionary describing queryable properties for this entry type, where each key is a property name.
EntryRelationships (Relationships)
pydantic-model
¶
This model wraps the JSON API Relationships to include type-specific top level keys.
EntryResourceAttributes (Attributes)
pydantic-model
¶
Contains key-value pairs representing the entry's properties.
immutable_id: str
pydantic-field
¶
The entry's immutable ID (e.g., an UUID). This is important for databases having preferred IDs that point to "the latest version" of a record, but still offer access to older variants. This ID maps to the version-specific record, in case it changes in the future.
-
Type: string.
-
Requirements/Conventions:
- Support: OPTIONAL support in implementations, i.e., MAY be
null
. - Query: MUST be a queryable property with support for all mandatory filter features.
- Support: OPTIONAL support in implementations, i.e., MAY be
-
Examples:
"8bd3e750-b477-41a0-9b11-3a799f21b44f"
"fjeiwoj,54;@=%<>#32"
(Strings that are not URL-safe are allowed.)
last_modified: datetime
pydantic-field
required
¶
Date and time representing when the entry was last modified.
-
Type: timestamp.
-
Requirements/Conventions:
- Support: SHOULD be supported by all implementations, i.e., SHOULD NOT be
null
. - Query: MUST be a queryable property with support for all mandatory filter features.
- Response: REQUIRED in the response unless the query parameter
response_fields
is present and does not include this property.
- Support: SHOULD be supported by all implementations, i.e., SHOULD NOT be
-
Example:
- As part of JSON response format:
"2007-04-05T14:30:20Z"
(i.e., encoded as an RFC 3339 Internet Date/Time Format string.)
- As part of JSON response format:
ReferenceRelationship (TypedRelationship)
pydantic-model
¶
StructureRelationship (TypedRelationship)
pydantic-model
¶
TypedRelationship (Relationship)
pydantic-model
¶
check_rel_type(data)
classmethod
¶
Source code in optimade/models/entries.py
@validator("data")
def check_rel_type(cls, data):
if not isinstance(data, list):
# All relationships at this point are empty-to-many relationships in JSON:API:
# https://jsonapi.org/format/1.0/#document-resource-object-linkage
raise ValueError("`data` key in a relationship must always store a list.")
if hasattr(cls, "_req_type") and any(
getattr(obj, "type", None) != cls._req_type for obj in data
):
raise ValueError("Object stored in relationship data has wrong type")
return data