From 29e7641e910901e813f5682da677f767a2aea5cc Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Tue, 20 Apr 2021 11:54:00 +0200 Subject: #915 Add /room/add POST method Adds POST method to add rooms (labs), required payload parameters are name, netmask and center; any additional attributes are optional. Required JSON: { "center": 0, "name": "classroom10", "netmask": "255.255.255.0" } Full JSON: { "center": 0, "name": "classroom11", "netmask": "255.255.255.0", "group": 0, "location": "First floor", "gateway": "192.168.56.1", "ntp": "hora.cica.es", "dns": "1.1.1.1", "remote": True } This commit also adds unit tests for /room/add POST method. --- src/dbi.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/dbi.h') diff --git a/src/dbi.h b/src/dbi.h index 798fecd..33b7afc 100644 --- a/src/dbi.h +++ b/src/dbi.h @@ -24,6 +24,7 @@ void og_dbi_close(struct og_dbi *db); #define OG_DB_COMPUTER_NAME_MAXLEN 100 #define OG_DB_CENTER_NAME_MAXLEN 100 #define OG_DB_ROOM_NAME_MAXLEN 100 +#define OG_DB_ROOM_LOC_MAXLEN 255 #define OG_DB_SERIAL_NUMBER_MAXLEN 25 #define OG_DB_IMAGE_DESCRIPTION_MAXLEN 250 #define OG_DB_IMAGE_NAME_MAXLEN 50 @@ -88,6 +89,18 @@ struct og_computer { char ip[OG_DB_IP_MAXLEN + 1]; }; +struct og_room { + uint32_t center; + uint32_t group; + char location[OG_DB_ROOM_LOC_MAXLEN + 1]; + char name[OG_DB_ROOM_NAME_MAXLEN + 1]; + char gateway[OG_DB_IP_MAXLEN + 1]; + char netmask[OG_DB_IP_MAXLEN + 1]; + char ntp[OG_DB_IP_MAXLEN + 1]; + char dns[OG_DB_IP_MAXLEN + 1]; + bool remote; +}; + struct in_addr; int og_dbi_get_computer_info(struct og_dbi *dbi, struct og_computer *computer, struct in_addr addr); -- cgit v1.2.3-18-g5258