included scripts for api interaction
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
from common import add_common_arguments, ask, client_from_args, run
|
||||
parser = argparse.ArgumentParser(description="POI anlegen")
|
||||
add_common_arguments(parser)
|
||||
for name, kwargs in [
|
||||
("--route-id", {"type": int}), ("--title", {}), ("--description", {}),
|
||||
("--lat", {"type": float}), ("--lon", {"type": float}),
|
||||
("--trigger-radius", {"type": float}), ("--sequence", {"type": int})
|
||||
]: parser.add_argument(name, **kwargs)
|
||||
args = parser.parse_args()
|
||||
def action():
|
||||
client = client_from_args(args)
|
||||
route_id = ask("Route-ID", args.route_id, required=True, cast=int)
|
||||
body = {
|
||||
"title": ask("Titel", args.title),
|
||||
"description": ask("Beschreibung", args.description),
|
||||
"lat": ask("Breitengrad", args.lat, required=True, cast=float),
|
||||
"lon": ask("Längengrad", args.lon, required=True, cast=float),
|
||||
"triggerRadiusM": ask("Auslöseradius in Metern", args.trigger_radius, cast=float),
|
||||
"sequence": ask("Reihenfolge", args.sequence, cast=int),
|
||||
}
|
||||
return client.request("POST", f"/api/routes/{route_id}/pois", json_body={k:v for k,v in body.items() if v is not None})
|
||||
run(action)
|
||||
Reference in New Issue
Block a user