httk.serve.optimade.model¶
Public request, response, configuration, and result models.
Submodules¶
Attributes¶
Exceptions¶
Represent an OPTIMADE response error. |
|
Represent a filter translation failure with an HTTP response contract. |
Classes¶
Configure a served OPTIMADE database. |
|
Configure an OPTIMADE index meta-database. |
|
Represent an endpoint response for serialization by the web layer. |
|
Represent an incoming OPTIMADE request from the web layer. |
|
Represent validated URL query parameters of an OPTIMADE request. |
|
Represent the result of validating a |
|
Structural adapter contract consumed by the public serving helpers. |
|
The callback seam through which the request engine runs queries on a backend. |
|
The results of a query against a backend, as consumed by the entry endpoints. |
|
Represent one entry result and its envelope data. |
Package Contents¶
- class httk.serve.optimade.model.OptimadeConfig[source]¶
Configure a served OPTIMADE database.
implementationextends/overrides the fields of themeta->implementationdictionary (e.g.issue_tracker,source_url,maintainer).database,schema_url, andrequest_delaypopulate the corresponding optionalmetafields (OPTIMADE v1.2+) when set.license,available_licenses, andavailable_licenses_for_entriespopulate the corresponding optional base-info attributes when set.- Parameters:
provider – Provider metadata for the OPTIMADE response envelope.
links – Provider links exposed by the
/linksendpoint.implementation – Implementation metadata merged into response metadata.
database – Optional database metadata for response metadata.
schema_url – URL of the served schema, when one is available.
request_delay – Optional advertised request delay.
license – License metadata exposed by the base-info endpoint.
available_licenses – Licenses advertised for the service.
available_licenses_for_entries – Licenses advertised for entries.
page_limit_max – Largest
page_limitaccepted; larger requests get a 403.partial_data_chunk_size – Number of outer items emitted per partial-data page.
cors_origins – Exact browser origins allowed to make cross-origin requests.
- Raises:
ValueError – If
page_limit_maxis not an integer >= 1.
- class httk.serve.optimade.model.OptimadeIndexConfig[source]¶
Bases:
OptimadeConfigConfigure an OPTIMADE index meta-database.
The links are the configured databases advertised by the index. Exactly one must have
link_type == "root"; child links are the databases that may be selected as the index’s default relationship. The regularOptimadeConfigremains a non-index service configuration.- Parameters:
default_link_id – Identifier of the default configured child link, or
Nonewhen the index has no default.- Raises:
ValueError – If configured links do not satisfy the links schema or the root/default-link constraints.
- exception httk.serve.optimade.model.OptimadeError(message, response_code, response_message, longmsg=None)[source]¶
Bases:
ExceptionRepresent an OPTIMADE response error.
- Parameters:
- response_code¶
- response_msg¶
- content¶
- exception httk.serve.optimade.model.TranslatorError(message, response_code, response_message, longmsg=None)[source]¶
Bases:
OptimadeErrorRepresent a filter translation failure with an HTTP response contract.
- class httk.serve.optimade.model.EndpointResponse[source]¶
Represent an endpoint response for serialization by the web layer.
Either
json_response(a JSON:API document) orcontent(a raw body) is set.- Parameters:
response_code – HTTP status code.
response_msg – HTTP status title.
content_type – Response media type.
encoding – Response character encoding.
content – Raw response body, when the response is not JSON.
json_response – JSON:API response document, when the response is JSON.
- class httk.serve.optimade.model.RawRequest[source]¶
Represent an incoming OPTIMADE request from the web layer.
Only
baseurlandrepresentationare mandatory; missing information is derived fromrepresentationduring validation.- Parameters:
baseurl – Base URL used when generating response links.
representation – Request path and query representation.
relurl – Relative request URL, when supplied by the web layer.
querystr – Raw query string.
query – Parsed query parameters.
endpoint – Preselected endpoint, when supplied by the caller.
request_id – Preselected entry identifier, when supplied by the caller.
version – API version declared by the caller.
- class httk.serve.optimade.model.ValidatedParameters[source]¶
Represent validated URL query parameters of an OPTIMADE request.
- Parameters:
response_format – Requested response format.
page_limit – Maximum number of entries in a page.
page_offset – Number of matching entries to skip.
response_fields – Comma-separated requested response fields.
filter – Raw OPTIMADE filter expression.
sort – Raw OPTIMADE sort expression.
include – Raw related-entry inclusion request.
as_of – Nanosecond timestamp cutoff for timestamp-capable stored sources; timestamp-disabled sources may serve current state and generic providers ignore it.
dimension_slices – Requested slices keyed by dimension name.
- dimension_slices: dict[str, RequestedSlice]¶
- class httk.serve.optimade.model.ValidatedRequest[source]¶
Represent the result of validating a
RawRequest.- Parameters:
baseurl – Base URL used when generating response links.
representation – Original request representation.
endpoint – Validated endpoint name.
version – Validated OPTIMADE version.
query – Validated query parameters.
url_version – Version segment present in the request URL.
request_id – Validated entry identifier.
recognized_response_fields – Requested fields known to the schema.
unrecognized_response_fields – Requested fields not known to the schema.
sort_fields – Validated sort fields and directions.
include_paths – Validated related-entry paths.
property_metadata_requested – Whether property metadata was requested.
partial_data_parts – Entry, identifier, and property for partial data.
partial_data_offset – Offset into a partial-data response.
warnings – Warnings collected while processing the request.
- query: ValidatedParameters¶
- class httk.serve.optimade.model.OptimadeAdapter[source]¶
Bases:
ProtocolStructural adapter contract consumed by the public serving helpers.
Query execution may be backed by the ordinary Store/Searcher adapter or a storage federation with its own bounded paging policy. The HTTP layer only needs the served schema and a callback implementing
QueryFunction.- property schema: httk.serve.optimade.schema.served.ServedSchema¶
Return the schema supplied by the adapter.
- class httk.serve.optimade.model.QueryFunction[source]¶
Bases:
ProtocolThe callback seam through which the request engine runs queries on a backend.
- class httk.serve.optimade.model.QueryResults[source]¶
Bases:
ProtocolThe results of a query against a backend, as consumed by the entry endpoints.
Iteration yields one
ResultRowper entry; itsvaluesmap OPTIMADE response-field names to values, and theidandtypekeys are always present.