Skip to content

Commit 0038287

Browse files
authored
Add server info to metadata endpoint; version 1.0 (#383)
* Add server block to metadata * Bump version to v1.0.0
1 parent 3626c88 commit 0038287

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

gramps_webapi/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
#
1919

2020
# make sure to match this version with the one in apispec.yaml
21-
__version__ = "0.7.0"
21+
__version__ = "1.0.0"

gramps_webapi/api/resources/metadata.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Gramps Web API - A RESTful API for the Gramps genealogy program
33
#
44
# Copyright (C) 2020 Christopher Horn
5+
# Copyright (C) 2023 David Straub
56
#
67
# This program is free software; you can redistribute it and/or modify
78
# it under the terms of the GNU Affero General Public License as published by
@@ -19,16 +20,14 @@
1920

2021
"""Metadata API resource."""
2122

22-
import yaml
23-
from flask import Response
23+
from flask import current_app, Response
2424
from gramps.cli.clidbman import CLIDbManager
2525
from gramps.gen.const import ENV, GRAMPS_LOCALE
2626
from gramps.gen.db.base import DbReadBase
2727
from gramps.gen.dbstate import DbState
2828
from gramps.gen.utils.grampslocale import INCOMPLETE_TRANSLATIONS
29-
from pkg_resources import resource_filename
3029

31-
from gramps_webapi.const import VERSION
30+
from gramps_webapi.const import TREE_MULTI, VERSION
3231

3332
from ..util import get_db_handle
3433
from . import ProtectedResource
@@ -62,11 +61,23 @@ def get(self) -> Response:
6261
if key == db_key:
6362
db_type = db_summary[0][key]
6463

64+
is_multi_tree = current_app.config["TREE"] == TREE_MULTI
65+
has_task_queue = bool(current_app.config["CELERY_CONFIG"])
66+
6567
result = {
66-
"database": {"id": db_handle.get_dbid(), "name": db_name, "type": db_type,},
68+
"database": {
69+
"id": db_handle.get_dbid(),
70+
"name": db_name,
71+
"type": db_type,
72+
},
6773
"default_person": db_handle.get_default_handle(),
68-
"gramps": {"version": ENV["VERSION"],},
69-
"gramps_webapi": {"schema": VERSION, "version": VERSION,},
74+
"gramps": {
75+
"version": ENV["VERSION"],
76+
},
77+
"gramps_webapi": {
78+
"schema": VERSION,
79+
"version": VERSION,
80+
},
7081
"locale": {
7182
"lang": GRAMPS_LOCALE.lang,
7283
"language": GRAMPS_LOCALE.language[0],
@@ -88,6 +99,7 @@ def get(self) -> Response:
8899
"tags": db_handle.get_number_of_tags(),
89100
},
90101
"researcher": db_handle.get_researcher(),
102+
"server": {"multi_tree": is_multi_tree, "task_queue": has_task_queue},
91103
"surnames": db_handle.get_surname_list(),
92104
}
93105
data = db_handle.get_summary()

gramps_webapi/data/apispec.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ info:
88
99
1010
* More about Gramps and the numerous features it provides for genealogists can be found at https://gramps-project.org
11-
version: "0.7.0" # make sure to match this version with the one in _version.py
11+
version: "1.0.0" # make sure to match this version with the one in _version.py
1212
license:
1313
name: "GNU Affero General Public License v3.0"
1414
url: "http://www.gnu.org/licenses/agpl-3.0.html"
@@ -9433,6 +9433,18 @@ definitions:
94339433
$ref: "#/definitions/ObjectCounts"
94349434
researcher:
94359435
$ref: "#/definitions/Researcher"
9436+
server:
9437+
description: "Information about the server setup."
9438+
type: object
9439+
properties:
9440+
multi_tree:
9441+
description: "Indicates whether the server is enabled to host multiple family tree databases."
9442+
type: boolean
9443+
example: false
9444+
task_queue:
9445+
description: "Indicates whether the server is using a task queue for long running operations."
9446+
type: boolean
9447+
example: false
94369448
surnames:
94379449
description: "A list of all surnames found in the database."
94389450
type: array

0 commit comments

Comments
 (0)