optimade_json¶
Modified JSON API v1.0 for OPTIMADE API
BaseRelationshipMeta
¶
Specific meta field for base relationship resource
Source code in optimade/models/optimade_json.py
356 357 358 359 360 361 |
|
description: str = StrictField(Ellipsis, description='OPTIONAL human-readable description of the relationship.')
class-attribute
¶
BaseRelationshipResource
¶
Minimum requirements to represent a relationship resource
Source code in optimade/models/optimade_json.py
364 365 366 367 368 369 370 |
|
meta: Optional[BaseRelationshipMeta] = StrictField(None, description="Relationship meta field. MUST contain 'description' if supplied.")
class-attribute
¶
DataType
¶
Optimade Data Types
See the section "Data types" in the OPTIMADE API specification for more information.
Source code in optimade/models/optimade_json.py
30 31 32 33 34 35 36 37 38 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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
BOOLEAN = 'boolean'
class-attribute
¶
DICTIONARY = 'dictionary'
class-attribute
¶
FLOAT = 'float'
class-attribute
¶
INTEGER = 'integer'
class-attribute
¶
LIST = 'list'
class-attribute
¶
STRING = 'string'
class-attribute
¶
TIMESTAMP = 'timestamp'
class-attribute
¶
UNKNOWN = 'unknown'
class-attribute
¶
from_json_type(json_type)
classmethod
¶
Get OPTIMADE data type from a named JSON type
Source code in optimade/models/optimade_json.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
from_python_type(python_type)
classmethod
¶
Get OPTIMADE data type from a Python type
Source code in optimade/models/optimade_json.py
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 87 88 89 90 91 |
|
get_values()
classmethod
¶
Get OPTIMADE data types (enum values) as a (sorted) list
Source code in optimade/models/optimade_json.py
45 46 47 48 |
|
Implementation
¶
Information on the server implementation
Source code in optimade/models/optimade_json.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
homepage: Optional[Union[AnyHttpUrl, jsonapi.Link]] = StrictField(None, description='A [JSON API links object](http://jsonapi.org/format/1.0/#document-links) pointing to the homepage of the implementation.')
class-attribute
¶
issue_tracker: Optional[Union[AnyUrl, jsonapi.Link]] = StrictField(None, description="A [JSON API links object](http://jsonapi.org/format/1.0/#document-links) pointing to the implementation's issue tracker.")
class-attribute
¶
maintainer: Optional[ImplementationMaintainer] = StrictField(None, description='A dictionary providing details about the maintainer of the implementation.')
class-attribute
¶
name: Optional[str] = StrictField(None, description='name of the implementation')
class-attribute
¶
source_url: Optional[Union[AnyUrl, jsonapi.Link]] = StrictField(None, description='A [JSON API links object](http://jsonapi.org/format/1.0/#document-links) pointing to the implementation source, either downloadable archive or version control system.')
class-attribute
¶
version: Optional[str] = StrictField(None, description='version string of the current implementation')
class-attribute
¶
ImplementationMaintainer
¶
Details about the maintainer of the implementation
Source code in optimade/models/optimade_json.py
216 217 218 219 |
|
email: EmailStr = StrictField(Ellipsis, description="the maintainer's email address")
class-attribute
¶
OptimadeError
¶
detail MUST be present
Source code in optimade/models/optimade_json.py
126 127 128 129 130 131 132 |
|
detail: str = StrictField(Ellipsis, description='A human-readable explanation specific to this occurrence of the problem.')
class-attribute
¶
Provider
¶
Information on the database provider of the implementation.
Source code in optimade/models/optimade_json.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
description: str = StrictField(Ellipsis, description='a longer description of the database provider')
class-attribute
¶
homepage: Optional[Union[AnyHttpUrl, jsonapi.Link]] = StrictField(None, description='a [JSON API links object](http://jsonapi.org/format/1.0#document-links) pointing to homepage of the database provider, either directly as a string, or as a link object.')
class-attribute
¶
name: str = StrictField(Ellipsis, description='a short name for the database provider')
class-attribute
¶
prefix: str = StrictField(Ellipsis, regex='^[a-z]([a-z]|[0-9]|_)*$', description='database-provider-specific prefix as found in section Database-Provider-Specific Namespace Prefixes.')
class-attribute
¶
Relationship
¶
Similar to normal JSON API relationship, but with addition of OPTIONAL meta field for a resource.
Source code in optimade/models/optimade_json.py
373 374 375 376 377 378 |
|
data: Optional[Union[BaseRelationshipResource, List[BaseRelationshipResource]]] = StrictField(None, description='Resource linkage', uniqueItems=True)
class-attribute
¶
ResponseMeta
¶
A JSON API meta member that contains JSON API meta objects of non-standard meta-information.
OPTIONAL additional information global to the query that is not specified in this document, MUST start with a database-provider-specific prefix.
Source code in optimade/models/optimade_json.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
api_version: SemanticVersion = StrictField(Ellipsis, description='Presently used full version of the OPTIMADE API.\nThe version number string MUST NOT be prefixed by, e.g., "v".\nExamples: `1.0.0`, `1.0.0-rc.2`.')
class-attribute
¶
data_available: Optional[int] = StrictField(None, description='An integer containing the total number of data resource objects available in the database for the endpoint.')
class-attribute
¶
data_returned: Optional[int] = StrictField(None, description='An integer containing the total number of data resource objects returned for the current `filter` query, independent of pagination.', ge=0)
class-attribute
¶
implementation: Optional[Implementation] = StrictField(None, description='a dictionary describing the server implementation')
class-attribute
¶
last_id: Optional[str] = StrictField(None, description='a string containing the last ID returned')
class-attribute
¶
more_data_available: bool = StrictField(Ellipsis, description='`false` if the response contains all data for the request (e.g., a request issued to a single entry endpoint, or a `filter` query at the last page of a paginated response) and `true` if the response is incomplete in the sense that multiple objects match the request, and not all of them have been included in the response (e.g., a query with multiple pages that is not at the last page).')
class-attribute
¶
optimade_schema: Optional[Union[AnyHttpUrl, jsonapi.Link]] = StrictField(None, alias='schema', description='A [JSON API links object](http://jsonapi.org/format/1.0/#document-links) that points to a schema for the response.\nIf it is a string, or a dictionary containing no `meta` field, the provided URL MUST point at an [OpenAPI](https://swagger.io/specification/) schema.\nIt is possible that future versions of this specification allows for alternative schema types.\nHence, if the `meta` field of the JSON API links object is provided and contains a field `schema_type` that is not equal to the string `OpenAPI` the client MUST not handle failures to parse the schema or to validate the response against the schema as errors.')
class-attribute
¶
provider: Optional[Provider] = StrictField(None, description='information on the database provider of the implementation.')
class-attribute
¶
query: ResponseMetaQuery = StrictField(Ellipsis, description='Information on the Query that was requested')
class-attribute
¶
response_message: Optional[str] = StrictField(None, description='response string from the server')
class-attribute
¶
time_stamp: Optional[datetime] = StrictField(None, description='A timestamp containing the date and time at which the query was executed.')
class-attribute
¶
warnings: Optional[List[Warnings]] = StrictField(None, description='A list of warning resource objects representing non-critical errors or warnings.\nA warning resource object is defined similarly to a [JSON API error object](http://jsonapi.org/format/1.0/#error-objects), but MUST also include the field `type`, which MUST have the value `"warning"`.\nThe field `detail` MUST be present and SHOULD contain a non-critical message, e.g., reporting unrecognized search attributes or deprecated features.\nThe field `status`, representing a HTTP response status code, MUST NOT be present for a warning resource object.\nThis is an exclusive field for error resource objects.', uniqueItems=True)
class-attribute
¶
ResponseMetaQuery
¶
Information on the query that was requested.
Source code in optimade/models/optimade_json.py
181 182 183 184 185 186 187 188 189 190 |
|
representation: str = StrictField(Ellipsis, description='A string with the part of the URL following the versioned or unversioned base URL that serves the API.\nQuery parameters that have not been used in processing the request MAY be omitted.\nIn particular, if no query parameters have been involved in processing the request, the query part of the URL MAY be excluded.\nExample: `/structures?filter=nelements=2`')
class-attribute
¶
Success
¶
errors are not allowed
Source code in optimade/models/optimade_json.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
|
meta: ResponseMeta = StrictField(Ellipsis, description='A meta object containing non-standard information')
class-attribute
¶
either_data_meta_or_errors_must_be_set(values)
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
|
Warnings
¶
OPTIMADE-specific warning class based on OPTIMADE-specific JSON API Error.
From the specification:
A warning resource object is defined similarly to a JSON API error object, but MUST also include the field type, which MUST have the value "warning". The field detail MUST be present and SHOULD contain a non-critical message, e.g., reporting unrecognized search attributes or deprecated features.
Note: Must be named "Warnings", since "Warning" is a built-in Python class.
Source code in optimade/models/optimade_json.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
type: str = StrictField('warning', description='Warnings must be of type "warning"', regex='^warning$')
class-attribute
¶
Config
¶
Source code in optimade/models/optimade_json.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
schema_extra(schema, model)
staticmethod
¶
Update OpenAPI JSON schema model for Warning
.
- Ensure
type
is in the list required properties and in the correct place. - Remove
status
property. This property is not allowed forWarning
, nor is it a part of the OPTIMADE definition of theWarning
object.
Note
Since type
is the last model field defined, it will simply be appended.
Source code in optimade/models/optimade_json.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
status_must_not_be_specified(values)
¶
Source code in optimade/models/optimade_json.py
153 154 155 156 157 |
|