Skip to content

resources

Pydantic models/schemas for entry-endpoint resources.

This module is mainly used for a special pydantic base model, which can be used as a mix-in class when creating entry-endpoint resources.

EntryResourceCreate

Bases: EntryResourceAttributes

Generic model for creating new entry resources in the MongoDB

Source code in optimade_gateway/models/resources.py
15
16
17
18
19
20
21
22
23
24
25
26
27
class EntryResourceCreate(EntryResourceAttributes):
    """Generic model for creating new entry resources in the MongoDB"""

    model_config = ConfigDict(extra="ignore")

    last_modified: datetime | None = None

    id: str | None = None

    @model_validator(mode="after")
    def check_illegal_attributes_fields(self) -> EntryResourceCreate:
        """Overwrite parental `check_illegal_attributes_fields` class validators."""
        return self

id: str | None = None class-attribute instance-attribute

last_modified: datetime | None = None class-attribute instance-attribute

model_config = ConfigDict(extra='ignore') class-attribute instance-attribute

check_illegal_attributes_fields()

Overwrite parental check_illegal_attributes_fields class validators.

Source code in optimade_gateway/models/resources.py
24
25
26
27
@model_validator(mode="after")
def check_illegal_attributes_fields(self) -> EntryResourceCreate:
    """Overwrite parental `check_illegal_attributes_fields` class validators."""
    return self