This commit is contained in:
@@ -1,16 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Ändert die Metadaten eines POIs."""
|
||||
|
||||
import argparse
|
||||
from collections.abc import Sequence
|
||||
|
||||
from common import add_common_arguments, ask, ask_with_default, client_from_args, run
|
||||
parser = argparse.ArgumentParser(description="POI ändern")
|
||||
add_common_arguments(parser)
|
||||
parser.add_argument("--route-id", type=int)
|
||||
parser.add_argument("--poi-id", type=int)
|
||||
args = parser.parse_args()
|
||||
def action():
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(description="POI ändern")
|
||||
add_common_arguments(parser)
|
||||
parser.add_argument("--route-id", type=int)
|
||||
parser.add_argument("--poi-id", type=int)
|
||||
return parser
|
||||
|
||||
|
||||
def main(argv: Sequence[str] | None = None):
|
||||
args = build_parser().parse_args(argv)
|
||||
client = client_from_args(args)
|
||||
route_id = ask("Route-ID", args.route_id, required=True, cast=int)
|
||||
poi_id = ask("POI-ID", args.poi_id, required=True, cast=int)
|
||||
current = client.request("GET", f"/api/routes/{route_id}/pois/{poi_id}")
|
||||
path = f"/api/routes/{route_id}/pois/{poi_id}"
|
||||
current = client.request("GET", path)
|
||||
body = {
|
||||
"title": ask_with_default("Titel", current.get("title", "")),
|
||||
"description": ask_with_default("Beschreibung", current.get("description", "")),
|
||||
@@ -19,5 +30,8 @@ def action():
|
||||
"triggerRadiusM": ask_with_default("Auslöseradius in Metern", current.get("triggerRadiusM"), float),
|
||||
"sequence": ask_with_default("Reihenfolge", current.get("sequence"), int),
|
||||
}
|
||||
return client.request("PUT", f"/api/routes/{route_id}/pois/{poi_id}", json_body=body)
|
||||
run(action)
|
||||
return client.request("PUT", path, json_body=body)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run(main)
|
||||
|
||||
Reference in New Issue
Block a user