Skip to content

databases

Pydantic models/schemas for the LinksResource used in /databases

DatabaseCreate pydantic-model

Model for creating new LinksResources representing /databases resources in the MongoDB

Required fields:

  • name
  • base_url

Original required fields for a LinksResourceAttributes model:

  • name
  • description
  • link_type

Ensure databases are not index meta-database-only types

I.e., ensure they're not of type "root" or "providers".

Note

Both "external" and "child" can still represent index meta-dbs, but "root" and "providers" can not represent "regular" dbs.

Source code in optimade_gateway/models/databases.py
@validator("link_type")
def ensure_database_link_type(cls, value) -> LinkType:
    """Ensure databases are not index meta-database-only types

    I.e., ensure they're not of type `"root"` or `"providers"`.

    !!! note
        Both `"external"` and `"child"` can still represent index meta-dbs,
        but `"root"` and `"providers"` can not represent "regular" dbs.

    """
    if value in (LinkType.ROOT, LinkType.PROVIDERS):
        raise ValueError(
            "Databases with 'root' or 'providers' link_type is not allowed for gateway-usable "
            f"database resources. Given link_type: {value}"
        )
    return value
Back to top