Skip to content

Commit

Permalink
Merge branch 'master' into update_grammar_v0.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperWA committed Jan 10, 2020
2 parents 9ef5b68 + c5b579f commit 5b4e813
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 9 deletions.
22 changes: 21 additions & 1 deletion openapi/index_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,8 @@
"required": [
"name",
"description",
"base_url"
"base_url",
"homepage"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -1228,6 +1229,25 @@
}
],
"description": "JSON API links object, pointing to the base URL for this implementation"
},
"homepage": {
"title": "Homepage",
"anyOf": [
{
"type": "string",
"minLength": 1,
"maxLength": 65536,
"format": "uri"
},
{
"allOf": [
{
"$ref": "#/components/schemas/Link"
}
]
}
],
"description": "JSON API links object, pointing to a homepage URL for this implementation"
}
},
"description": "Links endpoint resource object attributes"
Expand Down
22 changes: 21 additions & 1 deletion openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2924,7 +2924,8 @@
"required": [
"name",
"description",
"base_url"
"base_url",
"homepage"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -2956,6 +2957,25 @@
}
],
"description": "JSON API links object, pointing to the base URL for this implementation"
},
"homepage": {
"title": "Homepage",
"anyOf": [
{
"type": "string",
"minLength": 1,
"maxLength": 65536,
"format": "uri"
},
{
"allOf": [
{
"$ref": "#/components/schemas/Link"
}
]
}
],
"description": "JSON API links object, pointing to a homepage URL for this implementation"
}
},
"description": "Links endpoint resource object attributes"
Expand Down
5 changes: 5 additions & 0 deletions optimade/models/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class LinksResourceAttributes(Attributes):
description="JSON API links object, pointing to the base URL for this implementation",
)

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


class LinksResource(EntryResource):
"""A Links endpoint resource object"""
Expand Down
3 changes: 2 additions & 1 deletion optimade/server/data/test_links.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"type": "parent",
"name": "Index meta-database",
"description": "Index for example's OPTiMaDe databases",
"base_url": "http://localhost:5001/index/optimade"
"base_url": "http://localhost:5001/index/optimade",
"homepage": "https://example.com"
}
]
3 changes: 2 additions & 1 deletion optimade/server/index_links.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"type": "child",
"name": "OPTiMaDe API",
"description": "The [Open Databases Integration for Materials Design (OPTiMaDe) consortium](http://http://www.optimade.org/) aims to make materials databases interoperational by developing a common REST API.",
"base_url": "http://localhost:5000/optimade"
"base_url": "http://localhost:5000/optimade",
"homepage": "https://example.com"
}
]
4 changes: 1 addition & 3 deletions optimade/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def load_entries(endpoint_name: str, endpoint_collection: MongoCollection):
bson.json_util.loads(bson.json_util.dumps(data))
)
if endpoint_name == "links":
print(
"adding providers.json to links from github.com/Materials-Consortia/OPTiMaDe"
)
print("adding Materials-Consortia providers to links from optimade.org")
endpoint_collection.collection.insert_many(
bson.json_util.loads(bson.json_util.dumps(get_providers()))
)
Expand Down
4 changes: 2 additions & 2 deletions optimade/server/routers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ def retrieve_queryable_properties(schema: dict, queryable_properties: list) -> d


def get_providers():
"""Retrieve providers.json from /Materials-Consortia/OPTiMaDe"""
"""Retrieve Materials-Consortia providers (from https://www.optimade.org/providers/links)"""
import requests
from bson.objectid import ObjectId

mat_consortia_providers = requests.get(
"https://raw.githubusercontent.com/Materials-Consortia/OPTiMaDe/master/providers.json"
"https://www.optimade.org/providers/links"
).json()

providers_list = []
Expand Down

0 comments on commit 5b4e813

Please sign in to comment.