Skip to content

links

Aggregate

Enumeration of aggregate values

Source code in optimade/models/links.py
30
31
32
33
34
35
36
class Aggregate(Enum):
    """Enumeration of aggregate values"""

    OK = "ok"
    TEST = "test"
    STAGING = "staging"
    NO = "no"

NO = 'no' class-attribute

OK = 'ok' class-attribute

STAGING = 'staging' class-attribute

TEST = 'test' class-attribute

LinkType

Enumeration of link_type values

Source code in optimade/models/links.py
21
22
23
24
25
26
27
class LinkType(Enum):
    """Enumeration of link_type values"""

    CHILD = "child"
    ROOT = "root"
    EXTERNAL = "external"
    PROVIDERS = "providers"

CHILD = 'child' class-attribute

EXTERNAL = 'external' class-attribute

PROVIDERS = 'providers' class-attribute

ROOT = 'root' class-attribute

LinksResource

A Links endpoint resource object

Source code in optimade/models/links.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
class LinksResource(EntryResource):
    """A Links endpoint resource object"""

    type: str = StrictField(
        "links",
        description="These objects are described in detail in the section Links Endpoint",
        regex="^links$",
    )

    attributes: LinksResourceAttributes = StrictField(
        ...,
        description="A dictionary containing key-value pairs representing the Links resource's properties.",
    )

    @root_validator(pre=True)
    def relationships_must_not_be_present(cls, values):
        if values.get("relationships", None) is not None:
            raise ValueError('"relationships" is not allowed for links resources')
        return values

attributes: LinksResourceAttributes = StrictField(Ellipsis, description="A dictionary containing key-value pairs representing the Links resource's properties.") class-attribute

type: str = StrictField('links', description='These objects are described in detail in the section Links Endpoint', regex='^links$') class-attribute

relationships_must_not_be_present(values)

Source code in optimade/models/links.py
103
104
105
106
107
@root_validator(pre=True)
def relationships_must_not_be_present(cls, values):
    if values.get("relationships", None) is not None:
        raise ValueError('"relationships" is not allowed for links resources')
    return values

LinksResourceAttributes

Links endpoint resource object attributes

Source code in optimade/models/links.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
class LinksResourceAttributes(Attributes):
    """Links endpoint resource object attributes"""

    name: str = StrictField(
        ...,
        description="Human-readable name for the OPTIMADE API implementation, e.g., for use in clients to show the name to the end-user.",
    )
    description: str = StrictField(
        ...,
        description="Human-readable description for the OPTIMADE API implementation, e.g., for use in clients to show a description to the end-user.",
    )
    base_url: Optional[Union[AnyUrl, Link]] = StrictField(
        ...,
        description="JSON API links object, pointing to the base URL for this implementation",
    )

    homepage: Optional[Union[AnyUrl, Link]] = StrictField(
        ...,
        description="JSON API links object, pointing to a homepage URL for this implementation",
    )

    link_type: LinkType = StrictField(
        ...,
        title="Link Type",
        description="""The type of the linked relation.
MUST be one of these values: 'child', 'root', 'external', 'providers'.""",
    )

    aggregate: Optional[Aggregate] = StrictField(
        Aggregate.OK,
        title="Aggregate",
        description="""A string indicating whether a client that is following links to aggregate results from different OPTIMADE implementations should follow this link or not.
This flag SHOULD NOT be indicated for links where `link_type` is not `child`.

If not specified, clients MAY assume that the value is `ok`.
If specified, and the value is anything different than `ok`, the client MUST assume that the server is suggesting not to follow the link during aggregation by default (also if the value is not among the known ones, in case a future specification adds new accepted values).

Specific values indicate the reason why the server is providing the suggestion.
A client MAY follow the link anyway if it has reason to do so (e.g., if the client is looking for all test databases, it MAY follow the links marked with `aggregate`=`test`).

If specified, it MUST be one of the values listed in section Link Aggregate Options.""",
    )

    no_aggregate_reason: Optional[str] = StrictField(
        None,
        description="""An OPTIONAL human-readable string indicating the reason for suggesting not to aggregate results following the link.
It SHOULD NOT be present if `aggregate`=`ok`.""",
    )

aggregate: Optional[Aggregate] = StrictField(Aggregate.OK, title='Aggregate', description='A string indicating whether a client that is following links to aggregate results from different OPTIMADE implementations should follow this link or not.\nThis flag SHOULD NOT be indicated for links where `link_type` is not `child`.\n\nIf not specified, clients MAY assume that the value is `ok`.\nIf specified, and the value is anything different than `ok`, the client MUST assume that the server is suggesting not to follow the link during aggregation by default (also if the value is not among the known ones, in case a future specification adds new accepted values).\n\nSpecific values indicate the reason why the server is providing the suggestion.\nA client MAY follow the link anyway if it has reason to do so (e.g., if the client is looking for all test databases, it MAY follow the links marked with `aggregate`=`test`).\n\nIf specified, it MUST be one of the values listed in section Link Aggregate Options.') class-attribute

base_url: Optional[Union[AnyUrl, Link]] = StrictField(Ellipsis, description='JSON API links object, pointing to the base URL for this implementation') class-attribute

description: str = StrictField(Ellipsis, description='Human-readable description for the OPTIMADE API implementation, e.g., for use in clients to show a description to the end-user.') class-attribute

homepage: Optional[Union[AnyUrl, Link]] = StrictField(Ellipsis, description='JSON API links object, pointing to a homepage URL for this implementation') class-attribute

name: str = StrictField(Ellipsis, description='Human-readable name for the OPTIMADE API implementation, e.g., for use in clients to show the name to the end-user.') class-attribute

no_aggregate_reason: Optional[str] = StrictField(None, description='An OPTIONAL human-readable string indicating the reason for suggesting not to aggregate results following the link.\nIt SHOULD NOT be present if `aggregate`=`ok`.') class-attribute