Add collection info to /server-result #176
5 changed files with 85 additions and 3 deletions
|
|
@ -1,3 +1,11 @@
|
|||
# 5.3.0 (2025-12-02)
|
||||
|
||||
## New features
|
||||
|
||||
- The `/server`-endpoint result now contains the name of collections and the
|
||||
schemas that are used by the collections.
|
||||
|
||||
|
||||
# 5.2.1 (2025-11-26)
|
||||
|
||||
## Changes
|
||||
|
|
|
|||
12
README.md
12
README.md
|
|
@ -701,7 +701,17 @@ The service provides the following user endpoints (in addition to user-endpoints
|
|||
The response is a JSON object with the following structure:
|
||||
```json
|
||||
{
|
||||
"version": "<version of the server>"
|
||||
"version": "<version of the server>",
|
||||
"collections": [
|
||||
{
|
||||
"name": "collection_1",
|
||||
"schema": "https://example.org/schema_1.yaml"
|
||||
},
|
||||
{
|
||||
"name": "collection_2",
|
||||
"schema": "https://example.org/schema_2.yaml"
|
||||
},
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
__version__ = '5.2.1'
|
||||
__version__ = '5.3.0'
|
||||
|
|
|
|||
|
|
@ -97,8 +97,18 @@ class TokenCapabilityRequest(BaseModel):
|
|||
token: str | None
|
||||
|
||||
|
||||
class ServerCollectionResponse(BaseModel):
|
||||
name: str
|
||||
schema: str
|
||||
|
||||
|
||||
class ServerCollectionCountedResponse(ServerCollectionResponse):
|
||||
records: int
|
||||
|
||||
|
||||
class ServerResponse(BaseModel):
|
||||
version: str
|
||||
collections: list[ServerCollectionResponse|ServerCollectionCountedResponse]
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
|
|
@ -393,9 +403,16 @@ def validate_record(
|
|||
tags=['Server info'],
|
||||
name='get server information'
|
||||
)
|
||||
async def get_server() -> ServerResponse:
|
||||
async def server() -> ServerResponse:
|
||||
return ServerResponse(
|
||||
version = __version__,
|
||||
collections = [
|
||||
ServerCollectionResponse(
|
||||
name=collection_name,
|
||||
schema=g_instance_config.schemas[collection_name],
|
||||
)
|
||||
for collection_name in g_instance_config.collections
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from pathlib import Path
|
||||
|
||||
import pytest # F401
|
||||
|
||||
from .. import (
|
||||
|
|
@ -14,6 +16,9 @@ from .create_store import (
|
|||
)
|
||||
from .test_utils import basic_write_locations
|
||||
|
||||
# Path to a local simple test schema
|
||||
schema_file = Path(__file__).parent / 'testschema.yaml'
|
||||
|
||||
extra_record = {
|
||||
'schema_type': 'abc:Person',
|
||||
'pid': 'abc:aaaa',
|
||||
|
|
@ -390,6 +395,48 @@ def test_server(fastapi_client_simple):
|
|||
assert response.status_code == HTTP_200_OK
|
||||
assert response.json() == {
|
||||
'version': __version__,
|
||||
'collections': [
|
||||
{
|
||||
'name': 'collection_1',
|
||||
'schema': str(schema_file),
|
||||
},
|
||||
{
|
||||
'name': 'collection_2',
|
||||
'schema': str(schema_file),
|
||||
},
|
||||
{
|
||||
'name': 'collection_3',
|
||||
'schema': str(schema_file),
|
||||
},
|
||||
{
|
||||
'name': 'collection_4',
|
||||
'schema': str(schema_file),
|
||||
},
|
||||
{
|
||||
'name': 'collection_5',
|
||||
'schema': str(schema_file),
|
||||
},
|
||||
{
|
||||
'name': 'collection_6',
|
||||
'schema': str(schema_file),
|
||||
},
|
||||
{
|
||||
'name': 'collection_7',
|
||||
'schema': str(schema_file),
|
||||
},
|
||||
{
|
||||
'name': 'collection_8',
|
||||
'schema': str(schema_file),
|
||||
},
|
||||
{
|
||||
'name': 'collection_dlflatsocial-1',
|
||||
'schema': 'https://concepts.datalad.org/s/flat-social/unreleased.yaml',
|
||||
},
|
||||
{
|
||||
'name': 'collection_dlflatsocial-2',
|
||||
'schema': 'https://concepts.datalad.org/s/flat-social/unreleased.yaml',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue