Beispiel #1
0
def get_info(request: Request):
    from optimade.models import BaseInfoResource, BaseInfoAttributes

    parse_result = urllib.parse.urlparse(str(request.url))
    base_url = get_base_url(parse_result)

    return InfoResponse(
        meta=meta_values(str(request.url), 1, 1, more_data_available=False),
        data=BaseInfoResource(
            id=BaseInfoResource.schema()["properties"]["id"]["const"],
            type=BaseInfoResource.schema()["properties"]["type"]["const"],
            attributes=BaseInfoAttributes(
                api_version=__api_version__,
                available_api_versions=[
                    {
                        "url": f"{base_url}/v{__api_version__.split('.')[0]}",
                        "version": __api_version__,
                    }
                ],
                formats=["json"],
                available_endpoints=["info", "links"] + list(ENTRY_INFO_SCHEMAS.keys()),
                entry_types_by_format={"json": list(ENTRY_INFO_SCHEMAS.keys())},
                is_index=False,
            ),
        ),
    )
Beispiel #2
0
def get_info(request: Request):
    from optimade.models import BaseInfoResource, BaseInfoAttributes

    return InfoResponse(
        meta=meta_values(str(request.url), 1, 1, more_data_available=False),
        data=BaseInfoResource(
            id=BaseInfoResource.schema()["properties"]["id"]["const"],
            type=BaseInfoResource.schema()["properties"]["type"]["const"],
            attributes=BaseInfoAttributes(
                api_version=f"v{CONFIG.version}",
                available_api_versions=[
                    {
                        "url": f"http://localhost:5000/optimade/v{CONFIG.version}/",
                        "version": CONFIG.version,
                    }
                ],
                formats=["json"],
                available_endpoints=["info", "links"] + list(ENTRY_INFO_SCHEMAS.keys()),
                entry_types_by_format={"json": list(ENTRY_INFO_SCHEMAS.keys())},
                is_index=False,
            ),
        ),
    )
Beispiel #3
0
def get_info(request: Request):
    from optimade.models import BaseInfoResource, BaseInfoAttributes

    parse_result = urllib.parse.urlparse(str(request.url))
    return InfoResponse(
        meta=u.meta_values(str(request.url), 1, 1, more_data_available=False),
        data=BaseInfoResource(attributes=BaseInfoAttributes(
            api_version=CONFIG.version,
            available_api_versions=[{
                "url": f"{parse_result.scheme}://{parse_result.netloc}",
                "version": f"{CONFIG.version[1:]}",
            }],
            entry_types_by_format={"json": ["structures"]},
            available_endpoints=[
                "info",
                "structures",
                "extensions/docs",
                "extensions/redoc",
                "extensions/openapi.json",
            ],
        )),
    )