diff options
Diffstat (limited to 'cli/objects/room.py')
-rw-r--r-- | cli/objects/room.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/cli/objects/room.py b/cli/objects/room.py index 9198237..f22c843 100644 --- a/cli/objects/room.py +++ b/cli/objects/room.py @@ -85,9 +85,52 @@ class OgRoom(): rest.post('/room/add', payload=payload) @staticmethod + def update_room(rest, args): + parser = argparse.ArgumentParser(prog='ogcli update room') + parser.add_argument('--id', + type=int, + nargs='?', + required=True, + help='room id in database') + parser.add_argument('--name', + nargs='?', + required=True, + help='the updated name for the room') + parser.add_argument('--netmask', + nargs='?', + required=True, + help='the updated netmask for the room') + parser.add_argument('--gateway', + nargs='?', + required=True, + help='updated address of the main gateway in the room') + parsed_args = parser.parse_args(args) + + err = False + if parsed_args.netmask and not check_address(parsed_args.netmask): + print('invalid netmask address', file=sys.stderr) + err = True + if parsed_args.gateway and not check_address(parsed_args.gateway): + print('invalid gateway address', file=sys.stderr) + err = True + if err: + parser.print_help(file=sys.stderr) + sys.exit(1) + + payload = { + 'id': parsed_args.id, + 'name': parsed_args.name, + 'netmask': parsed_args.netmask, + 'gateway': parsed_args.gateway, + } + + rest.post('/room/update', payload=payload) + + @staticmethod def delete_room(rest, args): parser = argparse.ArgumentParser(prog='ogcli delete room') parser.add_argument('--id', + type=int, nargs='?', required=True, help='room id in database') |