From 9ecf638ba28ebcdecac69b04518aa67b576e30dc Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Mon, 13 Jun 2022 09:47:17 +0200 Subject: #915 Extend GET /repositories with param id Add id parameter to the response. This is useful to identify repositories that have several IPs. Request: GET /repositories { "repositories": [ { "id": 1, "ip": "192.168.56.10", "name": "Repositorio (Default)" } ] } Response: 200 OK Related-to: d5e6dc0 ("#915 Add API GET /repositories") --- src/rest.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/rest.c b/src/rest.c index 65cdf56..7e01e51 100644 --- a/src/rest.c +++ b/src/rest.c @@ -1915,7 +1915,7 @@ static int og_cmd_get_software(json_t *element, struct og_msg_params *params, static const int og_cmd_get_repositories(char *buffer_reply) { - json_t *root, *repositories, *repository, *ip, *name; + json_t *root, *repositories, *repository, *id, *ip, *name; struct og_buffer og_buffer = { .data = buffer_reply, }; @@ -1930,16 +1930,19 @@ static const int og_cmd_get_repositories(char *buffer_reply) } result = dbi_conn_queryf(dbi->conn, - "SELECT ip, nombrerepositorio " + "SELECT idrepositorio, ip, nombrerepositorio " "FROM repositorios"); repositories = json_array(); while (dbi_result_next_row(result)) { repository = json_object(); + id = json_integer(dbi_result_get_ulonglong(result, + "idrepositorio")); ip = json_string(dbi_result_get_string(result, "ip")); name = json_string(dbi_result_get_string(result, "nombrerepositorio")); + json_object_set_new(repository, "id", id); json_object_set_new(repository, "ip", ip); json_object_set_new(repository, "name", name); json_array_append_new(repositories, repository); -- cgit v1.2.3-18-g5258