#
# This file is part of Nominatim. (https://nominatim.org)
#
-# Copyright (C) 2022 by the Nominatim developer community.
+# Copyright (C) 2023 by the Nominatim developer community.
# For a full list of authors see the git log.
"""
Subcommand definitions for API calls from the command line.
from nominatim.tools.exec_utils import run_api_script
from nominatim.errors import UsageError
from nominatim.clicmd.args import NominatimArgs
+from nominatim.api import NominatimAPI, StatusResult
+import nominatim.result_formatter.v1 as formatting
# Do not repeat documentation of subcommand classes.
# pylint: disable=C0111
if args.node:
params = dict(osmtype='N', osmid=args.node)
elif args.way:
- params = dict(osmtype='W', osmid=args.node)
+ params = dict(osmtype='W', osmid=args.way)
elif args.relation:
- params = dict(osmtype='R', osmid=args.node)
+ params = dict(osmtype='R', osmid=args.relation)
else:
params = dict(place_id=args.place_id)
if args.object_class:
class APIStatus:
- """\
+ """
Execute API status query.
This command works exactly the same as if calling the /status endpoint on
"""
def add_args(self, parser: argparse.ArgumentParser) -> None:
+ formats = formatting.create(StatusResult).list_formats()
group = parser.add_argument_group('API parameters')
- group.add_argument('--format', default='text', choices=['text', 'json'],
+ group.add_argument('--format', default=formats[0], choices=formats,
help='Format of result')
def run(self, args: NominatimArgs) -> int:
- return _run_api('status', args, dict(format=args.format))
+ status = NominatimAPI(args.project_dir).status()
+ print(formatting.create(StatusResult).format(status, args.format))
+ return 0